// JScript File
var NS = (document.layers) ? true : false; 
var IE = (document.all) ? true : false; 
var DOM = (document.getElementById) ? true : false; 
if (IE) DOM = false; 

var MAC = (navigator.platform) && (navigator.platform.toUpperCase().indexOf("MAC") >= 0); 

if (NS) MAC = false; 

var commandImage; 
var sendImage = true;
var checkImgTimer = null;
var checkChatAvailabilityStartTimer = null;
var ctcAvailabilityInterval = 10000;
var chatURL = "";//ChatURL to Check Availability
var strEnv = "";//to check the environment ie,SIT/staging/Prodn
var strWirelessQues = "";//To check which type of Wireless Customer

var ns = (document.layers)? true:false
var ie = (document.all)? true:false
var arrStates;
//Function for Form submition
//function onSubmit()
//{
//    if(!FormValidation())
//	    return false;
//    else
//	    document.frmContactUsEmail.submit();
//}

//Function for Validation of the Form before Submition


function FormValidation()
{
	var strTempString1;
	var strTempString2;
	if(indicator == true)
	{
		indicator = false;
	    return false;
	}
	else	
	    indicator=false;	   
	
	
	document.getElementById('hdnCat').value=document.getElementById('ddlSelectService').value +'~'+ document.getElementById('ddlCategory').value+'~'+document.getElementById('ddlSubCategory').value+'~'+document.getElementById('cboState').value;
		
	
	if(document.getElementById('ddlSelectService').value=='Wireless')
	{  
	    
	    if(strWirelessQues != "")
	    {
	    
	        if(trim(document.getElementById('txtWMTN1').value) == "" && trim(document.getElementById('txtWMTN2').value) == "" && trim(document.getElementById('txtWMTN3').value) == "")
	        {
	            alert("Please enter Mobile Telephone Number.");
		        document.getElementById("txtWMTN1").focus();		
		        return;	
	        }
	        
	        if(trim(document.frmContactUsEmail.txtWMTN1.value) == "")
            {
                alert("Please Enter the Correct Area Code.");
                document.frmContactUsEmail.txtWMTN1.focus();
	            return;
            }	
            if(!validateField(document.getElementById('txtWMTN1').value,3))
            {
                alert("Please Enter the Correct Three digit Area Code.");
                document.frmContactUsEmail.txtWMTN1.focus();
	            return;
            }
            if(trim(document.frmContactUsEmail.txtWMTN2.value) == "")
            {
                alert("Please Enter the Correct Phone No.");
                document.frmContactUsEmail.txtWMTN2.focus();
	            return;
            }	
            if(!validateField(document.getElementById('txtWMTN2').value,3))
            {
                alert("Please Enter the Correct Three digit Phone No.");
                document.frmContactUsEmail.txtWMTN2.focus();
	            return;
            }
            if(trim(document.frmContactUsEmail.txtWMTN3.value) == "")
            {
                alert("Please Enter the Last four digits Correctly.");
                document.frmContactUsEmail.txtWMTN3.focus();
	            return;
            }	
            if(!validateField(document.getElementById('txtWMTN3').value,4))
            {
                alert("Please Enter the Last four digits Correctly.");
                document.frmContactUsEmail.txtWMTN3.focus();
	            return;
            }
        }
        
        if(document.getElementById('dvShowPassword').style.display=="")
	    {
	        if(trim(document.getElementById('WPassword').value) == "")	
	        {
		        alert("Please enter your Password.");
		        document.getElementById("WPassword").focus();		
		        return;		
	        }
	    }
	    
	    if(document.getElementById('dvShowAccNum').style.display=="")
	    {
	        if(trim(document.getElementById('txtwactNum').value) == "")	
	        {
		        alert("Please enter your Account Number.");
		        document.getElementById("txtwactNum").focus();		
		        return;		
	        }
	    }
	
	    if(trim(document.getElementById('txtWfName').value) == "")	
	    {
		    alert("Please enter your First Name.");
		    document.getElementById("txtWfName").focus();		
		    return;		
	    }
    	
	    if(trim(document.frmContactUsEmail.txtWlName.value) == "")	
	    {
		    alert("Please enter your Last Name.");
		    document.getElementById("txtWlName").focus();		
		    return;
	    }
	    
	    if(trim(document.frmContactUsEmail.txtWEmail.value) == "" )
	    {
		    alert("Please Enter your Email Address.");
		    document.frmContactUsEmail.txtWEmail.focus();
		    return;
	    }

	    if(trim(document.frmContactUsEmail.txtWRetypeEmail.value) == "" )
	    {
		    alert("Please retype your Email Address.");
		    document.frmContactUsEmail.txtWRetypeEmail.focus();
		    return;
	    }

	    if(ValidateEMail(document.frmContactUsEmail.txtWEmail) == false)
	    {
		    document.frmContactUsEmail.txtWEmail.focus();
		    return;
	    }

	    if(ValidateEMail(document.frmContactUsEmail.txtWEmail) == true)
	    {
		    if(document.frmContactUsEmail.txtWEmail.value != document.frmContactUsEmail.txtWRetypeEmail.value)
		    {
			    alert("Please retype your email address. The email addresses are not the same. They must match.");
			    document.frmContactUsEmail.txtWRetypeEmail.focus();
			    return;
		    }
	    }
	    
//        if(trim(document.frmContactUsEmail.txtWDTN1.value) == "")
//        {
//            alert("Please Enter the Correct Area Code.");
//            document.frmContactUsEmail.txtWDTN1.focus();
//	        return;
//        }	
        if(!validateField(document.getElementById('txtWDTN1').value,3))
        {
            alert("Please Enter the Correct Three digit Area Code.");
            document.frmContactUsEmail.txtWDTN1.focus();
	        return;
        }
//        if(trim(document.frmContactUsEmail.txtWDTN2.value) == "")
//        {
//            alert("Please Enter the Correct Phone No.");
//            document.frmContactUsEmail.txtWDTN2.focus();
//	        return;
//        }	
        if(!validateField(document.getElementById('txtWDTN2').value,3))
        {
            alert("Please Enter the Correct Three digit Phone No.");
            document.frmContactUsEmail.txtWDTN2.focus();
	        return;
        }
//        if(trim(document.frmContactUsEmail.txtWDTN3.value) == "")
//        {
//            alert("Please Enter the Last four digits Correctly.");
//            document.frmContactUsEmail.txtWDTN3.focus();
//	        return;
//        }	
        if(!validateField(document.getElementById('txtWDTN3').value,4))
        {
            alert("Please Enter the Last four digits Correctly.");
            document.frmContactUsEmail.txtWDTN3.focus();
	        return;
        }        
        
	    if(trim(document.getElementById('txtWZipCode').value) == "")
        {
            alert("Please Enter the ZipCode.");
            document.getElementById("txtWZipCode").focus();
	        return;
        }
        if(document.getElementById('txtWZipCode').value.length < 5)
        {
            alert("Please enter valid ZipCode.");
	        document.getElementById("txtWZipCode").focus();
            return;
        }
//        if(!validateZIP(document.frmContactUsEmail.txtWZipCode.value))
//        {        
//            document.frmContactUsEmail.txtWZipCode.focus();
//	        return;
//        }
        
         //code made by prasanna
        var flag=false;
        
        if(zipCode.indexOf(document.getElementById('txtWZipCode').value + '~') > -1)
            flag=true;
        
       
        if(flag==false)
        {
            alert('We currently do not have service for this zip code.  If you would like to choose a location by a different zip code please enter it now.');
            document.getElementById("txtWZipCode").focus();
            return;
        }	
	}
	else
	{
	    if(document.getElementById('dvIsPhoneService').style.display=="")
	    {
	        if(trim(document.getElementById('txtATN1').value) == "" && trim(document.getElementById('txtATN2').value) == "" && trim(document.getElementById('txtATN3').value) == "")
	        {
	            alert("Please enter Account Telephone Number.");
		        document.getElementById("txtATN1").focus();		
		        return;	
	        }	        
	        if(trim(document.frmContactUsEmail.txtATN1.value) == "")
            {
                alert("Please Enter the Correct Area Code.");
                document.frmContactUsEmail.txtATN1.focus();
	            return;
            }	
            if(!validateField(document.getElementById('txtATN1').value,3))
            {
                alert("Please Enter the Correct Three digit Area Code.");
                document.frmContactUsEmail.txtATN1.focus();
	            return;
            }
            if(trim(document.frmContactUsEmail.txtATN2.value) == "")
            {
                alert("Please Enter the Correct Phone No.");
                document.frmContactUsEmail.txtATN2.focus();
	            return;
            }	
            if(!validateField(document.getElementById('txtATN2').value,3))
            {
                alert("Please Enter the Correct Three digit Phone No.");
                document.frmContactUsEmail.txtATN2.focus();
	            return;
            }
            if(trim(document.frmContactUsEmail.txtATN3.value) == "")
            {
                alert("Please Enter the Last four digits Correctly.");
                document.frmContactUsEmail.txtATN3.focus();
	            return;
            }	
            if(!validateField(document.getElementById('txtATN3').value,4))
            {
                alert("Please Enter the Last four digits Correctly.");
                document.frmContactUsEmail.txtATN3.focus();
	            return;
            }	        
	    }	     
	     
	    if(document.getElementById('dvNonIsPhoneService').style.display=="")
        {
	        if(!validateField(document.getElementById('txtATN1').value,3))
            {
                alert("Please Enter the Correct Three digit Area Code.");
                document.frmContactUsEmail.txtATN1.focus();
	            return;
            }            	
            if(!validateField(document.getElementById('txtATN2').value,3))
            {
                alert("Please Enter the Correct Three digit Phone No.");
                document.frmContactUsEmail.txtATN2.focus();
	            return;
            }            
            if(!validateField(document.getElementById('txtATN3').value,4))
            {
                alert("Please Enter the Last four digits Correctly.");
                document.frmContactUsEmail.txtATN3.focus();
	            return;
            }
	    }	     
	     
	    if(document.getElementById('dvIConsole').style.display=="")
	    {
	        if(trim(document.getElementById('txtAddress').value) == "")
	        {
	            alert("Please enter Address.");
		        document.getElementById("txtAddress").focus();		
		        return;	
	        }
	        if(trim(document.getElementById('txtCity').value) == "")
	        {
	            alert("Please enter City.");
		        document.getElementById("txtCity").focus();		
		        return;	
	        }
	        if(trim(document.getElementById('txtZipCode').value) == "")
	        {
	            alert("Please enter ZipCode.");
		        document.getElementById("txtZipCode").focus();		
		        return;	
	        }
	        //validateZIP(document.getElementById('txtZipCode')
	        if(document.getElementById('txtZipCode').value.length < 5)
	        {
	            alert("Please enter valid ZipCode.");
		        document.getElementById("txtZipCode").focus();
	            return;
	        }
//	        if(!validateZIP(document.getElementById('txtZipCode').value))
//	        {
//	            return;
//	        }	        
	    }
	    if(trim(document.getElementById('txtfName').value) == "")	
	    {
		    alert("Please enter your First Name.");
		    document.getElementById("txtfName").focus();		
		    return;		
	    }
    	
	    if(trim(document.frmContactUsEmail.txtlName.value) == "")	
	    {
		    alert("Please enter your Last Name.");
		    document.getElementById("txtlName").focus();		
		    return;
	    }
	    
        if(document.getElementById('dvShowContactNumForKanaIConsole').style.display=="")
        {  
            if(trim(document.frmContactUsEmail.txtCTN1.value) == ''&& trim(document.frmContactUsEmail.txtCTN2.value)=='' && trim(document.frmContactUsEmail.txtCTN3.value)=='')
            {
                if(centreName=='IConsole')
                {
                    alert('Please enter the contact telephone number');
                    document.frmContactUsEmail.txtCTN1.focus();
                    return;
                }
            }
                    
            if(trim(document.frmContactUsEmail.txtCTN1.value) == "" && centreName=='IConsole')
            {
                alert("Please Enter the Correct Area Code.");
                document.frmContactUsEmail.txtCTN1.focus();
	            return;
            }	
            if(!validateField(document.getElementById('txtCTN1').value,3))
            {
                alert("Please Enter the Correct Three digit Area Code.");
                document.frmContactUsEmail.txtCTN1.focus();
	            return;
            }
            if(trim(document.frmContactUsEmail.txtCTN2.value) == "" && centreName=='IConsole')
            {
                alert("Please Enter the Correct Phone No.");
                document.frmContactUsEmail.txtCTN2.focus();
	            return;
            }	
            if(!validateField(document.getElementById('txtCTN2').value,3))
            {
                alert("Please Enter the Correct Three digit Phone No.");
                document.frmContactUsEmail.txtCTN2.focus();
	            return;
            }
            if(trim(document.frmContactUsEmail.txtCTN3.value) == "" && centreName=='IConsole')
            {
                alert("Please Enter the Last four digits Correctly.");
                document.frmContactUsEmail.txtCTN3.focus();
	            return;
            }	
            if(!validateField(document.getElementById('txtCTN3').value,4))
            {
                alert("Please Enter the Last four digits Correctly.");
                document.frmContactUsEmail.txtCTN3.focus();
	            return;
            }
        }
        if(trim(document.frmContactUsEmail.txtEmail.value) == "" )
	    {
		    alert("Please Enter your Email Address.");
		    document.frmContactUsEmail.txtEmail.focus();
		    return;
	    }

	    if(trim(document.frmContactUsEmail.txtReTypeEmail.value) == "" )
	    {
		    alert("Please retype your Email Address.");
		    document.frmContactUsEmail.txtReTypeEmail.focus();
		    return;
	    }

	    if(ValidateEMail(document.frmContactUsEmail.txtEmail) == false)
	    {
		    document.frmContactUsEmail.txtEmail.focus();
		    return;
	    }

	    if(ValidateEMail(document.frmContactUsEmail.txtEmail) == true)
	    {
		    if(document.frmContactUsEmail.txtEmail.value != document.frmContactUsEmail.txtReTypeEmail.value)
		    {
			    alert("Please retype your email address. The email addresses are not the same. They must match.");
			    document.frmContactUsEmail.txtReTypeEmail.focus();
			    return;
		    }
	    }
	    
	    if (document.frmContactUsEmail.cboState.selectedIndex <= 0 )
	    {
	        alert("Please select your State.");
		    document.frmContactUsEmail.cboState.focus();
		    return;
	    }
	}
	if (trim(document.frmContactUsEmail.suggestions.value) == "" )
    {
        alert("Please Enter your Comments.");
	    document.frmContactUsEmail.suggestions.focus();
	    return;
    }
    
    if(centreName!='IConsole' && document.getElementById('txtactNum').value !='')
	{
	    document.getElementById('suggestions').value='The Customer Code and Account ID is ' + document.getElementById('txtactNum').value + '.' + document.getElementById('suggestions').value;
	}
	
	document.getElementById('txtIsSubmitted').value="true";
	
	
	for(j=document.getElementById('ddlCategory').length -1;j>=0;j--)
    {
        document.getElementById('ddlCategory').remove(j);
    }
    for(j=document.getElementById('ddlSubCategory').length -1;j>=0;j--)
    {
        document.getElementById('ddlSubCategory').remove(j);
    }
    for(j=document.getElementById('ddlSelectService').length -1;j>=0;j--)
    {
        document.getElementById('ddlSelectService').remove(j);
    }
	
	document.frmContactUsEmail.submit();
}

