var pagebgColor="";
var PL_AltColor="#DEF7FE";
var selOption,selPlan;
var isLeaseOPtionDisable;// checks if the lease option is diabled
var previousSelectedPlan="PP";
var selectedPlan
// 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
selectedPlan = "2"


var isBackEnd;

//'''Cookie Flag
var CookieStatus;
CookieStatus="0";




//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", "code_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
		{
			if (Answer.indexOf("1")>-1)
			{
				alert("Sorry you have entered a Military zip code. We Can only sell HughesNet to the lower 48 states. If it is being installed on a base in the lower 48 states please use a zip code from a nearby city.");		
			}
			else if (Answer.indexOf("2")>-1)
			{
				if(confirm("Sorry we do NOT cover Alaska. We Can only sell HughesNet to the lower 48 states. Press OK to be redirect to an Alaska dealer, or cancel to reenter zip code"))
				{
					document.location.href="http://www.hughesnetalaska.com/";
				}				
			}
			else if (Answer.indexOf("3")>-1)
			{
				if(confirm("Sorry we do NOT cover Hawaii. We Can only sell HughesNet to the lower 48 states. Press OK to be redirect to an Hawaii dealer, or cancel to reenter zip code"))
				{
					document.location.href="http://www.google.com/#hl=en&q=hughesnet+hawaii";
				}
			}
			else if (Answer.indexOf("4")>-1)
			{
				if(confirm("Sorry we do NOT cover Guam. We Can only sell HughesNet to the lower 48 states. Press OK to be redirect to an Guam dealer, or cancel to reenter zip code"))
				{
					document.location.href="http://www.google.com/#hl=en&q=hughesnet+guam";
				}
			}
			else if (Answer.indexOf("5")>-1)
			{
				if(confirm("Sorry we do NOT cover Puerto Rico. We Can only sell HughesNet to the lower 48 states. Press OK to be redirect to an Puerto Rico dealer, or cancel to reenter zip code"))
				{
					document.location.href="http://www.google.com/#hl=en&q=hughesnet+Puerto+Rico" ;
				}
			}
			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(parseInt(selOption)>6 && parseInt(selOption)<17)
	{
		document.getElementById("Image32").src="images/purchase.png";
		CreateLeasePriceTable();
		document.getElementById("Image333").src="images/lease_o.png";		
	}
	else
	{
		document.getElementById("Image32").src="images/purchase_o.png";
		CreatePurchasePriceTable();
		document.getElementById("Image333").src="images/lease.png";		
	}	
}
//Funvtion that will create price table for purchanse
function CreatePurchasePriceTable()
{
    var response, pricetab, htab, hzip;
    hzip = document.getElementById("hZip").value;
    objAjax=creat_Object();
	if(blnDiscountMatch=="1")
	{
	    objAjax.open("GET", "code_hn_Plans.asp?hzip=" + hzip + "&func=cms&mod=Purchase&d=1&avc=" + CookieStatus, false); 
	}
	else
	{
		objAjax.open("GET", "code_hn_Plans.asp?hzip=" + hzip + "&func=cms&mod=Purchase&d=0&avc="+CookieStatus,false);
	}
	objAjax.send(" ");
	response=objAjax.responseText;
	response = response.split("|");
	///	document.getElementById("Htext").innerHTML=response[0];
	document.getElementById("PriceList").innerHTML=response[1];
	
}
//Funvtion that will create price table for Lease
function CreateLeasePriceTable()
{
    var response, pricetab, htab, hzip;
    hzip = document.getElementById("hZip").value;	
	objAjax=creat_Object();
	if(blnDiscountMatch=="1")
	{
	    objAjax.open("GET", "code_hn_Plans.asp?hzip=" + hzip + "&func=cms&mod=Lease&d=1&avc=" + CookieStatus, false); 
	}
	else
	{
	    objAjax.open("GET", "code_hn_Plans.asp?hzip=" + hzip + "&func=cms&mod=Lease&d=0&avc=" + CookieStatus, false);
	}
	objAjax.send(" ");
	response=objAjax.responseText;
	response=response.split("|");
	document.getElementById("PriceList").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,sPlanDetails;
	sPlanDetails="";
	selPlan=tagid;
	selectedPlan=tagid;
	DeSelectPrevPlans();
	document.getElementById("PlanID").value=selectedPlan;
	objAjax=creat_Object();
	if(blnDiscountMatch=="1")
	{
		objAjax.open("GET", "code_hn_Plans.asp?avc="+CookieStatus+"&func=pd&DM=1&pid="+selectedPlan+"&city="+document.getElementById("fldCity").value,false); 
	}
	else
	{
	    objAjax.open("GET", "code_hn_Plans.asp?avc=" + CookieStatus + "&func=pd&DM=0&pid=" + selectedPlan + "&city=" + document.getElementById("fldCity").value, false);
	}
	objAjax.send(" ");
	sPlanDetails = objAjax.responseText;
	document.getElementById("divPlanDetails").innerHTML = sPlanDetails;

	
	if (parseInt(selOption) > 0 && parseInt(selOption) < 7) {
	    if (parseInt(selectedPlan) >0 && parseInt(selectedPlan) < 7) {
	        document.getElementById("divPNAME" + selectedPlan).style.fontWeight = "Bold";
	    }
	    else {
	       document.getElementById("divPNAME" + (parseInt(selectedPlan) - 10)).style.fontWeight = "Bold";
	    }
	}
	else if (parseInt(selOption) > 10 && parseInt(selOption) < 17) {
	    if (parseInt(selectedPlan) > 0 && parseInt(selectedPlan) < 7) {
	        document.getElementById("divPNAME" + (parseInt(selectedPlan) + 10)).style.fontWeight = "Bold";
	    }
	    else {
	        document.getElementById("divPNAME" + selectedPlan).style.fontWeight = "Bold";
	    }
	}
	else {
	    document.getElementById("divPNAME" + selectedPlan).style.fontWeight = "Bold";
	}
	
	
	if (parseInt(selectedPlan) > 0 && parseInt(selectedPlan) < 7) {
	    document.getElementById("sImage" + selectedPlan).src = "images/purchase_o.png"
	}
	else if (parseInt(selectedPlan) > 10 && parseInt(selectedPlan) < 17) {
	     document.getElementById("sImage" + selectedPlan).src = "images/lease_o.png"
	}
	else {

	    document.getElementById("sImage" + (parseInt(selectedPlan)-20)).src = "images/purchase_o.png"
	}


	///displaying the extra drop box based on the plan selected
	if (selectedPlan == "1" || selectedPlan == "2" || selectedPlan == "11" || selectedPlan == "12") {
	    document.getElementById("div1").style.display = "block";
	    if (parseInt(selectedPlan) > 10)
	        document.getElementById("div1L").style.display = "block";
	    else
	        document.getElementById("div1P").style.display = "block";
	} else if (selectedPlan == "3" || selectedPlan == "4" || selectedPlan == "13" || selectedPlan == "14") {
	    document.getElementById("div3").style.display = "block";
	    if (parseInt(selectedPlan) > 10)
	        document.getElementById("div3L").style.display = "block";
	    else
	        document.getElementById("div3P").style.display = "block";
	}
	else if (selectedPlan == "5" || selectedPlan == "6" || selectedPlan == "15" || selectedPlan == "16") {
	    document.getElementById("div5").style.display = "block";
	    if (parseInt(selectedPlan) > 10)
	        document.getElementById("div5L").style.display = "block";
	    else
	        document.getElementById("div5P").style.display = "block";
	}
}

