/*
	
	 #############################################################################
	 #		File Name     : Validations.js										 #
	 #		Functionality : This javascript file contains common functions		 #	
 	 #		Last Modified : 													 #	  
	 #		Author        : 													 #	
 	 #############################################################################
		
*/

// initialize variables 
var ppcIE=((navigator.appName == "Microsoft Internet Explorer") || ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion)==5)));
var ppcNN6=((navigator.appName == "Netscape") && (parseInt(navigator.appVersion)==5));
//var ppcIE=(navigator.appName == "Microsoft Internet Explorer");
var ppcNN=((navigator.appName == "Netscape")&&(document.layers));

function trim(strInput)
{
// for trimLeft
	var strTemp = strInput
	while(strTemp.charAt(0)==" ")
	{
		strTemp = strTemp.slice(1);
	}
// for TrimRight
	var iLength = strTemp.length;
	iLength--;// accounts for zero based index
	while(strTemp.charAt(iLength)==" ")
	{
		strTemp = strTemp.slice(0,iLength--);
	}
	return strTemp;
}

function isEmail (s)
{
   var reEmail = /^.+\@.+\..+$/
   if (isEmpty(s))
	   return false;
    else {
       return reEmail.test(s)
    }
}

//This function returns true if string will check the given string is a Empty string
function isEmpty(s)
{
   return ((s == null) || (s.length == 0))
}

function isUSPhoneNumber(s)
{	
	reDigit=/\(\d{3}\)\d{3}\-\d{4}$/
	
	if (reDigit.test(s) == true)
	{
		return true;
	}
	else 
	{
		return false;
	}
	 
}

//function to validate phone numbers
function ValidatePhone(objPhone)
{
	var sPhone=objPhone.value;
	
	var sValidPhone="";
	var sFormatPhone="";
	var sRegExp="";
	sRegExp=/\(|\)|-/g
	sValidPhone=trim(sPhone.replace(sRegExp,""));
	
	if (sValidPhone > 0)	
	{
		if (isUSPhoneNumber(sPhone) == false)
		{
			
			if (sValidPhone.length!=10)
			{
				alert("Please enter a valid Phone Number of 10 digits");
				objPhone.value="";
				objPhone.focus();
				return false;
			}
			if (isNaN(sValidPhone)==true)
			{
				alert("Please enter a valid Phone Number of 10 digits");
				objPhone.value="";
				objPhone.focus();
				return false;
			}
			if ((sValidPhone.indexOf(".") == -1) || (sValidPhone.indexOf("'") == -1) || (sValidPhone.indexOf('"') == -1))
			{
				alert("Please enter a valid Phone Number of 10 digits");
				objPhone.value="";
				objPhone.focus();
				return false;
			}
			return true;
		}
	}
	else
	{
		alert ("Please enter a valid Phone Number of 10 digits");
		objPhone.value="";
		objPhone.focus();
		return false;
	}
}

function FormatPhone(objPhone)
{
	var sPhone=objPhone.value;
		
	if (isUSPhoneNumber(sPhone) == false)
	{
		var sValidPhone="";
		var sFormatPhone="";
		var sRegExp="";
		sRegExp=/\(|\)|-/g
		sValidPhone=trim(sPhone.replace(sRegExp,""));
	
		if (sValidPhone.length==10)
		{
			sFormatPhone="(" + sValidPhone.substring(0,3) + ")"
			sFormatPhone=sFormatPhone + sValidPhone.substring(3,6) + "-" + sValidPhone.substring(6)
					
		}
		else
		{
			sFormatPhone=sPhone;
		}
		objPhone.value=sFormatPhone;
		return true;
	}
	
		
}
function SelectFromCalendar(frmName,dteBox,btnImg,obj,prevYrs,nxtYrs,calTop,calLeft)
{
	if(obj != null)
	{
	objCal=obj.value
	}
   else
    {	
	objCal=new Date();
	}
	
	objprevYrs = prevYrs;
	objnxtYrs = nxtYrs;
	objfrmName = frmName;
	objdateCtrl = dteBox;
	if ( ppcIE ) {
        ppcX = getOffsetLeft(document.images[btnImg]);    
        ppcY = getOffsetTop(document.images[btnImg]) + document.images[btnImg].height;
    }
    else if (ppcNN){
        ppcX = document.images[btnImg].x; 
        ppcY = document.images[btnImg].y + document.images[btnImg].height;
    }
	if ((calLeft) && (calTop) && calTop != "" && calLeft != "")
       {
	   	ppcX = calTop ;    
        ppcY = calLeft;
       }
	dateSelected=eval("obj");
	objCalendar=window.open("Calendar.htm","Calendar", "width=" + 195 + ",height=" + 170 +",left=" + ppcX +",top=" + ppcY +",screenX=" +ppcX +",screenY=" +ppcY);
	objCalendar.focus();
	return false;
}


