var res = new Object();

function pleaseWait(theForm, theButton) {

	/* firefox will display wait screen on a page back, so don't show wait screen there */
	var detect = navigator.userAgent.toLowerCase();
	if (!(detect.indexOf('gecko')>-1&&detect.indexOf('safari')<0)) {
		for (i = 0; i < theForm.length; i++) {
			var el = theForm.elements[i];
			if (el.type.toLowerCase() == "submit" && el.name != theButton.name) {
				el.disabled = true;
			}
		}
		$(theButton).style.display='none';
		$(theButton.name+'Wait').style.display='';
		res['fx'+theButton.name+'WaitMessage'].toggle();

/*  		if (res['fx'+theButton.name+'WaitMessage'] != null) res['fx'+theButton.name+'WaitMessage'].toggle(); */
/*  		else $(theButton.name+'WaitMessage').style.display=''; */
	}

	return theButton.value;
}

function InitSiteCategory(strSite) {
	if (strSite.length == 0) {
		res.fxEquipmentSection.hide();
		res.fxEquipmentRVSection.hide();
	} else if (strSite == 'R') {
		res.fxEquipmentSection.hide();
	} else {
		res.fxEquipmentRVSection.hide();
	}
	InitRVType(document.step1.EquipmentRV.options[document.step1.EquipmentRV.selectedIndex].value);
}

function ChangeSiteCategory(strSite) {
	if (strSite.length == 0) {
		if (res.fxEquipmentSection.el.offsetHeight > 0) res.fxEquipmentSection.toggle();
		if (res.fxEquipmentRVSection.el.offsetHeight > 0) res.fxEquipmentRVSection.toggle();
	} else if (strSite == 'R') {
		if (res.fxEquipmentSection.el.offsetHeight > 0) {
			res.fxEquipmentSection.toggle();
			// open to orig height, deals with nested effects
			// should be able to use res.fxEquipmentRVSection.iniHeight instead of a hard number (130), but ie gags
			setTimeout('res.fxEquipmentRVSection.custom(0, 130);', 500);
		} else {
			// open to orig height
			res.fxEquipmentRVSection.custom(0, 130);
		}
		res.LengthMessage.style.display = '';
	} else {
		if (res.fxEquipmentRVSection.el.offsetHeight > 0) {
			res.fxEquipmentRVSection.toggle();
			setTimeout('res.fxEquipmentSection.toggle();', 500);
		} else if (res.fxEquipmentSection.el.offsetHeight == 0) {
			res.fxEquipmentSection.toggle();
		}
	}
}

function InitRVType(strEquip) {
	if (strEquip.length == 0) {
		res.fxEquipmentRVDetails.hide();
	} else {
		if (res.EquipmentRVLengthList.indexOf(','+strEquip+',') == -1) {
			res.LengthMessage.style.display = 'none';
		}
	}
}

function ChangeRVType(strEquip) {
	if (strEquip.length == 0) {
		if (res.fxEquipmentRVDetails.el.offsetHeight > 0) res.fxEquipmentRVDetails.toggle();
	} else {
		if (res.EquipmentRVLengthList.indexOf(','+strEquip+',') == -1) {
			res.LengthMessage.style.display = 'none';
		} else {
			res.LengthMessage.style.display = '';
		}
		// open to orig height
		if (res.fxEquipmentRVDetails.el.offsetHeight == 0) res.fxEquipmentRVDetails.custom(0, 92);
		document.step1.RVLength.focus();
		document.step1.RVLength.select();
	}
}

function InitSellVK(boolSell) {
	if (boolSell) {
		res.fxNoSellVK.hide();
	} else {
		res.fxSellVK.hide();
	}
}

function SwitchSellVK(boolSell) {
	if (boolSell) {
		res.fxNoSellVK.toggle();
		setTimeout('res.fxSellVK.toggle();', 500);
	} else {
		res.fxSellVK.toggle();
		setTimeout('res.fxNoSellVK.toggle();', 500);
	}
}

function InitCVC() {
	for (i=0; i<res.cvcList.length; i++) {
		if (res.CC != res.cvcList[i].el.id) {
			res.cvcList[i].hide();
		}
	}
}

function SwitchCVC(CC) {
	for (i=0; i<res.cvcList.length; i++) {
		if (res.CC == res.cvcList[i].el.id) {
			res.cvcList[i].toggle();
		}
		if (CC == res.cvcList[i].el.id) {
			setTimeout('res.fx'+CC+'.toggle();', 500);
		}
	}
	res.CC = CC;
}

function InitPolicyAgree(boolAgree) {
	if (boolAgree) {
		res.step4Submit.disabled=false;
	}
	else {
		res.step4Submit.disabled=true;
	}
}

