//____________________________________________________________________________________
//________      PrintReport                 __________________________________________


function printreport() {
 if (window.print) {
  setTimeout('window.print();',200);
 }
 else {
  alert("Press 'Ctrl+p' or 'Cmd+p' on your keyboard to print report.");
 }
}



//____________________________________________________________________________________
//________      ValidSSN                  __________________________________________


function ValidSSN() {


	  if (SSNValidation(document.myform.SSN.value)==false) {
		  document.myform.SSN.focus();
		return false;
		}
		if (document.myform.SendMode[1].checked) {
			if (isWhitespace(document.myform.FaxNo.value)) {
				alert ("Please provide the Fax Number where the report should be sent");
				return false;
			}
		if (IsPhone(document.myform.FaxNo.value)==false) {
			document.myform.FaxNo.focus();
			return false;	
			}
		}
		
return true; 

}

//____________________________________________________________________________________
//________      ValidSSA                  __________________________________________


function ValidSSA() {

if (isWhitespace(document.myform.SSACompany.value)) 
	{
		 alert("Please enter Company Name!  ");
		 document.myform.SSACompany.focus();
		 return false;
	}  
if (isWhitespace(document.myform.SSAContact.value)) 
	{
		 alert("Please enter Contact Name!  ");
		 document.myform.SSAContact.focus();
		 return false;
	}
	
	
	/*
	if (isWhitespace(document.myform.SSAZip.value)) 
	{
		 alert("Please enter Zip! ");
		 document.myform.SSAZip.focus();
		 return false;
	} 
	*/
		
	if (document.myform.SSAZip.value.length>0){ 
	 if (validateZIP(document.myform.SSAZip)==false) {
				document.myform.SSAZip.focus();
				return false;
	} 
	}
	if (isWhitespace(document.myform.SSAPhone.value)) 
	{
		 alert("Please enter Phone! ");
		 document.myform.SSAPhone.focus();
		 return false;
	}  
	
	if (document.myform.SSAPhone.value.length>0){ 
	if (IsPhone(document.myform.SSAPhone.value)==false) {
			document.myform.SSAPhone.focus();
			return false;
	}
	}	
	
	/*if (isWhitespace(document.myform.SSAFax.value)) 
	{
		 alert("Please enter Fax! ");
		 document.myform.SSAFax.focus();
		 return false;
	} 
	*/ 	
	if (document.myform.SSAFax.value.length>0){ 
	if (IsFax(document.myform.SSAFax.value)==false) {
			document.myform.SSAFax.focus();
			return false;
	}
	}
	
	
	
if (isWhitespace(document.myform.SSAEmail.value)) 
	{
		 alert("Please enter Email! ");
		 document.myform.SSAEmail.focus();
		 return false;
	}  
	if (document.myform.SSAEmail.value.length>0){ 
	document.myform.SSAEmail.value = NonSpace(document.myform.SSAEmail.value);

	if (isEmail(document.myform.SSAEmail.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.SSAEmail.focus();
			return false;
	}  
	}	
		
return true; 

}

//____________________________________________________________________________________
//________      ValidPay                  __________________________________________


function ValidPay() {
if (isWhitespace(document.myform.bname.value)) 
	{
		 alert("Please enter Name !  ");
		 document.myform.bname.focus();
		 return false;
	}  
	 
if (isWhitespace(document.myform.baddr1.value)) 
	{
		 alert("Please enter your Address !  ");
		 document.myform.baddr1.focus();
		 return false;
	}  

if (isWhitespace(document.myform.bcity.value)) 
	{
		 alert("Please enter City !  ");
		 document.myform.bcity.focus();
		 return false;
	} 
		
if (isWhitespace(document.myform.bzip.value)) 
	{
		 alert("Please enter Zip !  ");
		 document.myform.bzip.focus();
		 return false;
	}  
	
if (document.myform.bzip.value.length>0){ 
	 if (validateZIP(document.myform.bzip)==false) {
				document.myform.bzip.focus();
				return false;
	} 
	}
		
/*if (isWhitespace(document.myform.email.value)) 
	{
		 alert("Please enter Email! ");
		 document.myform.email.focus();
		 return false;
	}
*/	
	
	if (document.myform.email.value.length>0){ 
	document.myform.email.value = NonSpace(document.myform.email.value);

	if (isEmail(document.myform.email.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.email.focus();
			return false;
	}  
	}	
return true; 
}


//____________________________________________________________________________________
//________      ValidStep2                  __________________________________________


function ValidStep2() {
if (isWhitespace(document.myform.PIN.value)) 
	{
		 alert("Please enter PIN!  ");
		 document.myform.PIN.focus();
		 return false;
	}  
	if (document.myform.PIN.value.length!=9) {  
		 alert("Please enter 9 digits for PIN!  ");
		 document.myform.PIN.focus();
		 return false;
	}  
	if (isWhitespace(document.myform.TDL.value)) 
	{
		 alert("Please enter your Texas Driver Licence !  ");
		 document.myform.TDL.focus();
		 return false;
	}  
	if (document.myform.DOB.value =="MM/DD/YYYY"){
		alert("Please enter Date of Birth !  ");
		return false;
	}
	if (document.myform.DOB.value ==""){
		alert("Please enter Date of Birth !  ");
		return false;
	}
	if (document.myform.DOB.value !="MM/DD/YYYY"){
		if (document.myform.DOB.value !=""){
			return Valid_Date(document.myform.DOB.value)
			 
			//alert("Please type a Valid date");
			document.myform.DOB.focus();
		}
		return false;
	}
	
return true; 
}

//____________________________________________________________________________________
//________      ValidSSAadmin                  __________________________________________


function ValidSSAadmin() {

if (isWhitespace(document.myform.SSACompany.value)) 
	{
		 alert("Please enter Company Name!  ");
		 document.myform.SSACompany.focus();
		 return false;
	}  
if (isWhitespace(document.myform.SSAContact.value)) 
	{
		 alert("Please enter Contact Name!  ");
		 document.myform.SSAContact.focus();
		 return false;
	}
	
if (isWhitespace(document.myform.SSAEmail.value)) 
	{
		 alert("Please enter Email! ");
		 document.myform.SSAEmail.focus();
		 return false;
	}  
	if (document.myform.SSAEmail.value.length>0){ 
	document.myform.SSAEmail.value = NonSpace(document.myform.SSAEmail.value);

	if (isEmail(document.myform.SSAEmail.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.SSAEmail.focus();
			return false;
	}  
	}	
	 
		
if (isWhitespace(document.myform.SSAGroupCode.value)) 
	{
		 alert("Please enter Group Code !  ");
		 document.myform.SSAGroupCode.focus();
		 return false;
	}

		
return true; 

}

//____________________________________________________________________________________


function SSNValidation(ssn) {
var matchArr = ssn.match(/^(\d{3})-?\d{2}-?\d{4}$/);
var numDashes = ssn.split('-').length - 1;

if (matchArr == null || numDashes == 1) {
	alert('Invalid SSN. Must be 9 digits or in the form NNN-NN-NNNN.');
	msg = "does not appear to be valid";
	return false;
}
else 
	if (parseInt(matchArr[1],10)==0) {
		alert("Invalid SSN: SSN's can't start with 000.");
		msg = "does not appear to be valid";
		return false;
	}
	else {
		return true;
   }
}





//____________________________________________________________________________________
//________      ValidLogin                  __________________________________________

function ValidLogin() {
	if (isWhitespace(document.myform.UserLogon.value)) 
	{
		 alert("Please enter Account Name!  ");
		 document.myform.UserLogon.focus();
		 return false;
	}  
	if (document.myform.UserLogon.value.length < 4) 
	{
		 alert("The Minimum length for Account Name should be 4!");
		 document.myform.UserLogon.focus();
		 return false;
	 }

	if (isWhitespace(document.myform.UserPassword.value)) 
	{
		 alert("Please enter  User Password! ");
		 document.myform.UserPassword.focus();
		 return false;
	}  
	 if (document.myform.UserPassword.value.length < 4) 
	 {
		 alert("The Minimum length for User Password should be 4!");
		 document.myform.UserPassword.focus();
		 return false;
	 }
	 return true;
}



//____________________________________________________________________________________
//_____________     ValidSearch     __________________________________________________

function ValidSearch() {

	var theForm = document.forms[0];
	var nr = theForm.length;
	var cod = 0;
	
	for (i=0; i<nr; i++){
		if (theForm.elements[i].type != "hidden" && theForm.elements[i].type != "submit" && theForm.elements[i].type != "radio"){
			if (theForm.elements[i].value != "" && theForm.elements[i].value != "0"){cod = 1;}
		}
	}
		if (cod == 0) {
			alert("Please, fill at least one field to Search!");
			theForm.PIN.focus();
			return false;
		}			
	
	if (theForm.PIN.value.length > 0) {
	   if (theForm.PIN.value.length != 9){
		  alert ("PIN numbers should have 9 digits!")
		  theForm.PIN.focus();
		return false;
		}
	}
	if (theForm.SSN.value.length > 0) {
	  if (SSNValidation(theForm.SSN.value)==false) {
		  theForm.SSN.focus();
		return false;
		}
	}
	if (theForm.DOB.value !="MM/DD/YYYY"){
		if (theForm.DOB.value !=""){
			return Valid_Date(theForm.DOB.value)
			 
			//alert("Please type a Valid date");
			theForm.DOB.focus();
		}
		return false;
	}
	if (theForm.ExpDate.value !="MM/DD/YYYY"){
		if (theForm.ExpDate.value !=""){
			return Valid_Date(theForm.ExpDate.value)
			 
			//alert("Please type a Valid date");
			theForm.ExpDate.focus();
		}
		return false;
	}
	return true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      ValidUser     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ValidUser() {

	if (isWhitespace(document.myform.UserName.value)) 
	{
		 alert("Please enter User Name!  ");
		 document.myform.UserName.focus();
		 return false;
	}  

	if (document.myform.UserName.value.length < 4) 
	{
		 alert("The Minimum length for User Name should be 4!");
		 document.myform.UserName.focus();
		 return false;
	 }

	if (isWhitespace(document.myform.UserPassword.value)) 
	{
		 alert("Please enter  User Password! ");
		 document.myform.UserPassword.focus();
		 return false;
	}  
	 if (document.myform.UserPassword.value.length < 4) 
	 {
		 alert("The Minimum length for Password should be 4!");
		 document.myform.UserPassword.focus();
		 return false;
	 }
	if (isWhitespace(document.myform.UserEmail.value)) 
	{
		 alert("Please enter User Email! ");
		 document.myform.UserEmail.focus();
		 return false;
	}  
	if (document.myform.UserEmail.value.length>0){ 
	document.myform.UserEmail.value = NonSpace(document.myform.UserEmail.value);

	if (isEmail(document.myform.UserEmail.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.UserEmail.focus();
			return false;
	}  
	}
	 return true;
}





//____________________________________________________________________________________
//_____________     ValidSend      ________________________________________________

function ValidSend() {
	if (isWhitespace(document.myform.Email.value)) 
	{
			alert("Please enter Your Email Address");
			document.myform.Email.focus();
			return false;
	}	
	document.myform.Email.value = NonSpace(document.myform.Email.value);

	if (isEmail(document.myform.Email.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.Email.focus();
			return false;
	}
	if (isWhitespace(document.myform.REmail.value)) 
	{
			alert("Please enter Recipient's Email Address");
			document.myform.REmail.focus();
			return false;
	}	
	document.myform.REmail.value = NonSpace(document.myform.REmail.value);

	if (isEmail(document.myform.REmail.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.REmail.focus();
			return false;
	}
	
	 return true;
}




//____________________________________________________________________________________
//_____________      ValidModPIN     ____________________________________________________

function ValidModPIN() {
	if (isWhitespace(document.myform.PIN.value)) 
	{
		 alert("Please enter PIN!  ");
		 document.myform.PIN.focus();
		 return false;
	}  
	if (document.myform.PIN.value.length!=9) {  
		 alert("Please enter 9 digits for PIN!  ");
		 document.myform.PIN.focus();
		 return false;
	}  
	if (isWhitespace(document.myform.DLN.value)) 
	{
		 alert("Please enter DLN!  ");
		 document.myform.DLN.focus();
		 return false;
	}  
	if (document.myform.ExpDate.value ==""){
		alert("Please, set the Expire Date!")
		document.myform.ExpDate.focus();
		return false;
	}
	if (document.myform.ExpDate.value =="MM/DD/YYYY"){
		alert("Please, set the Expire Date!")
		document.myform.ExpDate.focus();
		return false;
	}
	
	return true;
}



//____________________________________________________________________________________
//_____________      ValidAddPIN     ____________________________________________________

function ValidAddPIN() {
	if (isWhitespace(document.myform.SSN.value)) 
	{
		 alert("Please enter SSN!  ");
		 document.myform.SSN.focus();
		 return false;
	}  
	if (SSNValidation(document.myform.SSN.value)==false) {
		  document.myform.SSN.focus();
		return false;
		}
	/*if (document.myform.DOB.value ==""){
		alert("Please, set the Birth Date!")
		document.myform.DOB.focus();
		return false;
	}
	if (document.myform.DOB.value =="MM/DD/YYYY"){
		alert("Please, set the Birth Date!")
		document.myform.DOB.focus();
		return false;
	}
	*/
	if (isWhitespace(document.myform.TDL.value)) 
	{
		 alert("Please enter Driver Licence Number!  ");
		 document.myform.TDL.focus();
		 return false;
	}  
	
	return true;
}	
	




//____________________________________________________________________________________
//_____________      ValidContact     ____________________________________________________

function ValidContact() {
	if (isWhitespace(document.myform.MFullName.value)) 
	{
		 alert("Please enter Your Name  ");
		 document.myform.MFullName.focus();
		 return false;
	}  
//	if ( (document.myform.MState.options[document.myform.MState.options.selectedIndex].value)>54)	{
//			document.myform.MCountry.options[document.myform.MCountry.options.selectedIndex].value="36";
//			document.myform.MCountry.value="36";
//			return true;
//	}
	if ( (document.myform.MState.options[document.myform.MState.options.selectedIndex].value)<53)	{
	if ( (document.myform.MCountry.options[document.myform.MCountry.options.selectedIndex].value)=="0")
	{
			alert("Please enter Country! ");
			document.myform.MCountry.focus();
			return false;
	}
	}
	if (isWhitespace(document.myform.MEmail.value)) 
	{
		 alert("Please enter email ");
		 document.myform.MEmail.focus();
		 return false;
	} 
	document.myform.MEmail.value = NonSpace(document.myform.MEmail.value);
	if (isEmail(document.myform.MEmail.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.myform.MEmail.focus();
			return false;
	} 

/*	if (isWhitespace(document.myform.comments.value)) 
	{
		 alert("Please enter your comments! ");
		 document.myform.comments.focus();
		 return false;
	} */
	return true;
}



//____________________________________________________________________________________
//_____________      ValidRD     ____________________________________________________

function ValidRD() {
	if (isWhitespace(document.myform.RDLinkName.value)) 
	{
		 alert("Please enter Link Name!");
		 document.myform.RDLinkName.focus();
		 return false;
	}  
	if (isWhitespace(document.myform.RDLink.value)) 
	{
		 alert("Please enter Link URL!");
		 document.myform.RDLink.focus();
		 return false;
	}  
	return true;
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      ValidEmail     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ValidEmail() {
	if (isWhitespace(document.frmEmail.email.value)) 
	{
		 alert("Please enter Email Address! ");
		 document.frmEmail.email.focus();
		 return false;
	}  
	if (document.frmEmail.email.value.length>0){ 
	document.frmEmail.email.value = NonSpace(document.frmEmail.email.value);

	if (isEmail(document.frmEmail.email.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmEmail.email.focus();
			return false;
	}  
	}
	 return true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      ValidEmail1     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ValidEmail1() {
	if (isWhitespace(document.frmEmail1.email.value)) 
	{
		 alert("Please enter Email Address! ");
		 document.frmEmail1.email.focus();
		 return false;
	}  
	if (document.frmEmail1.email.value.length>0){ 
	document.frmEmail1.email.value = NonSpace(document.frmEmail1.email.value);

	if (isEmail(document.frmEmail1.email.value)==false) {
			alert("Please enter a valid E-Mail address, like: name@companyname.com ");
			document.frmEmail1.email.focus();
			return false;
	}  
	}
	 return true;
}

//____________________________________________________________________________________
//_____________      NonSpace     ____________________________________________________

function NonSpace(field) {

	var xpos =0;
	var xlen =field.length;
	var xpos1 =0;
	var xpos2 =xlen;

	for (var i=0; i < xlen; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp == " ") {xpos++;}
		else {var xpos1=xpos;break;  }
	}
	field = field.substring(xpos1, xlen)
	var xlen1 = field.length;

	for (var i=0; i < xlen1; i++) {
		temp = "" + field.substring(i, i+1);
		if (temp != " ") {xpos1++;}
		else {xpos2=i;break;  }
	}
	field = field.substring(0, xpos2)
	return field;
}



//____________________________________________________________________________________
//_____________     IsChar      ______________________________________________________


var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|]/;

function IsChar(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
if(lchar.search(mikExp) != -1) {
var tst = val.value.substring(0, (strLength) - 1);
val.value = tst;
   }
}


//____________________________________________________________________________________
//____________  IsChara   ____________________________________________________________

function IsChara(form) {
if(form.value.length < 1) {
alert("Please fill this field; cannot be empty.");
return false;
}
if(form.value.search(mikExp) == -1) {
return true;
}
else {
alert("Sorry, but the following characters\n\r\n\r@ $ % ^ & * # ( ) [ ] \\ { + } ` ~ =  | \n\r\n\rare not allowed!\n");
form.select();
form.focus();
return false;
}
return true;
}


//____________________________________________________________________________________
//______________   Valid_Date  _______________________________________________________

function Valid_Date(datein){
		
		var indate=datein;
		if (indate.indexOf("-")!=-1){
				var sdate = indate.split("-")
		}
		else {
				var sdate = indate.split("/")
		}
		var chkDate=new Date(Date.parse(indate))
		var cmpDate=(chkDate.getMonth()+1)+"/"+(chkDate.getDate())+"/"+(chkDate.getFullYear())
		var indate2=(Math.abs(sdate[0]))+"/"+(Math.abs(sdate[1]))+"/"+(Math.abs(sdate[2]))

		if ((chkDate.getFullYear() > 2003)||(chkDate.getFullYear() < 1900)) {
				alert("You've entered an invalid year");
				return false;
		}				
		if ((Math.abs(sdate[2]) > 2003)||(Math.abs(sdate[2])< 1900)) {
				alert("You've entered an invalid year");
				return false;
		}				


   if (indate2=="0/NaN/NaN"){
				return true;
   }        
	else {
		
		if (indate2!=cmpDate){
				alert("You've entered an invalid date or date format.  Please use the MM/DD/YYYY format.");
				return false;
		}
		else {
				if (cmpDate=="NaN/NaN/NaN"){
						alert("You've entered an invalid date or date format. Please use the MM/DD/YYYY format.");
						return false;
				}
				else {
						return true;
				}       
		}
}        
}



//____________________________________________________________________________________
//__________    isEmail     __________________________________________________________

function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		return true;
	else
		return false;
}



//____________________________________________________________________________________
//______________    IsPhone     ______________________________________________________

function IsPhone(str)          // is phone str valid
	{
	if (str.length != 12) 
			  // nope - wrong str length
		{
		alert('Invalid PhoneNo. Must be in the form NNN-NNN-NNNN.');
		return false;
	}		
  for (i=0; i<12; i++)
	{
	if (i == 3 || i == 7)
	{
	  if (str.charAt(i) != "-")     // nope - "-" missing
			{
			alert(' Missing - . PhoneNo  must be in the form NNN-NNN-NNNN.');
			return false;
			}
	}		
	else
	{
	  if (!isNum(str.charAt(i)))
		{
		alert('Non-numeric characters. PhoneNo must be in the form NNN-NNN-NNNN.');
		return false;
		}
	}		
  }
  return true;                     

}


//____________________________________________________________________________________
//_______________    IsFax     _______________________________________________________

function IsFax(str)          // is Fax str valid
	{
	if (str.length != 12) 
			  // nope - wrong str length
		{
		alert('Invalid FaxNo. Must be in the form NNN-NNN-NNNN.');
		return false;
	}		
  for (i=0; i<12; i++)
	{
	if (i == 3 || i == 7)
	{
	  if (str.charAt(i) != "-")     // nope - "-" missing
			{
			alert(' Missing - . FaxNo  must be in the form NNN-NNN-NNNN.');
			return false;
			}
	}		
	else
	{
	  if (!isNum(str.charAt(i)))
		{
		alert('Non-numeric characters. FaxNo must be in the form NNN-NNN-NNNN.');
		return false;
		}
	}		
  }
  return true;                     

}


//____________________________________________________________________________________
//_____________     validateZIP   ____________________________________________________


function validateZIP(field) {
var valid = "0123456789-";
var hyphencount = 0;

if (field.value.length!=5 && field.value.length!=10) {
alert("Please enter your 5 digit or ( 5 + 4 ) digit  ZIP  code.");
return false;
}
for (var i=0; i < field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Invalid characters in your ZIP code.  Please try again.");
return false;
}
if ((hyphencount > 1) || ((field.value.length==10) && ""+field.value.charAt(5)!="-")) {
alert("The hyphen character should be used with a properly formatted 5 digit+four  ZIP  code, like '12345-6789'.   Please try again.");
return false;
   }
}
return true;
}



function isNum(chr)            // is character a number?
  {
  if (chr < "0" || chr > "9")  // nope
	return false;
  else                         // yep
	return true;
  }



function isNumber(InString)  {
		RefString="123456789";

		for (Count=0; Count < InString.length; Count++)  {
			TempChar= InString.substring (Count, Count+1);
			if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter numbers only: 1 - 9 ");
				return false;
			}
		}
		return true;
}

function isNumber1(InString)  {
		RefString="0123456789";

		for (Count=0; Count < InString.length; Count++)  {
			TempChar= InString.substring (Count, Count+1);
			if (RefString.indexOf (TempChar, 0)==-1) { 
				alert("Please enter numbers only: 0 - 9 ");
				return false;
			}
		}
		return true;
}




//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     validateW      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


function validateW(field) {
var valid = "0123456789.";
var hyphencount = 0;


for (var i=0; i < field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);

if (temp == ".") hyphencount++;
	if (valid.indexOf(temp) == "-1") {
	alert("Invalid characters.\n You must type only decimal numbers less than 1.");
	return false;
	}
}
if (field.value >= 1) {
	alert("You must type only decimal numbers less than 1.");
	return false;
}


return true;
}



var reWhitespace = /^\s+$/
// warnEmpty (theField, s)             Notify user that required field theField is empty.


// Notify user that required field theField is empty.
// String s describes expected contents of theField.value.
// Put focus in theField and return false.

function warnEmpty (theField, s)
{   theField.focus()
	alert(mPrefix + s + mSuffix)
	return false
}



// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}



// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   // Is s empty?
//    return (isEmpty(s));
	return (isEmpty(s) || reWhitespace.test(s));
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     goSort      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function goSort(url,sSortBy,sSortOrd)
{
		document.myform.action = url;
		document.myform.SortBy.value  = sSortBy;
		document.myform.SortOrd.value = sSortOrd;
		document.myform.submit( );
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~   DelConf   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function DelConf(url)   {
	if (confirm("This Record will be deleted! Are you sure !?"))
		{
		document.forms[0].sCMD.value = "del";
		document.forms[0].action = url;
		document.forms[0].submit();
		}
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     goDel      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function goDel(url,ID)   
{
	if (confirm("This Record will be deleted! Are you sure !?"))
		{
		document.forms[0].sCMD.value = "del";
		document.forms[0].ID.value = ID;
		document.forms[0].action = url;
		document.forms[0].submit();
		}
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     goRefresh      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function goRefresh(url)   
{
		document.forms[0].sCMD.value = "";
		document.forms[0].action = url;
		document.forms[0].submit();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     goAdd      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function goAdd(url)   
{

		document.forms[0].sCMD.value = "add";
		document.forms[0].ID.value = "";
		document.forms[0].action = url;
		document.forms[0].submit();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~     goMod      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function goMod(url,ID)   
{
		document.forms[0].sCMD.value = "edit";
		document.forms[0].action = url;
		document.forms[0].ID.value = ID;
		document.forms[0].submit();
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      getExtension      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function getExtension(field) {
	var xpos =0;
	var xlen =field.length;
	for (var i=xlen; i > 0 ; i--) {
		temp = "" + field.substring(i, i-1);
		if (temp != ".") {xpos--;}
			else {break;
		}
	}
	return (field.substring(xlen+xpos, xlen));
}



function ovrRow(eItem)
{
	eItem.DefaultBgColor=eItem.style.backgroundColor;
	eItem.style.backgroundColor="#CCCC99";		green
	
	eItem.style.cursor="hand"
}

function outRow(eItem)
{
	eItem.style.backgroundColor=eItem.DefaultBgColor;
	eItem.style.cursor="hand"
}

function ovrTD(Item,col_mover)
{
	Item.style.backgroundColor=col_mover;	

	Item.style.cursor="hand"
}

function outTD(Item,col_mout)
{
	Item.style.backgroundColor=col_mout; 
	Item.style.cursor="hand"
}

function go(eItem){top.location.href= findTag(eItem).getAttribute("HREF")}



function xCheck(x,col_check)
	{
	xItem = x.parentElement.parentElement.parentElement
	if (x.checked) {
		xItem.DefaultBgColor=xItem.style.backgroundColor;
		xItem.style.backgroundColor=col_check;
		xItem.style.cursor="hand";
	}
	else {
		xItem.style.backgroundColor=xItem.DefaultBgColor;
		xItem.style.cursor="hand";
	}
}

function AddFavorite()
{
	if ((navigator.platform!="MacPPC") &&	(navigator.appName=="Microsoft Internet Explorer") &&	(navigator.appVersion>="4")) {
	document.write("<A HREF='Javascript:window.external.")
	document.write("AddFavorite(location.href,document.title)'>")
	document.write("Add my site to your Favorites</A>")
	}
}


function PrintThis(text){
	text=document
	print(text)
}

function initMail(form) {
	text = "Check out this page:  " + window.location;
	form.message.value = "Hi " + form.sendto.value + " (" + form.to.value + "):\n\n"
	 + text + "\n\nYour Friend,\n" + form.sendername.value + "(" + form.senderemail.value + ")";
	return (form.to.value != "");
}

function Start(page) {
	OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=550,height=250,top=50,left=50");
}