function displayAccountSample() 
{
    if (document.getElementById("cboState").value=="MD" || document.getElementById("cboState").value=="DC" || document.getElementById("cboState").value=="VA" || document.getElementById("cboState").value=="WV")
	{
	    document.getElementById("divThreeDigits").style.display = "none";
		document.getElementById("divSixDigits").style.display = "none";			     
		document.getElementById("divTweleveDigits").style.display = "";
		return;
	}
	else if (document.getElementById("cboState").value=="NY" || document.getElementById("cboState").value=="CT" || document.getElementById("cboState").value=="NJ" || (document.getElementById("cboState").value=="PA" )|| document.getElementById("cboState").value=="DE" || document.getElementById("cboState").value=="MA" || document.getElementById("cboState").value=="ME" || document.getElementById("cboState").value=="NH" || document.getElementById("cboState").value=="RI" || document.getElementById("cboState").value=="VT")
	{
	    document.getElementById("divThreeDigits").style.display = "";
		document.getElementById("divSixDigits").style.display = "none";			     
		document.getElementById("divTweleveDigits").style.display = "none";
		return;
	}
	else if (document.getElementById("cboState").value=="AZ" || document.getElementById("cboState").value=="CA" || document.getElementById("cboState").value=="FL" || (document.getElementById("cboState").value=="IA" )|| document.getElementById("cboState").value=="IL" || document.getElementById("cboState").value=="IN" || document.getElementById("cboState").value=="MI" || document.getElementById("cboState").value=="NC" || document.getElementById("cboState").value=="NV" || document.getElementById("cboState").value=="OH" || document.getElementById("cboState").value=="OR" || document.getElementById("cboState").value=="SC" || document.getElementById("cboState").value=="TX" || document.getElementById("cboState").value=="WA" || document.getElementById("cboState").value=="WI")
	{
	    document.getElementById("divThreeDigits").style.display = "none";
		document.getElementById("divSixDigits").style.display = "";			     
		document.getElementById("divTweleveDigits").style.display = "none";
		return;
	}
	else
	{
	    document.getElementById("divThreeDigits").style.display = "none";
		document.getElementById("divSixDigits").style.display = "none";			     
		document.getElementById("divTweleveDigits").style.display = "none";
	}	
}
function ClickSampleBill()
{
	var selectedState;
	selectedState = document.getElementById("cboState")[document.getElementById("cboState").selectedIndex].value;
		
	if(selectedState == "state")
	{
	    alert("Please select a State first.");
	}
	else if((selectedState == "MD") || (selectedState == "DC") || (selectedState == "VA") || (selectedState == "WV"))
	{
	    window.open("images/bills/BillSample-expressTRAK-MD_DC_VA_and_WV.html", selectedState);
	}
	else if((selectedState == "NY") || (selectedState == "CT"))
	{
	    window.open("images/bills/BillSample-NYandCT.html", selectedState);
	}
	else if((selectedState == "NJ") || ((selectedState == "PA")) || (selectedState == "DE"))
	{
	    window.open("images/bills/BillSample-Mid Atlantic-PA-fBA_NJ_and_DE.html", selectedState);
	}
	else if((selectedState == "MA") || (selectedState == "ME") || (selectedState == "NH") || (selectedState == "RI") || (selectedState == "VT"))
	{
	    window.open("images/bills/BillSample-New England-MA_ME_NH_RI_and_VT.html", selectedState);
	}
	else if((selectedState == "AZ") || (selectedState == "CA")  || (selectedState == "FL")  || (selectedState == "IA")  || (selectedState == "IL")  || (selectedState == "IN")  || (selectedState == "MI")  || (selectedState == "NC")  || (selectedState == "NV")  || (selectedState == "OH")  || (selectedState == "OR")  || (selectedState == "SC")  || (selectedState == "TX")  || (selectedState == "WA")  || (selectedState == "WI"))
	{
	    window.open("images/bills/BillSample-fGTE Telephone Accounts Check Digits Routine-Including_PA-fGTE.html", selectedState)
	}	
}

