var indx = 0;

//If there any international fields have values, then disable the u.s. and canada fields
function disable_us_canada()
{	
	//If either of the international fields filled out
	if(document.forms[indx].frmRegion.value != ""  || document.forms[indx].frmCountry.value != "")
	{
		document.forms[indx].frmRegionDrop.disabled = true;
		document.forms[indx].frmRegionDrop.className = "disabled";
		div1.className = "disabledorderform";
	}
	else
	{
		document.forms[indx].frmRegionDrop.disabled = false;
		document.forms[indx].frmRegionDrop.className = "enabled";
		div1.className = "orderform";
	}
}	

//If there any u.s. and canada fields have values, then disable the international fields
function disable_international()
{
	//If either of the international fields filled out
	if(document.forms[indx].frmRegionDrop.value != "")
	{	
		document.forms[indx].frmRegion.disabled = true;
		document.forms[indx].frmCountry.disabled = true;
		document.forms[indx].frmRegion.className = "disabled";
		document.forms[indx].frmCountry.className = "disabled";
		div2.className = "disabledorderform";
	}
	else
	{
		document.forms[indx].frmRegion.disabled = false;
		document.forms[indx].frmCountry.disabled = false;
		document.forms[indx].frmRegion.className = "enabled";
		document.forms[indx].frmCountry.className = "enabled";
		div2.className = "orderform";
	}
}

function removeXSS(argText, argType) {
	var illegalchars = "()<>&";

	if (argType=="allow ampersand")
	{
		illegalchars = "()<>";
	}

	var output = "";
	var index = 0;
	var LimitCheck;
	var currChar;
	var blnHasIllegal = false;

	LimitCheck = argText.length;
	/** for each character, check if belongs to illegal characters */
	while (index != LimitCheck) {
		currChar = argText.charAt(index);
		if (illegalchars.indexOf(currChar) < 0)
		{
			output += currChar;
		} else {
			blnHasIllegal = true;
		}
		index = index + 1;
	}

	if (blnHasIllegal)
	{
		alert("Removing invalid characters.");
	}
	return output;
}
