
var curcontentindex				= 0;
var curcontentindex1			= 0;
var messages					= new Array();
var messages1					= new Array();
var spotlightTwo				= new Array();
var currentSpotTwoIndex			= 0;


//
//		CUFON
//
///////////////////////////////////////

Cufon.replace('h3:not("#FAQ_Content h3")', { fontFamily: 'Din' });
Cufon.replace('h1, .landingPanelOne h2', { fontFamily: 'Bree Rg' })
Cufon.replace(' .main-nav a, h2, h4, .promoBox h4, .addCufon, .titleIntro, .section_header, .form_block_separator', { fontFamily: 'Din' });


window.onload=function(){
	if (document.all || document.getElementById){
		getElements();       
		setInterval("rotateSpotLightTwo()",5000);
	}
}


$(document).ready( function() {
	
	//
	//		INPUT FUNCTIONS
	//
	///////////////////////////////////////
	
	var lifeCoverNameInput = $("#ctl00_rightHandPanel_secondaryWidget_CallBack_CallBackName");
	var lifeCoverPhoneInput = $("#ctl00_rightHandPanel_secondaryWidget_CallBack_CallBackPhone");
	var memberFirstNameInput = $("#ctl00_rightHandPanel_secondaryWidget_txtFirstName");
	var memberLastNameInput = $("#ctl00_rightHandPanel_secondaryWidget_txtLastName");
	var memberContactInput = $("#ctl00_rightHandPanel_secondaryWidget_txtPhone");
		
	var nameString = "Name";
	var phoneString = "Phone";
	var firstNameString = "First Name";
	var lastNameString = "Last Name";
	var daytimeContactString = "Daytime Contact";

	lifeCoverNameInput.focus(function() {
		if (lifeCoverNameInput.val() == nameString) {
			lifeCoverNameInput.val('');
		} 
	});
				
	lifeCoverNameInput.focusout(function(e) {
		if (lifeCoverNameInput.val() == 0) {
			lifeCoverNameInput.val(nameString);
		} 
	});
	
	lifeCoverPhoneInput.focus(function() {
		if (lifeCoverPhoneInput.val() == phoneString) {
			lifeCoverPhoneInput.val('');
		}
	});
	
	lifeCoverPhoneInput.focusout(function(e) {
		if (lifeCoverPhoneInput.val() == 0) {
			lifeCoverPhoneInput.val(phoneString);
		} 
	});
	
	memberFirstNameInput.focus(function() {
		if (memberFirstNameInput.val() == firstNameString) {
			memberFirstNameInput.val('');
		}
	});
	
	memberFirstNameInput.focusout(function(e) {
		if (memberFirstNameInput.val() == 0) {
			memberFirstNameInput.val(firstNameString);
		} 
	});
	
	memberLastNameInput.focus(function() {
		if (memberLastNameInput.val() == lastNameString) {
			memberLastNameInput.val('');
		}
	});
	
	memberLastNameInput.focusout(function(e) {
		if (memberLastNameInput.val() == 0) {
			memberLastNameInput.val(lastNameString);
		} 
	});
	
	memberContactInput.focus(function() {
		if (memberContactInput.val() == daytimeContactString) {
			memberContactInput.val('');
		}
	});
	
	memberContactInput.focusout(function(e) {
		if (memberContactInput.val() == 0) {
			memberContactInput.val(daytimeContactString);
		} 
	});

	
	
	
	//
	//		FAQ ACCORDION
	//
	///////////////////////////////////////														
	$("#FAQ_Content div").hide();
	$("#FAQ_Content div").addClass("closed");
	$("#FAQ_Content div.clear ").removeClass("closed");
	
	$("#FAQ_Content h3").click( function(){
		
		if($(this).next().attr("class").indexOf("closed") > -1){
			
			$(this).next().slideDown("fast");
			$(this).next().removeClass("closed");
			$(this).css("background-image", "url(/pet-insurance/images/faqOn.png)");
			
		} else {
			
			$(this).next().slideUp("fast");
			$(this).next().addClass("closed");
			$(this).css("background-image", "url(/pet-insurance/images/faqOff.png)");
			
		}
	});
	
	$(".btnCloseAnswer").click( function(){
		
		if($(this).parent().attr("class").indexOf("closed") > -1){
			
			$(this).parent().slideDown("fast");
			$(this).parent().removeClass("closed");
			$(this).parent().prev().css("background-image", "url(/pet-insurance/images/faqOn.png)");
			
		} else {
			
			$(this).parent().slideUp("fast");
			$(this).parent().addClass("closed");
			$(this).parent().prev().css("background-image", "url(/pet-insurance/images/faqOff.png)");
			
		}

	});
	
	//
	//		CUFON ON SUBMIT
	//
	///////////////////////////////////////		
	
	var submitButtons = ["submit_form_right", "log_in", "continue_button_right"];
	
	for(var i in submitButtons){
		$('.'+submitButtons[i]).each(function(){
			$(this).hide().after('<span class="'+submitButtons[i]+' addCufon">').next('span.'+submitButtons[i]).text($(this).val()).click(function(){
       		$(this).prev('input.'+submitButtons[i]).click();
			});
		});
	}	
	
});




function getElements(){
	
	spotlightTwo[0]=document.getElementById("promobox1");
	spotlightTwo[1]=document.getElementById("promobox2");
}


function rotateSpotLightTwo(){
	
	//get current message index (to show it):
	currentSpotTwoIndex=(currentSpotTwoIndex<spotlightTwo.length-1)? currentSpotTwoIndex+1 : 0;
	//get previous message index (to hide it):
	previndex=(currentSpotTwoIndex==0)? spotlightTwo.length-1 : currentSpotTwoIndex-1;
	spotlightTwo[previndex].style.display="none"; //hide previous message
	spotlightTwo[currentSpotTwoIndex].style.display="block"; //show current message 	
} 


//
//
// FONT SIZE ADJUSTMENTS MADE ON CONTENT PAGES
//
/////////////////////////////////////////////////////////

var min=8;
var max=12;

function increaseFontSize() {
	var p = document.getElementsByTagName('div');
	for(i=0;i<p.length;i++) {
		if(p[i].style.fontSize) {
			var s = parseInt(p[i].style.fontSize.replace("px",""));
		} else {
			var s = 12;
		}

		if(s!=max) {
			s += 1;
		}
		
		p[i].style.fontSize = s+"px"
	}
}
	
	
function decreaseFontSize() {
	var p = document.getElementsByTagName('div');
	for(i=0;i<p.length;i++) {
		if(p[i].style.fontSize) {
			var s = parseInt(p[i].style.fontSize.replace("px",""));
		} else {
			var s = 11;
		}

		if(s!=min) {
			s -= 1;
		}
		
		p[i].style.fontSize = s+"px"
	} 
} 



//
//
// 		DROPDOWN SIDE MENU
//
///////////////////////////////////////////////////////// 

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("sideMenu");
		if(navRoot!=null){
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
				this.className+=" over";
	  		}
			
	  		node.onmouseout=function() {
	  			this.className=this.className.replace(" over", "");
	   		}
	   }
	   }
	 }
	}
}
window.onload=startList;


//
//
// 		FAQ OLD STYLE
//
///////////////////////////////////////////////////////// 

function toggleQuestion(id) {
	var elem = document.getElementById(id);
	if (elem.style.display == "none") {
		elem.style.display = "block";
	}
	else {
		elem.style.display = "none";
	}
}


