//------------------------------------------------------------------
// Used by files inheriting UserControlPageAnimatedTopMenu
//------------------------------------------------------------------

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr;
	for(i=0; a&&i<a.length&&(x=a[i])&&x.oSrc; i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
	for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ 
	d.MM_p[j]=new Image; 
	d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;
	if(!d) d=document; 
	if( (p=n.indexOf("?") )>0 && parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;for(i=0; i<(a.length-2); i+=3)
	if ((x=MM_findObj(a[i]))!=null) { 
	document.MM_sr[j++]=x; 
	if(!x.oSrc) x.oSrc=x.src; 
	x.src=a[i+2];}
}

function PageLoad(){
	MM_preloadImages('Images/DealPass_Button_ss_on.gif', 'Images/DealPass_Button_travel_on.gif', 'Images/DealPass_Button_grocery_on.gif', 'Images/DealPass_Button_LowPrice_on.gif', 'Images/DealPass_Button_credit_on.gif', 'Images/DealPass_Button_seasonal_on.gif', 'Images/DealPass_Button_tips_on.gif');
}

//------------------------------------------------------------------
// Used in Index.ascx
//------------------------------------------------------------------

// Creates new window to post to partner site
function SearchBoxSubmit() {
	var formAction = document.forms[0].action;
	var formTarget = document.forms[0].target;

	document.forms[0].action = 'http://www.simpli.com/serp.php';
	document.forms[0].target='Search123Top5';
	document.forms[0].submit();

	document.forms[0].action = formAction;
	document.forms[0].target = formTarget;
}

//------------------------------------------------------------------
// Used in SavingsStory.ascx
//------------------------------------------------------------------

<!-- 

// This JavaScript code toggles the validation of different fields based on whether certain options have been selected
// For example, the Membership Id field is not required if the user has selected 'Not a member' in the Program drop-down

function ProgramDropDownChange(){
	var ddProgram = document.getElementById("_ctl0__ctl0_ddProductName");

	// If user has selected 'Not a member' for their Program, membership id and zip code fields are not required
	if (ddProgram.options[ddProgram.selectedIndex].value == '_NM') {
		ToggleMembershipIdValidation(false);
		ToggleZipCodeValidation(false);
	}
	else {
		ToggleMembershipIdValidation(true);
		ToggleZipCodeValidation(true);
	}
}

function ToggleMembershipIdValidation(enable) {
	ValidatorEnable(_ctl0__ctl0_rfvMembershipId, enable);
	if(enable) {
		MakeVisible('rfvIndicatorMembershipId');
	}
	else {
		MakeHidden('rfvIndicatorMembershipId');
	}
}

function ToggleZipCodeValidation(enable) {
	ValidatorEnable(_ctl0__ctl0_rfvZipCode, enable);
	if(enable) {
		MakeVisible('rfvIndicatorZipCode');
	}
	else {
		MakeHidden('rfvIndicatorZipCode');
	}
}

function ContactRadioButtonChange(){
	var radioContactNo = document.getElementById("_ctl0__ctl0_radContactNo");
	var radioContactByEmail = document.getElementById("_ctl0__ctl0_radMethodEmail");

	// If user does not want to be contacted or wants to be contacted by email, phone fields are not required
	if (radioContactNo.checked || radioContactByEmail.checked) {
		TogglePhoneValidation(false);
	}

	// If user does want to be contacted and wants to be contacted by phone, phone fields are required
	if (!radioContactNo.checked && !radioContactByEmail.checked) {
		TogglePhoneValidation(true);
	}

	// If user does not want to be contacted or wants to be contacted by phone, email fields are not required
	if (radioContactNo.checked || !radioContactByEmail.checked) {
		ToggleEmailValidation(false);
	}

	// If user does want to be contacted and wants to be contacted by email, email fields are required
	if (!radioContactNo.checked && radioContactByEmail.checked) {
		ToggleEmailValidation(true);
	}
}

function TogglePhoneValidation(enable) {
	ValidatorEnable(_ctl0__ctl0_rfvPhone, enable);
	ValidatorEnable(_ctl0__ctl0_revPhone, enable);
	if(enable) {
		MakeVisible('rfvIndicatorPhone');
	}
	else {
		MakeHidden('rfvIndicatorPhone');
	}
}

function ToggleEmailValidation(enable) {
	ValidatorEnable(_ctl0__ctl0_rfvEmail, enable);
	ValidatorEnable(_ctl0__ctl0_revEmail, enable);
	ValidatorEnable(_ctl0__ctl0_cvConfimEmail, enable);
	ValidatorEnable(_ctl0__ctl0_rfvConfirmEmail, enable);
	if(enable) {
		MakeVisible('rfvIndicatorEmail');
		MakeVisible('rfvIndicatorConfirmEmail');
	}
	else {
		MakeHidden('rfvIndicatorEmail');
		MakeHidden('rfvIndicatorConfirmEmail');
	}
}

// Copyright 2004 Bontrager Connection, LLC
// See the "Dynamic HTML; Quick 'n Easy Layers" article 
//    in the WillMaster Possibilities archives for more 
//    information.

function MakeVisible(layerid) {
	if (document.getElementById) {
		document.getElementById(layerid).style.visibility = 'visible';
	}
	else if (document.all) {
		eval('document.all.' + layerid + 'myLayer.style.visibility = "visible"');
	}
	else if (document.layers) {
		eval('document.' + layerid + '.visibility="show"');
	}
} // function MakeVisible()

function MakeHidden(layerid) {
	if (document.getElementById) {
		document.getElementById(layerid).style.visibility = 'hidden';
	}
	else if (document.all) {
		eval('document.all.' + layerid + 'myLayer.style.visibility = "hidden"');
	}
	else if (document.layers) {
		eval('document.' + layerid + '.visibility="hide"');
	}
} // function MakeHidden()

//-->