// Main Indicator, if Something Wrong it's = true
var cFlag=false
//**************************************************************/
//var phMain = new Array("txtPhoneMainArea","txtPhoneMainOne","txtPhoneMainTwo");
var phCompany = new Array("txtPhoneCompanyArea","txtPhoneCompanyOne","txtPhoneCompanyTwo");
var phFax = new Array("txtFaxArea","txtFaxOne","txtFaxTwo");
var TypeName="Visa"
var varNamesArr = new Array("PhoneCompany","Fax"/*,"PhoneMain"*/)
var phNamesArr= new Array(["txtPhoneCompanyArea","txtPhoneCompanyOne","txtPhoneCompanyTwo"],["txtFaxArea","txtFaxOne","txtFaxTwo"]/*,["txtPhoneMainArea","txtPhoneMainOne","txtPhoneMainTwo"]*/)
var fieldAll=new Array("txtFirstName","txtLastName","txtAddress1","txtAddress2","txtCompanyName","txtCity","txtZip","txtEmail","txtDept");
var phAll = new Array("txtPhoneCompanyArea","txtPhoneCompanyOne","txtPhoneCompanyTwo","txtPhoneCompanyExt","txtPhoneCompany","txtFaxArea","txtFaxOne","txtFaxTwo","txtFax"/*,"txtPhoneMainArea","txtPhoneMainOne","txtPhoneMainTwo","txtPhoneMain"*/);

//////////////////////////////////////////////DOM FUNCTIONS//////////////////////////////////////////////

