
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function firstFocus(prmtabindex){
	//MM_preloadImages('../Images/Home1.gif','../Images/Members1.gif','../Images/Contactus1.gif')
	var eleindex;
	var frmlen = document.forms[0].elements.length;		
	var flag=false;	
	
	for(var i=0;i<frmlen;i++){

		if(document.forms[0].elements[i].tabIndex==prmtabindex){	
			//alert(prmtabindex);		
			flag=true;
			eleindex =i;
			break;			
		}		
	}			
	if(flag==true){		
	//alert(eleindex);
		document.forms[0].elements[eleindex].focus();
	}
	
}

// ***********    Function to Validate the Given Zip		***********    
function isValidZip(formName,fieldName)
{
	var returnFlag	= true;
	var frmIndex	= findFormIndex(formName);
	var fieldIndex	= findElementIndex(frmIndex, fieldName);
	 
	var zipVal=document.forms[frmIndex].elements[fieldIndex].value; 
	
	if (zipVal!=0)	
	{
		if((zipVal.substring(5,6)) != "-")
		{
			if(isNaN(zipVal))
			{
				alert("Enter only Numbers");
				document.forms[frmIndex].elements[fieldIndex].focus();
				document.forms[frmIndex].elements[fieldIndex].value='';
				returnFlag = false;
				return false ;
			}	 
			else if( zipVal.charAt(0)=='-')
			{
				alert("Negative Numbers not Allowed");
				document.forms[frmIndex].elements[fieldIndex].focus();
				returnFlag = false;
				return false ;
			}
			else
			{
				if(zipVal.length < 5)
				{
					alert("Zip should be at least 5 Digits");
					document.forms[frmIndex].elements[fieldIndex].focus();
					returnFlag = false;
					return false ;
				}
				else if(zipVal.length > 5)	
					document.forms[frmIndex].elements[fieldIndex].value=
							zipVal.substring(0,5)+"-"+zipVal.substring(5,9);
			}
		}
	}	
  
	if (returnFlag==true)
	{
		 return true;
	}

}		// end of Function

// ***********    Function to  the find Index of specified Form		***********    
function findFormIndex(formName)
{
	var frmLen = document.forms.length ;
	var frmIndex;
	var formFlag = false;
		
	for (var i=0; i<frmLen; i++)
	{	
		if(document.forms[i].name == formName )
		{
			frmIndex = i;
			formFlag = true;
		}
	}
	
	if (formFlag==true)
		return frmIndex;
	else
	{
	    alert('Invalid Form Name');
	    return false;
	}
	    
}		// end of Function  findFormIndex(formName)

// ***********    Function to  the find Index of specified Element		***********    


function findElementIndex(frmIndex, fieldName)
{
	var elemLen = document.forms[frmIndex].elements.length;
	var fieldIndex;
	var fieldFlag = false;
	
	for (var i=0; i<elemLen; i++)
	{	
		if(document.forms[frmIndex].elements[i].type == 'text'  || 
			document.forms[frmIndex].elements[i].type == 'select-one')
		{	
			if (document.forms[frmIndex].elements[i].name == fieldName)
			{
				fieldIndex = i;
				fieldFlag = true;
			}	
		}
	}
	if (fieldFlag == true)
		return fieldIndex;
	else
	{
	    alert('Invalid Field Name');
	    return false;
	}
	
}		// end of Function findElementIndex(frmIndex, fieldName) 

// ***********    Function to Validate the Given Number		***********    


function isValidNumber(formName, fieldName,DispName)
{
	var returnFlag	= true;
	var frmIndex	= findFormIndex(formName);
	var fieldIndex	= findElementIndex(frmIndex, fieldName);
	
	var num = document.forms[frmIndex].elements[fieldIndex].value;	
	
	 if  (isNaN(num))
	{	
		alert("Please enter valid number in "+DispName);
		document.forms[frmIndex].elements[fieldIndex].focus();
		document.forms[frmIndex].elements[fieldIndex].value='';
		returnFlag = false;
		return false;
	}
	 if  (num<0)
	{	
		alert("Please enter  number not less than 0 in "+DispName);
		document.forms[frmIndex].elements[fieldIndex].focus();
		document.forms[frmIndex].elements[fieldIndex].value='';
		returnFlag = false;
		return false;
	}
	if(num.indexOf('.')>0)
	{
		alert("Please enter valid number in "+DispName);
		document.forms[frmIndex].elements[fieldIndex].focus();
		document.forms[frmIndex].elements[fieldIndex].value='';
		returnFlag = false;
		return false;
	}
	if(returnFlag==true)
	{
		return true;
	}
}