function validateField(lField, nop)
{
    var i;
    
    if ((lField.length > 0) && (parseInt(lField.length) < parseInt(nop)))
    {        
		return;
    }
    else
    {		
	    return true;	 			
    }     
}	

function ValidateEMail(obj)
{
    var sEmail= new Object;
   	sEmail=trim(obj.value);
	if (sEmail=="")
	{
		alert("You have not entered an email address. \n Please enter it now.") 
		obj.focus(); 
		obj.select();
		return false;
	}
			
	if (sEmail.length > 0)
	{
	    //Return false if e-mail field does not contain a '@' and '.' .
		if (sEmail.indexOf ('@',0) == -1 || sEmail.indexOf ('.',0) == -1)
	  	{
	    	alert("Your Email Address is in wrong format.")
			obj.focus(); 
			obj.select();
			return false;
		}
		sEmail = trim(sEmail)
		if(CheckEmailid(sEmail))
			return true;
		else
			return false;
	}
	return true;	
}

function CheckEmailid(lemailStr)
{
	if (lemailStr =='')
    	return '';

	var Mesg = "Please Enter the Valid Email."
	var lemailPat=/^(.+)@(.+)$/
	var lspecialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var lvalidChars="\[^\\s" + lspecialChars + "\]"
	var lfirstChars=lvalidChars
	var lquotedUser="(\"[^\"]*\")"
	var lipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var latom="(" + lfirstChars + lvalidChars + "*" + ")"
	var lword="(" + latom + "|" + lquotedUser + ")"
	var luserPat=new RegExp("^" + lword + "(\\." + lword + ")*$")
	var ldomainPat=new RegExp("^" + latom + "(\\." + latom +")*$")
	var lmatchArray=lemailStr.match(lemailPat)
	
	if (lmatchArray==null) 
	{
		alert (Mesg);
		return false;
	}
	
	var luser=lmatchArray[1]
	var ldomain=lmatchArray[2]

	if (luser.match(luserPat)==null) 
	{
		alert (Mesg);
		document.frmContactUsEmail.txtEmailAddr.focus();
		document.frmContactUsEmail.txtEmailAddr.select()
		return false;
    }
	  
	var lIPArray=ldomain.match(lipDomainPat)

	if (lIPArray!=null) 
	{
	  	for (var li=1;li<=4;li++) 
	  	{
	    	if (lIPArray[li]>255) 
			{
				alert (Mesg);
				document.frmContactUsEmail.txtEmailAddr.focus();
				document.frmContactUsEmail.txtEmailAddr.select()
				return false;
	    	}
    	}  
	}

	var ldomainArray=ldomain.match(ldomainPat)
	
	if (ldomainArray==null)
 	{
		alert (Mesg);
		document.frmContactUsEmail.txtEmailAddr.focus();
		document.frmContactUsEmail.txtEmailAddr.select()
		return false;
	}
		
	var latomPat=new RegExp(latom,"g")
	var ldomArr=ldomain.match(latomPat)
	var llen=ldomArr.length
	
	if (ldomArr[ldomArr.length-1].length<1 || 
    	ldomArr[ldomArr.length-1].length>255) 
    {
			alert (Mesg);
			document.frmContactUsEmail.txtEmailAddr.focus();
			document.frmContactUsEmail.txtEmailAddr.select()
			return false;
	}
	if (((ldomArr[ldomArr.length-1].length>=1) && (ldomArr[ldomArr.length-1].length<=255)) && (llen<2)) 
	{
		alert (Mesg);
		document.frmContactUsEmail.txtEmailAddr.focus();
		document.frmContactUsEmail.txtEmailAddr.select()
    	return  false;
	}	
	return true;
}