function TextAreaMaxLengthCheck(txtfield,maxlimit)
{
	if (txtfield.value.length > maxlimit)
	{
		txtfield.focus();
		txtfield.value = txtfield.value.substring(0, maxlimit);
	}
	else
	{ 
		//txtcount.value = maxlimit - txtfield.value.length;
	}
			
}

/* *** Function to display the message/tooltip in the status bar *** */
function DisplayStatusMessage(sMessage)
{		
	window.status=sMessage;
	return true;
}

function maskIt(fldVal,objField)
{
   var isNamedFone;	
   var tmpStr = "(";
   keyCount = fldVal.length;
   keyEntered =fldVal.substring(keyCount-1,keyCount);
	
   if (keyCount <= 1)   isNamedFone = false;
   if (!isNamedFone)    
     
   keyCount++;
   switch (keyCount)
   {
	  case 2: 
         tmpStr +=  fldVal;
        objField.value = tmpStr;
         break;
      case 5:
         objField.value += ")" ;
         break;
      case 9:
         objField.value += "-" ;
         break;
   }     
}

function maskZip(fldVal,objField)
{
	var isNamedFone;	
	var tmpStr = "";
	keyCount = fldVal.length;
	keyEntered =fldVal.substring(keyCount-1,keyCount);
			
	if (keyCount <= 1)   isNamedFone = false;
	if (!isNamedFone)    
				
	keyCount++;
	switch (keyCount)
	{
		case 2: 
			tmpStr +=  fldVal;
			objField.value = tmpStr;
			break;
		case 6:
			objField.value += "-" ;
			break;
	}     
}

function CheckKeyCode(objEvent)
{
	var Obj, keyvalue, varchar;
	
	if(document.all)
		keyvalue=window.event.keyCode;
		
	if(document.layers)
		keyvalue=objEvent.which;
	
	if (ppcNN6)
		keyvalue = (window.Event) ? objEvent.which : objEvent.keyCode;
	
    keychar = String.fromCharCode(keyvalue);
    
    
    if (keychar== ".")
    {
        return true ;
    }    
    
    else
    {
		if(keyvalue<=46 || keyvalue>57 || (keyvalue==47))
		{
			if (keyvalue != 8)
			{
				if(document.all)
					window.event.keyCode=0;
					return false;
				if (ppcNN6)
					return false;
			}
		}
	} 

	return true;
}

