
<!--
var digits = new String("0123456789");
var reg = /\w/;
var regDig = /\D/;

/*****************************************************************
FUNCTION:		stripPhoneNumber()
PARAMS:			sPhoneNumber
DESCRIPTION:
This function will strip out any characters that are not numeric
digits out of the phone number passed.  It will return any numbers
that were found.
*****************************************************************/
function stripPhoneNumber(sPhoneNumber) {
	var sNewVal = "";
	var indx;
	var c;

	for (indx = 0; indx < sPhoneNumber.length; indx++) {
        // Check that current character isn't whitespace.
        var c = sPhoneNumber.charAt(indx);
        if (digits.indexOf(c) != -1) sNewVal += c;
	} // for

	return (sNewVal);
} // stripPhoneNumber();

/*****************************************************************
FUNCTION:		checkEmail()
PARAMS:			sEmail
DESCRIPTION:
This function will check to make sure that the email address
is in the proper format: x@xx, with all of the proper characters
*****************************************************************/
function checkEmail(Email){
	
	var regEmail=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (!regEmail.test(Email.value)) {
		alert("Email address seems incorrect. Please try again.");
		Email.select();
		return false;
	}


} // checkEmail()

/*****************************************************************
FUNCTION:		checkPhoneNumbers()
*****************************************************************/
function checkPhoneNumbers(objForm) {
	var bisOk = true;
	var sNumber = new String();
   if (	objForm.value != "" ) {//only check it value is not null
	if (reg.test(objForm.value)) {
		// Fax Number is entered...Validate the format
		sNumber = stripPhoneNumber(objForm.value);
		// Must have at least 10 digits entered.
		if (sNumber.length < 10) {
			alert(objForm.name + " seems incorrect. Please enter a 10 digit number now (555.555.5555)");
			bisOk = false;
			objForm.select();
			
		}

		// Check to make sure all of the stripped values are numeric
		if (regDig.test(sNumber)) {
			// Non-numeric value found
			alert(objForm.name + " seems incorrect. Please enter a 10 digit number now (555.555.5555)");
			bisOk = false;
			objForm.select();
			
		}
		
	}
   
	return (bisOk);
    }//end check if null
} // checkPhoneNumbers()

//Validate Email============================================================
function emailCheck () {


		var emailStr = document.frm.Email.value;
		/* The following pattern is used to check if the entered e-mail address
		   fits the user@domain format.  It also is used to separate the username
		   from the domain. */
		var emailPat=/^(.+)@(.+)$/
		/* The following string represents the pattern for matching all special
		   characters.  We don't want to allow special characters in the address.
		   These characters include ( ) < > @ , ; : \ " . [ ]    */
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		/* The following string represents the range of characters allowed in a
		   username or domainname.  It really states which chars aren't allowed. */
		var validChars="\[^\\s" + specialChars + "\]"
		/* The following pattern applies if the "user" is a quoted string (in
		   which case, there are no rules about which characters are allowed
		   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		   is a legal e-mail address. */
		var quotedUser="(\"[^\"]*\")"
		/* The following pattern applies for domains that are IP addresses,
		   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		   e-mail address. NOTE: The square brackets are required. */
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		/* The following string represents an atom (basically a series of
		   non-special characters.) */
		var atom=validChars + '+'
		/* The following string represents one word in the typical username.
		   For example, in john.doe@somewhere.com, john and doe are words.
		   Basically, a word is either an atom or quoted string. */
		var word="(" + atom + "|" + quotedUser + ")"
		// The following pattern describes the structure of the user
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		/* The following pattern describes the structure of a normal symbolic
		   domain, as opposed to ipDomainPat, shown above. */
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		
		
		/* Finally, let's start trying to figure out if the supplied address is
		   valid. */
		
		/* Begin with the coarse pattern to simply break up user@domain into
		   different pieces that are easy to analyze. */
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
		  /* Too many/few @'s or something; basically, this address doesn't
			 even fit the general mould of a valid e-mail address. */
			alert("Email address seems incorrect (check @ and .'s)")
			
			document.frm.Email.select();
			return false;
		}
		var user=matchArray[1]
		var domain=matchArray[2]
		
		// See if "user" is valid
		if (user.match(userPat)==null) {
			// user is not valid
			alert("The username doesn't seem to be valid.")
			document.frm.Email.select();
			return false;
		}
		
		/* if the e-mail address is at an IP address (as opposed to a symbolic
		   host name) make sure the IP address is valid. */
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			// this is an IP address
			  for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					alert("Destination IP address is invalid!")
				document.frm.Email.select();
				return false;
				}
			}
			return true
		}
		
		// Domain is symbolic name
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			alert("The domain name doesn't seem to be valid.")
			document.frm.Email.select();
			return false;
		}
		
		/* domain name seems valid, but now make sure that it ends in a
		   three-letter word (like com, edu, gov) or a two-letter word,
		   representing country (uk, nl), and that there's a hostname preceding
		   the domain or country. */
		
		/* Now we need to break up the domain to get a count of how many atoms
		   it consists of. */
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 ||
			domArr[domArr.length-1].length>3) {
		   // the address must end in a two letter or three letter word.
		   alert("The address must end in a three-letter domain, or two letter country.")
		   document.frm.Email.select();
			return false;
		}
		
		// Make sure there's a host name preceding the domain.
		if (len<2) {
		   var errStr="This address is missing a hostname!"
		   alert(errStr)
			document.frm.Email.select();
			return false;
		}
		
		// If we've gotten this far, everything's valid!
		return true;

}

