<!--
function toggle(theDiv) {
    var elem = document.getElementById(theDiv);
    elem.style.display = (elem.style.display == "none")?"":"none";
}


<!--

/*
		function radioCheck(isChecked) {
			if (isChecked == 1) {
				//alert("checked");
				document.theForm.mailListContact.disabled = false;
			}
			else {
				//alert("notChecked")
				document.theForm.mailListContact.disabled = true;
				document.theForm.mailListContact.value = "";
			}
		
		}	

function popup(w,h)
{
	var winl = (screen.width - w) / 2;
	var wint = ((screen.height - h) / 2)-20;
	var pop = window.open('progressBar.htm', 'fileUpload', 'height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}
*/
	
		
  function validateFormOnSubmit(theForm) {
var reason = "";
var cnt = -1;
iErrorCount =0;
errorColor = '#f0e6e6'

	reason += validateButtons(theForm.contactSelect,"You must choose an area to send your comments to.\n");
  reason += validateEmpty(theForm.contactComments,"Please enter your comments.\n");
	if ((theForm.contactName.value.length != 0) || (theForm.contactEmail.value.length != 0 )) {
	  reason += validateEmpty(theForm.contactName,"Please enter your name.\n");
	  reason += validateEmail(theForm.contactEmail);
	}

//  reason += validatePassword(theForm.pwd);
//  reason += validatePhone(theForm.phone);
//  reason += validateEmpty(theForm.manager,"Please enter the Unit Managers' name.\n");
//	reason += validateEmpty(theForm.office,"Please enter your office name.");
//	reason += validateDivision(theForm.division);
//	reason += validateEmpty(theForm.projectTitle,"Please enter the project title.\n");
//	reason += validateProjectType(theForm.projectType);
//	reason += validateEmpty(theForm.projectDesc,"Please provide a project description.\n");
//	reason += validateEmpty(theForm.firstProof,"Please provide the first proof date.\n");
//	reason += validateEmpty(theForm.deliverDate,"Please provide the delivery date for this request.\n");
//	reason += validateEmpty(theForm.endDate,"Please provide the project end date.\n");
//	reason += validateEmpty(theForm.chargeNum,"Please provide a charge number for this request.\n");
//  reason += validateEmpty(theForm.from);
      
  if (reason != "") {
    alert("The following information is required:\n" + reason);
    return false;
  }

  return true;
}


