/***********************
*  Site Specific JS   *
************************/

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/1809/steward-armstrong-smash-repairs_5a6db63d1c.ico','http://cdn.myld.com.au/2/1809/steward-armstrong-smash-repairs_a6e315b0c5.png');
	
	menu.contactDetails({
		phone: '0294172102',
					//optional, can have multiple values['0752212345', ['Head Office', '0752212345']]
		email: 'reception@sandasmash.com.au',
					//optional, can have multiple values['email@gmail.com', ['Support', 'support@yahoo.com']]
		address: [['Head Office', '273 High Street Chatswood, NSW 2067'], ['Workshop', '356 Eastern Valley Way Chatswood, NSW 2067']],
					//optional, can have multiple values['Robina, QLD', ['Southport', 'Southport, QLD']]
		 hours: [ 
					['Mon-Fri', '7:30am - 5:00pm']
			] 
			//optional 
	});
	
	//check if hash tag exists in the URL
	if(window.location.hash) {
			
			//set the value as a variable, and remove the #
			var hash_value = window.location.hash.replace('#', '');
			
			if(hash_value=='module1') {
				$('html, body').animate({ 
				'scrollTop': $('#module1').offset().top 
				}, 800);
			} else if(hash_value=='module2') {
				$('html, body').animate({ 
				'scrollTop': $('#module2').offset().top 
				}, 800);
			} else if(hash_value=='module3') {
				$('html, body').animate({ 
				'scrollTop': $('#module3').offset().top 
				}, 800);
			} else if(hash_value=='module4') {
				$('html, body').animate({ 
				'scrollTop': $('#module4').offset().top 
				}, 800);
			} else if(hash_value=='module5') {
				$('html, body').animate({ 
				'scrollTop': $('#module5').offset().top 
				}, 800);
			} else if(hash_value=='module6') {
				$('html, body').animate({ 
				'scrollTop': $('#module6').offset().top 
				}, 800);
			} else if(hash_value=='module7') {
				$('html, body').animate({ 
				'scrollTop': $('#module7').offset().top 
				}, 800);
			} else if(hash_value=='module8') {
				$('html, body').animate({ 
				'scrollTop': $('#module8').offset().top 
				}, 800);
			}
	}
	
	//content nav
	$('#contentNav li:eq(0) a').click(function(){
		$('html, body').animate({ 
		'scrollTop': $('#module1').offset().top 
		}, 800);
	});
	$('#contentNav li:eq(2) a').click(function(){
		$('html, body').animate({ 
		'scrollTop': $('#module2').offset().top 
		}, 800);
	});
	$('#contentNav li:eq(3) a').click(function(){
		$('html, body').animate({ 
		'scrollTop': $('#module3').offset().top 
		}, 800);
	});
	$('#contentNav li:eq(4) a').click(function(){
		$('html, body').animate({ 
		'scrollTop': $('#module4').offset().top 
		}, 800);
	});
	$('#contentNav li:eq(5) a').click(function(){
		$('html, body').animate({ 
		'scrollTop': $('#module5').offset().top 
		}, 800);
	});
	$('#contentNav li:eq(6) a').click(function(){
		$('html, body').animate({ 
		'scrollTop': $('#module6').offset().top 
		}, 800);
	});
	$('#contentNav li:eq(7) a').click(function(){
		$('html, body').animate({ 
		'scrollTop': $('#module7').offset().top 
		}, 800);
	});
	$('#contentNav li:eq(0) a').click(function(){
		$('html, body').animate({ 
		'scrollTop': $('#module8').offset().top 
		}, 800);
	});
	
	//footer contact
	$('#footerIcons a').removeClass('active');
	$('.footerContact').hide();
	$(".footerPhone").hover(
		function () {
			$('.footerContact').hide();
			$('#footerPhone').show();
			$('#footerIcons a').removeClass('active');
			$('.footerPhone').addClass('active');
		}
	);
	$(".footerMail").hover(
		function () {
			$('.footerContact').hide();
			$('#footerMail').show();
			$('#footerIcons a').removeClass('active');
			$('.footerMail').addClass('active');
		}
	);
	$(".footerAddress").hover(
		function () {
			$('.footerContact').hide();
			$('#footerAddress').show();
			$('#footerIcons a').removeClass('active');
			$('.footerAddress').addClass('active');
		}
	);
	$(".footerHours").hover(
		function () {
			$('.footerContact').hide();
			$('#footerHours').show();
			$('#footerIcons a').removeClass('active');
			$('.footerHours').addClass('active');
		}
	);
	$(".footerLSicon").hover(
		function () {
			$('.footerContact').hide();
			$('#footerLSdetails').show();
			$('#footerIcons a').removeClass('active');
			$('.footerLSicon').addClass('active');
		}
	);
	
	//home services links
	$('#htLink1').replaceWith('<a href="contact">Get a quote</a>');
	$('#htLink2').replaceWith('<a href="contact">Make an appointment</a>');
	$('#htLink3').replaceWith('<a href="contact">Book yours</a>');
	
	//match
	$('.homeThumb h3').matchHeight();
	$('.homeThumb p').matchHeight();
	
	//slider
	$("#slider").backstretch([
		"http://cdn.myld.com.au/2/1809/steward-armstrong-smash-repairs_99425e2b79.jpg",
		"http://cdn.myld.com.au/2/1809/steward-armstrong-smash-repairs_dd52a922e1.jpg",
		"http://cdn.myld.com.au/2/1809/steward-armstrong-smash-repairs_c85bcc6c01.jpg"
	], {duration: 3000, fade: 750, random: true});
     
});

