function _aPassword(){
	var re = /^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$/
	if (!re.test(this.value)) { 
		this.error = "The " + this.description + " field must start with a letter and contain at least one number [1-0], one uppercase Letter[A-Z] and one lowercase letter[a-z]"; 
	}
}
function _AnAlphaNumeric(){
	// Set the parsed variable to equal true
	var parsed = true;
	// Set the valid characters
  	var validchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ ";
	// Set the form field in a variable for easier access
	var the_value = this.value;
	// Loop over the form field and compare the value of each character with the allowed list
  	for (var i=0; i < the_value.length; i++) {
    		var letter = the_value.charAt(i).toLowerCase();
		// If an illegal character is found, set the parsed variable to false and then break the loop
    		if (validchars.indexOf(letter) != -1)
      			continue;
		parsed = false;
  		// Set an error message to ensure that Q-Forms displays appropriately
    		this.error = "The " + this.description + " field can only contain Alphanumeric Characters (a-z,A-Z,1-0)";
    	break;
  	}
}

function _AnAlpha(){
	// Set the parsed variable to equal true
	var parsed = true;
	// Set the valid characters
 	 var validchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_ ";
	// Set the form field in a variable for easier access
	var the_value = this.value;
	// Loop over the form field and compare the value of each character with the allowed list
  	for (var i=0; i < the_value.length; i++) {
    		var letter = the_value.charAt(i).toLowerCase();
		// If an illegal character is found, set the parsed variable to false and then break the loop
    		if (validchars.indexOf(letter) != -1)
      			continue;
		parsed = false;
 		// Set an error message to ensure that Q-Forms displays appropriately
    		this.error = "The " + this.description + " field can only contain Alphabetic Characters (a-z,A-Z)";
    	break;
  	}
}

//This JavaScript uses the Date function to dynamically generate accurate dates for the pull-down menus.
//Each time the user selects a year or month, JavaScript gets the correct number of days in that month and updates
//the pull down menu. The script is Y2K compliant and also works for leap years. Cool!
//you might need to change the field name(day, month,year) as well as form name (f1) here we use "frmCustomerDetails"
//
//Modify by William Liu on 09-04-04 add fieldtype foe dynamic date drop down box for DOB, item service date start & until
//The following function is not using anymore, keep for one month, if nothing wrong just del it
//function populate(objForm,selectIndex,FieldType) {
//	//alert ("ok");
//	//alert (eval("objForm.month" + FieldType + ".options[objForm.month" + FieldType + ".selectedIndex].value"));
//	timeA = new Date(eval("objForm.year" + FieldType + ".options[objForm.year" + FieldType + ".selectedIndex].text"), eval("objForm.month" + FieldType + ".options[objForm.month" + FieldType + ".selectedIndex].value"),1);
//	timeDifference = timeA - 86400000;
//	timeB = new Date(timeDifference);
//	var daysInMonth = timeB.getDate();
//	for (var i = 0; i < eval("objForm.day" + FieldType + ".length"); i++) {
//		eval("objForm.day" + FieldType + ".options[0] = null");
//	}
//	for (var i = 0; i < daysInMonth; i++) {
//		eval("objForm.day" + FieldType + ".options[i] = new Option(i+1)");
//	}
//	eval("objForm.day" + FieldType + ".options[0].selected = true");
//}

//function getYears() {
	// You can easily customize what years can be used
//	var years = new Array(1997,1998,1999,2000,2001,2005)
//
//	for (var i = 0; i < document.f1.year.length; i++) {
//		document.f1.year.options[0] = null;
//	}
//	timeC = new Date();
//	currYear = timeC.getFullYear();
//	for (var i = 0; i < years.length; i++) {
//		document.f1.year.options[i] = new Option(years[i]);
//	}
//	document.f1.year.options[2].selected=true;
//}
//window.onLoad = getYears;

function getListValue(list)
{
	var listValue = "";
	
	if (list.selectedIndex != -1) {
		listValue = list.options[list.selectedIndex].value;
	}
	location.href=listValue
	return (listValue);
}

// Auto-tab code Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autotab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode;
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	
	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length)
		if(arr[index] == ele)
			found = true;
		else
			index++;
		return found;
	}
	
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
		if (input.form[i] == input)index = i;
		else i++;
		return index;
	}
	
	return true;
}
// Auto-tab code End