
function MM_jump(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function jsFormChecker(theForm, fields) {	
	var filled = true;
	for (i in fields)
	{
		var theField = theForm.elements[i];
		switch(theField.type)
		{
			case "text":
			case "textarea":
			case "password":
				if (theField.value == "" || theField.value.length == 0) {
					alert(fields[i]);
					return false;
				} 
				break;
			
		   case "select-one":
			   if (theField.selectedIndex <= 0 || theField.value == ""){
					alert(fields[i]);
					return false;
			   }
			   break;

		   case "select-multiple":
			  var valid = false;
			  for(j = 0; j < theField.options.length; j++){
					if (theField.options[j].selected){
						valid = true;
						break;
					}
			 }
			 if (!valid){
				 alert(fields[i]);
				 return false;
			 }
			 break;
			
		  default: //radio or checkbox
			 if(theField[0].type == "radio" || theField[0].type == "checkbox") {
				var ischecked = false;
				for (j = 0; j < theField.length; j++){
					if (theField[j].checked){
						ischecked = true;
						break;
	  				}
				}
				if (!ischecked){
					alert(fields[i]);
					return false;
				}
			 }else {
				 alert("I couldn't figure out what type this field is.");
			 }
			break;

		}//end switch		
	}//end for
	
	return filled;	
	
}// end jsFormChecker()


function dynamicFormChecker(theForm, dynFields){
	var filled = true;
	for(i in dynFields){
		var target = document.getElementById(i);
		if(target.style.display == "block"){
			for(j in dynFields[i]){// check each req fields under the id
				if (theForm.elements[j].value == "" || theForm.elements[j].value.length == 0){
					alert(dynFields[i][j]);					
					return false;		
				}
			}//end for j
		}//end if target			
	}//end for i				
	return filled;
}

function formChecker(theForm, reqFields, dynFields){
	return(jsFormChecker(theForm, reqFields)&& dynamicFormChecker(theForm, dynFields) );
}

function IEHoverPseudo() {
	
	var navItems = document.getElementById("popMenu").getElementsByTagName("li","ul");
	popMenu.HideDelayTime = 1;	// seconds
	for (var i=0; i<navItems.length; i++) {
		if(navItems[i].className == "menuparent") {
			navItems[i].onmouseover=function() { this.className += " over"; }
			navItems[i].onmouseout=function() { this.className = "menuparent"; }
		}
		else if (navItems[i].className == "secondparent") {
			navItems[i].onmouseover=function() { this.className += " secondover"; }
			navItems[i].onmouseout=function() { this.className = "secondparent"; }
		}
	}
}

function validateConfirm(id1,id2){
	var str1 = document.getElementById(id1).value;
	var str2 = document.getElementById(id2).value;
	if (str1 != str2){
		alert(id1+'s must match.');
		return false;
	}
}

// NO LONGER USED: code to demand username when entering a new person - by bminton
var emptyString = /^\s*$/;
var global_valuefield; 

function setFocus(valuefield){
	global_valuefield = valuefield;  //this variable will make the form remember to do the focus action
	setTimeout('global_valuefield.focus()', 100);
}
function msg (fld, msgtype, message) {
	var dispmessage;
	dispmessage = message;
	var elem = document.getElementById(fld);  //the real magik starts here
	elem.firstChild.nodeValue = dispmessage;
	elem.className = msgtype;
}
function fieldValidate(valuefield, infofield, required) { //elem to be evaluated, id of that elem, true if required
	if (emptyString.test(valuefield.value)) {  // if the field is empty, which we don't want it to, then..
		if (required) {  //if the field is required, then..
			msg(infofield, "error", "ERROR: required"); 
			setFocus(valuefield);  //put the cursor in the box with an error
			return false;  //doesn't send
		}else {
			msg(infofield, "warn", "");  //this is only if a field doens't have to be filled out
			return true;  //good to go so send away
		}
	}
	return true; //the form is sent with no issue
}
function correctPNG()
{
   for(var i=0; i<document.images.length; i++)
   {
      var img = document.images[i]
      var imgName = img.src.toUpperCase()

      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
         var imgID = (img.id) ? "id='" + img.id + "' " : ""
         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
         var imgStyle = "display:inline-block;" + img.style.cssText

         if (img.align == "left") imgStyle = "float:left;" + imgStyle
         if (img.align == "right") imgStyle = "float:right;" + imgStyle
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle

         var strNewHTML = "<span " + imgID + imgClass + imgTitle
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;"
             + imgStyle + ";"      + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
             + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"

         img.outerHTML = strNewHTML
         i = i-1
      }
   }
}
//end of code from bminton
//added by Joshua Nichols - June 01, 2009
function echeck(str) {
		
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		//if((str.substring(lat) != "@iupui.edu") && (str.substring(lat) != "@iu.edu") && (str.substring(lat) != "@indiana.edu")){
		//Requires Valid IUPUI/IU email account
		//	return false
		//}
		if (str.indexOf(at)==-1){
		 //  alert("Invalid E-mail ID")
		   return false;
		}
		if (ldot == (lstr-1)){
			return false;	
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		 // alert("Invalid E-mail ID")
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   // alert("Invalid E-mail ID")
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   // alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   // alert("Invalid E-mail ID")
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   // alert("Invalid E-mail ID")
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false;
		 }

 		 return true;					
	}
	function isNumeric(strString)
  {
   var strValidChars = "0123456789-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
//end of code added by Joshua Nichols