// ***********    Function to Validate the Given Area Codes Number with Commas	***********    
function isValidAreaCodes(formName, fieldName,DispName)
{
	var returnFlag	= true;
	var frmIndex	= findFormIndex(formName);
	var fieldIndex	= findElementIndex(frmIndex, fieldName);
	
	var num = document.forms[frmIndex].elements[fieldIndex].value;	
				
	if (num != '')
	{				
		var num_arr = num.split(",")
		for (var i=0; i<num_arr.length;i++)
		{
			if (isNaN(num_arr[i]))
			{	
				alert("Please enter valid number in "+DispName);
				document.forms[frmIndex].elements[fieldIndex].focus();
				//document.forms[frmIndex].elements[fieldIndex].value='';
				returnFlag = false;
				return false;
			}
		}
	}			
	if  (num<0)
	{	
		alert("Please enter  number not less than 0 in "+DispName);
		document.forms[frmIndex].elements[fieldIndex].focus();
		document.forms[frmIndex].elements[fieldIndex].value='';
		returnFlag = false;
		return false;
	}
	if(num.indexOf('.')>0)
	{
		alert("Please enter valid number in "+DispName);
		document.forms[frmIndex].elements[fieldIndex].focus();
		document.forms[frmIndex].elements[fieldIndex].value='';
		returnFlag = false;
		return false;
	}
	if(returnFlag==true)
	{
		return true;
	}
}

		function TxtPhone1_onkeypress() 
		{
			if(document.Form1.txtPhone1.value.length > 2)
			{
				document.Form1.txtPhone2.focus();
			}
		}
		function TxtPhone2_onkeypress() 
		{
			if(document.Form1.txtPhone2.value.length > 2)
			{
				document.Form1.txtPhone3.focus();
			}
		}
		function TxtPhone3_onkeypress() 
		{
			if(document.Form1.txtPhone3.value.length > 3)
			{
				document.Form1.txtPhone4.focus();
			}
		} 
		function TxtFax1_onkeypress() 
		{
			if(document.Form1.txtFax1.value.length > 2)
			{
				document.Form1.txtFax2.focus();
			}
		}
		function TxtFax2_onkeypress() 
		{
			if(document.Form1.txtFax2.value.length > 2)
			{
				document.Form1.txtFax3.focus();
			}
		}
		
		function PhoneExtension_Validate()
		{	
		 if(document.Form1.txtPhone4.value.length == 0)
			{			
			 if((document.Form1.txtPhone1.value.length == 0) && (document.Form1.txtPhone2.value.length == 0) && (document.Form1.txtPhone3.value.length == 0))
			 {		   		   
				alert("Extension is not valid without Phone Number");
				document.Form1.txtPhone4.value = '';
				document.Form1.txtPhone1.focus();
				
			 }			
			}
		}
		
	// Additional Phone 1
	function TxtAddPhone11_onkeypress()
	{
		if(document.Form1.txtAddPhone11.value.length > 2)
		{
			document.Form1.txtAddPhone12.focus();
		}
	}	
	
	function TxtAddPhone12_onkeypress()
	{
		if(document.Form1.txtAddPhone12.value.length > 2)
		{
			document.Form1.txtAddPhone13.focus();
		}
	}
	
	function TxtAddPhone13_onkeypress()
	{
		if(document.Form1.txtAddPhone13.value.length > 3)
		{
			document.Form1.txtAddPhone14.focus();
		}
	}
	
	function AddPhoneExtension14_Validate()
	{	
		if(document.Form1.txtAddPhone14.value.length == 0)
		{			
			if((document.Form1.txtAddPhone11.value.length == 0) && (document.Form1.txtAddPhone12.value.length == 0) && (document.Form1.txtAddPhone13.value.length == 0))
			{		   		   
			alert("Extension is not valid without Phone Number");
			document.Form1.txtAddPhone14.value = '';
			document.Form1.txtAddPhone11.focus();
			
			}			
		}
	}
		
	// Additional Other Phone 1
	function txtAddOPhone11_onkeypress()
	{
		if(document.Form1.txtAddOPhone11.value.length > 2)
		{
			document.Form1.txtAddOPhone12.focus();
		}
	}
	
	function txtAddOPhone12_onkeypress()
	{
		if(document.Form1.txtAddOPhone12.value.length > 2)
		{
			document.Form1.txtAddOPhone13.focus();
		}
	}
	
	function txtAddOPhone13_onkeypress()
	{
		if(document.Form1.txtAddOPhone13.value.length > 3)
		{
			document.Form1.txtAddOPhone14.focus();
		}
	}
	
	function AddOtherPhoneExtension14_Validate()
	{	
		if(document.Form1.txtAddOPhone14.value.length == 0)
		{			
			if((document.Form1.txtAddOPhone11.value.length == 0) && (document.Form1.txtAddOPhone12.value.length == 0) && (document.Form1.txtAddOPhone13.value.length == 0))
			{		   		   
				alert("Extension is not valid without Phone Number");
				document.Form1.txtAddOPhone14.value = '';
				document.Form1.txtAddOPhone11.focus();			
			}			
		}
	}
	
	// Additional Fax 1
	function TxtAddFax11_onkeypress()
	{
		if(document.Form1.txtAddFax11.value.length > 2)
		{
			document.Form1.txtAddFax12.focus();
		}
	}
	
	function TxtAddFax12_onkeypress()
	{
		if(document.Form1.txtAddFax12.value.length > 2)
		{
			document.Form1.txtAddFax13.focus();
		}
	}
	
	// Additional Phone 2
	function TxtAddPhone21_onkeypress()
	{
		if(document.Form1.txtAddPhone21.value.length > 2)
		{
			document.Form1.txtAddPhone22.focus();
		}
	}
	
	function TxtAddPhone22_onkeypress()
	{
		if(document.Form1.txtAddPhone22.value.length > 2)
		{
			document.Form1.txtAddPhone23.focus();
		}
	}
	
	function TxtAddPhone23_onkeypress()
	{
		if(document.Form1.txtAddPhone23.value.length > 3)
		{
			document.Form1.txtAddPhone24.focus();
		}
	}
	
	function AddPhoneExtension24_Validate()
	{	
		if(document.Form1.txtAddPhone24.value.length == 0)
		{			
			if((document.Form1.txtAddPhone21.value.length == 0) && (document.Form1.txtAddPhone22.value.length == 0) && (document.Form1.txtAddPhone23.value.length == 0))
			{		   		   
				alert("Extension is not valid without Phone Number");
				document.Form1.txtAddPhone24.value = '';
				document.Form1.txtAddPhone21.focus();			
			}			
		}
	}
	
	// Additional Other Phone 2
	function txtAddOPhone21_onkeypress()
	{
		if(document.Form1.txtAddOPhone21.value.length > 2)
		{
			document.Form1.txtAddOPhone22.focus();
		}
	}
	
	function txtAddOPhone22_onkeypress()
	{
		if(document.Form1.txtAddOPhone22.value.length > 2)
		{
			document.Form1.txtAddOPhone23.focus();
		}
	}
	
	function txtAddOPhone23_onkeypress()
	{
		if(document.Form1.txtAddOPhone23.value.length > 3)
		{
			document.Form1.txtAddOPhone24.focus();
		}
	}
	
	function AddOtherPhoneExtension24_Validate()
	{	
		if(document.Form1.txtAddOPhone24.value.length == 0)
		{			
			if((document.Form1.txtAddOPhone21.value.length == 0) && (document.Form1.txtAddOPhone22.value.length == 0) && (document.Form1.txtAddOPhone23.value.length == 0))
			{		   		   
				alert("Extension is not valid without Phone Number");
				document.Form1.txtAddOPhone24.value = '';
				document.Form1.txtAddOPhone21.focus();			
			}			
		}
	}
	
	// Additional Fax 2
	function TxtAddFax21_onkeypress()
	{
		if(document.Form1.txtAddFax21.value.length > 2)
		{
			document.Form1.txtAddFax22.focus();
		}
	}
	
	function TxtAddFax22_onkeypress()
	{
		if(document.Form1.txtAddFax22.value.length > 2)
		{
			document.Form1.txtAddFax23.focus();
		}
	}