
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function confirm_toggle(){
input_box=confirm("By continuing, you may lose access to some areas of this site. All access is restored, however, once you log out and sign back in.");
if (input_box==false){ return false; } else{ return true; }
}

function confirm_delete(URL){
input_box=confirm("Are you sure you want to delete this record?");
if (input_box==true){location.href=URL; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function validateForm(what){
   var valid = true;       
   // 1. check that all fields are filled out
    for (var i=0, j=what.elements.length; i<j; i++) {
        myType = what.elements[i].type;
        if (myType == 'hidden' || myType == 'password' || myType == 'text' || myType == 'textarea')
            if (what.elements[i].value == "") valid = false;
        if (myType == 'select-one' || myType == 'select-multiple')
            if (what.elements[i].selectedIndex == 0) valid = false;
    }

    if (!valid){ 
		err= "Please fill out all the fields";
		MM_openBrWindow("pop_error.asp?error="+err,"error","width=400,height=130");
	} else {
	// 2. password is more than 6 characters and if IDs are the right number of digits
		return enroll(what);
	}
    return valid;
}
function enroll(what){
var valid = true;       
var pswd = theForm.passwd.value;
		var repID = theForm.repID.value;
	 	if(pswd.length < 6){
	 		valid = false;
			err = "Please make your password 6 or more characters";
		 } else if(repID.length != 5){
			valid = false;
			err="Your rep ID should be a six digit number, please be sure you entered it correctly";
		 } else if(theForm.passwd.value !=theForm.confirm_password.value){
	 		valid = false;
	 		err = "Please retype your password properly";
	 	 } else if((theForm.userLevel.value != "2")&&(theForm.userLevel.value != "1")){
			valid = false;
			err="please be sure you entered your REP ID correctly";
		}
		 if(!valid){ MM_openBrWindow("pop_error.asp?error="+err,"error","width=400,height=130");}
		return valid;
}
function formItems(what){
var valid = true;       
var pswd = theForm.passwd.value;
		var repID = theForm.repID.value;
	 	if(pswd.length < 6){
	 		valid = false;
			err = "Please make your password 6 or more characters";
		 } else if((repID.length != 5)&&(repID.length != "")){
			valid = false;
			err="Your rep ID should be a five digit number, please be sure you entered it correctly";
		 } else if(theForm.passwd.value !=theForm.confirm_password.value){
	 		valid = false;
	 		err = "Please retype your password properly";
	 	 }
		 if(!valid){ MM_openBrWindow("pop_error.asp?error="+err,"error","width=400,height=130");}
		return valid;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function toggleMnu(e, link, ttl) {
  var imageTitle;
  var div = document.getElementById(e);
  var linkDiv = document.getElementById(link);
  var display = div.style.display;

  if (display == "none") {
    div.style.display = "block";
    imageTitle = "img/arrow_down.gif";
  }
  else if (display == "block") {
    div.style.display = "none";
    imageTitle = "img/arrow_left.gif";
  }
  if(linkDiv != null) {
  	linkDiv.innerHTML = "<a href=\"\" onClick=\"toggleDiv('" + e + "','" + link + "'); return false;\"><img src=\""+ imageTitle +"\" width=\"9\" height=\"9\" border=\"0\" /></a>";
  }
}

function contact(what){
   var valid = true;       
   // 1. check that all fields are filled out
    for (var i=0, j=what.elements.length; i<j; i++) {
        myType = what.elements[i].type;
        if (myType == 'text' || myType == 'textarea')
            if (what.elements[i].value == "") valid = false;
        if (myType == 'select-one' || myType == 'select-multiple')
            if (what.elements[i].selectedIndex == 0) valid = false;
    }

    if (!valid){ 
		err= "Please fill out all the fields";
		MM_openBrWindow("pop_error.asp?error="+err,"error","width=400,height=130");
	} else {
		valid = true;
	}
    return valid;
}
