

function load() {
	var imgs = load.arguments;
	if (document.images) {
		if (document.preload == null) document.preload = new Array();
		var i = document.preload.length;
		for (var j = 0; j < imgs.length; j++) {
			document.preload[i] = new Image();
			document.preload[i++].src = imgs[j];
		}
	}
}

function restore(){ 
	var i, x, a = document.swaps; 
	if( a ) for( i = 0; i < a.length; i++)
		if( a[i].oldSrc ) a[i].src=a[i].oldSrc;
}

function swap(){ 
	var i, j = 0, a = swap.arguments; 
	document.swaps = new Array; 
	for( i = 0; i < ( a.length - 1 ); i += 2 ){
		document.swaps[j++] = a[i];
		if( !a[i].oldSrc ) a[i].oldSrc = a[i].src;
		a[i].src = a[i + 1];
	}
}

function openW(url, name, w, h) {
	var windowprops = "width=" + w + ",height=" + h;
	popup = window.open(url, name, windowprops);
	setTimeout('popup.focus();',250);
}

function showpopup(url, w, h) {

	if(typeof(w)== "undefined") w = 800;
	if(typeof(h)== "undefined") h = 600;
	
	var windowprops = 'scrollbars=yes,status=no,width=" + w + ",height=" + h + "';
	var mywin ; 
	mywin = window.open(url,'popupWindow',windowprops) ;
}

//////////////////////////////////////////////////////////////////
function setCheckboxvalues(){
	for(i=0;i<document.mainForm.elements.length;i++){
		if (document.mainForm.elements[i].type=="checkbox"){
			
			if (document.mainForm.elements[i+1].name == "hd_" + document.mainForm.elements[i].name){
				if (document.mainForm.elements[i].checked==true){
				document.mainForm.elements[i+1].value=document.mainForm.elements[i].value;
				}
				else{
				document.mainForm.elements[i+1].value="0";
				}
			}
		}
	}
}

//////////////////////////////////////////////////////////////////
function SelectAllCheckboxes()
{
	for(i=0;i<document.mainForm.elements.length;i++)
	{
		if (document.mainForm.elements[i].type=="checkbox")
		{
			document.mainForm.elements[i].checked = true
		}
	}
}
//////////////////////////////////////////////////////////////////
function submitForm(strPage,strMethod)
{ 
	document.mainForm.action=strPage;
	document.mainForm.method=strMethod;
	document.mainForm.submit();
	//return true;
}
//////////////////////////////////////////////////////////////////
function AssignProductValues(prodid,prodnsme,prodcateg,prodpricedrc,prodpricenrc,strPage,strMethod)
{

	document.mainForm.elements["productid1"].value=prodid;
	document.mainForm.elements["productname"].value=prodnsme;
	document.mainForm.elements["productquantity"].value= document.mainForm.productquantity.value;
	document.mainForm.elements["productcategory"].value=prodcateg;
	document.mainForm.elements["productpricedrc"].value=prodpricedrc;
	document.mainForm.elements["productpricenrc"].value=prodpricenrc;
	document.mainForm.action=strPage;
	document.mainForm.method=strMethod;
	document.mainForm.submit();     
}

//////////////////////////////////////////////////////////////////
function Checkcreditinfo() {
		if(document.mainForm.bus_type_Owner[0].checked) {
			document.mainForm.action='credit_info.aspx';
			document.mainForm.method='post'; 
			}
		else if (document.mainForm.bus_type_Owner[1].checked){
				document.mainForm.action='credit_infopartner.aspx';
				document.mainForm.method='post';
			}	
		else if (document.mainForm.bus_type_Owner[2].checked){
				document.mainForm.action='credit_infocorporation.aspx';
				document.mainForm.method='post';
			}		
		else{
				document.mainForm.action='credit_info.aspx';
				document.mainForm.method='post';
				}
		
		document.mainForm.submit();
			
}
//********************************************************

//********************************************************
function jumpAnchor(targ,selObj,restore)
{ 
    
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    
	if (restore) selObj.selectedIndex=0;
}
//-------------------------------
//Validate For Number
function validateForNumber(sText){
		var sText=new String(sText);
		var notFound;
		var validNumbers=new Array(0,1,2,3,4,5,6,7,8,9);
		var stringLength=sText.length;
		var numberLength=validNumbers.length;
		for (i=0; i < stringLength;i++){
			notFound=0;
			for (j=0; j < numberLength;j++){
				if (sText.charAt(i)!= validNumbers[j]){
					notFound=notFound+1
				}
			}
	}
if (notFound==numberLength)
	return false;
else
	return true;
}
//-----------------------------