//function to validate ZipCode Number
function ValidateZip(objZipCode)
{
	var sZipCode=objZipCode.value;	
	if(sZipCode!="")
	{
		var sValidZip="";
		sValidZip=trim(sZipCode.replace('-',''));
	
			if (isNaN(sValidZip)==true)
			{
				alert("Please enter a valid Zip Code of 9 digits");
				objZipCode.value="";
				objZipCode.focus();
				return false;
			}
	}
}
function CheckPhone(objPhone)
{
	if(trim(objPhone.value)=="")
		return true
	var sPhone=objPhone.value;
	var sValidPhone="";
	var sFormatPhone="";
	var sRegExp="";
	sRegExp=/\(|\)|-/g
	sValidPhone=trim(sPhone.replace(sRegExp,""));
	if (isUSPhoneNumber(sPhone) == false)
	{
		if (sValidPhone.length!=10)
		{
			return false;
		}
		if (isNaN(sValidPhone)==true)
		{
			
			return false;
		}
		if ((sValidPhone.indexOf(".") == -1) || (sValidPhone.indexOf("'") == -1) || (sValidPhone.indexOf('"') == -1))
		{
			return false;
		}
		return true;
	}
	return true;
}

function TextAreaMaxLengthCheck(txtfield,maxlimit)
{
	if (txtfield.value.length > maxlimit)
	{
		txtfield.focus();
		txtfield.value = txtfield.value.substring(0, maxlimit);
	}
	else
	{ 
		//txtcount.value = maxlimit - txtfield.value.length;
	}
			
}