function validateZIP(field) 
{
    var valid = "0123456789-";
    var hyphencount = 0;

    if (field.length!=5 && field.length!=10)
    {
        alert("Please enter your 5 digit or 5 digit+4 zip code.");
        return false;
    }
    for (var i=0; i < field.length; i++)
    {
        temp = "" + field.substring(i, i+1);
        if (temp == "-")
            hyphencount++;
        if (valid.indexOf(temp) == "-1") 
        {
            alert("Invalid characters in your zip code.  Please try again.");
            return false;
        }
        if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-"))
        {
            alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
            return false;
        }
    }
    return true;
}

//below codes are made by Prasanna starts here 
function showhideDiv(divID)
{
    if (document.getElementById(divID).style.display == 'none')
	    document.getElementById(divID).style.display="";
    else 
	    document.getElementById(divID).style.display="none";
}

function showDiv(divID)
{
    document.getElementById(divID).style.display="";
}

function hideDiv(divID)
{
    document.getElementById(divID).style.display="none";    
}    
    
function validateCommentsLength(obj,eventKeyCode,limit)
{
    var isNN = (navigator.appName.indexOf("Netscape")!=-1);
    var keyCode = (isNN) ? eventKeyCode.which : eventKeyCode.keyCode; 	
    if((obj.value.length>limit)&&(keyCode!=8))
    {
        alert("Exceeds Maximum Length");
        return false;
    }
    else
    {
        return true;
    }
}
    
    
function NautoTab(thisObj,len,e) 
{       
    if (!isNumeric(e))
	    return false;
    		
    var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : e.keyCode; 	   
	//len = (isNN) ? len-1 : len;

	 if((keyCode==8)||(keyCode==46))
	        return true;
	 if(keyCode!=9)
	 {  

	    if(thisObj.value.length >= len &&  bAutotab ) 
		{
		    thisObj.value = thisObj.value.slice(0, len);
			for(i=0;i<document.forms[0].elements.length;i++)
			{
			    if(document.forms[0].elements[i].name==thisObj.name)
			    {
			        document.forms[0].elements[i+1].focus();
	            }
	        }		   
	
		}
	
	 }
    bAutotab = true;
	return true;
}
 
