var pagebgColor="";
var PL_AltColor="#DEF7FE";
var selOption,selPlan;
var isLeaseOPtionDisable;// checks if the lease option is diabled
var previousSelectedPlan="PP";

// Variables for holding default values for cart when options are selected
var str_Pur_Equipment,str_Pur_Activation,str_Pur_StdInstall,str_Pur_Shipping;
var str_Lea_Equipment,str_Lea_Activation,str_Lea_StdInstall,str_Lea_Shipping;
// Variable dec ends here
var objAjax;
//Global variable to check if discount is matched
var blnDiscountMatch
//Function for creating XMLHTTP Object
function creat_Object()
{ 
	var xmlhttp;
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
	{
		try 
		{
		xmlhttp = new XMLHttpRequest();
		} 
		catch (e) 
		{
		alert("Your browser is not supporting XMLHTTPRequest");
		xmlhttp = false;
		}
	}
	else
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlhttp;
}
//Function is used to validate the search form
function ValidateForm()
{
	var zipcode,phNo,name;
	zipcode=document.getElementById("txtZip").value;
	phNo=document.getElementById("txtPhone").value;
	name=document.getElementById("txtNameS1").value;
	if(Trim(zipcode)=="")
	{
		alert("Please enter Zip Code");
		document.getElementById("txtZip").focus();
		return false;
	}
	else
	{
		if(isNaN(zipcode))
		{
			alert("Please enter valid Zip Code");
			document.getElementById("txtZip").focus();
			return false;	
		}
		else
		{
			if(zipcode.length>5 || zipcode.length<5)
			{
				alert("Zip Code can be 5 digit long.");
				document.getElementById("txtZip").focus();
				return false;
			}
		}
	}
	if(Trim(phNo)=="")
	{
		alert("Please enter Phone Number");
		document.getElementById("txtPhone").value="";
		document.getElementById("txtPhone").focus();
		return false;
	}
	else
	{
		if(!ValidatePhoneNumber(phNo))
		{
			alert("Please enter Phone Number in valid format");
			document.getElementById("txtPhone").focus();
			return false;	
		}
	}
	document.getElementById("imgLoading").style.display="block";
	objAjax=creat_Object();
	objAjax.open("GET", "hn_Plans.asp?func=srch&zip="+zipcode+"&phone="+phNo+"&name="+name); 
	objAjax.onreadystatechange = sever_interaction;
	objAjax.send('');		
}
function ValidateFormA()
{
	var zipcode,phNo,name;
	zipcode=document.getElementById("txtZip").value;
	phNo=document.getElementById("txtPhone").value;
	name=document.getElementById("txtNameS1").value;
	if(Trim(zipcode)=="")
	{
		alert("Please enter Zip Code");
		document.getElementById("txtZip").value="";
		document.getElementById("txtZip").focus();
		return false;
	}
	else
	{
		if(isNaN(zipcode))
		{
			alert("Please enter valid Zip Code");
			document.getElementById("txtZip").focus();
			return false;	
		}
		else
		{
			if(zipcode.length>5 || zipcode.length<5)
			{
				alert("Zip Code can be 5 digit long.");
				document.getElementById("txtZip").focus();
				return false;
			}
		}
	}
	if(Trim(phNo)=="")
	{
		alert("Please enter Phone Number");
		document.getElementById("txtPhone").value="";
		document.getElementById("txtPhone").focus();
		return false;
	}
	else
	{
		if(!ValidatePhoneNumber(phNo))
		{
			alert("Please enter Phone Number in valid format");
			document.getElementById("txtPhone").focus();
			return false;	
		}
	}
	document.getElementById("imgLoading").style.display="block";
	objAjax=creat_Object();
	objAjax.open("GET", "a_hn_Plans.asp?func=srch&zip="+zipcode+"&phone="+phNo+"&name="+name); 
	objAjax.onreadystatechange = sever_interaction;
	objAjax.send('');	
}
// This function is used the handle enter key on search form
function HandleEnterKey(e)
{
	var e,unicode
	if(window.event)
	{
		unicode = window.event.keyCode	
	}
	else
	{
		unicode = e.which;
	}	
	if(unicode==13)
	{
		return ValidateForm();						
	}
}
// This function is used the handle enter key on search form
function HandleEnterKey2(e)
{
	var e,unicode
	if(window.event)
	{
		unicode = window.event.keyCode
		e=window.event;	
	}
	else
	{
		unicode = e.which;
	}	
	if(unicode==13)
	{
		e.returnValue=false;
		e.cancel = true;
		return ValidateForm();
	}
}
/// This function is called when AJAX request is procesing
function sever_interaction()
{
	if(objAjax.readyState == 1)
	{
	
	}
	if(objAjax.readyState == 4)
	{
		var Answer=objAjax.responseText;
		document.getElementById("imgLoading").style.display="none";
		if(Answer.indexOf("Found")>-1)
		{
			alert("We currently have coverage in your area.\n Please press Ok to view Service Plans.")
			document.getElementById("fldIContact").value="0";
			document.getElementById("fldSend").value="0";
			document.getElementById("FlgForm").value="1";
			document.getElementById("MyForm").submit();
		}
		else
		{
			DisplayStep1Error();			
		}
	}
}
//function to validate the phone nuumber
function ValidatePhoneNumber(strPhone)
{
	var objRegExp  = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
	return objRegExp.test(strPhone);
}

//function to trim a string
function Trim(str)
{
  if(str.charAt(0) == " ")
  {  
  	str = Trim(str.substring(1));
  }
  if (str.charAt(str.length-1) == " ")
  {  
  	str = Trim(str.substring(0,str.length-1));
  }
  return str;
}
///This function is called when there is no match for the zip code 
function DisplayStep1Error()
{
	var strText;
	strText="Sorry, no match found, please check the zip code entered.\n If you continue to have a problem, please call us at 866.884.8966."
	alert(strText);
}

// this function is called when user cliks on any of the option
function SelectOption(tagid)
{
	DeSelectPrevPlans(); // deselect previous plans
	selOption=tagid;
	if(tagid=="Purchase")
	{
		CreatePurchasePriceTable();
        DeselectLease();
		if(isLeaseOPtionDisable=="0")
		{
			
		}
		document.getElementById("tdOptionH").innerHTML="Purchase Option Highlights";
		document.getElementById("PP").checked="true";
		previousSelectedPlan="PP"		
		SelectPlan("PP");
	}
	else
	{
		CreateLeasePriceTable();
	    DeselectPurchase();
		document.getElementById("tdOptionH").innerHTML="Lease Option Highlights";
		document.getElementById("PP").checked="true";
		previousSelectedPlan="PP"		
		SelectPlan("PP");
	}	
}
//Funvtion that will create price table for purchanse
function CreatePurchasePriceTable()
{
	var response,pricetab,htab;
	objAjax=creat_Object();
	if(blnDiscountMatch=="1")
	{
		objAjax.open("GET", "hn_Plans.asp?func=cms&mod=Purchase&d=1",false); 
	}
	else
	{
		objAjax.open("GET", "hn_Plans.asp?func=cms&mod=Purchase&d=0",false);
	}
	objAjax.send(" ");
	response=objAjax.responseText;
	response=response.split("|");
	document.getElementById("Htext").innerHTML=response[0];
	document.getElementById("PriceTab").innerHTML=response[1];
	
}
//Funvtion that will create price table for Lease
function CreateLeasePriceTable()
{
	var response,pricetab,htab;
	objAjax=creat_Object();
	if(blnDiscountMatch=="1")
	{
		objAjax.open("GET", "hn_Plans.asp?func=cms&mod=Lease&d=1",false); 
	}
	else
	{
		objAjax.open("GET", "hn_Plans.asp?func=cms&mod=Lease&d=0",false);
	}
	objAjax.send(" ");
	response=objAjax.responseText;
	response=response.split("|");
	document.getElementById("Htext").innerHTML=response[0];
	document.getElementById("PriceTab").innerHTML=response[1];
}