$(window).load(function(){
	mapcanvas1();
	mapcanvas2();
});

//form validation
$('#custom_form').smartCaptcha({ 
  validateText: ["name", "message", "number"],
  validateEmail: ["email"],
	validateStyle: "default"
});

//map-canvas1
function mapcanvas1() {
  var myLatlng = new google.maps.LatLng(-33.79132, 151.19885);
  var image = 'http://cdn.myld.com.au/2/1809/steward-armstrong-smash-repairs_f317966b06.png';
  var mapOptions = {
    zoom: 13,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  
  if ($('#map-canvas1').length > 0) {
      var map = new google.maps.Map(document.getElementById('map-canvas1'), mapOptions);
    
      var marker = new google.maps.Marker({
          position: myLatlng,
          map: map,
          icon: image
      });
      
      google.maps.event.addDomListener(window, 'resize', function() {
			map.setCenter(myLatlng);
	  });         
      google.maps.event.addDomListener(window, 'orientationchange', function() {
			map.setCenter(myLatlng);
	  });   
	}
}

//map-canvas2
function mapcanvas2() {
  var myLatlng = new google.maps.LatLng(-33.78659, 151.20113);
  var image = 'http://cdn.myld.com.au/2/1809/steward-armstrong-smash-repairs_f317966b06.png';
  var mapOptions = {
    zoom: 13,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  
  if ($('#map-canvas2').length > 0) {
      var map = new google.maps.Map(document.getElementById('map-canvas2'), mapOptions);
    
      var marker = new google.maps.Marker({
          position: myLatlng,
          map: map,
          icon: image
      });
      
      google.maps.event.addDomListener(window, 'resize', function() {
			map.setCenter(myLatlng);
	  });         
      google.maps.event.addDomListener(window, 'orientationchange', function() {
			map.setCenter(myLatlng);
	  });   
	}
}

//view section 1
$('#view_section_1').insertAfter('#cta');

//error div
$('#error').insertAfter('#cta');

//nav justify
$('.navbar .nav').addClass('nav-justified');

//Detect mac
	var Browser = menu.browserDetect('version');
		if (Browser.OS == 'Mac') {
		$('body').addClass('mac');
}