function convert_date(field1)
{
var fLength = field1.value.length; // Length of supplied field in characters.
var divider_values = new Array ('-','.','/',' ',':','_',','); // Array to hold permitted date seperators.  Add in '\' value
var array_elements = 7; // Number of elements in the array - divider_values.
var day1 = new String(null); // day value holder
var month1 = new String(null); // month value holder
var year1 = new String(null); // year value holder
var divider1 = null; // divider holder
var outdate1 = null; // formatted date to send back to calling field holder
var counter1 = 0; // counter for divider looping 
var divider_holder = new Array ('0','0','0'); // array to hold positions of dividers in dates
var s = String(field1.value); // supplied date value variable

//If field is empty do nothing
if ( fLength == 0 ) {
   return true;
}

// Deal with today or now
if ( field1.value.toUpperCase() == 'NOW' || field1.value.toUpperCase() == 'TODAY' ) {
   
	var newDate1 = new Date();
	
  		if (navigator.appName == "Netscape") {
    		var myYear1 = newDate1.getYear() + 1900;
  		}
  		else {
  			var myYear1 =newDate1.getYear();
  		}
  
	var myMonth1 = newDate1.getMonth()+1;  
	var myDay1 = newDate1.getDate();
	field1.value = myDay1 + "/" + myMonth1 + "/" + myYear1;
	fLength = field1.value.length;//re-evaluate string length.
	s = String(field1.value)//re-evaluate the string value.
}

//Check the date is the required length
if ( fLength != 0 && (fLength < 6 || fLength > 11) ) {
	invalid_date(field1);
	return false;   
	}

// Find position and type of divider in the date
for ( var i=0; i<3; i++ ) {
	for ( var x=0; x<array_elements; x++ ) {
		if ( s.indexOf(divider_values[x], counter1) != -1 ) {
			divider1 = divider_values[x];
			divider_holder[i] = s.indexOf(divider_values[x], counter1);
		   //alert(i + " divider1 = " + divider_holder[i]);
			counter1 = divider_holder[i] + 1;
			//alert(i + " counter1 = " + counter1);
			break;
		}
 	}
 }

// if element 2 is not 0 then more than 2 dividers have been found so date is invalid.
if ( divider_holder[2] != 0 ) {
   invalid_date(field1);
	return false;   
}

// See if no dividers are present in the date string.
if ( divider_holder[0] == 0 && divider_holder[1] == 0 ) { 
   
		//continue processing
		if ( fLength == 6 ) {//ddmmyy
   		month1= field1.value.substring(0,2);
     		day1 = field1.value.substring(2,4);
  			year1 = field1.value.substring(4,6);
  			if ( (year1 = validate_year(year1)) == false ) {
   			invalid_date(field1);
				return false; 
				}
			}
			
		else if ( fLength == 7 ) {//ddmmmy
   		month1 = field1.value.substring(2,5);
  			day1 = field1.value.substring(0,2);
  			year1 = field1.value.substring(5,7);
  			if ( (month1 = convert_month(month1)) == false ) {
   			invalid_date(field1);
				return false; 
				}
  			if ( (year1 = validate_year(year1)) == false ) {
   			invalid_date(field1);
				return false; 
				}
			}
		else if ( fLength == 8 ) {//ddmmyyyy
   		month1 = field1.value.substring(2,4);
  			day1 = field1.value.substring(0,2);
  			year1 = field1.value.substring(4,8);
			}
		else if ( fLength == 9 ) {//ddmmmyyyy
   		month1 = field1.value.substring(2,5);
  			day1 = field1.value.substring(0,2);
  			year1 = field1.value.substring(5,9);
  			if ( (month1 = convert_month(month1)) == false ) {
   			invalid_date(field1);
				return false; 
				}
			}
		
		if ( (outdate1 = validate_date(month1,day1,year1)) == false ) {
   		
   		alert("The value " + field1.value + " is not a vaild date.\n\r" +  
			"Please enter a valid date in the format mm/dd/yyyy");
			
			field1.focus();
			field1.value="";
			field1.select();
			return false;
			}

		field1.value = outdate1;
		return true;// All OK
		}
		
// 2 dividers are present so continue to process	
if ( divider_holder[0] != 0 && divider_holder[1] != 0 ) { 	
  	month1 = field1.value.substring(0, divider_holder[0]);
  	day1 = field1.value.substring(divider_holder[0] + 1, divider_holder[1]);
  	//alert(month1);
  	year1 = field1.value.substring(divider_holder[1] + 1, field1.value.length);
	}

if ( isNaN(day1) && isNaN(year1) ) { // Check day and year are numeric
	invalid_date(field1);
	return false;  
   }

if ( day1.length == 1 ) { //Make d day dd
   day1 = '0' + day1;  
}

if ( month1.length == 1 ) {//Make m month mm
	month1 = '0' + month1;   
}

if ( year1.length == 2 ) {//Make yy year yyyy
   if ( (year1 = validate_year(year1)) == false ) {
   	invalid_date(field1);
		return false;  
		}
}

if ( month1.length == 3 || month1.length == 4 ) {//Make mmm month mm
   if ( (month1 = convert_month(month1)) == false) {
   	//alert("month1" + month1);
   	invalid_date(field1);
   	return false;  
   }
}

// Date components are OK
if ( (day1.length == 2 || month1.length == 2 || year1.length == 4) == false) {
   invalid_date(field1);
   return false;
}

//Validate the date
if ( (outdate1 = validate_date(day1, month1, year1)) == false ) {

   alert("The value " + field1.value + " is not a vaild date.\n\r" +  
	"Please enter a valid date in the format mm/dd/yyyy");
	
	field1.focus();
	field1.value="";
	field1.select();
	return false;
}

// Redisplay the date in mm/dd/yyyy format
field1.value = outdate1;
return true;//All is well

}
/******************************************************************
   convert_month()
   
   Function to convert mmm month to mm month 
   
   Called by convert_date()    
   
*******************************************************************/
function convert_month(monthIn) {

var month_values = new Array ("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");

monthIn = monthIn.toUpperCase(); 

if ( monthIn.length == 3 ) {
	for ( var i=0; i<12; i++ ) 
		{
   	if ( monthIn == month_values[i] ) 
   		{
			monthIn = i + 1;
			if ( i != 10 && i != 11 && i != 12 ) 
				{
   			monthIn = '0' + monthIn;
				}
			return monthIn;
			}
		}
	}

else if ( monthIn.length == 4 && monthIn == 'SEPT') {
   monthIn = '09';
   return monthIn;
	}
	
else {
	return false;
	} 
}
/******************************************************************
   invalid_date()
   
   If an entered date is deemed to be invalid, invali
   d_date() is called to display a warning message to
   the user.  Also returns focus to the date  in que
   stion and selects the date for edit.
        
   Called by convert_date()
   
*******************************************************************/
function invalid_date(inField) 
{
alert("The value " + inField.value + " is not in a vaild date format.\n\r" + 
        "Please enter date in the format mm/dd/yyyy");
inField.focus();
inField.value="";
inField.select();
return true   
}
/******************************************************************
   validate_date()
   
   Validates date output from convert_date().  Checks
   day is valid for month, leap years, month !> 12,.
   
 
   Notes: Please feel free to use/edit this script.  If you do please keep my comments and details 
   intact and notify me via a quick Email to the address above.  Enjoy!
*******************************************************************/
function validate_date(day2, month2, year2)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
var DayArray = new Array(31,28,31,30,31,30,31,31,30,31,30,31);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
var MonthArray = new Array("01","02","03","04","05","06","07","08","09","10","11","12");                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
var inpDate = day2 + month2 + year2;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
var filter=/^[0-9]{2}[0-9]{2}[0-9]{4}$/;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