//End Validate Email========================================================

//This Function is called on the "onKeyUP" event for input fields that 
//can only have numeric values.
function CkNumEvent(txtField)
{	
	
	var val1 = txtField.value

	if (isNaN(val1))
	{	
		alert("Numeric value required.");
		txtField.value = 0;
		txtField.select();
			
	}
}	 

/*****************************************************************
FUNCTION:		stripChars()
PARAMS:			sBagofChars, sWord
DESCRIPTION:
This function will strip out any characters not in the bag of
characters passed to the function.
*****************************************************************/
function stripChars(sBagofChars, sWord) {
	var sNewVal = "";
	var indx;
	var c;

	for (indx = 0; indx < sWord.length; indx++) {
        // Check that current character isn't whitespace.
        var c = sWord.charAt(indx);
        if (sBagofChars.indexOf(c) != -1) sNewVal += c;
	} // for

	return (sNewVal);
} // stripPhoneNumber();


/*****************************************************************
FUNCTION:		formatValue()
PARAMS:			lValue
DESCRIPTION:
This function will format the text box value in proper Dollar
format.
*****************************************************************/
function formatValue(lAmount) {
	lAmount = Math.floor((lAmount * 100) + .5) / 100;
	var amount = new String(lAmount);
	var num = new String();

	if (amount.indexOf('.') < 0) {
		amount = amount + ".00"
	}
	num = CommaFormatted(amount);

	return ('$' + num);
} // formatValue()

/*****************************************************************
FUNCTION:		CommaFormated()
PARAMS:			amount
DESCRIPTION:
This function will format the value passed in proper comma format.
*****************************************************************/
function CommaFormatted(amount)
{
	var delimiter = ",";
	var a = amount.split('.')
	var d = a[1];
	var i = parseInt(a[0]);
	var bNeg = false;

	if(isNaN(i)) { return ''; }
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }

	if (d.length == 1) {amount += "0";}

	if (bNeg) { amount = '(' + amount + ')'; }

	return amount;
} // CommaFormatted()

/*****************************************************************
FUNCTION:		MM_validateForm()
PARAMS:			x number of forms passed in call MM_validateForm.arguments
DESCRIPTION:
This function will alert user if form objects have not been completed.
*****************************************************************/

function MM_validateForm() { //v4.0
	
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=args[i+1]; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } 
  if (errors) { alert('The following error(s) occurred:\n'+errors);
 		document.MM_returnValue = (errors == '');
  } else {
			if (!confirm("Is the following information on this page correct? Press 'OK' to submit. 'Cancel' to change.") ){
				document.MM_returnValue = false;
			} else {
			document.MM_returnValue = true;
			}
		
  }
   
 }
 
 //open pop-up browser
 var IntsWindow = null;
 function MM_openBrWindow(theURL,winName,features) { //v2.0
   
   if(IntsWindow && !IntsWindow.closed)
   	{
             IntsWindow.focus();
   	}
   	else {
             IntsWindow = window.open(theURL, winName,features);
   	     IntsWindow.focus();
	}

}

function popUp(element,iColor) {
		    while (element.tagName.toUpperCase() != 'TR' && element != null)
				    element = document.all ? element.parentElement : element.parentNode;
			if (iColor == 1 ){
	   		 element.bgColor = '#0066cc"';
	   		 element.foreColor = '#ffffff';
			 }
			if (iColor == 2 ){
			element.bgColor = '#26243a';
	   		 element.foreColor = '#817f92';
			}
}

function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = ".";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = day + seperator + month + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Date is incorrect!");
      DateField.select();
	  DateField.focus();
	  return false;
   }
}


//-->


