
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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 newWindow(a_str_windowURL, a_str_windowName, a_int_windowWidth, a_int_windowHeight, a_bool_scrollbars, a_bool_resizable, a_bool_menubar, a_bool_toolbar, a_bool_addressbar, a_bool_statusbar, a_bool_fullscreen) {
  var int_windowLeft = (screen.width - a_int_windowWidth) / 2;
  var int_windowTop = (screen.height - a_int_windowHeight) / 2;
  var str_windowProperties = 'height=' + a_int_windowHeight + ',width=' + a_int_windowWidth + ',top=' + int_windowTop + ',left=' + int_windowLeft + ',scrollbars=' + a_bool_scrollbars + ',resizable=' + a_bool_resizable + ',menubar=' + a_bool_menubar + ',toolbar=' + a_bool_toolbar + ',location=' + a_bool_addressbar + ',statusbar=' + a_bool_statusbar + ',fullscreen=' + a_bool_fullscreen + '';
  var obj_window = window.open(a_str_windowURL, a_str_windowName, str_windowProperties)
    if (parseInt(navigator.appVersion) >= 4) {
      obj_window.window.focus();
    }
}

function validateForm(what){
   var valid = true;  
   var err = "Please fill out all the fields";     
   // 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;err= "Please fill out all the fields";
        if (myType == 'select-one' || myType == 'select-multiple')
            if (what.elements[i].selectedIndex == 0) valid = false;err= "Please fill out all the fields";
		if (myType == 'checkbox')
			if (what.elements[i].checked == false) valid = false;err= "You must agree to the terms of this site before proceeding. Please check the box once you have read and agree to them.";
    }

    if (!valid){ 
		newWindow("pop_error.asp?error="+err, 'error', 400, 130, 0, 0, 0, 0, 0, 0, 0);
    	return valid;
	} else {
	// 2. password is more than 6 characters and if IDs are the right number of digits
		var pswd = theForm.passwd.value;
		if(pswd.length < 6){
			valid = false; err = "Please make your password 6 or more characters";
		} else if(theForm.passwd.value !=theForm.confirm_password.value){
			valid = false; err = "Please retype your password properly";
		} 
	}
	if(!valid){ newWindow("pop_error.asp?error="+err, 'error', 400, 130, 0, 0, 0, 0, 0, 0, 0);}
    return valid;
}
function enroll(what){
	var valid = true;       
	var pswd = theForm.passwd.value;
	if(pswd.length < 6){
		valid = false;
		err = "Please make your password 6 or more characters";
	} else if(theForm.passwd.value !=theForm.confirm_password.value){
		valid = false;
		err = "Please retype your password properly";
	} 
	if(!valid){ newWindow("pop_error.asp?error="+err, 'error', 400, 130, 0, 0, 0, 0, 0, 0, 0);}
	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";
		newWindow("pop_error.asp?error="+err, 'error', 400, 130, 1, 1, 0, 0, 0, 1, 0);
	} else {
		valid = true;
	}
    return valid;
}

function confirm_delete(){
	input_box=confirm("Are you sure you want to delete this record?");
	if (input_box==true){return true; } else { return false; }
}

function confirm_approve(){
	input_box=confirm("Upon approval, the user will be notified their account has been activated. \nAre you sure you wish to approve this user?");
	if (input_box==true){return true; } else { return false; }
}

function validateTips(what){
   var valid = true;  
   var err = "Please fill out all the fields";     
   // 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";
		newWindow("pop_error.asp?error="+err, 'error', 400, 130, 0, 0, 0, 0, 0, 0, 0);
	} 
    return valid;
}