//Clears off any previous selection in the plan table
function DeSelectPrevPlans()
{
	var j,k;
	if(selOption=='undefined' || selOption==null)
	{
	    if(CookieStatus=="5")
	    {
	        selOption="21";
	    }
	    else
	    {
		    selOption="1";	
		}
	}
	if(CookieStatus=="5")
	{
	    for(i=21;i<24;i++)
	    {
	        document.getElementById("divPNAME"+i).style.fontWeight="";
	    }
	    for(i=1;i<4;i++)
	    {
	        document.getElementById("sImage"+i).src="images/purchase.png"
	    }
	}
	else
	{
	    if(parseInt(selOption)>0 && parseInt(selOption)<7)	
	    {
		    j=1;k=7;
	    }
	    else
	    {
		    j=11;k=17;
	    }
	    for(i=j;i<k;i++) {
	        if (i % 2 == 1) {
	            document.getElementById("divPNAME" + i).style.fontWeight = "";
	        }
	    }
	    if (document.getElementById("divPNAME0") != 'undefined' && document.getElementById("divPNAME0") != null) {
	        document.getElementById("divPNAME0").style.fontWeight = "";
	    }
	    for(i=1;i<17;i++)
	    {
		    if(i>0 && i<7) {
		        if (i % 2 == 1) {
		            document.getElementById("sImage" + i).src = "images/purchase.png"
		        }
		    }
		    else if(i>10 && i<17) {
		        if (i % 2 == 1) {
		            document.getElementById("sImage" + i).src = "images/lease.png"
		        }
		    }
		}
		/*
		if (document.getElementById("sImage0") != 'undefined' && document.getElementById("divPNAME0") != null) {
		    document.getElementById("sImage0").src = "images/purchase.png"
		    document.getElementById("sImage10").src = "images/lease.png"
		}*/
	}


	//Hiding Extra dropdowns
	if (parseInt(selectedPlan) < 21) {
	    for (i = 1; i < 6; i = i + 2) {
	        document.getElementById("div" + i).style.display = "none";
	        document.getElementById("div" + i+"P").style.display = "none";
	        document.getElementById("div" + i + "L").style.display = "none";
	    }
	}
}
/// Extra Chaning dropdowm