function ReRenderLists(controlName)
{
var controlChar="";
if(controlName!='') controlChar="_";
	controlName=controlName.substring(0,controlName.indexOf("_"))
	var formNameWithDot="document." +formName +"."+ controlName
	var evalString="FillState(" + formNameWithDot +controlChar+ "cboCountry," + formNameWithDot + controlChar+"cboState, '')"
	eval(evalString)
		fromBoxToVar(controlName)
		ChangePhone(controlName)
		fromVarToBox(controlName)
}
function NExpirationDate()
{
var d = new Date();
var selMonth=cName + "cboMonth.selectedIndex"
var selYear=cName+"cboYear.options["+ cName+"cboYear.selectedIndex].text"
var str=selYear + " <= " + d.getFullYear() + " && " + selMonth + " <= " + d.getMonth()
if(TypeName!='Invoice' && TypeName!='Check')
	{if(eval(str))
		{document.getElementById('spExpDate').innerHTML='<font color=red>Enter Valid Expiration Date</font>';
		return true;}
	}
		document.getElementById('spExpDate').innerHTML=""
} 
/****************************************************************/
function NValidateCard()
{alert(isEmpty(CardNumber.value))
	CardNumber=eval(cName+"txtCard")
	var msg=isValidCCNumber(CardNumber.value,TypeName)
	if(msg=="OK") 	document.getElementById('spCardNumber').innerHTML=""
	else
	{
		document.getElementById('spCardNumber').innerHTML='<font color=red>'+msg+'</font>';
		return true;
	}
	/*secCode=eval(cName+"txtSecCode")
	alert(isEmpty(CardNumber.value))
	if(!isEmpty(CardNumber.value)) 	document.all('spSecCode').innerHTML=""
	else
	{
		document.all('spSecCode').innerHTML='<font color=red>Enter Security Code</font>';
		return true;
	}*/
}
/****************************************************************/
function fromToInfo(flag,from,to)
{//Transfers values from one WebControl to another and cleans the textboxes if check box is unchecked
var frmDocFrm ="document." +formName +".";
if (flag)
	{
		for(i=0;i<fieldAll.length;i++)
		{
			document.getElementById(to + "_" + fieldAll[i]).value=document.getElementById(from + "_" + fieldAll[i]).value
		}
		document.getElementById(to + "_cboCountry").selectedIndex=document.getElementById(from + "_cboCountry").selectedIndex
		ReRenderLists(to + "_cboCountry")
		document.getElementById(to + "_cboState").selectedIndex=document.getElementById(from + "_cboState").selectedIndex
		for(i=0;i<phAll.length;i++)
		{
			document.getElementById(to + "_" + phAll[i]).value=document.getElementById(from + "_" + phAll[i]).value
		}
	}
else
	{
		for(i=0;i<fieldAll.length;i++)
		{
			document.getElementById(to + "_" + fieldAll[i]).value=''
		}
		document.getElementById(to + "_cboCountry").selectedIndex=0
		ReRenderLists(to + "_cboCountry")
		eval("FillState("+ frmDocFrm  + to + "_cboCountry,"+ frmDocFrm  + to + "_cboState,'')");
		for(i=0;i<phAll.length;i++)
		{
			document.getElementById(to + "_" + phAll[i]).value=''
		}
	}
}
/****************************************************************/
function tabPhone(controlName,from,to)
{//Moves Cursor to the next field
var controlChar="";
if(controlName!='') controlChar="_";
controlName=controlName.substring(0,controlName.indexOf("_"));
	if(from=='txtPhoneCompanyTwo')
	{
		if(document.getElementById(controlName + controlChar + from).value.length==4)
		{
		document.getElementById(controlName + controlChar + to).focus()
		document.getElementById(controlName + controlChar + to).select()
		}
	}
	else
	{
		if(document.getElementById(controlName + controlChar + from).value.length==3)
		{
			document.getElementById(controlName + controlChar + to).focus()
			document.getElementById(controlName + controlChar + to).select()
		}
	}
}
/****************************************************************/
function fromVarToBox(controlName)
{//Makes the copy of Phone variables and writes them into Phone textboxes
	var controlChar="";
	if(controlName!='') controlChar="_";
	for(i=0;i<phNamesArr.length ;i++)
	{
		document.getElementById(controlName + controlChar+ phNamesArr[i][0]).value=document.getElementById(varNamesArr[i]+controlName).value.substr(0, 3)
		document.getElementById(controlName + controlChar+ phNamesArr[i][1]).value=document.getElementById(varNamesArr[i]+controlName).value.substr(3, 3)
		document.getElementById(controlName + controlChar+ phNamesArr[i][2]).value=document.getElementById(varNamesArr[i]+controlName).value.substr(6, 4)
	}

 /*if (document.getElementById(varNamesArr[1]+controlName).length>10)
	document.getElementById(controlName + controlChar + varNamesArr[1] + "Ext").value = document.getElementById(varNamesArr[1] + controlName).value.substr(10)
        */
        for(i=0;i<varNamesArr.length ;i++)
		{
		  document.getElementById(controlName + controlChar + "txt"+ varNamesArr[i]).value=document.getElementById(varNamesArr[i]+"Full"+controlName).value
        }
}
/****************************************************************/
function fromBoxToVar(controlName)
{//Makes the copy of Phone textboxes and stores them in  Phone variables
	var controlChar="";
	if(controlName!='') controlChar="_";
	if (document.getElementById("Flag"+ controlName).value == "USA")
	{
		for(i=0;i<phNamesArr.length;i++)
		{var PhoneFields="";
			for(j=0;j<phNamesArr[i].length;j++)
			{
				PhoneFields+=document.getElementById(controlName + controlChar + phNamesArr[i][j]).value
			}
			document.getElementById(varNamesArr[i] + controlName).value=PhoneFields
			if (StripNonNumeric(document.getElementById(varNamesArr[i] + "Full" + controlName).value)!= PhoneFields)
				document.getElementById(varNamesArr[i] + "Full" + controlName).value = PhoneFields
		}
	}
	else
	{
		for(i=0;i<varNamesArr.length;i++)
		{
		document.getElementById(varNamesArr[i] + controlName).value=StripNonNumeric(document.getElementById(controlName + controlChar + "txt" +varNamesArr[i]).value)
		document.getElementById(varNamesArr[i] + "Full" + controlName).value= document.getElementById(controlName + controlChar + "txt" + varNamesArr[i]).value	
		}
	}
}
/****************************************************************/
function StripNonNumeric(s)
{//Cleans non numeric characters in numeric fields
var i,res =""
for (i = 0; i< s.length; i++)
	{
		if (s.substr(i, 1) >= "0" && s.substr(i,1) <= "9")
			res += s.substr(i, 1);
	}
return res;
}
/****************************************************************/
function SingleFieldsCheck()
{/// Checks For Main Email 
	if(!isEmail(document.getElementById("txtEmail").value))
		{
		document.getElementById("spMainEmail").innerHTML="<font color=red>Enter Valid Email</font>";
		cFlag=true;
		}
	/*else if(isEmail(document.getElementById("txtEmail").value)==false)
		{
		document.getElementById("spMainEmail").innerHTML="<font color=red>Enter Valid Email</font>";
		cFlag=true;
		}*/
		else document.getElementById("spMainEmail").innerHTML="" ;
/// Checks For Password			
	if(isEmpty(document.getElementById("txtPassword").value))
		{
		document.getElementById("spPassword").innerHTML="<font color=red>Enter Password</font>";
		cFlag=true;
		}
	else document.getElementById("spPassword").innerHTML=""	;
/// Checks For Password Confirmation 
	if(isEqual(document.getElementById("txtPassword").value,document.getElementById("txtPasswordConfirm").value))
		document.getElementById("spMatch").innerHTML="";
	else
		{
		document.getElementById("spMatch").innerHTML="<font color=red>Password does not Match</font>";
		cFlag=true;
		}
	if(document.getElementById("cboJobFunction").value=="0")
		{
		document.getElementById("spJobFunction").innerHTML="<font color=red>Select Profession</font>";
		cFlag=true;
		}
	else document.getElementById("spJobFunction").innerHTML="" ;	
	if(document.getElementById("cboOccupationType").value=="0")
		{
		document.getElementById("spOccupationType").innerHTML="<font color=red>Select Work environment</font>";
		cFlag=true;
		}
	else document.getElementById("spOccupationType").innerHTML="" ;
	if(document.getElementById("cboAboutPub").value=="")
		{
		document.getElementById("spAboutPub").innerHTML="<font color=red>Select How did you hear</font>";
		cFlag=true;
		}
	else document.getElementById("spAboutPub").innerHTML="" ;
}
/****************************************************************/
function PhoneComplete(webControlName,FieldNamesArr,divName)
{//Checks if Country is USA or Canada and evaluates Phone for correct format ### ### #### or empty
var controlChar="";
if(webControlName!='') controlChar="_";
if (document.getElementById(webControlName+controlChar+"cboCountry")[document.getElementById(webControlName+controlChar+"cboCountry").selectedIndex].value=="USA" ||document.getElementById(webControlName+controlChar+"cboCountry")[document.getElementById(webControlName+controlChar+"cboCountry").selectedIndex].value=="Canada" )
	{	var cnt=0
		for(j=0;j<FieldNamesArr.length;j++)
			cnt+=document.getElementById(webControlName+controlChar +FieldNamesArr[j]).value.length
			if ((divName=="spCompanyPhone" && (cnt<10 || cnt==0)) || (divName!="spCompanyPhone" && (cnt<10 && cnt!=0)))
				{document.getElementById(webControlName+divName).innerHTML="<font color=red>Enter Phone</font>"
				cFlag=true}
			else
				document.getElementById(webControlName+divName).innerHTML=""
	}
}
/****************************************************************/
function BrowserValidation(withCard)
{//Main Function
 //Gets Parameter which indicates what control invoked the function and passes it to the correspondent function
	if(isIE)
		return ValidateCustAllIE(withCard);
	else
		return ValidateCustAll(withCard);
}
/****************************************************************/
function ValidateCustAll(withCard)
{//Validates All fields on a form	
var fieldNames=new Array("FirstName","LastName","Address1","City","Zip","Email");
	for(i=0;i<contNames.length;i++ )
		{	
			//PhoneComplete(contNames[i],phMain,"spMainPhone");
			PhoneComplete(contNames[i],phCompany,"spCompanyPhone");
			PhoneComplete(contNames[i],phFax,"spFax");
			FieldsComplete(contNames[i],fieldNames);
		}
//// Credit Card Validation
if(withCard=="Personal" || withCard=="All") SingleFieldsCheck();
if (withCard=="All") ValidateAllCC()
	cFlag=!cFlag;
if(!cFlag) alert("Please correct highlighted fields")
	return cFlag;
}
/****************************************************************/
function FieldsComplete(webControlName,FieldNamesArr)
{//Checks all input fields from fieldNames array  except Phone  
	var controlChar="";
	if(webControlName!='') controlChar="_";
var j=0;
	for(j=0;j<FieldNamesArr.length;j++)
	{
	var cfName= webControlName + controlChar + "txt" +FieldNamesArr[j]
	if(isEmpty(document.getElementById(cfName).value))
		{
			document.getElementById(webControlName+"sp" +FieldNamesArr[j]).innerHTML="<font color=red>Enter " + FieldNamesArr[j]+"</font>"
			cFlag=true
		}
	else
		{
		document.getElementById(webControlName+"sp" +FieldNamesArr[j]).innerHTML=""
		if(FieldNamesArr[j]=="Email" && isEmail(document.getElementById(cfName).value)==false){
			cFlag=true;
			document.getElementById(webControlName+"sp" +FieldNamesArr[j]).innerHTML="<font color=red>Enter Valid Email</font>"
			}
		}
	}
///Check for State if Selected
	if(document.getElementById(webControlName + controlChar + "cboState").selectedIndex<1)
		{
		document.getElementById(webControlName+"spState").innerHTML="<font color=red>Enter State</font>"
		cFlag=true
		}
	else document.getElementById(webControlName+"spState").innerHTML=""	
}
/****************************************************************/
function ValidateAllCC()
{//Validates Credit Card for expiration and valid card number 	
	var cardFlag=false
	if(TypeName=='Check' || TypeName=='Invoice')
		{
		document.getElementById('spCardNumber').innerHTML="";
		document.getElementById('spExpDate').innerHTML="";
			document.all('spSecCode').innerHTML="";
		}
	else
		{
		if(isEmpty(eval(cName+"txtCard").value))
			{
			document.getElementById('spCardNumber').innerHTML='<font color=red>Enter Number</font>';
			cardFlag=true;}
		else document.getElementById('spCardNumber').innerHTML='';
		if(isEmpty(eval(cName+"txtSecCode").value))
			{
			document.getElementById('spSecCode').innerHTML='<font color=red>Enter Security Code</font>';
			cardFlag=true;}
		else document.getElementById('spSecCode').innerHTML='';
		
		/*if(NValidateCard()==true)cardFlag=true;*/
		if(NExpirationDate()==true)cardFlag=true;
		}
	if (cardFlag==true)
		{cFlag=cardFlag;
		return false;}
	else return true;
}
//////////////////////////////////////////////IE FUNCTIONS//////////////////////////////////////////////
function ValidateCustAllIE(withCard)
{//Validates All fields on a form	
var fieldNames=new Array("FirstName","LastName","Address1","City","Zip","Email");
	for(i=0;i<contNames.length;i++ )
		{	
			//PhoneCompleteIE(contNames[i],phMain,"spMainPhone");
			PhoneCompleteIE(contNames[i],phCompany,"spCompanyPhone");
			PhoneCompleteIE(contNames[i],phFax,"spFax");
			FieldsCompleteIE(contNames[i],fieldNames);
		}
		//// Credit Card Validation
if(withCard=="Personal" || withCard=="All") SingleFieldsCheckIE();
if (withCard=="All") ValidateAllCCIE();
	cFlag=!cFlag;
if(!cFlag) alert("Please correct highlighted fields")
	return cFlag;
}
/****************************************************************/
function FieldsCompleteIE(webControlName,FieldNamesArr)
{//Checks all input fields from fieldNames array  except Phone  
var controlChar="";
	if(webControlName!='') controlChar="_";
var j=0;
	for(j=0;j<FieldNamesArr.length;j++)
	{
	var cfName= webControlName+controlChar+"txt" +FieldNamesArr[j]
	if(isEmpty(document.all(cfName).value))
		{
			document.all(webControlName+"sp" +FieldNamesArr[j]).innerHTML="<font color=red>Enter " + FieldNamesArr[j]+"</font>"
			cFlag=true
		}
	else
		{
		document.all(webControlName+"sp" +FieldNamesArr[j]).innerHTML=""
		if(FieldNamesArr[j]=="Email" && isEmail(document.all(cfName).value)==false)
			{	cFlag=true;
				document.all(webControlName+"sp" +FieldNamesArr[j]).innerHTML="<font color=red>Enter Valid Email</font>"
			}
		}
	}
///Check for State if Selected
	if(document.all(webControlName+controlChar+"cboState").selectedIndex<1)
		{
		document.all(webControlName+"spState").innerHTML="<font color=red>Enter State</font>"
		cFlag=true
		}
	else{document.all(webControlName+"spState").innerHTML=""	}
}
/****************************************************************/
function ValidateAllCCIE()
{//Validates Credit Card for expiration and valid card number 	
	var cardFlag=false
	if(TypeName=='Check' || TypeName=='Invoice')
		{
		document.all('spCardNumber').innerHTML="";
		document.all('spSecCode').innerHTML="";
		document.all('spExpDate').innerHTML="";
		}
	else
		{if(isEmpty(eval(cName+"txtCard").value))
			{
			document.all('spCardNumber').innerHTML='<font color=red>Enter Number</font>';
			cardFlag=true;}
		else document.all('spCardNumber').innerHTML='';
		if(isEmpty(eval(cName+"txtSecCode").value))
			{
			document.getElementById('spSecCode').innerHTML='<font color=red>Enter Security Code</font>';
			cardFlag=true;}
		else document.getElementById('spSecCode').innerHTML='';
		/*if(NValidateCardIE()==true)cardFlag=true;*/
		if(NExpirationDateIE()==true)cardFlag=true;
		}
	if (cardFlag==true)
		{cFlag=cardFlag;
		return false;}
	else return true;
}
/****************************************************************/
function SingleFieldsCheckIE()
{	//Checks For Main Email 
	if(!isEmail(document.all("txtEmail").value))
		{
		document.all("spMainEmail").innerHTML="<font color=red>Enter Valid Email</font>"
		cFlag=true;
		}
	/*else if(isEmail(document.all("txtEmail").value)==false)
		{
		document.all("spMainEmail").innerHTML="<font color=red>Enter Valid Email</font>"
		cFlag=true;
		}*/
	else document.all("spMainEmail").innerHTML="" ;
////////Checks For Password			
	if(isEmpty(document.all("txtPassword").value))
		{
		document.all("spPassword").innerHTML="<font color=red>Enter Password</font>"
		cFlag=true;
		}
	else document.all("spPassword").innerHTML="";
/// Check For Confirmation of the Password
	if(isEqual(document.all("txtPassword").value,document.all("txtPasswordConfirm").value))
		document.all("spMatch").innerHTML="";
	else
		{
		document.all("spMatch").innerHTML="<font color=red>Password does not Match</font>"
		cFlag=true;
		}
	if(document.all("cboJobFunction").value=="0")
		{
		document.all("spJobFunction").innerHTML="<font color=red>Select Profession</font>";
		cFlag=true;
		}
	else document.all("spJobFunction").innerHTML="" ;	
	if(document.all("cboOccupationType").value=="0")
		{
		document.all("spOccupationType").innerHTML="<font color=red>Select Work environment</font>";
		cFlag=true;
		}
	else document.all("spOccupationType").innerHTML="" ;
	if(document.all("cboAboutPub").value=="")
		{
		document.all("spAboutPub").innerHTML="<font color=red>Select How did you hear</font>";
		cFlag=true;
		}
	else document.all("spAboutPub").innerHTML="" ;
}
/****************************************************************/
function PhoneCompleteIE(webControlName,FieldNamesArr,divName)
{//Checks if Country is USA or Canada and evaluates Phone for correct format ### ### #### or empty
var controlChar="";
if(webControlName!='') controlChar="_";
if (document.all(webControlName+controlChar+"cboCountry")[document.all(webControlName+controlChar+"cboCountry").selectedIndex].value=="USA" ||document.all(webControlName+controlChar+"cboCountry")[document.all(webControlName+controlChar+"cboCountry").selectedIndex].value=="Canada" )
	{	var cnt=0
		for(j=0;j<FieldNamesArr.length;j++)
			cnt+=document.all(webControlName + controlChar + FieldNamesArr[j]).value.length
			if ((divName=="spCompanyPhone" && (cnt<10 || cnt==0)) || (divName!="spCompanyPhone" && (cnt<10 && cnt!=0)))
				{document.all(webControlName+divName).innerHTML="<font color=red>Enter Phone</font>"
				cFlag=true}
			else
				document.all(webControlName+divName).innerHTML=""
	}
}
//**************************************************************/
function NExpirationDateIE()
{
var d = new Date();
var selMonth=cName + "cboMonth.selectedIndex"
var selYear=cName+"cboYear.options["+ cName+"cboYear.selectedIndex].text"
var str=selYear + " <= " + d.getFullYear() + " && " + selMonth + " <= " + d.getMonth()
if(TypeName!='Invoice' && TypeName!='Check')
	{if(eval(str))
		{document.all('spExpDate').innerHTML='<font color=red>Enter Valid Expiration Date</font>';
		return true;}
	}
		document.all('spExpDate').innerHTML=""
} 
/****************************************************************/
function NValidateCardIE()
{alert(isEmpty(CardNumber.value))
	CardNumber=eval(cName+"txtCard")
	var msg=isValidCCNumber(CardNumber.value,TypeName)
	if(msg=="OK") 	document.all('spCardNumber').innerHTML=""
	else
	{
		document.all('spCardNumber').innerHTML='<font color=red>'+msg+'</font>';
		return true;
	}
	/*secCode=eval(cName+"txtSecCode")
	alert(isEmpty(CardNumber.value))
	if(!isEmpty(CardNumber.value)) 	document.all('spSecCode').innerHTML=""
	else
	{
		document.all('spSecCode').innerHTML='<font color=red>Enter Security Code</font>';
		return true;
	}*/
}
/****************************************************************/
function fromToInfoIE(flag,from,to)
{//Transfers values from One WebControl to Another and Cleans the textboxes if check box is unchecked
var frmDocFrm ="document." +formName +".";
if (flag)
	{
		for(i=0;i<fieldAll.length;i++)
		{
			document.all(to + "_" + fieldAll[i]).value=document.all(from + "_" + fieldAll[i]).value
		}
		document.all(to + "_cboCountry").selectedIndex=document.all(from + "_cboCountry").selectedIndex
		ReRenderListsIE(to + "_cboCountry")
		document.all(to + "_cboState").selectedIndex=document.all(from + "_cboState").selectedIndex
		for(i=0;i<phAll.length;i++)
		{
			document.all(to + "_" + phAll[i]).value=document.all(from + "_" + phAll[i]).value
		}
	}
else
	{
		for(i=0;i<fieldAll.length;i++)
		{
			document.all(to + "_" + fieldAll[i]).value=''
		}
		document.all(to + "_cboCountry").selectedIndex=0
		ReRenderListsIE(to + "_cboCountry")
		eval("FillState("+ frmDocFrm  + to + "_cboCountry,"+ frmDocFrm  + to + "_cboState,'')");
		for(i=0;i<phAll.length;i++)
		{
			document.all(to + "_" + phAll[i]).value=''
		}
	}
}
/****************************************************************/
function tabPhoneIE(controlName,from,to)
{// Does move Cursor to the next field
var controlChar="";
if(controlName!='') controlChar="_";
controlName=controlName.substring(0,controlName.indexOf("_"));
	if(from=='txtPhoneCompanyTwo')
	{
		if(document.all(controlName + controlChar + from).value.length==4)
		{
			document.all(controlName + controlChar + to).focus()
			document.all(controlName + controlChar + to).select()
		}
	}
	else
	{
		if(document.all(controlName + controlChar + from).value.length==3)
		{
			document.all(controlName + controlChar + to).focus()
			document.all(controlName + controlChar + to).select()
		}
	}
}
/****************************************************************/
function fromVarToBoxIE(controlName)
{////Makes the copy of Phone variables and writes them into Phone textboxes
var controlChar="";
if(controlName!='') controlChar="_";
	for(i=0;i<phNamesArr.length ;i++)
	{
		document.all(controlName + phNamesArr[i][0]).value=document.all(varNamesArr[i]+controlName).value.substr(0, 3)
		document.all(controlName + phNamesArr[i][1]).value=document.all(varNamesArr[i]+controlName).value.substr(3, 3)
		document.all(controlName + phNamesArr[i][2]).value=document.all(varNamesArr[i]+controlName).value.substr(6, 4)
	}
	/*if (document.all(varNamesArr[1]+controlName).length>10)
		document.all(controlName + controlChar + varNamesArr[1] + "Ext").value = document.all(varNamesArr[1] + controlName).value.substr(10)
*/
        for(i=0;i<varNamesArr.length ;i++)
		{
		  document.all(controlName +controlChar+"txt"+ varNamesArr[i]).value=document.all(varNamesArr[i]+"Full"+controlName).value
        }
}
/****************************************************************/
function fromBoxToVarIE(controlName)
{//Makes the copy of Phone textboxes and stores them in  Phone variables
var controlChar="";
if(controlName!='') controlChar="_";	
	if (document.all("Flag"+ controlName).value == "USA")
	{
		for(i=0;i<phNamesArr.length;i++)
		{var PhoneFields="";
			for(j=0;j<phNamesArr[i].length;j++)
			{
				PhoneFields+=document.all(controlName + phNamesArr[i][j]).value
			}
			document.all(varNamesArr[i] + controlName).value=PhoneFields
			if (StripNonNumeric(document.all(varNamesArr[i] + "Full" + controlName).value)!= PhoneFields)
				{
				document.all(varNamesArr[i] + "Full" + controlName).value = PhoneFields
				}
		}
	}
	else
	{
		for(i=0;i<varNamesArr.length;i++)
		{
		document.all(varNamesArr[i] + controlName).value=StripNonNumeric(document.all(controlName + controlChar + "txt" +varNamesArr[i]).value)
		document.all(varNamesArr[i] + "Full" + controlName).value= document.all(controlName + controlChar + "txt" +varNamesArr[i]).value	
		}
	}
}
function ReRenderListsIE(controlName)
{var controlChar="";
if(controlName!='') controlChar="_";	
	controlName=controlName.substring(0,controlName.indexOf("_"))
	var formNameWithDot="document." +formName +"."+ controlName
	var evalString="FillState(" + formNameWithDot + controlChar + "cboCountry," + formNameWithDot + controlChar + "cboState, '')"
	eval(evalString)
		fromBoxToVarIE(controlName)
		ChangePhone(controlName)
		fromVarToBoxIE(controlName)
}