$(document).ready(function() {
	addHover();
	initSlider();
	$('div.equalContent').equalHeightColumns();
	/*initBoxes();
	createMap();*/
	preload([
		'/media/images/bg_box_hover.png',
		'/media/images/HFL_hearForLife_book_assessment.png'
	]);
	
	$(".styleswitch").click(function(e) {
		e.preventDefault();
		
		console.log('reset heights');
		
		$('div.equalContent').css('height', 'auto');
		$('div.equalContent').equalHeightColumns();
	});
});

function addHover(){
	$("div.call a").bigTarget({
		hoverClass: 'hover', // CSS class applied to the click zone onHover
		clickZone : '.call' // jQuery parent selector
	});
}

function pickLocation(){
	if($('#options').val() == 'no'){
		$('#comments').hide();
	}
	else{
		number = $('#options option:selected').attr('name');
		$('#theNumber').html(number);
		loc = $('#options').val();
		$('#hiddenLocation').val(loc);
		$('#comments').show();
	}
}

function initBoxes(){
	$('.hearing').mouseover(function(){
		$('.hearing_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_hearing_button_hover.png)');
	});
	$('.hearing').mouseout(function(){
		$('.hearing_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_hearing_button.png)');
	});
	$('.services').mouseover(function(){
		$('.services_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_services_button_hover.png)');
	});
	$('.services').mouseout(function(){
		$('.services_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_services_button.png)');
	});
	$('.promotions').mouseover(function(){
		$('.promotions_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_promotions_button_hover.png)');
	});
	$('.promotions').mouseout(function(){
		$('.promotions_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_promotions_button.png)');
	});
	$('.faq').mouseover(function(){
		$('.faq_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_faq_button_hover.png)');
	});
	$('.faq').mouseout(function(){
		$('.faq_bottom a').css('background-image', 'url(/media/images/HFL_hearForLife_faq_button.png)');
	});
}

function initSlider(){
	$('#slider').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:500, //Slide transition speed
		pauseTime:8000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:true, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
		controlNavThumbsFromRel:true, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left & right arrows
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){}, //Triggers after all slides have been shown
		lastSlide: function(){}, //Triggers when last slide is shown
		afterLoad: function(){} //Triggers when slider has loaded
	});
}


function preload(arrayOfImages) {
	$(arrayOfImages).each(function(){
		$('<img/>')[0].src = this;
		// Alternatively you could use:
		// (new Image()).src = this;
	});
}

function createMap(lat, lang, mapID) {
  var myLatlng = new google.maps.LatLng(lat, lang);
  var myOptions = {
	zoom: 14,
	center: myLatlng,
	mapTypeId: google.maps.MapTypeId.ROADMAP
  }
var map = new google.maps.Map(document.getElementById(mapID), myOptions);

var markerLatlng = new google.maps.LatLng(lat, lang);

var marker = new google.maps.Marker({
	title: "some text",
	position: markerLatlng,
	map: map,
	title:"Hear For Life"
});
  
// To add the marker to the map, call setMap();
marker.setMap(map);
//infowindow.open(map,marker);
 
}