function ChangePlanID(ddID) {

    selectedPlan = document.getElementById(ddID).value;
    document.getElementById("PlanID").value = selectedPlan
}


// Main function of the script. Loads the page parameters and makes table gray out. Loadd default settings 
function InitPage(blnposted,blnMailSent,blnDiacount,selPlanID)
{
	
	isLeaseOPtionDisable="0";
	blnDiscountMatch=blnDiacount;
	selectedPlan = selPlanID;
	selOption = selPlanID
	if(selectedPlan>0 && selectedPlan<7)
	{
	    CreatePurchasePriceTable();	    
	}
	else
	{
		CreateLeasePriceTable();
	}
	if(blnposted=="0")
	{
		//GrayOutTable()
	}
	else
	{
		//UnGrayTable()
	}
	DeSelectPrevPlans();
	var divID;
	SelectPlan(selPlanID);
	if(blnMailSent=="1")
	{
		alert("Thanks for submiting your information. Our representative will contact you soon.")
	}
}

function GrayOutTable()
{
	
	var elm;
	elm = document.getElementById("HidableDiv")
	_width = elm.offsetWidth
	_height = elm.offsetHeight
	_top = elm.offsetTop
	_left = elm.offsetLeft
	document.getElementById("divModalMain").style.Float = "left";
	document.getElementById("divModalMain").style.width=_width+"px";
	if(_height>=0)
	{
		_height=1860;
	}
	document.getElementById("divModalMain").style.height=_height+"px";
	document.getElementById("divModalMain").style.filter="alpha(opacity=70)";
	if(navigator.appName=="Microsoft Internet Explorer")
	{
		//document.getElementById("divModalMain").style.left=(_left-731)+"px";
		document.getElementById("divModalMain").style.top=(_top+520)+"px";
	}
	else
	{
		//document.getElementById("divModalMain").style.left=_left+"px";
		document.getElementById("divModalMain").style.top=(_top+225)+"px";
	}	
	document.getElementById("divModalMain").style.opacity="0.7";
	document.getElementById("divModalMain").style.MozOpacity="0.7";
	document.getElementById("divModalMain").style.KhtmlOpacity="0.7";
	document.getElementById("divModalMain").style.display="block";	
}

function UnGrayTable()
{
	
}
//Rounds a particular number
function RoundNumber(num)
{
	return (Math.round(num*100))/100;
}


//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";
		    if (isBackEnd == "1") {
		        document.getElementById("MyForm").action = "a_orderedit.asp" 
		    }
		    else {
		        document.getElementById("MyForm").action = "hn_order.asp" //"https://www.elitesat.com/hn_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")
		{
		    var oid;
		    oid = document.getElementById("OrderID").value;
		    document.location.href="a_orderview.asp?oid="+oid
		}
		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
		document.getElementById("MyForm").action="hn_plans.asp";
		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
		document.getElementById("fldIContact").value="0";
		document.getElementById("fldSend").value="0";
		document.getElementById("FlgForm").value="0";
		document.getElementById("MyForm").action="HughesNet_Plan_Details.asp";
		document.getElementById("MyForm").submit();
	}
	else
	{
		//Call a function that will set the order status
		if(SetOrderStatus("2")=="1")
		{
			document.getElementById("MyForm").action="hn_plans.asp";
			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.")
		}
	}
}


