﻿var isNN = ( navigator.appName.indexOf( "Netscape" ) != -1 ); 


function autoTab(input,len, e) { 
	var keyCode	= ( isNN ) ? e.which : e.keyCode; 	
	var filter	= [48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105];
	//alert(input.value);
	if (containsElement( filter, keyCode )) 
	{
	    alert(input.value);
	    if( input.value.length >= len)
	    { 
	        input.value = input.value.slice( 0, len ); 
	        var NextText;
	        NextText = input.form[( getIndex( input ) + 1 ) % input.form.length];
	        NextText.focus();
	        NextText.select();
	    }
	    return true;
	}
	return true;
} 

function autoTabPhone( input, len, e ) 
{ 
    var vContactPhone= document.getElementById('ctl00_ContentPlaceHolderMain_uinfo_txtContactPhone');
    var vNPA= document.getElementById('ctl00_ContentPlaceHolderMain_uinfo_txtNPA');
    var vNXX= document.getElementById('ctl00_ContentPlaceHolderMain_uinfo_txtNXX');
    var vSuffix= document.getElementById('ctl00_ContentPlaceHolderMain_uinfo_txtSuffix');
    vContactPhone.value = vNPA.value + vNXX.value + vSuffix.value;
	var keyCode	= ( isNN ) ? e.which : e.keyCode; 	
	var filter	= [48,49,50,51,52,53,54,55,56,57];
	if (containsElement( filter, keyCode )) 
	{
	    if( input.value.length >= len)
	    { 
	        input.value = input.value.slice( 0, len ); 
	        var NextText;
	        var NextIndex = getIndex( input );
	        NextText = input.form[( NextIndex + 1 ) % input.form.length];
	        NextText.focus();
	        NextText.select();
	        
	        if (NextText.id=='ctl00_ContentPlaceHolderMain_uinfo_txtContactPhone')
	        {
	            alert(NextText.id);
	            NextText = input.form[( NextIndex + 2 ) % input.form.length];
	            NextText.focus();
	            NextText.select();
	        }
	    }
	    return true;
	}
	return true;
} 

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 HandleEnterNext( input , e )
{
	var keyCode	= ( isNN ) ? e.which : e.keyCode;
	if (keyCode == 13)
	{
		var NextText;
		NextText = input.form[( getIndex( input ) + 1 ) % input.form.length];
		NextText.focus();
		NextText.select();
		return false;
	}
	else return true;
}
var isNN = ( navigator.appName.indexOf( "Netscape" ) != -1 ); 


function autoTab( input,len, e ) { 
	var keyCode	= ( isNN ) ? e.which : e.keyCode; 	
	var filter	= [48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105];
	if (containsElement( filter, keyCode )) 
	{	  
	    if( input.value.length >= len)
	    { 
	        input.value = input.value.slice( 0, len ); 
	        var NextText = input.form[( getIndex( input ) + 1 ) % input.form.length];
	        if (NextText.type != "hidden")
	        {
	            NextText.focus();
	            NextText.select();
	        }
	    }
	    return true;
	}
	return true;
} 
function HideValidator(ctlID)
{
    var i;
    for (i = 0; i < Page_Validators.length; i++) {
        if (!Page_Validators[i].isvalid) 
        {           
            if(Page_Validators[i].controltovalidate == ctlID)
            {                         
                var vld = document.getElementById(Page_Validators[i].id);
                //alert(vld.innerHTML);
                vld.style.display="none";                          
            }            
        }        
    }
}

function autoTabPhone( input, len, e ) 
{ 
    var vContactPhone= document.getElementById('ctl00_ContentPlaceHolderMain_uinfo_txtContactPhone');
    var vNPA= document.getElementById('ctl00_ContentPlaceHolderMain_uinfo_txtNPA');
    var vNXX= document.getElementById('ctl00_ContentPlaceHolderMain_uinfo_txtNXX');
    var vSuffix= document.getElementById('ctl00_ContentPlaceHolderMain_uinfo_txtSuffix');
    vContactPhone.value = vNPA.value + vNXX.value + vSuffix.value;
	var keyCode	= ( isNN ) ? e.which : e.keyCode; 	
	var filter	= [48,49,50,51,52,53,54,55,56,57];
	if (containsElement( filter, keyCode )) 
	{
	    if( input.value.length >= len)
	    { 
	        input.value = input.value.slice( 0, len ); 
	        var NextText;
	        var NextIndex = getIndex( input );
	        NextText = input.form[( NextIndex + 1 ) % input.form.length];
	        NextText.focus();
	        NextText.select();
	        
	        if (NextText.id=='ctl00_ContentPlaceHolderMain_uinfo_txtContactPhone')
	        {
	            alert(NextText.id);
	            NextText = input.form[( NextIndex + 2 ) % input.form.length];
	            NextText.focus();
	            NextText.select();
	        }
	    }
	    return true;
	}
	return true;
} 

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 toggleDiv(a)
    {      
      var e=document.getElementById(a);
      var img= document.getElementById('img' + a);
      if(!e)return true;
      if(e.style.display=="none")
      {
        e.style.display="block"
        img.src="images/minus.gif";
      } 
      else 
      {
        e.style.display="none"
        img.src="images/plus.gif";        
      }
      return true;
    }          
function HandleEnterNext( input , e )
{
	var keyCode	= ( isNN ) ? e.which : e.keyCode;
	if (keyCode == 13)
	{
		var NextText;
		NextText = input.form[( getIndex( input ) + 1 ) % input.form.length];
		if (NextText.type != "hidden")
	        {
	            NextText.focus();
	            NextText.select();
	        }
		return false;
	}
	else return true;
}
function OpenWindow(parameters)
        {
            var win;
            var destPage = parameters;            
            var wwidth=859;
            var wheight=595;
            var left=(window.screen.width - wwidth)/2;
            var top= (window.screen.height - wheight)/2;
            if (window.showModelessDialog)                 
                    win = window.showModelessDialog(destPage,window,"status:off;unadorned:on;resizable:on;edge:Raised;dialogWidth:" + wwidth + "px;dialogHeight:" + wheight + "px");
                else
                    win = window.open(destPage,"","status=no,width=" + wwidth + ",height=" + wheight + ",left=" + left + ",top=" + top + ",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");                       
         }
function ShowFAQs(parameters)
        {
            var win;
            var destPage = parameters;
            var wwidth = (window.screen.width) * 0.7;
            var wheight = (window.screen.height) * 0.8;
            var left = (window.screen.width - wwidth) / 2;
            var top = (window.screen.height - wheight) / 2;
            win = window.open(destPage,"","status=no,width=" + wwidth + ",height=" + wheight + ",left=" + left + ",top=" + top + ",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");                       
        }
function ShowWindow(parameters,width,height)
        {
            var win;
            var destPage = parameters;
            var wwidth = (window.screen.width) * width;
            var wheight = (window.screen.height) * height;
            var left = (window.screen.width - wwidth) / 2;
            var top = (window.screen.height - wheight) / 2;
            if (window.showModelessDialog)                 
                    win = window.showModelessDialog(destPage,window,"status:0;unadorned:on;resizable:on;edge:Raised;dialogWidth:" + wwidth + "px;dialogHeight:" + wheight + "px");
                else
                    win = window.open(destPage,"","status=0,width=" + wwidth + ",height=" + wheight + ",left=" + left + ",top=" + top + ",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");                       
         }    