function stopAutoTab()
{
	bAutotab = false;
}
	
function isNumeric(e)
{
	var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	var keyCode = (isNN) ? e.which : e.keyCode; 
		
	if (isNN)
	{
		if (keyCode == 0)
			return true;
	}
	
	if((keyCode>47&&keyCode<58)||(keyCode==8)||(keyCode==9)||(keyCode==46)||(keyCode==189))  
	{
		return true;
	}	
	else	
		return false;		
}

function bindStates(states,selState)
{
    var temp;    
    var obj=document.getElementById('cboState');
    var npaStates=states.split('|');
    arrStates=new Array(npaStates.length);
    for(i=0;i<arrStates.length -1;i++)
    {
        arrStates[i]=new Array(2);
        arrStates[i][0]=npaStates[i].split(',')[0];
        arrStates[i][1]=npaStates[i].split(',')[1];
        if(temp!=arrStates[i][1])
        {
            temp=arrStates[i][1];
            var opt=document.createElement('OPTION');      
            opt.value=arrStates[i][1];
            opt.text=arrStates[i][1];
            obj.options.add(opt);  
        }
    }
    if(selState!='')
        document.getElementById('cboState').value=selState;
}

function trim(inputString)
{
    if(inputString.indexOf(' ')>-1)
    {
        var value='';
        var arrSplit=inputString.split(' ');
        for(i=0;i<arrSplit.length;i++)
        {
            if(arrSplit[i].length > 1)
            {
                value=value + arrSplit[i]+' '; 
            }
        }    
        return value.substring(0,value.length-1);
    }
    else
        return inputString;
}

var arrRec;
var arrEachRec; 
var zipCode;
  
