    var masterID = '_ctl0_ContentPlaceHolder1_';
    
    function CaptureEnterKey(e)
    {
        var isNN = (navigator.appName.indexOf("Netscape")!=-1);
        var keyCode = (isNN) ? e.which : e.keyCode; 
        var element = (isNN) ? e.target : window.event.srcElement;		

        if(element.id == 'zipcode')
        {	
	        if((isNNumeric(e) == 'true')) 
	        {
		        return true;
	        }
        }
        else
        {
	        if((isNNumeric(e) == 'true')) 
	        {
		        return true;
	        }
	        else if(keyCode == 13)
	        {
		        if (e.returnValue) 
		        {
			        e.returnValue = false;
			        return false;
		        } 
		        else if (e.preventDefault) 
		        {
			        getTNQueryString();
			        e.preventDefault();
			        return false;
		        }
		        e.cancel=true;
		        getTNQueryString();  
		        this.event.returnValue = false;	
		        return false;
	        }   
        }
    }

    function isNumeric()
	{
		if (navigator.appName.indexOf("Netscape")<0)
		{
			get=event.keyCode;
			if((get>47&&get<58)||(get==8)||(get==9)) 
			{
				return true;
			}
			else
			{
				event.returnValue=false;
			}
		}
	}

	function CaptureEnterKey1(e)
	{
	    var isNN = (navigator.appName.indexOf("Netscape")!=-1);
	    var keyCode = (isNN) ? e.which : e.keyCode; 

	    if((isNNumeric(e) == 'true')) 
	    {
		    return true;
	    }
	    else if(keyCode == 13)

	    {
		    if (e.returnValue) 
		    {
			    e.returnValue = false;
			    return false;
		    } 
		    else if (e.preventDefault) 
		    {
			    getTNQueryString();
			    e.preventDefault();
			    return false;
		    }

		    e.cancel=true;
		    getTNQueryString();  
		    this.event.returnValue = false;	
		    return false;
	    }   
    }			

    function getTNQueryString()
    {
  
        var npa = document.aspnetForm.txtAreaCode.value ;
        var nxx = document.aspnetForm.txtPrefix.value;
        var nbr = document.aspnetForm.txtPhoneNumber.value;
        var url = document.getElementById('_ctl0_ContentPlaceHolder1_url').value;

        var strPromoCode = document.getElementById('_ctl0_ContentPlaceHolder1_hidPromoCode').value;
        var strCampaignCode = document.getElementById('_ctl0_ContentPlaceHolder1_hidCampaignCode').value;
        var strSourceId =document.getElementById('_ctl0_ContentPlaceHolder1_hidSourceId').value;
        var strqs="";
        var result = 0; 

        //validate phone number		
        result =  validatePhoneNumber(npa, nxx, nbr);

        if(result)
        { 
            if((strPromoCode !='') && (strPromoCode !=null))
            {
                strqs= "&Promotion_Code=" + strPromoCode;
            }

            if((strCampaignCode !='') && (strCampaignCode !=null))
            {
                strqs= strqs + "&CampaignCode=" + strCampaignCode;
            }

            if((strSourceId !='') && (strSourceId !=null))
            {
                strqs= strqs + "&sourceID=" + strSourceId;
            }
            var str = url + "&txtAreaCode=" + npa + "&txtPrefix=" + nxx + "&txtPhoneNumber=" + nbr + strqs; 
            if(location.href.toLowerCase().indexOf("highspeedinternet")>-1)
            {
            str = url  + "&txtAreaCode=" + npa + "&txtPrefix=" + nxx + "&txtPhoneNumber=" + nbr ;//+ "&hdnFlow=TV" + "&exmarket=N";
            }
            if(location.href.toLowerCase().indexOf("fiosinternet")>-1)
            {
            str = url  + "&txtAreaCode=" + npa + "&txtPrefix=" + nxx + "&txtPhoneNumber=" + nbr ;//+ "&hdnFlow=TV" + "&exmarket=N";
            }	
            if((location.href.toLowerCase().indexOf("/residential/tv")>-1) ||(location.href.toLowerCase().indexOf("fiostv")>-1))
            {
            str = url  + "&txtAreaCode=" + npa + "&txtPrefix=" + nxx + "&txtPhoneNumber=" + nbr + "&hdnFlow=TV" + "&exmarket=N";
            }
            
            document.location.href = str;
            //this.event.returnValue = false;
            return false;
        }
        else
        {
            var error_count = 0;
            var errorMessage = 'Please enter a valid 10 digit number';

            if (npa == '' || npa.length != 3)
		    {
			    error_count++;
		    }
		    if (nxx == '' || nxx.length != 3)
		    {	
			    error_count++;
		    }
		    if (nbr == '' || nbr.length != 4)
		    {
			    error_count++;
		    }
            if (error_count > 0)
            {  
                document.aspnetForm.txtAreaCode.className= 'redfield'; 
                document.aspnetForm.txtPrefix.className='redfield';
                document.aspnetForm.txtPhoneNumber.className ='redfield';
                alert (errorMessage);	
                return false;
            }	 	 	 		
            return false;
        }	 
    }				
	// this function will validate a phone number
	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 NautoTab(input,len, e) 
	{	
		if (!isNNumeric(e))
			return false;
			
		var isNN = (navigator.appName.indexOf("Netscape")!=-1);
		var keyCode = (isNN) ? e.which : e.keyCode; 
		var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
		len = (isNN) ? len-1 : len;

		if(input.value.length >= len && !containsElement(filter,keyCode)) 
		{
			input.value = input.value.slice(0, len);
			input.form[(getIndex(input)+1) % input.form.length].focus();
		}
		return true;
	}
			
	bAutotab = true;

	function stopAutoTab()
	{
		bAutotab = false;
	}						
		
	function isNNumeric(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)) 
		{
			return true;
		}
		else
		{	
			if (e.returnValue) 
			{
				e.returnValue = false;
				return false;
			} 
			else if (e.preventDefault) 
			{
				e.preventDefault();
				return false;
			}
			this.event.returnValue = false;
			return false;            
		}	
	}

    function containsElement(arr, ele) 
    {
	    var found = false, index = 0;
		
	    while(!found && index < arr.length)
		    if(arr[index] == ele)
			    found = true;
		    else
		    index++;
	    return found;
    }
	    
    function getIndex(input) 
    {
	    var index = -1, i = 0, found = false;
	    while (i < input.form.length && index == -1)
	    if (input.form[i] == input)
		    index = i;
	    else 
		    i++;
	    return index;
    }
    
    function open_popup(sURL, w, h)	
{		
	if (w == undefined && h == undefined)
	{		
		if(typeof(sURL)!='string')
            newwindow = window.open(sURL.link,sURL.title,"menubar="+sURL.menubar+",resizable="+sURL.resizeable+",width="+sURL.width+",height="+sURL.height);
        else 
   			newwindow = window.open(sURL,"Popup","width="+ 550+" ,height="+500+ ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
	} else
	{
		if(typeof(sURL)!='string')
			newwindow = window.open(sURL.link,sURL.title,"menubar="+sURL.menubar+",resizable="+sURL.resizeable+",width="+sURL.width+",height="+sURL.height);
        else 
   		    newwindow = window.open(sURL,"Popup","width="+ w+" ,height="+h+ ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
	}
	if (window.focus) 
	{
		newwindow.focus()
	}
}

    
    /*function open_popup(sURL, w, h)	
	{		
		//	window.open(sURL,"Popup","width="+ w+" ,height="+h+ " ,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
		if(typeof(sURL)!='string')
                newwindow = window.open(sURL.link,sURL.title,"menubar="+sURL.menubar+",resizable="+sURL.resizeable+",width="+sURL.width+",height="+sURL.height);
        else 
   		        newwindow = window.open(sURL,"Popup","width="+ w+" ,height="+h+ " ,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
		if (window.focus) 
		{
			newwindow.focus()
		}
	}
	
	function open_popup(sURL)	
	{		
		//	window.open(sURL,"Popup","width="+ w+" ,height="+h+ " ,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
		if(typeof(sURL)!='string')
                newwindow = window.open(sURL.link,sURL.title,"menubar="+sURL.menubar+",resizable="+sURL.resizeable+",width="+sURL.width+",height="+sURL.height);
        else 
   		        newwindow = window.open(sURL,"Popup","width="+ 500+" ,height="+600+ " ,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
		if (window.focus) 
		{
			newwindow.focus()
		}
	}	 */ 	        
        
    function getCookie(cookieName)
	{
		if (document.cookie.length>0)
		{
			cStart=document.cookie.indexOf(cookieName + "=");
			if (cStart!=-1)
				{ 
				cStart=cStart + cookieName.length+1; 
				cEnd=document.cookie.indexOf(";",cStart);
				if (cEnd==-1) cEnd=document.cookie.length;
				return unescape(document.cookie.substring(cStart,cEnd));
				} 
		}
		return '';
	}
		
	function setCookie(name, value,  path, domain) {
		var curCookie = name + "=" + escape(value) +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") ; 
			document.cookie = curCookie;
	}
	
