function checkForm(frm) {
	resetForm(frm);

	errors=0;
	//if (typeof dsp == 'undefined'){
		dsp="";
	//}
	with (document[frm]) {

		if (chkEmail == 1) {
		  resetHighlight('Email',frm);
		}

		UsingNetscape = (document.layers) ? true : false;
		  cntr = 0;
		  while (cntr <= (arrFields.length -1)) {
			   if (!UsingNetscape) {          
					resetHighlight(arrFields[cntr],frm);
			   }
			   cntr++;
		  }

		  cntr = 0;
		  while (cntr <= (arrFields.length -1)) {
			   if (eval(arrFields[cntr]).value == "") {

					str = String(arrFields[cntr]);
					
					doHighlight(1, str, frm);
					//eval(arrFields[cntr]).focus();
					errors=1;
			   }
			   cntr++;
		  }

		  if (chkEmail == 1) {
			  re = /^[\w\-\.\_]+\@[\w\-]+\.[\w\-\.]+/
			  if(!re.test(Email.value)) {
				   dsp+="*Please enter a properly formatted E-mail \naddress like: yourname@host.com.\n";
				   if (!UsingNetscape) { 
					doHighlight(1, 'Email', frm);
				   }
				   //Email.focus();
				   errors=1;
			  }
		  }

		  if (chkImage == 1) {
			if (fileImage.value != "") {
					str = fileImage.value;
					len = str.length;
					ext = str.substring(len - 3, len);
					if (fileImage.value) {
						str = fileImage.value;
						len = str.length;
						i = len;
						rslt = "";

						while (i <= len && i != 0) {
							s = str.substring(i,i-1);
							if (s != "\\") {
								rslt = s + rslt;
							} else {
								break;
							}
							i = i - 1;
						}
					}

					if (ext != "jpg" && ext != "gif" && ext != "png") {
						doHighlight(1, 'fileImage');
						dsp+="*Please enter a .GIF, .JPG or .PNG file.\n";
						//fileImage.focus();
						errors=1;
					} else {
						fileName = fileImage.value;
						var imgURL = 'file:///' + fileName;
						var img = new Image();

						img.src = imgURL;

						if (img.width > 400) {
						   doHighlight(1, 'fileImage');
						   dsp+="*Your image is " + img.width + " pixels wide.\nPlease enter a image 400 pixels\nwide or smaller.\n";
						   //fileImage.focus();
						   errors=1;
						}
					}
			}
		}

	}
	if (errors==1){
		if (dsp!=""){
			if (!UsingNetscape) {
				LayerWrite('<span class="red">'+dsp+'</span>');
			} else {
				alert(dsp);
			}
		}
		return false;
	}
	return true;
}

function doHighlight(cntr, txt, frm) {

	UsingNetscape = (document.layers) ? true : false;

     if (!UsingNetscape) {
          document.forms[frm][txt].style.backgroundColor = bgColor[cntr];
          if (cntr <= 5) {
               cntr++;
               var id = setTimeout("doHighlight(" + cntr + ", '" + txt + "', '" + frm + "')", 25);
          }
     } else {
          dsp+="*Please make an entry.\n";
     }
}

function resetHighlight(txt,frm) {
    if (typeof(document.forms[frm][txt].type) != "undefined" && document.forms[frm][txt].type != "checkbox") {
		document.forms[frm][txt].style.backgroundColor = "#FFFFFF";
	}
}

function resetForm(frm) {
	LayerWrite('');
	for (i=0; i <= document[frm].length - 3; i++) {
		resetHighlight(document[frm][i].name,''+frm+'');
	}
}

function checkBrowser() {
	ns4 = (document.layers)? true:false
	ie4 = (document.all)? true:false

	// Microsoft Stupidity Check.
	if (ie4) {
		if (navigator.userAgent.indexOf('MSIE 5')>0) {
			ie5 = true;
		} else {
			ie5 = false; }
	} else {
		ie5 = false;
	}
}


checkBrowser();


function LayerWrite(txt) {
        if (ns4) {
                var lyr = document.divErrors.document
                lyr.write(txt)
                lyr.close()
        }
        else if (ie4) document.all["divErrors"].innerHTML = txt;
}