//Check ddmmyyyy date supplied
if (! filter.test(inpDate))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
  {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  return false;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
/* Check Valid Month */                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
filter=/01|02|03|04|05|06|07|08|09|10|11|12/ ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
if (! filter.test(month2))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
  return false;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
/* Check For Leap Year */                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
var N = Number(year2);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
if ( ( N%4==0 && N%100 !=0 ) || ( N%400==0 ) )                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  	{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
   DayArray[1]=29;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  	}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
/* Check for valid days for month */                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
for(var ctr=0; ctr<=11; ctr++)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  	{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
   if (MonthArray[ctr]==month2)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
   	{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
      if (day2<= DayArray[ctr] && day2 >0 )                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
        {
        inpDate = month2 + '/' + day2 + '/' + year2;       
        return inpDate;
        }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
      else                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
        {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
        return false;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
        }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
   	}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
   }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
}
/******************************************************************
   validate_year()
   
   converts yy years to yyyy
   Uses a hinge date of 10
        < 10 = 20yy 
        => 10 = 19yy.
         
   Called by convert_date() before validate_date().
      
 
   Notes: Please feel free to use/edit this script.  If you do please keep my comments and details 
   intact and notify me via a quick Email to the address above.  Enjoy!
*******************************************************************/
function validate_year(inYear) 
{
if ( inYear < 10 ) 
	{
   inYear = "20" + inYear;
   return inYear;
	}
else if ( inYear >= 10 )
	{
   inYear = "19" + inYear;
   return inYear;
	}
else 
	{
	return false;
	}   
}



function maskZip(fldVal,objField)
{
    var isNamedFone;	
    var tmpStr = "";
    keyCount = fldVal.length;
    keyEntered =fldVal.substring(keyCount-1,keyCount);
			
	if (keyCount <= 1)   isNamedFone = false;
	if (!isNamedFone)    
		        
	keyCount++;
	switch (keyCount)
	{
		case 2: 
			tmpStr +=  fldVal;
			objField.value = tmpStr;
			break;
		case 6:
			objField.value += "-" ;
			break;
	}     
}

function IsNumeric(sText)
{
    var ValidChars = "0123456789.";
    var Char;

    for (i = 0; i < sText.length && IsNumber == true; i++) 
    { 
        Char = sText.charAt(i); 
        if (ValidChars.indexOf(Char) == -1) 
        {
            return false;
        }
    }
    return true;

}


function ValidateZip(objZipCode)
{
	var sZipCode=objZipCode.value;	
	if(sZipCode!="")
	{
		var sValidZip="";
		sValidZip=trim(sZipCode.replace('-',''));
	
			if (isNaN(sValidZip)==true)
			{
				//alert("Please enter a valid Zip Code of 9 digits");
				//objZipCode.value="";
				//objZipCode.focus();
				return false;
			}
	}
}

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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
	