function DeselectPurchase()
{
	var stable,i,j;
	stable=document.getElementById("tdPurchase")
	for(i=0;i<stable.rows.length;i++)
	{
		for(j=0;j<stable.rows[i].cells.length;j++)
		{
			stable.rows[i].cells[j].style.color="#999999";
		}
	}
	stable=document.getElementById("tdLease")
	for(i=0;i<stable.rows.length;i++)
	{
		for(j=0;j<stable.rows[i].cells.length;j++)
		{
			if(stable.rows[i].cells[j].className=="optionsText")
				stable.rows[i].cells[j].style.color="#000099";
			else
				stable.rows[i].cells[j].style.color="#000000";
		}
	}
}
function DeselectLease()
{
	var stable,i,j;
	stable=document.getElementById("tdLease")
	for(i=0;i<stable.rows.length;i++)
	{
		for(j=0;j<stable.rows[i].cells.length;j++)
		{
			stable.rows[i].cells[j].style.color="#999999";
		}
	}
	stable=document.getElementById("tdPurchase")
	for(i=0;i<stable.rows.length;i++)
	{
		for(j=0;j<stable.rows[i].cells.length;j++)
		{
			if(stable.rows[i].cells[j].className=="optionsText")
				stable.rows[i].cells[j].style.color="#000099";
			else
				stable.rows[i].cells[j].style.color="#000000";
		}
	}
}
//This function is called when the user clicks any of the plan
function SelectPlan(tagid)
{
	var i,response;
	selPlan=tagid;
	DeSelectPrevPlans();
	previousSelectedPlan=tagid;
	//Code to get the usage text for the selected plan
	objAjax=creat_Object();
	if(blnDiscountMatch=="1")
	{
		objAjax.open("GET", "hn_Plans.asp?func=getU&plan="+selPlan+"&mod="+selOption+"&d=1",false); 
	}
	else
	{
		objAjax.open("GET", "hn_Plans.asp?func=getU&plan="+selPlan+"&mod="+selOption+"&d=0",false);
	}
	objAjax.send(" ");
	response=objAjax.responseText;
	document.getElementById("UsageText").innerHTML=response;
	document.getElementById("col"+tagid+"1").style.color="#000099";
	document.getElementById("col"+tagid+"1").style.fontSize="14px";
	document.getElementById("col"+tagid+"1").style.fontWeight="bold";
	UpdateCart();	
}

//Clears off any previous selection in the plan table
function DeSelectPrevPlans()
{
	document.getElementById("col"+previousSelectedPlan+"1").style.color="#000000";
	document.getElementById("col"+previousSelectedPlan+"1").style.fontSize="11px";
	document.getElementById("col"+previousSelectedPlan+"1").style.fontWeight="normal";
}
// Main function of the script. Loads the page parameters and makes table gray out. Loadd default settings 
function InitPage(blnposted,blnMailSent,blnDiacount)
{
	
	isLeaseOPtionDisable="0";
	blnDiscountMatch=blnDiacount;
	//Graying out the table when page in initially loaded
	if(blnposted=="0")
	{
		GrayOutTable(blnposted);
		document.getElementById("HP").disabled="true";
		document.getElementById("PP").disabled="true";
		document.getElementById("PPP").disabled="true";
		document.getElementById("EP").disabled="true";
		document.getElementById("EPP").disabled="true";
		document.getElementById("EPRP").disabled="true";
		document.getElementById("Purchase").disabled="true";
		//Check for a_hn_plans.asp
		if(document.getElementById("selPartner")!=null)
		{
			document.getElementById("txtPrivNotes").disabled="true";
		}
		/*document.getElementById("rbtnFormSubmit_1").disabled="true";
		document.getElementById("rbtnFormSubmit_2").disabled="true";
		document.getElementById("rbtnFormSubmit_3").disabled="true";*/
		document.getElementById("Lease").disabled="true";				
	}
	else
	{
		//Ungray the table
		GrayOutTable(blnposted);		
		document.getElementById("HP").enabled="true";
		document.getElementById("PP").enabled="true";
		document.getElementById("PPP").enabled="true";
		document.getElementById("EP").enabled="true";
		document.getElementById("EPP").enabled="true";
		document.getElementById("EPRP").enabled="true";
		/*document.getElementById("rbtnFormSubmit_1").enabled="true";
		document.getElementById("rbtnFormSubmit_2").enabled="true";
		document.getElementById("rbtnFormSubmit_3").enabled="true";*/
		//Check for a_hn_plans.asp
		if(document.getElementById("selPartner")!=null)
		{
			document.getElementById("txtPrivNotes").enabled="true";
		}
		document.getElementById("Purchase").enabled="true";
		document.getElementById("Lease").enabled="true";
		document.getElementById("Purchase").checked="true";
		SelectOption("Purchase");
		document.getElementById("PP").checked="true";
		previousSelectedPlan="PP"
	}
	if(blnMailSent=="1")
	{
		alert("Thanks for submiting your information. Our representative will contact you soon.")
	}
}
function GrayOutTable(isPosted)
{
	var tagid;
	if(isPosted=="0")
	{
		var tds=document.getElementsByTagName("td");
		for(i=0;i<tds.length;i++)
		{
			tagid=tds[i].id;
			if(tagid.indexOf("Mo")<0 && tagid.indexOf("Up")<0)
			{
				tds[i].style.color="#999999";
			}
		}
	}
	else
	{
		var tds=document.getElementsByTagName("td");
		for(i=0;i<tds.length;i++)
		{
			tagid=tds[i].id;
			if(tagid.indexOf("Mo")<0 && tagid.indexOf("Up")<0 && tagid.indexOf("txtPlanH")<0 && tds[i].className!="optionsText" && tds[i].className!="optionsHL")
			{
				tds[i].style.color="#000000";
			}
		}
	}
}