function showServiceProduct(cuData,count,dtStates,selState,strZipCode)
{
    var temp='';    
    zipCode=strZipCode;
    var obj=document.getElementById('ddlSelectService');
    arrRec=new Array(count);
    arrEachRec=cuData.split('|');    
    for(i=0;i<count-1;i++)
    {
        if(temp!=arrEachRec[i].split('~')[0])
        {
        
            temp=arrEachRec[i].split('~')[0];
            var opt=document.createElement('OPTION');
            opt.text=arrEachRec[i].split('~')[0];
            opt.value=arrEachRec[i].split('~')[0];
            obj.options.add(opt);
        }
    }

    orderServiceProduct();
    
    if(document.getElementById('ddlSelectService').value=='Wireless')
    {
        showDiv(document.getElementById('dvWireless').id);
        hideDiv(document.getElementById('dvOthers').id);        
    }
    else
    {
        showDiv(document.getElementById('dvOthers').id);
        hideDiv(document.getElementById('dvWireless').id);        
    }
    strEnv = strEnvUsed;//To get the Host name
    
   showCategory();
   bindStates(dtStates,selState);
}
 
function orderServiceProduct()
{    
    var arrAdd;
    var arrRemove;
    var rCnt;
    
    for(rCnt=document.getElementById('ddlSelectService').length-1; rCnt >= 0; rCnt--)
    {    
        if(document.getElementById('ddlSelectService')[rCnt].value == "Wireless")
        {
            document.getElementById('ddlSelectService')[rCnt].text = document.getElementById('ddlSelectService')[0].text;
            document.getElementById('ddlSelectService')[rCnt].value = document.getElementById('ddlSelectService')[0].value;
            document.getElementById('ddlSelectService')[0].text = "Wireless";
            document.getElementById('ddlSelectService')[0].value = "Wireless";             
        } 
        if(document.getElementById('ddlSelectService')[rCnt].value == "TV or Entertainment")
        {
            document.getElementById('ddlSelectService')[rCnt].text = document.getElementById('ddlSelectService')[3].text;
            document.getElementById('ddlSelectService')[rCnt].value = document.getElementById('ddlSelectService')[3].value;
            document.getElementById('ddlSelectService')[3].text = "TV or Entertainment";
            document.getElementById('ddlSelectService')[3].value = "TV or Entertainment";
        }
        if(document.getElementById('ddlSelectService')[rCnt].value == "Phone Service")
        {
            document.getElementById('ddlSelectService')[rCnt].text = document.getElementById('ddlSelectService')[2].text;
            document.getElementById('ddlSelectService')[rCnt].value = document.getElementById('ddlSelectService')[2].value;
            document.getElementById('ddlSelectService')[2].text = "Phone Service";
            document.getElementById('ddlSelectService')[2].value = "Phone Service";
        }        
        if(document.getElementById('ddlSelectService')[rCnt].value == "Internet Service")
        {
            document.getElementById('ddlSelectService')[rCnt].text = document.getElementById('ddlSelectService')[1].text;
            document.getElementById('ddlSelectService')[rCnt].value = document.getElementById('ddlSelectService')[1].value;
            document.getElementById('ddlSelectService')[1].text = "Internet Service";
            document.getElementById('ddlSelectService')[1].value = "Internet Service";
        }
        if(document.getElementById('ddlSelectService')[rCnt].value == "Customer Advocacy")
        {
            document.getElementById('ddlSelectService')[rCnt].text = document.getElementById('ddlSelectService')[5].text;
            document.getElementById('ddlSelectService')[rCnt].value = document.getElementById('ddlSelectService')[5].value;
            document.getElementById('ddlSelectService')[5].text = "Customer Advocacy";
            document.getElementById('ddlSelectService')[5].value = "Customer Advocacy";
        }
        if(document.getElementById('ddlSelectService')[rCnt].value == "Other")
        {            
            document.getElementById('ddlSelectService')[rCnt].text = document.getElementById('ddlSelectService')[4].text;
            document.getElementById('ddlSelectService')[rCnt].value = document.getElementById('ddlSelectService')[4].value;
            document.getElementById('ddlSelectService')[4].text = "Other";
            document.getElementById('ddlSelectService')[4].value = "Other";
        }
    }    
}
    
function showCategory()    
{    
    var temp='';
    var tempCustType='';
    for(j=document.getElementById('ddlCategory').length -1;j>=0;j--)
    {
        document.getElementById('ddlCategory').remove(j);
    }
    var obj=document.getElementById('ddlSelectService');
    var objCat=document.getElementById('ddlCategory');
    var objCustType=document.getElementById('ddlWirelessCustType');
    
    for(i=0;i<arrEachRec.length-1;i++)
    {
        if(obj.value=='Wireless')
        {
            if(arrEachRec[i].split('~')[0]==obj.value && temp!=arrEachRec[i].split('~')[1] && arrEachRec[i].split('~')[4]==objCustType.value)
            {
                temp=arrEachRec[i].split('~')[1];
                var opt=document.createElement('OPTION');
                opt.text=temp;
                opt.value=temp;
                objCat.options.add(opt); 
            }            
        }
        else
        {
            if(arrEachRec[i].split('~')[0]==obj.value && temp!=arrEachRec[i].split('~')[1])
            {
                temp=arrEachRec[i].split('~')[1];
                var opt=document.createElement('OPTION');
                opt.text=temp;
                opt.value=temp;
                objCat.options.add(opt); 
            } 
        } 
    }    
    
    if(document.getElementById('ddlSelectService').value=='Wireless')
    {
        showDiv(document.getElementById('dvWireless').id);
        showDiv(document.getElementById('dvWCustType').id);
        hideDiv(document.getElementById('dvOthers').id)
        if(objCustType.value=='I receive a monthly statement')
        {
            strWirelessQues = "I receive a monthly statement";
            showDiv(document.getElementById('dvShowPassword').id);
            showDiv(document.getElementById('dvMobileTN').id);
            showDiv(document.getElementById('dvMobileTNDesc').id);
            hideDiv(document.getElementById('dvShowAccNum').id)
        }
        else if(objCustType.value=='I pay as I go/prepay')
        {
            strWirelessQues = "I pay as I go/prepay";
            showDiv(document.getElementById('dvShowAccNum').id);
            showDiv(document.getElementById('dvMobileTN').id);
            showDiv(document.getElementById('dvMobileTNDesc').id);
            hideDiv(document.getElementById('dvShowPassword').id)
        }
        else
        {
            strWirelessQues = "";
            hideDiv(document.getElementById('dvMobileTN').id);
            hideDiv(document.getElementById('dvMobileTNDesc').id);
            hideDiv(document.getElementById('dvShowAccNum').id)
            hideDiv(document.getElementById('dvShowPassword').id)
        }        
    }
    else
    {
        showDiv(document.getElementById('dvOthers').id);
        hideDiv(document.getElementById('dvWireless').id)
        hideDiv(document.getElementById('dvWCustType').id);
        /*
        if(document.getElementById('ddlSelectService').value=='Phone Service')
        {
            showDiv(document.getElementById('dvPhoneService').id);
            hideDiv(document.getElementById('dvNonPhoneService').id)
        }
        else
        { 
           showDiv(document.getElementById('dvNonPhoneService').id)
           hideDiv(document.getElementById('dvPhoneService').id) 
        }   */     
    }
    showSubCategory();
}