//-checking for Wire Plan Selection------
function checkforthis(btn){
var len,lenChecked,stValue,msgError;
msgError=""
lenChecked=0;
stValue=0;
var strName=new String();
len=document.mainForm.elements.length;
for (i=0;i<len;i++){
	strName=document.mainForm.elements[i].name;
	if ((strName.indexOf(btn) > -1) && (document.mainForm.elements[i].type =="radio")){
		if (document.mainForm.elements[i].checked==true){
		lenChecked=lenChecked+1;
			if (document.mainForm.elements[i].value != "NO,0,0,0"){
				if (document.mainForm.elements["nos"].value =="1"){ 
					
					if ((Trim(document.mainForm.elements["st"+btn].value)=="")||(Trim(document.mainForm.elements["st"+btn].value) =="0")||(Trim(document.mainForm.elements["st"+btn].value) =="00"))
						stValue=1;
					else if (isNaN(Trim(document.mainForm.elements["st"+btn].value))) 
						stValue=2;
					
					//else if (!validateForNumber(document.mainForm.elements["st"+btn].value))
					//	stValue=2;
					
				 }   	
			}		
		}
	}
}
	if (lenChecked == 0){
	msgError="Error: Please select Wire Plan Radio Button for Telephone Number " + btn + "\n" }
	else{
		if (stValue==1)
			msgError="Error: Please Enter the Number of Stations for Telephone Number " + btn + "\n" 
		else if (stValue==2)
			msgError="Error: Please Enter Correct Value for Number of Stations for Telephone Number " + btn + "\n"	
	}
	return msgError;
}
//-checking for Wire Plan Selection------
function OpenWindow(url)
{
	window.open(url)

}
//*****************************************
/*function validateForNumber(strText)
	{
		var sNum=new String(strText);
		var len;
		//var i, j, iEmailIdLength, iNumValidValues, iNumAts			//counters and subscripts
		var aValidValues = new Array("0","1","2","3","4","5","6","7","8","9")		 //array that stores valid values
		//var pEmailId
		iNumAts = 0
		//iEmailIdLength = pEmailId.length
		iNumValidValues = aValidValues.length
		len=strText.Length;
		alert(len)
		for (i = 0; i < sNum.Length; i++) 
		{   alert(sNum.charAt(i))
			for (j = 0; j < iNumValidValues; j++) 
			{  
				if (sNum.charAt(i) == aValidValues[j])
				iNumAts++;
				break;            
			}
			if (j > (iNumValidValues -1))
				return false;
		}
		alert(iNumAts)
		if (iNumAts ==0) 
		{
			return false;
		}
		return true;
	}*/
//******************************
/*
** This function will trim leading
** and trailing spaces from the
** passed string with the
** result returned as the return value.
*/

function Trim(xstrValue){
	// Trim leading characters
	xstrValue = xstrValue.replace(/^\s+/, "");

	// Trim trailing characters
	xstrValue = xstrValue.replace(/\s+$/, "");

	return xstrValue;
}

function isZipCode(zipcode){
	if ((Trim(zipcode).length == 10) || (Trim(zipcode).length == 5)|| (Trim(zipcode).length == 9)){
	//alert(Trim(zipcode).length)
	if (Trim(zipcode).length==10) {
			var len=Trim(zipcode).indexOf("-");
			if (len==5) {
				var str1,str2;
				str1=Trim(zipcode).substr(0,len)
				str2=Trim(zipcode).substr(len+1,Trim(zipcode).length)
				if ((isNaN(str1)) ||(isNaN(str2))){
					return false;
				}
			}
			else 
			{return false;}
		}	
		else if ((Trim(zipcode).length==5)||(Trim(zipcode).length==9)) {
			if (isNaN(Trim(zipcode))){
				return false;
			}
		}	
		
	}
	else
	{	//alert(Trim(zipcode).length)
		return false;
	}
}

