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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/1189/murwillumbah-exhaust-service-centre-pty-ltd_f595ed0c47.png');
	
	menu.contactDetails({
		phone: '0266721263', 
					//optional, can have multiple values['0266721263', ['Head Office', '0266721263']]
		fax: '0404470134', 
					//optional, can have multiple values
		email: 'mbahexhaust@bigpond.com',
					//optional, can have multiple values['mbahexhaust@bigpond.com', ['Support', 'mbahexhaust@bigpond.com']]
		address: '51 Nullum Street, Murwillumbah NSW 2484', 
					//optional, can have multiple values
        hours: [ 
					['Mon - Fri', '7:00am - 5:30pm']
			] 
			//optional 
		
	});
     
});

//tabs
  //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('#tab', '');
			$('#tabNav li:eq('+(hash_value - 1)+') a').tab('show');
	};
	
	if ($('body#services').is('*')) {
		$(".main-tab-container a").attr("data-toggle", "tab");
		$('li[data-menu="main-tab-container"] ul li a').attr("data-toggle", "tab");
	};
	
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  var target = this.href.split('#');
  		$('#tabNav a').filter('[href="#'+target[1]+'"]').tab('show');
});
  
//tab animate
$(".sub1").click(function() {
    $('html, body').animate({
        scrollTop: $("#content").offset().top
    }, 100);
});

$(document).ready(function(){
    $(".navbar-nav a").click(function(){
        $(this).tab('show');
    });
});

//insert view section
$('#view_section_1').insertAfter('.navbar-bg-one');

//add class in navbar
$( '.navbar-placeholder' ).addClass( "navbar-bg-two" );
$( '.collapse .navbar-collapse' ).addClass( "navbar-centered" );

//add class in navbar a tag
$( '.navbar .navbar-nav > li > a' ).eq( 0 ).addClass( "bg-nav-hover" );
$( '.navbar .navbar-nav > li > a' ).eq( 1 ).addClass( "bg-nav-hover" );
$( '.navbar .navbar-nav > li > a' ).eq( 2 ).addClass( "bg-nav-hover" );
$( '.navbar .navbar-nav > li > a' ).eq( 3 ).addClass( "bg-nav-hover" );
$( '.navbar .navbar-nav > li > a' ).eq( 4 ).addClass( "bg-nav-hover" );

//add class in navbar li tag
$( '.navbar .navbar-nav > li' ).eq( 4 ).addClass( "margin-r" );

//add div in navbar
$('.navbar .navbar-nav > li > a').eq(0).append('<div class="background-hover"></div>');
$('.navbar .navbar-nav > li > a').eq(1).append('<div class="background-hover2"></div>');
$('.navbar .navbar-nav > li > a').eq(2).append('<div class="background-hover3"></div>');
$('.navbar .navbar-nav > li > a').eq(3).append('<div class="background-hover4"></div>');
$('.navbar .navbar-nav > li > a').eq(4).append('<div class="background-hover5"></div>');

menu.reset();

//nav tab add and remove class
    jQuery('.home-modules-container .main-tab-container a .module-img-1-hover').on('click', function(){
    jQuery('.home-modules-container .main-tab-container a .module-img-1-hover').removeClass('tab-display');
    jQuery(this).addClass('tab-display');
});

//nav tab add and remove class
    jQuery('.home-modules-container .main-tab-container a .module-img-2-hover').on('click', function(){
    jQuery('.home-modules-container .main-tab-container a .module-img-2-hover').removeClass('tab-display');
    jQuery(this).addClass('tab-display');
});

//nav tab add and remove class
    jQuery('.home-modules-container .main-tab-container a .module-img-3-hover').on('click', function(){
    jQuery('.home-modules-container .main-tab-container a .module-img-3-hover').removeClass('tab-display');
    jQuery(this).addClass('tab-display');
});


//map image
function mapcontainer() {
  var myLatlng = new google.maps.LatLng(-28.33276, 153.39256);
  var image = 'http://cdn.myld.com.au/2/1189/murwillumbah-exhaust-service-centre-pty-ltd_1711459f8e.png';
  var mapOptions = {
    zoom: 13,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  
  if ($('#map-container').length > 0) {
      var map = new google.maps.Map(document.getElementById('map-container'), 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);
	  });   
	}
}

$(window).load(function(){
	mapcontainer();
});

//map 2
function mapcanvas() {
  var myLatlng = new google.maps.LatLng(-28.33276, 153.39256);
  var image = 'http://cdn.myld.com.au/2/1189/murwillumbah-exhaust-service-centre-pty-ltd_1711459f8e.png';
  var mapOptions = {
    zoom: 13,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    scrollwheel: false
  }
  
  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);
	  });   
	}
}

$(window).load(function(){
	mapcanvas();
});


//form required field
$('#custom_form').smartCaptcha({ 
    validateText: ["name", "last_name"],
    validateEmail: ["email"],
    validateLetters: ["letters"], 
    validateChar: [{ id: "char", max: 7 }],
    validateNum: [{ id: "zip", max: 4, min: 2 }],
    validateRange: [{ id: "range", limit: [5,20] }],
    validateRadiobutton: ["radiogroup_id"],
    validateCheckbox: [{ id: "cb", limit: [1,1] }],
    validateDropdown: ["state"],
    validateURL: ["website"],
    redirectLink: null,
    validateStyle: "default"
});  

//form validation
$('#custom_form').smartCaptcha({ 
  validateText: ["name", "email", "number", "message"],
  redirectLink: "http://api.jquery.com/jquery.fn.extend/",
	validateStyle: "default"
}); 


//Detect mac
  var Browser = menu.browserDetect('version');
  	if (Browser.OS == 'Mac') {
		$('body').addClass('mac');
}