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

//Javascripts
$(document).ready(function(){ 
  $.favicon('http://cdn.myld.com.au/2/1349/north-australian-electrical_54fc8811d4.ico','http://cdn.myld.com.au/2/1349/north-australian-electrical_6d2f057650.png');
	
	menu.contactDetails({
		phone: '0889474243',
					//optional, can have multiple values['0752212345', ['Head Office', '0752212345']]
	//	mobile: '0417894353', //
					//optional, can have multiple values['0452212345', ['Tom', '0452212345']]
		email: 'admin@northaustralianelectrical.com.au',
					//optional, can have multiple values['email@gmail.com', ['Support', 'support@yahoo.com']]
		address: '27 Swan Crescent, Winnellie 0820',
					//optional, can have multiple values['Robina, QLD', ['Southport', 'Southport, QLD']]
	});
	
	//match
	$('.match').matchHeight();
	
	//slider {
		$("#slider").backstretch([
			"http://cdn.myld.com.au/2/1349/north-australian-electrical_8aa5ff1312.jpg",
			"http://cdn.myld.com.au/2/1349/north-australian-electrical_4d9947a268.jpg",
			"http://cdn.myld.com.au/2/1349/north-australian-electrical_3bf6c2f520.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(){
	mapcanvas();
	
	//parallax
	$('#jmm-content').css({"background": "transparent"});
	
	//logo
	$('#logo').addClass('animated fadeInUp showMe');
});

//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(-12.43199, 130.86414);
  var image = 'http://cdn.myld.com.au/2/1349/north-australian-electrical_074b5866c1.png';
  var mapOptions = {
    zoom: 16,
		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);
	  });   
	}
}

//inserts
$('#map-canvas').prependTo('#featureBox');
$('#slider').prependTo('#featureBox');
$('#feature').prependTo('#featureBox');

//view section 1
$('#view_section_1').insertAfter('#header');

//error div
$('#error').insertAfter('#header');

//nav justify
$('.navbar .nav').addClass('nav-justified');

//Detect mac
	var Browser = menu.browserDetect('version');
		if (Browser.OS == 'Mac') {
		$('body').addClass('mac');
}