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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/201/blakeys-brake-and-air-con-services-pty-limited_e84631391f.png');
	
	menu.contactDetails({
		phone: '0740923111',
					//optional, can have multiple values['0752212345', ['Head Office', '0752212345']]
		email: [['Parts', 'parts@iig.com.au'], ['Accounts', 'dblakey@iig.com.au']],
					//optional, can have multiple values['email@gmail.com', ['Support', 'support@yahoo.com']]
		address: '8 Costin Street Mareeba QLD 4880',
					//optional, can have multiple values['Robina, QLD', ['Southport', 'Southport, QLD']]
		 hours: [ 
					['Mon-Fri', '8:00am - 5:00pm']
			] 
			//optional 
	});
	
	//match
	$('.match').matchHeight();
	$('.htText h3').matchHeight();
	$('.htText p').matchHeight();
	
	//slider
	$("#slider").backstretch([
		"http://cdn.myld.com.au/2/250/blakeys-brake-and-air-con-services-pty-limited_c63afa33f5.jpg",
		"http://cdn.myld.com.au/2/251/blakeys-brake-and-air-con-services-pty-limited_81fe2ceefd.jpg",
		"http://cdn.myld.com.au/2/251/blakeys-brake-and-air-con-services-pty-limited_ef2e80eb42.jpg"
	], {duration: 3000, fade: 750, random: true});
	// Set active for the first bullet when document ready;;
	$('.pagination').first().addClass('active');
	// Since you called it as $.backstretch, it's attached to the body
	var instance = $("#slider").data("backstretch");
	$('.pagination').click(function () {
		var index = $('.pagination').index( $(this) );
		$('.pagination').removeClass('active');
		$(this).addClass('active');
		// Show the slide based on the clicked index
		instance.show(index);
		// Return false, so that the click doesn't change the page hash
		return false;
	});
	// Set the current pagination active while running as slideshow
	$("#slider").on("backstretch.before", function (e, instance, index) {
		$('.pagination').removeClass('active').eq(index).addClass('active');
	});
     
});

$(window).load(function(){
	footermap();
	mapcanvas();
	
	//logo
	$('#logo img').addClass('animated rotateIn').show();
});

//form validation
$('#custom_form').smartCaptcha({ 
  validateText: ["name", "message"],
  validateEmail: ["email"],
	validateStyle: "default"
});

//footer-map
function footermap() {
  var myLatlng = new google.maps.LatLng(-17.007914, 145.421197);
  var mapOptions = {
    zoom: 14,
		//scrollwheel: false,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
		styles: [
        {
  		    "featureType": "landscape",
  		    "stylers": [
  		      { "saturation": -100 }
  		    ]
  		  },{
  		    "featureType": "poi",
  		    "stylers": [
  		      { "saturation": -100 }
  		    ]
  		  },{
  		    "featureType": "road",
  		    "stylers": [
  		      { "saturation": -100 }
  		    ]
  		  },{
  		    "featureType": "transit",
  		    "stylers": [
  		      { "saturation": -100 }
  		    ]
  		  },{
  		    "featureType": "administrative",
  		    "stylers": [
  		      { "saturation": -100 }
  		    ]
  		  },{
  		    "featureType": "water",
  		    "stylers": [
  		      { "hue": "#20487e" }
  		    ]
  		  }
          ]
  }
  
  if ($('#footer-map').length > 0) {
      var map = new google.maps.Map(document.getElementById('footer-map'), mapOptions);
    
      var marker = new google.maps.Marker({
          position: myLatlng,
          map: map 
      });
      
      google.maps.event.addDomListener(window, 'resize', function() {
			map.setCenter(myLatlng);
	  });         
      google.maps.event.addDomListener(window, 'orientationchange', function() {
			map.setCenter(myLatlng);
	  });   
	}
}

//map-canvas
function mapcanvas() {
  var myLatlng = new google.maps.LatLng(-17.007914, 145.421197);
  var mapOptions = {
    zoom: 14,
		scrollwheel: false,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
		styles: [
        {
  		    "featureType": "landscape",
  		    "stylers": [
  		      { "saturation": -100 }
  		    ]
  		  },{
  		    "featureType": "poi",
  		    "stylers": [
  		      { "saturation": -100 }
  		    ]
  		  },{
  		    "featureType": "road",
  		    "stylers": [
  		      { "saturation": -100 }
  		    ]
  		  },{
  		    "featureType": "transit",
  		    "stylers": [
  		      { "saturation": -100 }
  		    ]
  		  },{
  		    "featureType": "administrative",
  		    "stylers": [
  		      { "saturation": -100 }
  		    ]
  		  },{
  		    "featureType": "water",
  		    "stylers": [
  		      { "hue": "#20487e" }
  		    ]
  		  }
          ]

  }
  
  if ($('#map-canvas').length > 0) {
      var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    
      var marker = new google.maps.Marker({
          position: myLatlng,
          map: map 
      });
      
      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('#sliderWrap');

//error div
$('#error').insertAfter('#sliderWrap');

//nav justify
$('.navbar .nav').addClass('nav-justified');

//Detect mac
	var Browser = menu.browserDetect('version');
		if (Browser.OS == 'Mac') {
		$('body').addClass('mac');
}