//*******************************
function selectState(controlName,value){
	if (value!=""){
	var len=controlName.options.length;
	for (i=0;i<len;i++){
		if (controlName.options[i].value==value){
			controlName.selectedIndex=i;
		}
		//controlName.value=value;
		}
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//******************************
/*
** This function will delete offending characters
** Inmplemented to guard against cross-site scripting
*/
function cleanString(InStr){
    InStr = InStr.replace(/\</g,"");
    InStr = InStr.replace(/\>/g,"");
    InStr = InStr.replace(/\"/g,"");
    InStr = InStr.replace(/\'/g,"");
    InStr = InStr.replace(/\%/g,"");
    InStr = InStr.replace(/\;/g,"");
    InStr = InStr.replace(/\(/g,"");
    InStr = InStr.replace(/\)/g,"");
    InStr = InStr.replace(/\&/g,"");
    InStr = InStr.replace(/\+/g,"");
    InStr = InStr.replace(/\=/g,"");
    return InStr;
}

function cleanForm(dirtyForm){
	var elements = dirtyForm.getElementsByTagName('input');
	
	for (var i = 0; i < elements.length; i++){
		elements.item(i).value = cleanString(elements.item(i).value);
	}
}

//*******************************************

function preloader() 
{
var i = 0;
imageObj = new Image();
images = new Array();     
images[0]="/FiosForHome/images/FiosTV/a_aboutFiosTVon.gif";
images[1]="/FiosForHome/images/FiosTV/b_packagesPriceson.gif";    
images[2]="/FiosForHome/images/FiosTV/c_channelLineupon.gif";     
images[3]="/FiosForHome/images/FiosTV/c1_interactiveProgrammingOn.gif";
images[4]="/FiosForHome/images/FiosTV/d_onDemandon.gif";
images[5]="/FiosForHome/images/FiosTV/e_HDTVon.gif";
images[6]="/FiosForHome/images/FiosTV/f_dvrOn.gif";
images[7]="/FiosForHome/images/FiosTV/h_fiosInternetOn.gif";

for(i=0; i<=7; i++)      
{          
imageObj.src=images[i];     
}

}


//*******************************************

// START   Autotab Functionality --  Manivannan 09/27/2005

function validateLoopQual()
{
        var valid_form = 0;
        
        valid_form=validatePhoneNumber(document.form1.txtAreaCode.value, document.form1.txtPrefix.value, document.form1.txtPhoneNumber.value);
        
        if(valid_form)
        {
			return true;
        }
        else
        {
            alert("Please enter a valid 10 digit number");
            return false;
        }
}
                
function validatePhoneNumber(area_code, exchange, last4)
{
    var area_code_string=area_code+"";
    var exchange_string=exchange+"";
    var last4_string=last4+"";
    var valid=1;
    
    if(area_code=="" || exchange=="" || last4=="")
    {
            valid=0;
    }
    else if(isNaN(area_code) || isNaN(exchange) || isNaN(last4))
    {
            valid=0;
    }
    else if(area_code_string.length!=3 || exchange_string.length!=3 || last4_string.length!=4)
    {
            valid=0;
    }
    
    return valid;
}

function isNumeric()
{
		if (navigator.appName.indexOf("Netscape")<0)
		{
				get=event.keyCode;
				if((get>47&&get<58)||(get==8)||(get==9) || (get==46))
				{
					return true;
				}
				else
				{
					event.returnValue=false;
				}
		}
}
function AutoTab( hItem, maxLength, linkItem, e )
{

var agt=navigator.userAgent.toLowerCase();
var appName=navigator.appName;
var appVer = navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_nav  = ((agt.indexOf('mozilla')!=-1)
		&& (agt.indexOf('compatible') == -1));
var is_mac    = (agt.indexOf("mac")!=-1);

	isNumeric();
	if(is_mac||(is_nav&&is_minor<5))
	{
	return;
	}
	else
	{
		var vKeyCode,oItem;oItem=eval('document.'+linkItem);
		if(window.event||!e.which)
		{
			if (appName.indexOf('MSIE'))
			{
				key=e.keyCode;
			}
			else
			{
				key=e.charCode;
			}
		}
		else if(e)
		{
			key=e.which;
		}
		vKeyCode=key;		
		if(vKeyCode==9&&e&&e.shiftKey)
		{
			return;
		}
		switch(vKeyCode)
		{
			case 37:return;
			case 39:return;
			case 16:return;
			case 46:return;
		}		
		
		if (vKeyCode!=9)
		{
			if(typeof(oItem)=="object")
			{
				if(bAutotab&&(String(oItem.value).length==0)&&(String(hItem.value).length==maxLength)&&(vKeyCode!=8))			
				{
				oItem.focus();				
				oItem.value = String.fromCharCode(e.charCode);
				}
			}
		}
}
bAutotab=true;
}

var bAutotab=true;

function stopAutoTab()
{
	bAutotab=false;
}
	
function HardCodeEnter()
{
	var HKeyCode = window.event.keyCode
	if(HKeyCode==13)
	{
        var valid_form = 0;
        
        valid_form=validatePhoneNumber(document.form1.txtAreaCode.value, document.form1.txtPrefix.value, document.form1.txtPhoneNumber.value);
        if(valid_form){
            document.form1.submit();
        }else{
                alert("Please enter a valid 10 digit number");
                return false;
        }
	
	}
}


// END Autotab Functionality -- Manivannan