function showSubCategory()
{
    for(j=document.getElementById('ddlSubCategory').length -1;j>=0;j--)
    {
        document.getElementById('ddlSubCategory').remove(j);
    }
    var obj=document.getElementById('ddlSelectService');
    var objCat=document.getElementById('ddlCategory');
    var objSubCat=document.getElementById('ddlSubCategory');
    var objCustType=document.getElementById('ddlWirelessCustType');
    /*if(objCat.value.length>40)
    {
         document.getElementById('ddlCategory').style.width="325";
    }
    else
        document.getElementById('ddlCategory').style.width="225";*/
        
    for(i=0;i<arrEachRec.length-1;i++)
    {
        if(obj.value=='Wireless')
        {
            if(arrEachRec[i].split('~')[0]==obj.value && objCat.value==arrEachRec[i].split('~')[1] && arrEachRec[i].split('~')[4]==objCustType.value)
            {
                temp=arrEachRec[i].split('~')[2];     
                var opt=document.createElement('OPTION');
                opt.text=temp;
                opt.value=temp;
                objSubCat.options.add(opt);
            }
        }
        else
        {
            if(arrEachRec[i].split('~')[0]==obj.value && objCat.value==arrEachRec[i].split('~')[1])
            {
                temp=arrEachRec[i].split('~')[2];     
                var opt=document.createElement('OPTION');
                opt.text=temp;
                opt.value=temp;
                objSubCat.options.add(opt);
            }
        }
    }  
    
    showIConsoleKanaAdditionalCtrls();    
}

function showWireLessCategory()
{
    for(j=document.getElementById('ddlCategory').length -1;j>=0;j--)
    {
        document.getElementById('ddlCategory').remove(j);
    }
    var obj=document.getElementById('ddlSelectService');
    var objCat=document.getElementById('ddlCategory');
    var objCustType=document.getElementById('ddlWirelessCustType');
    
    for(i=0;i<arrEachRec.length-1;i++)
    {
        if(obj.value=='Wireless')
        {
            if(arrEachRec[i].split('~')[0]==obj.value && temp!=arrEachRec[i].split('~')[1] && arrEachRec[i].split('~')[4]==objCustType.value)
            {
                temp=arrEachRec[i].split('~')[1];
                var opt=document.createElement('OPTION');
                opt.text=temp;
                opt.value=temp;
                objCat.options.add(opt);
            }    
        }
    }    
    showCategory();    
}

var centreName='';
var indicator = false;

