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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/901/cumming-airconditioning-sheetmetal_282a0fba72.ico','http://cdn.myld.com.au/2/901/cumming-airconditioning-sheetmetal_6030e2eb69.png');
	
	menu.contactDetails({
		phone: '747434548', 
					//optional, can have multiple values['0752212345', ['Head Office', '0752212345']]
		email: 'admin@cummingair.com.au', 
					//optional, can have multiple values['email@gmail.com', ['Support', 'support@yahoo.com']]
		address: '4 Barnes Street Mount Isa, 4825', 
					//optional, can have multiple values['Robina, QLD', ['Southport', 'Southport, QLD']]
		 hours: [ 
					['Mon-Fri', '8:00am - 5:00pm']
			] 
			//optional 
	});
	
	//slider
	$("#slider").backstretch([
		"http://cdn.myld.com.au/2/900/cumming-airconditioning-sheetmetal_09413e12e3.jpg",
		"http://cdn.myld.com.au/2/900/cumming-airconditioning-sheetmetal_618412f84f.jpg",
		"http://cdn.myld.com.au/2/900/cumming-airconditioning-sheetmetal_06d3fdc11a.jpg",
		"http://cdn.myld.com.au/2/900/cumming-airconditioning-sheetmetal_0163ba24aa.jpg",
		"http://cdn.myld.com.au/2/900/cumming-airconditioning-sheetmetal_5fd43c713e.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');
		});
		
	//tabs
	$('#homeThumbs .ht:eq(0) a').hover( function(){
      $('#tabNav li:eq(0) a').tab('show');
		 	$('.ht a').removeClass("active");
    	$('.ht:eq(0) a').addClass("active");
   });
	$('#homeThumbs .ht:eq(1) a').hover( function(){
      $('#tabNav li:eq(1) a').tab('show');
		 	$('.ht a').removeClass("active");
    	$('.ht:eq(1) a').addClass("active");
   });
	$('#homeThumbs .ht:eq(2) a').hover( function(){
      $('#tabNav li:eq(2) a').tab('show');
		 	$('.ht a').removeClass("active");
    	$('.ht:eq(2) a').addClass("active");
   });
	$('#homeThumbs .ht:eq(3) a').hover( function(){
      $('#tabNav li:eq(3) a').tab('show');
		 	$('.ht a').removeClass("active");
    	$('.ht:eq(3) a').addClass("active");
   });
	 
	//htLinks
	$('#htLink1').replaceWith('<a href="https://www.seeleyinternational.com/index.html" target="_blank">Seeley International</a>');
	$('#htLink2').replaceWith('<a href="tel://1300608318">1300 608 318</a>');
	$('#htLink3').replaceWith('<a href="mailto:isa@hydrokleen.com.au">isa@hydrokleen.com.au</a>');
	
	//brands
	$('#brands').slick({
		autoplay: true,
		dots: false,
		infinite: true,
		arrows: true,
		slidesToShow: 7,
		slidesToScroll: 1
	});
	
	//slickMe
	$('#slickMe').slick({
		autoplay: true,
		dots: false,
		arrows: true,
		infinite: true,
		slidesToShow: 4,
		slidesToScroll: 1,
		responsive: [
			{
				breakpoint: 1024,
				settings: {
					autoplay: true,
					dots: false,
					arrows: true,
					infinite: true,
					slidesToShow: 3,
					slidesToScroll: 1,
				}
			},
			{
				breakpoint: 600,
				settings: {
					autoplay: true,
					dots: false,
					arrows: true,
					infinite: true,
					slidesToShow: 2,
					slidesToScroll: 1,
				}
			},
			{
				breakpoint: 480,
				settings: {
					autoplay: true,
					dots: false,
					arrows: true,
					infinite: true,
					slidesToShow: 1,
					slidesToScroll: 1,
				}
			}
		]
	});
     
});

$(window).load(function(){
	footermap();
	mapcanvas();
});

//form validation
$('#custom_form').smartCaptcha({ 
  validateText: ["name", "message", "number"],
  validateEmail: ["email"],
	redirectLink: "http://api.jquery.com/jquery.fn.extend/",
	validateStyle: "default"
}); 

//footer-map
function footermap() {
  var myLatlng = new google.maps.LatLng(-20.69718, 139.49794);
  var image = 'http://cdn.myld.com.au/2/901/cumming-airconditioning-sheetmetal_9c0b386d67.png';
  var mapOptions = {
    zoom: 18,
		scrollwheel: false,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  
  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,
          icon: image
      });
      
      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(-20.69718, 139.49794);
  var image = 'http://cdn.myld.com.au/2/901/cumming-airconditioning-sheetmetal_9c0b386d67.png';
  var mapOptions = {
    zoom: 18,
		scrollwheel: false,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  
  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,
          icon: image
      });
      
      google.maps.event.addDomListener(window, 'resize', function() {
			map.setCenter(myLatlng);
	  });         
      google.maps.event.addDomListener(window, 'orientationchange', function() {
			map.setCenter(myLatlng);
	  });   
	}
}
$('#map-canvas').insertAfter('#slider');

//view section 1
$('#view_section_1').prependTo('#main');

//error div
$('#error').prependTo('#main');

//nav justify
$('.navbar .nav').addClass('nav-justified');

//Detect mac
	var Browser = menu.browserDetect('version');
		if (Browser.OS == 'Mac') {
		$('body').addClass('mac');
}