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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/979/dubbo-hardcore-soils-earthmoving_ebd6b1f76d.ico','http://cdn.myld.com.au/2/979/dubbo-hardcore-soils-earthmoving_6fc6b627fa.png');
	
	menu.contactDetails({
		phone: '0268855538',
					//optional, can have multiple values['0752212345', ['Head Office', '0752212345']]
		mobile: '0418639302',
					//optional, can have multiple values['0452212345', ['Tom', '0452212345']]
		email: ['dubhcore@bigpond.net.au', 'admin@dubbohardcore.com.au'],
					//optional, can have multiple values['email@gmail.com', ['Support', 'support@yahoo.com']]
		address: 'Lower Darling Street Dubbo',
					//optional, can have multiple values['Robina, QLD', ['Southport', 'Southport, QLD']]
		 hours: [ 
					['Mon-Fri', '7:00am - 4:00pm']
			] 
			//optional 
	});
	
	//slider
	$('.carousel').carousel({
		interval: 3000
	});
	
	//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('#', '');
			
			if(hash_value=='tab1') {
				$('#tabNav li:eq(0) a').tab('show');
			}
			else
			if(hash_value=='tab2') {
				$('#tabNav li:eq(1) a').tab('show');
			}
			else
			if(hash_value=='tab3') {
				$('#tabNav li:eq(2) a').tab('show');
			}
			else
			if(hash_value=='tab4') {
				$('#tabNav li:eq(3) a').tab('show');
			}
			else
			if(hash_value=='tab5') {
				$('#tabNav li:eq(4) a').tab('show');
			}
			else
			if(hash_value=='tab6') {
				$('#tabNav li:eq(5) a').tab('show');
			}
	};
	
	$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
			var target = this.href.split('#');
			$('#tabNav a').filter('[href="#'+target[1]+'"]').tab('show');
	});
	
	//call to action
	if ($('body#home').is('*')) {
		$('#ctaWrap').appendTo('#intro');
	} 
	else {
		$('#ctaWrap').appendTo('#content');
	};
     
});

$(window).load(function(){
	mapcanvas();
});

//form validation
$('#custom_form').smartCaptcha({ 
  validateText: ["name", "message", "number"],
  validateEmail: ["email"],
	redirectLink: "http://api.jquery.com/jquery.fn.extend/",
	validateStyle: "default"
}); 

//map
function mapcanvas() {
  var myLatlng = new google.maps.LatLng(-32.23512, 148.60841);
  var image = 'http://cdn.myld.com.au/2/979/dubbo-hardcore-soils-earthmoving_ef983fc89c.png';
  var mapOptions = {
    zoom: 15,
		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);
	  });   
	}
}

//view section 1
$('#view_section_1').insertAfter('#slider');

//error div
$('#error').insertAfter('#slider');

//Detect mac
	var Browser = menu.browserDetect('version');
		if (Browser.OS == 'Mac') {
		$('body').addClass('mac');
}