function showIConsoleKanaAdditionalCtrls()
{
    var obj=document.getElementById('ddlSelectService');
    var objCat=document.getElementById('ddlCategory');
    var objSubCat=document.getElementById('ddlSubCategory');
/*
    if(objSubCat.value.length>=37 && objSubCat.value.length<40)
    {
        document.getElementById('ddlSubCategory').style.width="275";
    }
    else if(objSubCat.value.length>=40 && objSubCat.value.length<=50)
    {
         document.getElementById('ddlSubCategory').style.width="325";
    }
    else if(objSubCat.value.length>=50)
    {
        document.getElementById('ddlSubCategory').style.width="375";
    }
    else
        document.getElementById('ddlSubCategory').style.width="225";
     */   
    if((obj.value.toUpperCase() == "TV OR ENTERTAINMENT" || obj.value.toUpperCase() == "INTERNET SERVICE") && (objSubCat.value.toUpperCase() == "GET TECHNICAL SUPPORT"))
    {
       
        indicator = true;
        window.location = strEnv + "ResidentialHelp/";
    }
    
    if((obj.value.toUpperCase() == "TV OR ENTERTAINMENT" && objSubCat.value.toUpperCase() == "FIOS TECH SUPPORT (CALL/CHAT ONLY)") || (obj.value.toUpperCase() == "INTERNET SERVICE" && objSubCat.value.toUpperCase() == "HIGH SPEED INTERNET TECH SUPPORT (CALL/CHAT ONLY)"))
    {       
        document.getElementById("dvButtons").style.display = "none";
    }
    else
    {
        document.getElementById("dvButtons").style.display = "block";
    }
    
//    if(objSubCat.value.indexOf('Get help with an order due today or past due') > -1 || objSubCat.value.indexOf('Report a repair or installation issue') > -1)
//    {
//        showDiv(document.getElementById('dvIConsole').id);        
//    }
//    else
//        hideDiv(document.getElementById('dvIConsole').id)

    if(obj.value=='Phone Service')
    {
        showDiv(document.getElementById('dvIsPhoneService').id);
        hideDiv(document.getElementById('dvNonIsPhoneService').id);
     }   
    else
    {
        showDiv(document.getElementById('dvNonIsPhoneService').id);
        hideDiv(document.getElementById('dvIsPhoneService').id);
    }
        

    for(i=0;i<arrEachRec.length-1;i++)
    {
        if(obj.value!='Wireless')
        {
            if(arrEachRec[i].split('~')[0]==obj.value && objCat.value==arrEachRec[i].split('~')[1] && arrEachRec[i].split('~')[2]==objSubCat.value)
            {
                if(arrEachRec[i].split('~')[3]=='Kana')
                {
                    centreName=arrEachRec[i].split('~')[3];
                    //showDiv(document.getElementById('dvIsKana').id);
                    showDiv(document.getElementById('dvShowContactNumForKanaIConsole').id); 
                    showDiv(document.getElementById('dvShowKana').id);  
                    hideDiv(document.getElementById('dvShowIConsole').id);
                    ///showDiv(document.getElementById('dvATN').id);
                    hideDiv(document.getElementById('dvIConsole').id);
                }
                else if(arrEachRec[i].split('~')[3]=='IConsole')
                {
                    centreName=arrEachRec[i].split('~')[3];
                    showDiv(document.getElementById('dvIConsole').id);
                    showDiv(document.getElementById('dvShowContactNumForKanaIConsole').id); 
                    hideDiv(document.getElementById('dvShowKana').id);
                    showDiv(document.getElementById('dvShowIConsole').id);                 
                    ///showDiv(document.getElementById('dvATN').id);                 
                }
                else                    
                {                   
                    hideDiv(document.getElementById('dvShowContactNumForKanaIConsole').id);
                    //hideDiv(document.getElementById('dvIsKana').id);
                    hideDiv(document.getElementById('dvIConsole').id);
                    ///hideDiv(document.getElementById('dvATN').id);
                    
                    
                }
              }
        }
    }    
}

function AssignState()
{
    document.getElementById('cboState').disabled=false;
    document.getElementById('cboState').value="state";
    for(i=0;i<arrStates.length -1;i++)
    {
        if(arrStates[i][0]==document.getElementById('txtATN1').value)
        {
            document.getElementById('cboState').value=arrStates[i][1];
            document.getElementById('cboState').disabled=true;
            SelectAccNumforSampleBill(arrStates[i][1]);
            break;
            
        }
        else
        {
            showDiv(document.getElementById('dvShowDefaultAccNumCount').id);
	        hideDiv(document.getElementById('dvNonShowDefaultAccNumCount').id);
        } 
    }
}

function showVoiceMail()
{
    showModalDialog("https://www22.verizon.com/ForYourHome/eRepairNet/VMXRepairANR/common/VMXMainmenu.aspx",'','dialogHeight:500px;dialogWidth:500px');

}

//code made by Prasanna ends here

function ResetForm()
{
	window.frmContactUsEmail.reset();
}
function BackForm()
{
	window.history.back();
}

function SelectAccNumforSampleBill(strSampleBillAccNo)
{   	
    var btnCount = 12;
    if((strSampleBillAccNo == "MD") || (strSampleBillAccNo == "DC") || (strSampleBillAccNo == "VA") || (strSampleBillAccNo == "WV"))
    {
        btnCount=12;
    }
    else if((strSampleBillAccNo == "NY") || (strSampleBillAccNo == "CT"))
    {
        btnCount=3;
    }
    else if((strSampleBillAccNo == "NJ") || ((strSampleBillAccNo == "PA")) || (strSampleBillAccNo == "DE"))
    {
        btnCount=3;
    }
    else if((strSampleBillAccNo == "MA") || (strSampleBillAccNo == "ME") || (strSampleBillAccNo == "NH") || (strSampleBillAccNo == "RI") || (strSampleBillAccNo == "VT"))
    {
         btnCount=3;
    }
    else if((strSampleBillAccNo == "AZ") || (strSampleBillAccNo == "CA")  || (strSampleBillAccNo == "FL")  || (strSampleBillAccNo == "IA")  || (strSampleBillAccNo == "IL")  || (strSampleBillAccNo == "IN")  || (strSampleBillAccNo == "MI")  || (strSampleBillAccNo == "NC")  || (strSampleBillAccNo == "NV")  || (strSampleBillAccNo == "OH")  || (strSampleBillAccNo == "OR")  || (strSampleBillAccNo == "SC")  || (strSampleBillAccNo == "TX")  || (strSampleBillAccNo == "WA")  || (strSampleBillAccNo == "WI"))
    {
        btnCount=6;
    }	
    document.getElementById('lblDigCount').innerHTML="(To protect the privacy of your account records, please enter your " + btnCount + "<br/> digit number located at the top of your telephone bill)";
    showDiv(document.getElementById('dvNonShowDefaultAccNumCount').id);
    hideDiv(document.getElementById('dvShowDefaultAccNumCount').id);
}