// 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 = "code_hn_plans.asp?func=order&OrderID=" + orderid + "&status=" + document.getElementById("drpStatus").value + "&cs=" + document.getElementById("drpCallStatus").value + "&pn=" + document.getElementById("txtPrivNotes").value;
			objAjax.open("GET",url,false)
		}
		else
		{
			if(strStatus=="3") {			
			    
				objAjax.open("GET","code_hn_Plans.asp?func=order&cs=12&OrderID="+orderid+"&status="+strStatus,false)
			}
			else
			{
				objAjax.open("GET","code_hn_Plans.asp?func=order&OrderID="+orderid+"&status="+strStatus,false)
			}
		}
		objAjax.send(" ");
		response = objAjax.responseText;
		if(response.indexOf("Success")>=0)
		{
			return "1";
		}
		else
		{
			return "0";
		}
	}
	else
	{
		return "0";
	}
}
var x,y
//Custom Popup
function ShowCustomPopUp()
{
	var scrollPos;
	GetPageXY();
	scrollPos=Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
	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=y+"px";
	document.getElementById("divModalSub").style.top=(scrollPos/2+350)+"px";
	document.getElementById("divModalMain").style.filter="alpha(opacity=70)";
	document.getElementById("divModalMain").style.left="0px";
	document.getElementById("divModalMain").style.top="0px";
	document.getElementById("divModalMain").style.opacity="0.7";
	document.getElementById("divModalMain").style.MozOpacity="0.7";
	document.getElementById("divModalMain").style.KhtmlOpacity="0.7";
}
function HideCustomPopUp()
{
	document.getElementById("divModalSub").style.display="none";
	document.getElementById("divModalMain").style.display="none";
}
/// 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("PhMo3").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;
		document.getElementById("txtCcAddress2").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("PhMo3").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;
			document.getElementById("txtCcAddress2").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("PhMo3").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;
			document.getElementById("txtCcAddress2").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,act,checkCode,st)
{
	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;
	}
	if(st=="9" && sval=="11")
	{
		if(!confirm("This order has been submitted to HNS already. Are you sure you want to resubmit new order?"))
		{
			return false;
		}
	}
	if(sval=="11" && act=="M")
	{
		//if(!confirm("This will Update Customer and Service Plan Information to Hughes. This will NOT change  Purchase option. To change Purchase Cancel HNS Order and replace. Click \"OK\" to Update Information with Hughes or click \"Cancel\""))
		//{
		ShowCustomPopUp();
		return false;
		//}
	}
	document.getElementById("flgSForm").value=sval;
	document.getElementById("flgAction").value=act;
	document.getElementById("MyForm").submit();
}
function SubmitOrderEditForm(sval,act,checkCode,st)
{
	if(act=="M3")
	{
		HideCustomPopUp();
	}
	else
	{
		document.getElementById("flgSForm").value=sval;
		document.getElementById("flgAction").value=act;
		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";
}
function DoAddressVerification() {
    var fpAddr, addr1, zip, phoneno;
    addr1 = document.getElementById("txtAVAddress1").value;
    fpAddr = addr1.substring(0, addr1.indexOf(" "))
    zip = document.getElementById("txtAVZipCode").value;
    phoneno = document.getElementById("txtAVPhone").value;
    if (Trim(phoneno) == "") {
        alert("Please enter Phone Number");
        return false;
    }
    else {
        if (!ValidatePhoneNumber(phoneno)) {
            alert("Please enter Phone Number in valid format");
            return false;
        }
    }
//    if (isNaN(fpAddr)) {
//        alert("Please check Street Address and re submit");
//        return false;
//    }
    if (zip.length < 5 || isNaN(zip)) {
        alert("Invalid zip code");
        return false;
    }
    if (document.getElementById("MyForm") == "undefined" || document.getElementById("MyForm") == null) {
        document.getElementById("AVForm").action = "hn_plans.asp";
    }
    else {
        document.getElementById("AVForm").action = document.getElementById("MyForm").action;
    }
    document.getElementById("AVForm").submit();
}