///Function to update cart /floating table when user selected any option or plan
function UpdateCart()
{
	var sumUpfront,SumMonthly;
	var rebate,Monthly,rental;
	if(selOption=="Purchase")
	{
		sumUpfront=0.0;
		SumMonthly=0.0;
		str_Pur_Equipment="199.99";
		str_Pur_StdInstall="199.99";
		str_Pur_Activation="0";
		str_Pur_Shipping="0";
		sumUpfront=sumUpfront+parseFloat(str_Pur_Equipment)+parseFloat(str_Pur_StdInstall)+parseFloat(str_Pur_Activation)+parseFloat(str_Pur_Shipping)
		document.getElementById("colEqUp").innerHTML="$"+str_Pur_Equipment;
		document.getElementById("colSIUp").innerHTML="$"+str_Pur_StdInstall;
		document.getElementById("colAcUp").innerHTML="$"+str_Pur_Activation;
		document.getElementById("colSHUp").innerHTML="$"+str_Pur_Shipping;
		switch(selPlan)
		{
			case "HP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Upfront Payment<br> Home Plan</b>";
				rebate=document.getElementById("colHP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colHP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colHP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colHP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colHP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);	
				break;
			case "PP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Upfront Payment<br> Pro Plan</b>";
				rebate=document.getElementById("colPP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colPP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colPP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colPP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colPP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);	
				break;
			case "PPP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Upfront Payment<br> ProPlus Plan</b>";
				rebate=document.getElementById("colPPP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colPPP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colPPP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colPPP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colPPP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);
				break;
			case "EP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Upfront Payment<br> Elite Plan</b>";
				rebate=document.getElementById("colEP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colEP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colEP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colEP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colEP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);
				break;
			case "EPP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Upfront Payment<br> ElitePlus Plan</b>";
				rebate=document.getElementById("colEPP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colEPP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colEPP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colEPP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colEPP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);
				break;
			case "EPRP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Upfront Payment<br> ElitePremium Plan</b>";
				rebate=document.getElementById("colEPRP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colEPRP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colEPRP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colEPRP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colEPRP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);
				break;			
		}
		
	}
	else
	{
		sumUpfront=0.0;
		SumMonthly=0.0;
		str_Lea_Equipment="0";
		str_Lea_StdInstall="0";
		str_Lea_Activation="99.99";
		str_Lea_Shipping="0";
		document.getElementById("colEqUp").innerHTML="$"+str_Lea_Equipment;
		document.getElementById("colSIUp").innerHTML="$"+str_Lea_StdInstall;
		document.getElementById("colAcUp").innerHTML="$"+str_Lea_Activation;
		document.getElementById("colSHUp").innerHTML="$"+str_Lea_Shipping;
		sumUpfront=sumUpfront+parseFloat(str_Lea_Equipment)+parseFloat(str_Lea_StdInstall)+parseFloat(str_Lea_Activation)+parseFloat(str_Lea_Shipping)
		switch(selPlan)
		{
			case "HP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Lease option<br> Home Plan</b>";
				rebate=document.getElementById("colHP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colHP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colHP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colHP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colHP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);
			break;
			case "PP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Lease option<br> Pro Plan</b>";
				rebate=document.getElementById("colPP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colPP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colPP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colHP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colHP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);
			break;
			case "PPP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Lease option<br> ProPlus Plan</b>";
				rebate=document.getElementById("colPPP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colPPP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colPPP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colHP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colHP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);
			break;
			case "EP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Lease option<br> Elite Plan</b>";
					rebate=document.getElementById("colEP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colEP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colEP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colHP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colHP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);
			break;
			case "EPP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Lease option<br> ElitePlus Plan</b>";
				rebate=document.getElementById("colEPP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colEPP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colEPP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colHP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colHP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);
			break;
			case "EPRP":
				document.getElementById("colPlanMoUp").innerHTML="<b>Lease option<br> ElitePremium Plan</b>";
				rebate=document.getElementById("colEPRP7").innerHTML.substring(2);
				document.getElementById("colRUp").innerHTML="$"+rebate
				monthly=document.getElementById("colEPRP2").innerHTML.substring(1);
				document.getElementById("colMSMo").innerHTML="$"+monthly;
				rental=document.getElementById("colEPRP3").innerHTML;	
				document.getElementById("colLRMo").innerHTML=rental;
				rental=rental.substring(1);	
				sumUpfront=sumUpfront-parseFloat(rebate);
				if(sumUpfront<0)
				{
					sumUpfront=0;
				}
				document.getElementById("colTotUp").innerHTML="$"+RoundNumber(sumUpfront);
				if(blnDiscountMatch=="1")
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)-parseFloat(document.getElementById("colHP4").innerHTML.substring(2));
					document.getElementById("colSMo").innerHTML=document.getElementById("colHP4").innerHTML
				}
				else
				{
					SumMonthly=parseFloat(monthly)+parseFloat(rental)
				}
				document.getElementById("colTotMo").innerHTML="$"+RoundNumber(SumMonthly);
			break;			
		}
	}
		
}

/// This function is used to show Saving option Curently this functionality is commented.
function UpdateCartForSaving()
{
	var rebates,Saving,UpTot,Montot;
	var upTotNew,MontotNew;
	if(document.getElementById("chkShowMoBill").checked)
	{
		rebates=document.getElementById("colRUp").innerHTML;
		document.getElementById("colRUp").innerHTML="$0";
		UpTot=document.getElementById("colTotUp").innerHTML;
		upTotNew=parseFloat(rebates.substring(1))+parseFloat(UpTot.substring(1));
		document.getElementById("colTotUp").innerHTML="$"+RoundNumber(upTotNew);
		Saving=parseFloat(rebates.substring(1))/4;
		document.getElementById("colSMo").innerHTML="$"+RoundNumber(Saving);
		Montot=document.getElementById("colTotMo").innerHTML;
		MontotNew=parseFloat(Montot.substring(1))-Saving;
		document.getElementById("colTotMo").innerHTML="$"+RoundNumber(MontotNew);
	}
	else
	{
		document.getElementById("colSMo").innerHTML="";
		UpdateCart();
	}
}
//Rounds a particular number
function RoundNumber(num)
{
	return (Math.round(num*100))/100;
}

//This function is called ehen state=VT
function DisableLeaseOption()
{
	document.getElementById("Lease").disabled="true";
	 DeselectLease();
	alert("Sorry, due to state regulations our Lease Option is not available in Vermont");
	isLeaseOPtionDisable="1";
}

//This function is used to submit the form
var sPlan;
function SubmitThisPage(valType)
{
	if(valType=="PlaceOrder")
	{
		//Call a function that will set the order status
		if(SetOrderStatus("4")=="1")
		{
			document.getElementById("FlgForm").value="1";
			document.getElementById("MyForm").action="https://www.elitesat.com/order.asp"	
			document.getElementById("MyForm").submit();
		}
		else
		{
			alert("Error!  Sorry, please complete the form and verify coverage in your area before continuing.")
		}
	}
	else if (valType=="APlaceOrder")
	{
		if(SetOrderStatus("4")=="1")
		{
			document.getElementById("FlgForm").value="1";
			document.getElementById("MyForm").action="a_OrderEdit.asp"
			//document.location.href="a_OrderEdit.asp?oid="+orderid
			document.getElementById("MyForm").submit()
		}
		else
		{
			alert("Error!  Sorry, please complete the form and verify coverage in your area before continuing.")
		}
	}
	else if (valType=="AddAPrivNotes")
	{
		if(SetOrderStatus("11")=="1")
		{
			alert("Private notes added.")
		}
		else
		{
			alert("Error!  Sorry, please complete the form and verify coverage in your area before continuing.")
		}
	}
	else if (valType=="CallMe")
	{
		//Call a function that will set the order status
		if(SetOrderStatus("3")=="1")
		{
			DisplayModalDialog()
		}
		else
		{
			alert("Error!  Sorry, please complete the form and verify coverage in your area before continuing.")
		}
	}
	else if (valType=="ViewPlan")
	{
		//Call a function that will set the order status
		var pn
		switch(selPlan)
			{
				case "HP":
					sPlan="Home";
				break;
				case "PP":
					sPlan="Pro";
				break;
				case "PPP":
					sPlan="ProPlus";
				break;
				case "EP":
					sPlan="Elite";
				break;
				case "EPP":
					sPlan="ElitePlus";
				break;
				case "EPRP":
					sPlan="ElitePremium";
				break;
			}
		objAjax=creat_Object();
		pn=sPlan+" "+selOption
		objAjax.open("GET", "hn_Plans.asp?func=gp&pn="+pn); 
		objAjax.onreadystatechange = Plan_Callback;
		objAjax.send('');
	}
	else
	{
		//Call a function that will set the order status
		if(SetOrderStatus("2")=="1")
		{
			switch(selPlan)
			{
				case "HP":
					sPlan="HomePlan";
				break;
				case "PP":
					sPlan="ProPlan";
				break;
				case "PPP":
					sPlan="ProPlusPlan";
				break;
				case "EP":
					sPlan="ElitePlan";
				break;
				case "EPP":
					sPlan="ElitePlusPlan";
				break;
				case "EPRP":
					sPlan="ElitePremiumPlan";
				break;
			}
			ShowIContactDialog();
		}				
		else
		{
			alert("Error!  Sorry, please complete the form and verify coverage in your area before continuing.")
		}
	}
}

//''CallBackFunction for planid
function Plan_Callback()
{
	if(objAjax.readyState == 1)
	{
	
	}
	if(objAjax.readyState == 4)
	{
		var Answer,pid,arr
		Answer=objAjax.responseText;
		arr=Answer.split("|")
		pid=arr[0];
		if(Answer.indexOf("Found")>-1)
		{
			document.getElementById("fldIContact").value="0";
			document.getElementById("fldSend").value="0";
			document.getElementById("FlgForm").value="0";
			document.getElementById("PlanID").value=pid
			document.getElementById("MyForm").action="HughesNet_Plan_Details.asp";
			document.getElementById("MyForm").submit();
		}
		else
		{
			alert("Error!  Sorry, please complete the form and verify coverage in your area before continuing.")			
		}
	}
}


// This function used Ajax to set the order status for the current order
function SetOrderStatus(strStatus)
{
	var orderid,response;
	orderid=document.getElementById("OrderID").value
	if(orderid!="")
	{
		objAjax=creat_Object();
		if(strStatus=="11")
		{
			var url
			url="a_hn_plans.asp?func=order&OrderID="+orderid+"&status=3&pn="+document.getElementById("txtPrivNotes").value+"&p="+document.getElementById("selPartner").value
			objAjax.open("GET",url,false)
		}
		else
		{
			objAjax.open("GET","hn_plans.asp?func=order&OrderID="+orderid+"&status="+strStatus,false)
		}
		objAjax.send(" ");
		response=objAjax.responseText;
		if(response=="Success")
		{
			return "1";
		}
		else
		{
			return "0";
		}
	}
	else
	{
		return "0";
	}
}
var x,y
/// Dispalys CALL ME dialog
function DisplayModalDialog()
{
	var scrollPos;
	GetPageXY();
	scrollPos=Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
	//document.getElementById("txtName").value="";
	//document.getElementById("txtEPhone").value="";
	document.getElementById("txtEmail").value="";
	document.getElementById("divModalMain").style.top="0px";
	document.getElementById("divModalMain").style.width=x+"px";
	document.getElementById("divModalMain").style.height=y+"px";
	document.getElementById("divModalMain").style.display="block";
	document.getElementById("divModalSub").style.display="block";
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		document.getElementById("divModalSub").style.position="absolute";
	}
	//document.getElementById("divModalSub").style.top=(scrollPos/2-100)+"px";
	document.getElementById("divModalSub").style.top=200
	document.getElementById("divModalMain").style.filter="alpha(opacity=70)";
	document.getElementById("divModalMain").style.left="0px";
	document.getElementById("divModalMain").style.opacity="0.7";
	document.getElementById("divModalMain").style.MozOpacity="0.7";
	document.getElementById("divModalMain").style.KhtmlOpacity="0.7";	
}
//Closes CALL ME dialog
function CloseMe()
{
	document.getElementById("divModalSub").style.display="none";
	document.getElementById("divModalMain").style.display="none";
}
/// Dispalys Icontact  dialog
function ShowIContactDialog()
{
	var scrollPos;
	GetPageXY();
	scrollPos=Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
	document.getElementById("fields_email").value="";
	//document.getElementById("fields_fname").value="";
	//document.getElementById("fields_lname").value="";
	//document.getElementById("fields_phone").value="";
	document.getElementById("divModalMain").style.top="0px";
	document.getElementById("divModalMain").style.width=x+"px";
	document.getElementById("divModalMain").style.height=y+"px";
	document.getElementById("divModalMain").style.display="block";
	document.getElementById("divMoIContact").style.display="block";
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		document.getElementById("divMoIContact").style.position="absolute";
	}
	//document.getElementById("divMoIContact").style.top=(scrollPos/2+100)+"px";
	document.getElementById("divMoIContact").style.top=200
	document.getElementById("divModalMain").style.filter="alpha(opacity=70)";
	document.getElementById("divModalMain").style.left="0px";
	document.getElementById("divModalMain").style.opacity="0.7";
	document.getElementById("divModalMain").style.MozOpacity="0.7";
	document.getElementById("divModalMain").style.KhtmlOpacity="0.7";	
}
function SubmitToiContact()
{
	if(ValidateIContactForm())
	{
		document.getElementById("fldIContact").value="1";
		document.getElementById("fldSend").value="0";
		document.getElementById("FlgForm").value="1";
		document.getElementById("MyForm").submit();		
	}
}
function CloseToiContact()
{
	document.getElementById("divMoIContact").style.display="none";
	document.getElementById("divModalMain").style.display="none";
}
//Validates iContact form
function ValidateIContactForm()
{
	var name,email;
	name=document.getElementById("fields_fname").value;
	email=document.getElementById("fields_email").value;
	if(Trim(email)=="")
	{
		alert("Please enter your email");
		document.getElementById("fields_email").value="";
		document.getElementById("fields_email").focus();
		return false;
	}
	else if(!IsValidEmail(email))
	{
		alert("Please enter a valid email Id.");
		document.getElementById("fields_email").value="";
		document.getElementById("fields_email").focus();
		return false;
	}
	if(Trim(name)=="")
	{
		alert("Please enter your name");
		document.getElementById("fields_fname").value="";
		document.getElementById("fields_fname").focus();
		return false;
	}	
	return true;
}
//submiots CALL ME Dialog 
function SubmitDialog()
{
	if(ValidateEmailForm())
	{
		name=document.getElementById("fldIContact").value="0";
		name=document.getElementById("fldSend").value="1";
		name=document.getElementById("FlgForm").value="1";	
		document.getElementById("MyForm").submit();
	}
}
//validates CALL ME dialog
function ValidateEmailForm()
{
	var name,phNo,email;
	name=document.getElementById("txtName").value;
	phNo=document.getElementById("txtEPhone").value;
	email=document.getElementById("txtEmail").value;
	if(Trim(name)=="")
	{
		alert("Please enter your name");
		document.getElementById("txtName").value="";
		document.getElementById("txtName").focus();
		return false;
	}
	if(Trim(phNo)=="")
	{
		alert("Please enter Phone Number");
		document.getElementById("txtEPhone").value="";
		document.getElementById("txtEPhone").focus();
		return false;
	}
	else
	{
		if(!ValidatePhoneNumber(phNo))
		{
			alert("Please enter Phone Number in valid format");
			document.getElementById("txtEPhone").focus();
			return false;	
		}
	}	
	return true;
}
//Checks if the email entered is valid
function IsValidEmail(strmail)
{
	var objRegExp = /^.+@.+\..{2,3}$/
	return objRegExp.test(strmail);
}

//Gets the page sixe
function GetPageXY()
{
	var D=document;
	y =Math.max(Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),Math.max(D.body.clientHeight, D.documentElement.clientHeight));
	x =Math.max(Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),Math.max(D.body.clientWidth, D.documentElement.clientWidth));		   	
}
/// functions for Order.asp
function DiableBAddress(checkCode)
{
	if(checkCode=="")
	{
		ocode=0;
	}
	else
	{
		ocode=parseInt(checkCode);
	}
	if(!(ocode==1||ocode==2||ocode==4||ocode==6||ocode==49||ocode==101||ocode==105||ocode==106||ocode==107||ocode==108||ocode==109||ocode==110||ocode==111||ocode==112||ocode==113||ocode==114||ocode==115||ocode==116||ocode==117||ocode==118||ocode==119||ocode==120||ocode==121||ocode==122||ocode==123||ocode==124||ocode==125||ocode==126))
	{
		document.getElementById("NameSMo2").style.color="#999999";
		document.getElementById("ZipMo1").style.color="#999999";
		document.getElementById("PhMo1").style.color="#999999";
		document.getElementById("PhMo2").style.color="#999999";
		document.getElementById("txtCcfName").disabled=true;
		document.getElementById("txtCcmName").disabled=true;
		document.getElementById("txtCclName").disabled=true;
		document.getElementById("txtCcCompany").disabled=true;
		document.getElementById("txtCcAddress").disabled=true;
		if(ocode!=11)
		{
			document.getElementById("txtCcCity").disabled=true;
			document.getElementById("txtCcState").disabled=true;
			document.getElementById("txtCcZip").disabled=true;
		}
	}
}
function EnableBAddress(checkCode)
{
	if(checkCode=="")
	{
		ocode=0;
	}
	else
	{
		ocode=parseInt(checkCode);
	}
	if(!(ocode==1||ocode==2||ocode==4||ocode==6||ocode==49||ocode==101||ocode==105||ocode==106||ocode==107||ocode==108||ocode==109||ocode==110||ocode==111||ocode==112||ocode==113||ocode==114||ocode==115||ocode==116||ocode==117||ocode==118||ocode==119||ocode==120||ocode==121||ocode==122||ocode==123||ocode==124||ocode==125||ocode==126))
	{
		if(document.getElementById("BAddress").checked==true)
		{
			document.getElementById("NameSMo2").style.color="#000000";
			document.getElementById("ZipMo1").style.color="#000000";
			document.getElementById("PhMo1").style.color="#000000";
			document.getElementById("PhMo2").style.color="#000000";
			document.getElementById("txtCcfName").disabled=false;
			document.getElementById("txtCcmName").disabled=false;
			document.getElementById("txtCclName").disabled=false;
			document.getElementById("txtCcCompany").disabled=false;
			document.getElementById("txtCcAddress").disabled=false;
			if(ocode!=11)
			{
				document.getElementById("txtCcCity").disabled=false;
				document.getElementById("txtCcState").disabled=false;
				document.getElementById("txtCcZip").disabled=false;
			}
		}
		else
		{
			document.getElementById("NameSMo2").style.color="#999999";
			document.getElementById("ZipMo1").style.color="#999999";
			document.getElementById("PhMo1").style.color="#999999";
			document.getElementById("PhMo2").style.color="#999999";
			document.getElementById("txtCcfName").disabled=true;
			document.getElementById("txtCcmName").disabled=true;
			document.getElementById("txtCclName").disabled=true;
			document.getElementById("txtCcCompany").disabled=true;
			document.getElementById("txtCcAddress").disabled=true;
			if(ocode!=11)
			{
				document.getElementById("txtCcCity").disabled=true;
				document.getElementById("txtCcState").disabled=true;
				document.getElementById("txtCcZip").disabled=true;
			}
		}
	}	
}

//Validating order form
function ValidateOrderForm()
{
	var zipcode,phNo,name,lname,email,email1,password,InstAddress,city,state,baddress;
	zipcode=document.getElementById("txtZip").value;
	phNo=document.getElementById("txtPhone").value;
	name=document.getElementById("txtFName").value;
	lname=document.getElementById("txtLName").value;
	email=document.getElementById("txtEmail").value;
	email1=document.getElementById("txtEmail1").value;
	//password=document.getElementById("txtPassword").value;
	InstAddress=document.getElementById("txtAddress1").value;
	city=document.getElementById("txtCity").value;
	state=document.getElementById("txtState").value;
	if(Trim(name)=="")
	{
		alert("Please enter name");
		document.getElementById("txtFName").focus();
		return false;
	}
	if(Trim(lname)=="")
	{
		alert("Please enter last name");
		document.getElementById("txtLName").focus();
		return false;
	}
	if(!ValidatePhoneNumber(phNo))
	{
		alert("Please enter Phone Number in valid format");
		document.getElementById("txtPhone").focus();
		return false;	
	}
	if(!IsValidEmail(email))
	{
		alert("Please enter a valid email Id.");
		document.getElementById("txtEmail").focus();
		return false;
	}
	if(!IsValidEmail(email1))
	{
		alert("Please enter a valid email Id.");
		document.getElementById("txtEmail1").focus();
		return false;
	}
	if(email!=email1)
	{
		alert("Please enter a same email Id in both boxes.");
		document.getElementById("txtEmail1").focus();
		return false;
	}
	/* commenting out this portion
	if(Trim(password)=="")
	{
		alert("Please enter password");
		document.getElementById("txtPassword").focus();
		return false;
	}
	*/
	if(Trim(InstAddress)=="")
	{
		alert("Please enter installation address");
		document.getElementById("txtAddress1").focus();
		return false;
	}
	if(Trim(city)=="")
	{
		alert("Please enter city");
		document.getElementById("txtCity").focus();
		return false;
	}
	if(Trim(state)=="")
	{
		alert("Please enter state");
		document.getElementById("txtState").focus();
		return false;
	}	
	if(Trim(zipcode)=="")
	{
		alert("Please enter zip code");
		document.getElementById("txtZip").focus();
		return false;
	}
	else
	{
		if(isNaN(zipcode))
		{
			alert("Please enter valid Zip Code");
			document.getElementById("txtZip").focus();
			return false;	
		}
		else
		{
			if(zipcode.length>5 || zipcode.length<5)
			{
				alert("Zip Code can be 5 digit long.");
				document.getElementById("txtZip").focus();
				return false;
			}
		}
	}
	if(document.getElementById("BAddress").checked==true)
	{
		zipcode=document.getElementById("txtCcZip").value;
		InstAddress=document.getElementById("txtCcAddress").value;
		city=document.getElementById("txtCcCity").value;
		state=document.getElementById("txtCcState").value;
		name=document.getElementById("txtCcfName").value;
		if(Trim(name)=="")
		{
			alert("Please enter billing name");
			document.getElementById("txtCcfName").value="";
			document.getElementById("txtCcfName").focus();
			return false;
		}
		if(Trim(InstAddress)=="")
		{
			alert("Please enter billing address");
			document.getElementById("txtCcAddress").value="";
			document.getElementById("txtCcAddress").focus();
			return false;
		}
		if(Trim(city)=="")
		{
			alert("Please enter billing city");
			document.getElementById("txtCcCity").value="";
			document.getElementById("txtCcCity").focus();
			return false;
		}
		if(Trim(state)=="")
		{
			alert("Please enter billing state");
			document.getElementById("txtCcState").value="";
			document.getElementById("txtCcState").focus();
			return false;
		}	
		if(Trim(zipcode)=="")
		{
			alert("Please enter billing zip code");
			document.getElementById("txtCcZip").value="";
			document.getElementById("txtCcZip").focus();
			return false;
		}
		else
		{
			if(isNaN(zipcode))
			{
				alert("Please enter valid billing Zip Code");
				document.getElementById("txtCcZip").focus();
				return false;	
			}
			else
			{
				if(zipcode.length>5 || zipcode.length<5)
				{
					alert("Zip Code can be 5 digit long.");
					document.getElementById("txtCcZip").focus();
					return false;
				}
			}
		}
	}
	document.getElementById("MyForm").submit();
}

function DisplayCorrectBox()
{
	var boption
	boption=document.getElementById("BulkAction").value;
	if(boption=="Email")
	{
		document.getElementById("EmailLetter").style.display="block";
		document.getElementById("RWindow3").style.display="none";
	}
	else if (boption=="ChangeStatus")
	{
		document.getElementById("EmailLetter").style.display="none";
		document.getElementById("RWindow3").style.display="block";
	}
	else
	{
		document.getElementById("EmailLetter").style.display="none";
		document.getElementById("RWindow3").style.display="none";
	}
}
function ValidateSubmitASPForm(checkCode)
{
		var zipcode,phNo,name,lname,email,password,InstAddress,city,state,baddress,cctype,ccNumber,ccMonth,ccYear,SSN;
		var prevAddress,prevcity,prevstate,prevzip;
		var ocode;
		if(checkCode=="")
		{
			ocode=0;
		}
		else
		{
			ocode=parseInt(checkCode);
		}
		cctype=document.getElementById("CcType").value;
		ccNumber=document.getElementById("CcNumber").value;
		ccMonth=document.getElementById("CcMonth").value;
		ccYear=document.getElementById("CcYear").value;
		if(Trim(ccNumber)=="")
		{
			alert("Please enter your credit card number");
			document.getElementById("CcNumber").focus();
			return false;
		}
		else
		{
			if(isNaN(ccNumber))
			{
				alert("Please enter only digits for card number");
				document.getElementById("CcNumber").focus();
				return false;
			}
		}
		if(ocode==115||ocode==116||ocode==120||ocode==121||ocode==122||ocode==126)
		{
			if(!document.getElementById("LandloardPermission").checked)
			{
				alert("Please check whether you have Landlord's permission.");
				return false;
			}
		}
		if(ocode==117 || ocode==119)
		{
			if(!document.getElementById("OwnerPermission").checked)
			{
				alert("Please check whether you have Owner permission.");
				return false;
			}
		}
		if(ocode==125)
		{
			if(!document.getElementById("VermontFlag").checked)
			{
				alert("Please check whether you Live in Vermont.");
				return false;
			}		
		}		
		if(ocode==1||ocode==2||ocode==4||ocode==10||ocode==18||ocode==49||ocode==101||ocode==105||ocode==106||ocode==107||ocode==108||ocode==109||ocode==110||ocode==111||ocode==112||ocode==113||ocode==114||ocode==115||ocode==116||ocode==117||ocode==118||ocode==119||ocode==120||ocode==121||ocode==122||ocode==123||ocode==124||ocode==125||ocode==126)
		{
			zipcode=document.getElementById("txtCcZip").value;
			InstAddress=document.getElementById("txtCcAddress").value;
			city=document.getElementById("txtCcCity").value;
			state=document.getElementById("txtCcState").value;
			name=document.getElementById("txtCcfName").value;
			lname=document.getElementById("txtCclName").value;
			if(Trim(name)=="")
			{
				alert("Please enter billing name");
				document.getElementById("txtCcfName").focus();
				return false;
			}
			if(Trim(lname)=="")
			{
				alert("Please enter billing last name");
				document.getElementById("txtCclName").focus();
				return false;
			}
			if(Trim(InstAddress)=="")
			{
				alert("Please enter billing address");
				document.getElementById("txtCcAddress").focus();
				return false;
			}
			if(Trim(city)=="")
			{
				alert("Please enter billing city");
				document.getElementById("txtCcCity").focus();
				return false;
			}
			if(Trim(state)=="")
			{
				alert("Please enter billing state");
				document.getElementById("txtCcState").focus();
				return false;
			}	
			if(Trim(zipcode)=="")
			{
				alert("Please enter billing zip code");
				document.getElementById("txtCcZip").focus();
				return false;
			}
			else
			{
				if(isNaN(zipcode))
				{
					alert("Please enter valid billing Zip Code");
					document.getElementById("txtCcZip").focus();
					return false;	
				}
				else
				{
					if(zipcode.length>5 || zipcode.length<5)
					{
						alert("Zip Code can be 5 digit long.");
						document.getElementById("txtCcZip").focus();
						return false;
					}
				}
			}
			SSN=document.getElementById("txtSSN").value;			
			if(Trim(SSN)!="")
			{
				if(SSN.length==9)
				{
					if(isNaN(SSN))
					{
						alert("Please enter only digits for SSN number");
						document.getElementById("txtSSN").focus();
						return false;
					}			
				}
				else
				{
					alert("You have entered an invalid SSN. Please enter last 4 digit or complete 9 digit SSN");
					return false;
				}
			}	
		}
		if(ocode==6||ocode==10||ocode==18)
		{
			zipcode=document.getElementById("txtCcZip21").value;
			InstAddress=document.getElementById("txtCcAddress21").value;
			city=document.getElementById("txtCcCity21").value;
			state=document.getElementById("txtCcState21").value;
			name=document.getElementById("txtCcfName21").value;
			lname=document.getElementById("txtCclName21").value;
			if(Trim(name)=="")
			{
				alert("Please enter billing name");
				document.getElementById("txtCcfName21").focus();
				return false;
			}
			if(Trim(lname)=="")
			{
				alert("Please enter billing last name");
				document.getElementById("txtCclName21").focus();
				return false;
			}
			if(Trim(InstAddress)=="")
			{
				alert("Please enter billing address");
				document.getElementById("txtCcAddress21").focus();
				return false;
			}
			if(Trim(city)=="")
			{
				alert("Please enter billing city");
				document.getElementById("txtCcCity21").focus();
				return false;
			}
			if(Trim(state)=="")
			{
				alert("Please enter billing state");
				document.getElementById("txtCcState21").focus();
				return false;
			}	
			if(Trim(zipcode)=="")
			{
				alert("Please enter billing zip code");
				document.getElementById("txtCcZip21").focus();
				return false;
			}
			else
			{
				if(isNaN(zipcode))
				{
					alert("Please enter valid billing Zip Code");
					document.getElementById("txtCcZip21").focus();
					return false;	
				}
				else
				{
					if(zipcode.length>5 || zipcode.length<5)
					{
						alert("Zip Code can be 5 digit long.");
						document.getElementById("txtCcZip21").focus();
						return false;
					}
				}
			}
		}
		if(ocode==11||ocode==100)
		{
			city=document.getElementById("txtCity1").value;
			state=document.getElementById("txtState1").value;
			zipcode=document.getElementById("txtZip1").value;
			if(Trim(city)=="")
			{
				alert("Please enter billing city");
				document.getElementById("txtCity1").focus();
				return false;
			}
			if(Trim(state)=="")
			{
				alert("Please enter billing state");
				document.getElementById("txtState1").focus();
				return false;
			}	
			if(Trim(zipcode)=="")
			{
				alert("Please enter billing zip code");
				document.getElementById("txtZip1").focus();
				return false;
			}
			else
			{
				if(isNaN(zipcode))
				{
					alert("Please enter valid billing Zip Code");
					document.getElementById("txtZip1").focus();
					return false;	
				}
				else
				{
					if(zipcode.length>5 || zipcode.length<5)
					{
						alert("Zip Code can be 5 digit long.");
						document.getElementById("txtZip1").focus();
						return false;
					}
				}
			}
			if (document.getElementById("txtCcCity2")==null || document.getElementById("txtCcCity2")=='undefined')
			{
			}
			else
			{
				city=document.getElementById("txtCcCity2").value;
				state=document.getElementById("txtCcState2").value;
				zipcode=document.getElementById("txtCcZip2").value;
				if(Trim(city)=="")
				{
					alert("Please enter billing city");
					document.getElementById("txtCcCity2").focus();
					return false;
				}
				if(Trim(state)=="")
				{
					alert("Please enter billing state");
					document.getElementById("txtCcState2").focus();
					return false;
				}	
				if(Trim(zipcode)=="")
				{
					alert("Please enter billing zip code");
					document.getElementById("txtCcZip2").focus();
					return false;
				}
				else
				{
					if(isNaN(zipcode))
					{
						alert("Please enter valid billing Zip Code");
						document.getElementById("txtCcZip2").focus();
						return false;	
					}
					else
					{
						if(zipcode.length>5 || zipcode.length<5)
						{
							alert("Zip Code can be 5 digit long.");
							document.getElementById("txtCcZip2").focus();
							return false;
						}
					}
				}
			}
			if (document.getElementById("txtPreviousCity2")==null || document.getElementById("txtPreviousCity2")=='undefined')
			{
			}
			else
			{
				city=document.getElementById("txtPreviousCity2").value;
				state=document.getElementById("txtPreviousState2").value;
				zipcode=document.getElementById("txtPreviousZipCode2").value;
				if(Trim(city)=="")
				{
					alert("Please enter billing city");
					document.getElementById("txtPreviousCity2").focus();
					return false;
				}
				if(Trim(state)=="")
				{
					alert("Please enter billing state");
					document.getElementById("txtPreviousState2").focus();
					return false;
				}	
				if(Trim(zipcode)=="")
				{
					alert("Please enter billing zip code");
					document.getElementById("txtPreviousZipCode2").focus();
					return false;
				}
				else
				{
					if(isNaN(zipcode))
					{
						alert("Please enter valid billing Zip Code");
						document.getElementById("txtPreviousZipCode2").focus();
						return false;	
					}
					else
					{
						if(zipcode.length>5 || zipcode.length<5)
						{
							alert("Zip Code can be 5 digit long.");
							document.getElementById("txtPreviousZipCode2").focus();
							return false;
						}
					}
				}				
			}
		}
		if(!document.getElementById("AgreeTnC").checked)
		{
			alert("Please accept the terms and conditions of HughesNet Subscriber Agreement");
			return false;
		}
		document.getElementById("MyForm").submit();
}
function ValidateOrderEditForm(sval,checkCode)
{
	var zipcode,phNo,name,lname,email,password,InstAddress,city,state,baddress,cctype,ccNumber,ccMonth,ccYear,SSN;
	var prevAddress,prevcity,prevstate,prevzip;
	var ocode;
	if(checkCode=="")
	{
		ocode=0;
	}
	else
	{
		ocode=parseInt(checkCode);
	}
	if(sval!="1")
	{
		if(ocode>=0)
		{
			phNo=document.getElementById("txtPhone").value;
			name=document.getElementById("txtFName").value;
			lname=document.getElementById("txtLName").value;
			email=document.getElementById("txtEmail").value;
			//password=document.getElementById("txtPassword").value;
			InstAddress=document.getElementById("txtAddress1").value;		
			if(Trim(name)=="")
			{
				alert("Please enter name");
				document.getElementById("txtFName").focus();
				return false;
			}
			if(Trim(lname)=="")
			{
				alert("Please enter last name");
				document.getElementById("txtLName").focus();
				return false;
			}
			if(!ValidatePhoneNumber(phNo))
			{
				alert("Please enter Phone Number in valid format");
				document.getElementById("txtPhone").focus();
				return false;	
			}
			if(!IsValidEmail(email))
			{
				alert("Please enter a valid email Id.");
				document.getElementById("txtEmail").focus();
				return false;
			}
			/*
			if(Trim(password)=="")
			{
				alert("Please enter password");
				document.getElementById("txtPassword").focus();
				return false;
			}*/
			if(Trim(InstAddress)=="")
			{
				alert("Please enter installation address");
				document.getElementById("txtAddress1").focus();
				return false;
			}
			if(ocode!=11)
			{
				city=document.getElementById("txtCity").value;
				state=document.getElementById("txtState").value;
				zipcode=document.getElementById("txtZip").value;
				if(Trim(city)=="")
				{
					alert("Please enter city");
					document.getElementById("txtCity").focus();
					return false;
				}
				if(Trim(state)=="")
				{
					alert("Please enter state");
					document.getElementById("txtState").focus();
					return false;
				}	
				if(Trim(zipcode)=="")
				{
					alert("Please enter zip code");
					document.getElementById("txtZip").focus();
					return false;
				}
				else
				{
					if(isNaN(zipcode))
					{
						alert("Please enter valid Zip Code");
						document.getElementById("txtZip").focus();
						return false;	
					}
					else
					{
						if(zipcode.length>5 || zipcode.length<5)
						{
							alert("Zip Code can be 5 digit long.");
							document.getElementById("txtZip").focus();
							return false;
						}
					}
				}
			}
			if(!(ocode==1||ocode==2||ocode==4||ocode==6||ocode==49||ocode==101||ocode==105||ocode==106||ocode==107||ocode==108||ocode==109||ocode==110||ocode==111||ocode==112||ocode==113||ocode==114||ocode==115||ocode==116||ocode==117||ocode==118||ocode==119||ocode==120||ocode==121||ocode==122||ocode==123||ocode==124||ocode==125||ocode==126))
			{
				if(document.getElementById("BAddress").checked)
				{
					InstAddress=document.getElementById("txtCcAddress").value;
					name=document.getElementById("txtCcfName").value;
					lname=document.getElementById("txtCclName").value;
					if(Trim(name)=="")
					{
						alert("Please enter billing name");
						document.getElementById("txtCcfName").value="";
						document.getElementById("txtCcfName").focus();
						return false;
					}
					if(Trim(lname)=="")
					{
						alert("Please enter billing last name");
						document.getElementById("txtCclName").value="";
						document.getElementById("txtCclName").focus();
						return false;
					}
					if(Trim(InstAddress)=="")
					{
						alert("Please enter billing address");
						document.getElementById("txtCcAddress").value="";
						document.getElementById("txtCcAddress").focus();
						return false;
					}
					if(ocode!=11)
					{
						city=document.getElementById("txtCcCity").value;
						state=document.getElementById("txtCcState").value;
						zipcode=document.getElementById("txtCcZip").value;
						if(Trim(city)=="")
						{
							alert("Please enter billing city");
							document.getElementById("txtCcCity").value="";
							document.getElementById("txtCcCity").focus();
							return false;
						}
						if(Trim(state)=="")
						{
							alert("Please enter billing state");
							document.getElementById("txtCcState").value="";
							document.getElementById("txtCcState").focus();
							return false;
						}	
						if(Trim(zipcode)=="")
						{
							alert("Please enter billing zip code");
							document.getElementById("txtCcZip").value="";
							document.getElementById("txtCcZip").focus();
							return false;
						}
						else
						{
							if(isNaN(zipcode))
							{
								alert("Please enter valid billing Zip Code");
								document.getElementById("txtCcZip").focus();
								return false;	
							}
							else
							{
								if(zipcode.length>5 || zipcode.length<5)
								{
									alert("Zip Code can be 5 digit long.");
									document.getElementById("txtCcZip").focus();
									return false;
								}
							}
						}
					}
				}
			}		
		}
		cctype=document.getElementById("CcType").value;
		ccNumber=document.getElementById("CcNumber").value;
		ccMonth=document.getElementById("CcMonth").value;
		ccYear=document.getElementById("CcYear").value;
		if(Trim(ccNumber)=="")
		{
			alert("Please enter your credit card number");
			document.getElementById("CcNumber").focus();
			return false;
		}
		else
		{
			if(isNaN(ccNumber))
			{
				alert("Please enter only digits for card number");
				document.getElementById("CcNumber").focus();
				return false;
			}
		}
		if(ocode==115||ocode==116||ocode==120||ocode==121||ocode==122||ocode==126)
		{
			if(!document.getElementById("LandloardPermission").checked)
			{
				alert("Please check whether you have Landlord's permission.");
				return false;
			}
		}
		if(ocode==117 || ocode==119)
		{
			if(!document.getElementById("OwnerPermission").checked)
			{
				alert("Please check whether you have Owner permission.");
				return false;
			}
		}
		if(ocode==125)
		{
			if(!document.getElementById("VermontFlag").checked)
			{
				alert("Please check whether you Live in Vermont.");
				return false;
			}		
		}
		if(ocode==1||ocode==2||ocode==4||ocode==10||ocode==18||ocode==49||ocode==101||ocode==105||ocode==106||ocode==107||ocode==108||ocode==109||ocode==110||ocode==111||ocode==112||ocode==113||ocode==114||ocode==115||ocode==116||ocode==117||ocode==118||ocode==119||ocode==120||ocode==121||ocode==122||ocode==123||ocode==124||ocode==125||ocode==126)
		{
			zipcode=document.getElementById("txtCcZip1").value;
			InstAddress=document.getElementById("txtCcAddress1").value;
			city=document.getElementById("txtCcCity1").value;
			state=document.getElementById("txtCcState1").value;
			name=document.getElementById("txtCcfName1").value;
			lname=document.getElementById("txtCclName1").value;
			if(Trim(name)=="")
			{
				alert("Please enter billing name");
				document.getElementById("txtCcfName1").focus();
				return false;
			}
			if(Trim(lname)=="")
			{
				alert("Please enter billing last name");
				document.getElementById("txtCclName1").focus();
				return false;
			}
			if(Trim(InstAddress)=="")
			{
				alert("Please enter billing address");
				document.getElementById("txtCcAddress1").focus();
				return false;
			}
			if(Trim(city)=="")
			{
				alert("Please enter billing city");
				document.getElementById("txtCcCity1").focus();
				return false;
			}
			if(Trim(state)=="")
			{
				alert("Please enter billing state");
				document.getElementById("txtCcState1").focus();
				return false;
			}	
			if(Trim(zipcode)=="")
			{
				alert("Please enter billing zip code");
				document.getElementById("txtCcZip1").focus();
				return false;
			}
			else
			{
				if(isNaN(zipcode))
				{
					alert("Please enter valid billing Zip Code");
					document.getElementById("txtCcZip1").focus();
					return false;	
				}
				else
				{
					if(zipcode.length>5 || zipcode.length<5)
					{
						alert("Zip Code can be 5 digit long.");
						document.getElementById("txtCcZip1").focus();
						return false;
					}
				}
			}
			SSN=document.getElementById("txtSSN").value;
			if(Trim(SSN)!="")
			{
				if(SSN.length==9)
				{
					if(isNaN(SSN))
					{
						alert("Please enter only digits for SSN number");
						document.getElementById("txtSSN").focus();
						return false;
					}			
				}
				else
				{
					alert("You have entered an invalid SSN. Please enter last 4 digit or complete 9 digit SSN");
					return false;
				}
			}		
		}
		if(ocode==6||ocode==10||ocode==18)
		{
			zipcode=document.getElementById("txtCcZip21").value;
			InstAddress=document.getElementById("txtCcAddress21").value;
			city=document.getElementById("txtCcCity21").value;
			state=document.getElementById("txtCcState21").value;
			name=document.getElementById("txtCcfName21").value;
			lname=document.getElementById("txtCclName21").value;
			if(Trim(name)=="")
			{
				alert("Please enter billing name");
				document.getElementById("txtCcfName21").focus();
				return false;
			}
			if(Trim(lname)=="")
			{
				alert("Please enter billing last name");
				document.getElementById("txtCclName21").focus();
				return false;
			}
			if(Trim(InstAddress)=="")
			{
				alert("Please enter billing address");
				document.getElementById("txtCcAddress21").focus();
				return false;
			}
			if(Trim(city)=="")
			{
				alert("Please enter billing city");
				document.getElementById("txtCcCity21").focus();
				return false;
			}
			if(Trim(state)=="")
			{
				alert("Please enter billing state");
				document.getElementById("txtCcState21").focus();
				return false;
			}	
			if(Trim(zipcode)=="")
			{
				alert("Please enter billing zip code");
				document.getElementById("txtCcZip21").focus();
				return false;
			}
			else
			{
				if(isNaN(zipcode))
				{
					alert("Please enter valid billing Zip Code");
					document.getElementById("txtCcZip21").focus();
					return false;	
				}
				else
				{
					if(zipcode.length>5 || zipcode.length<5)
					{
						alert("Zip Code can be 5 digit long.");
						document.getElementById("txtCcZip21").focus();
						return false;
					}
				}
			}
		}
		if(ocode==11||ocode==100)
		{
			city=document.getElementById("txtCity11").value;
			state=document.getElementById("txtState11").value;
			zipcode=document.getElementById("txtZip11").value;
			if(Trim(city)=="")
			{
				alert("Please enter billing city");
				document.getElementById("txtCity11").focus();
				return false;
			}
			if(Trim(state)=="")
			{
				alert("Please enter billing state");
				document.getElementById("txtState11").focus();
				return false;
			}	
			if(Trim(zipcode)=="")
			{
				alert("Please enter billing zip code");
				document.getElementById("txtZip11").focus();
				return false;
			}
			else
			{
				if(isNaN(zipcode))
				{
					alert("Please enter valid billing Zip Code");
					document.getElementById("txtZip11").focus();
					return false;	
				}
				else
				{
					if(zipcode.length>5 || zipcode.length<5)
					{
						alert("Zip Code can be 5 digit long.");
						document.getElementById("txtZip11").focus();
						return false;
					}
				}
			}
			if (document.getElementById("txtCcCity11")==null || document.getElementById("txtCcCity11")=='undefined')
			{
			}
			else
			{
				city=document.getElementById("txtCcCity11").value;
				state=document.getElementById("txtCcState11").value;
				zipcode=document.getElementById("txtCcZip11").value;
				if(Trim(city)=="")
				{
					alert("Please enter billing city");
					document.getElementById("txtCcCity11").focus();
					return false;
				}
				if(Trim(state)=="")
				{
					alert("Please enter billing state");
					document.getElementById("txtCcState11").focus();
					return false;
				}	
				if(Trim(zipcode)=="")
				{
					alert("Please enter billing zip code");
					document.getElementById("txtCcZip11").focus();
					return false;
				}
				else
				{
					if(isNaN(zipcode))
					{
						alert("Please enter valid billing Zip Code");
						document.getElementById("txtCcZip11").focus();
						return false;	
					}
					else
					{
						if(zipcode.length>5 || zipcode.length<5)
						{
							alert("Zip Code can be 5 digit long.");
							document.getElementById("txtCcZip11").focus();
							return false;
						}
					}
				}
			}
			if (document.getElementById("txtPreviousCity11")==null || document.getElementById("txtPreviousCity11")=='undefined')
			{
			}
			else
			{
				city=document.getElementById("txtPreviousCity11").value;
				state=document.getElementById("txtPreviousState11").value;
				zipcode=document.getElementById("txtPreviousZipCode11").value;
				if(Trim(city)=="")
				{
					alert("Please enter billing city");
					document.getElementById("txtPreviousCity11").focus();
					return false;
				}
				if(Trim(state)=="")
				{
					alert("Please enter billing state");
					document.getElementById("txtPreviousState11").focus();
					return false;
				}	
				if(Trim(zipcode)=="")
				{
					alert("Please enter billing zip code");
					document.getElementById("txtPreviousZipCode11").focus();
					return false;
				}
				else
				{
					if(isNaN(zipcode))
					{
						alert("Please enter valid billing Zip Code");
						document.getElementById("txtPreviousZipCode11").focus();
						return false;	
					}
					else
					{
						if(zipcode.length>5 || zipcode.length<5)
						{
							alert("Zip Code can be 5 digit long.");
							document.getElementById("txtPreviousZipCode11").focus();
							return false;
						}
					}
				}				
			}
		}
	}
	if(!document.getElementById("AgreeTnC").checked)
	{
		alert("Please accept the terms and conditions of HughesNet Subscriber Agreement");
		return false;
	}
	document.getElementById("flgSForm").value=sval;
	document.getElementById("MyForm").submit();
}
function CreateOrder()
{
	var zip;
	zip=document.getElementById("txtZipSearch").value;
	if(Trim(zip)=="")
	{
		alert("Please enter the zip Code.")
		return false;
	}
	else
	{
		if(isNaN(zip)&&zip.length!=5)
		{
			alert("Please enter the zip Code in digits and 5 digit long.")
			return false;
		}
	}
	document.getElementById("flgSForm").value="CO";
	document.getElementById("MyForm").submit();
}
function SelectAllCheckBoxes(sType)
{
	var f,i;
	f=document.getElementById("MyForm");
	if(sType=="1")
	{
		for(i=0;i<f.elements.length;i++)
		{
			if(f.elements[i].id.indexOf("OchkAction_")>=0)
			{
				if(document.getElementById("chkAction").checked)
					f.elements[i].checked=true;
				else
					f.elements[i].checked=false;
			}
		}
	}
	else if(sType=="2")
	{
		for(i=0;i<f.elements.length;i++)
		{
			if(f.elements[i].id.indexOf("ZchkAction_")>=0)
			{
				if(document.getElementById("ZchkAction").checked)
					f.elements[i].checked=true;
				else
					f.elements[i].checked=false;
			}
		}
	}
	else if(sType=="5")
	{
		for(i=0;i<f.elements.length;i++)
		{
			if(f.elements[i].id.indexOf("chkAction_")>=0)
			{
				if(document.getElementById("chkAction").checked)
					f.elements[i].checked=true;
				else
					f.elements[i].checked=false;
			}
		}
	}
	else
	{
		for(i=0;i<f.elements.length;i++)
		{
			if(f.elements[i].id.indexOf("RchkAction_")>=0)
			{
				if(document.getElementById("RchkAction").checked)
					f.elements[i].checked=true;
				else
					f.elements[i].checked=false;
			}
		}
	}
	
}
function ViewOrderXML(oid)
{
	//mywin=window.open("a_ViewXML.asp?oid="+oid,"myWin","Status=0,Toolbar=0,address=0,width=500,height=400")
	mywin=window.open ("a_ViewXML.asp?oid="+oid,"mywindow","location=0,status=0,scrollbars=1,width=700,height=500");
}
//this function is used to automatically load the xity and state based on zip
function AutoFillFromZip(zipid,cityid,stateid)
{
	var zip,sResponse,sResponseArr;
	zip=document.getElementById(zipid).value;
	objAjax=creat_Object();
	objAjax.open("GET", "accessdenied.asp?Func=GetZipD&zip="+zip,false); 
	objAjax.send('');
	sResponse=objAjax.responseText;
	if(sResponse.indexOf("Found")>0)
	{
		sResponseArr=sResponse.split("|");
		document.getElementById(cityid).value=sResponseArr[1];
		document.getElementById(stateid).value=sResponseArr[2];
	}
	else
	{
		alert("No Match found");
	}
	
}
function CloseFlowingTable()
{
	document.getElementById("floatdiv").style.visibility="hidden";
}