// Radio Button Validation
// copyright Stephen Chapman, 15th Nov 2004,14th Sep 2005
// you may copy this function but please keep the copyright notice with it
function validateButtons(fld,msg) {
    var cnt = -1;
		var error = "";
    for (var i=fld.length-1; i > -1; i--) {
        if (fld[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) 
		{
			return error;
		} 
		else 
		{
			error=msg;
			if (iErrorCount == 0){
			fld[0].focus();
			}
			iErrorCount++;
			return error;
		}
		
}
                  



function validateEmpty(fld,msg) {
	var error = "";
  
	if (fld.value.length == 0) {
  	fld.style.background = errorColor; 
//        error = "The required field has not been filled in.\n"
		error = msg;
		if(iErrorCount ==0){
			fld.focus();
		}
			iErrorCount ++;
    } else {
        fld.style.background = 'White';
    }
    return error;   
}

function validateUserName(fld) {
    var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
 
    if (fld.value == "") {
        fld.style.background = errorColor; 
        error = "The coordinator's name.\n";
//    } else if ((fld.value.length < 5) || (fld.value.length > 15)) {
//        fld.style.background = '#fbf4d2'; 
//        error = "The name should be more than 5 is the wrong length.\n";
			if(iErrorCount ==0){
				document.theForm.name.focus();
			}
			iErrorCount ++;
    } else if (illegalChars.test(fld.value)) {
        fld.style.background = errorColor; 
        error = "A name with only letters, underlines and hyphens are allowed.\n";
			if(iErrorCount ==0){
				document.theForm.name.focus();
			}
			iErrorCount ++;

    } else {
        fld.style.background = 'White';
    } 
    return error;
}


function validatePassword(fld) {
    var error = "";
    var illegalChars = /[\W_]/; // allow only letters and numbers 
 
    if (fld.value == "") {
        fld.style.background = errorColor;
        error = "You didn't enter a password.\n";
    } else if ((fld.value.length < 7) || (fld.value.length > 15)) {
        error = "The password is the wrong length. \n";
        fld.style.background = errorColor;
    } else if (illegalChars.test(fld.value)) {
        error = "The password contains illegal characters.\n";
        fld.style.background = errorColor;
    } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) {
        error = "The password must contain at least one numeral.\n";
        fld.style.background = errorColor;
    } else {
        fld.style.background = 'White';
    }
   return error;
}   

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
} 

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
//    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
		var emailFilter = /^([\w\d\-\.]+)@{1}(([\w\d\-]{1,67})|([\w\d\-]+\.[\w\d\-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$/;
    var illegalChars= /[\(\)\<\>\,\;\:\\\[\]]/ ;
    
    if (fld.value == "") {
        fld.style.background = errorColor;
        error = "An e-mail address.\n";
			if(iErrorCount ==0){
				document.theForm.contactEmail.focus();
			}
			iErrorCount ++;

    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = errorColor;
        error = 'A valid e-mail address.\n';
			if(iErrorCount ==0){
				document.theForm.contactEmail.focus();
			}
			iErrorCount ++;

    } else if (fld.value.match(illegalChars)) {
        fld.style.background = errorColor;
        error = 'A valid e-mail address.\n';
			if(iErrorCount ==0){
				document.theForm.contactEmail.focus();
			}
			iErrorCount ++;

    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');     

   if (fld.value == "") {
        error = "A phone number.\n";
        fld.style.background = errorColor;
			if(iErrorCount ==0){
				document.theForm.phone.focus();
			}
			iErrorCount ++;
    } else if (isNaN(parseInt(stripped))) {
        error = "A valid phone number.\n";
        fld.style.background = errorColor;
			if(iErrorCount ==0){
				document.theForm.phone.focus();
			}
			iErrorCount ++;

//    } else if (!(stripped.length == 10)) {
//        error = "The phone number is the wrong length. Make sure you included an area code.\n";
//        fld.style.background = errorColor;
//			if(iErrorCount ==0){
//				document.theForm.phone.focus();
//			}
//			iErrorCount ++;

    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validateDivision(fld) {
    var error = "";
    if (fld.value == 0) {
			fld.style.background = errorColor;
      error = "Select a department/division from the drop-down list.\n";
			if(iErrorCount ==0){
				document.theForm.division.focus();
			}
			iErrorCount ++;

    } else {
        fld.style.background = 'White';
    }    
return error;
}    

function validateProjectType(fld) {
    var error = "";
    if (fld.value == 0) {
			fld.style.background = errorColor;
      error = "Please select a project type from the drop-down list.\n";
			if(iErrorCount ==0){
				document.theForm.projectType.focus();
			}
			iErrorCount ++;

    } else {
        fld.style.background = 'White';
    }    
return error;
}    

//-->
		
		
		
		
function isValidDate(dateStr, format) {
		if (format == null) { format = "MDY"; }
		format = format.toUpperCase();
		if (format.length != 3) { format = "MDY"; }
		if ((format.indexOf("M") == -1) || (format.indexOf("D") == -1) || (format.indexOf("Y") == -1)) { format = "MDY"; }
		if (format.substring(0, 1) == "Y") { // If the year is first
			var reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
			var reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
		} else if (format.substring(1, 2) == "Y") { // If the year is second
			var reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/
			var reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/
		} else { // The year must be third
			var reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/
			var reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
		}
		// If it doesn't conform to the right format (with either a 2 digit year or 4 digit year), fail
		if ( (reg1.test(dateStr) == false) && (reg2.test(dateStr) == false) ) { return false; }
		var parts = dateStr.split(RegExp.$1); // Split into 3 parts based on what the divider was
		// Check to see if the 3 parts end up making a valid date
		if (format.substring(0, 1) == "M") { var mm = parts[0]; } else if (format.substring(1, 2) == "M") { var mm = parts[1]; } else { var mm = parts[2]; }
		if (format.substring(0, 1) == "D") { var dd = parts[0]; } else if (format.substring(1, 2) == "D") { var dd = parts[1]; } else { var dd = parts[2]; }
		if (format.substring(0, 1) == "Y") { var yy = parts[0]; } else if (format.substring(1, 2) == "Y") { var yy = parts[1]; } else { var yy = parts[2]; }
		if (parseFloat(yy) <= 50) { yy = (parseFloat(yy) + 2000).toString(); }
		if (parseFloat(yy) <= 99) { yy = (parseFloat(yy) + 1900).toString(); }
		var dt = new Date(parseFloat(yy), parseFloat(mm)-1, parseFloat(dd), 0, 0, 0, 0);
		if (parseFloat(dd) != dt.getDate()) { return false; }
		if (parseFloat(mm)-1 != dt.getMonth()) { return false; }
		return true;
	}


function KeyCheck(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (((keycode>47) && (keycode<58) )  || (keycode==8)) { return true; }
else return false;
}
//-->



//-->
