function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function show(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility = 'visible';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = 'visible';
  }
  else if (document.all) {
    document.all[object].style.visibility = 'visible';
  }
}

function hide(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility = 'hidden';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = 'hidden';
  }
  else if (document.all) {
    document.all[object].style.visibility = 'hidden';
  }
}

function CheckFile(f1,f2,xfa) {
	if (!f1.value) {
		alert("Please select a file to upload!");
		return false;
	} else {
		f2.value=xfa;
		hide('on_off_form');
		show('pleasewait');
		return true;
	  }
}

function confirmchanges() {
if (window.confirm("Are you sure you want to delete this record? Please note that these changes cannot be undone!")) 
        { return true;
        } 
else { return false; 
        }  
   }

function confirmandgo(url) {
if (window.confirm("Are you sure you want to delete this record? Please note that these changes cannot be undone!")) 
        { parent.location=url;
        } 
else { return false; 
        }  
   }

function selectall(selfield,holder,selbutton,el){
if (holder.value == 'true'){
	var elval = false;
	holder.value = 'false'
	selbutton.value = 'Select All'
	} 
	else{
	var elval = true;
	holder.value = 'true'
	selbutton.value = 'Clear All'
	}
	for (var i=0;i<el.elements.length;i++){
    var e = el.elements[i];

    if (e.name == selfield) {e.checked = elval;}
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function confirmchanges() {
if (window.confirm("Are you sure you want to delete this record? Please note that these changes cannot be undone!")) 
        { return true;
        } 
else { return false; 
        }  
}

function confirmBatchDelete() {
	if (document.forms[0].DeletePageContents == null) {
		return true;
	} else {
		for (i=0; i<document.forms[0].DeletePageContents.length; i++) {
			if (document.forms[0].DeletePageContents[i].checked) {
				return confirm('Are you sure you want to DELETE all selected elements?');
			}
		}
	}
	return true;
} 

function change(e,bg){
	if (!bg) var bg = "#e0e0e0";
	document.getElementById(e).style.borderColor = "#ff0000";
	document.getElementById(e).style.backgroundColor = bg;
}

function change_back(e){
	document.getElementById(e).style.borderColor = "#cccccc";
	document.getElementById(e).style.backgroundColor = "";
}

function checkSearch(fieldlen) {
	if (!fieldlen) {
		alert("You must specify a search criteria.");
		return false;
	} else {
		return true;
	}
}

function highlight(e,cell, bg) {
	if (e.checked) {
		change(cell, bg);
	} else {
		change_back(cell, bg);
	}
}

function confirmandsubmit(msg, f) {
	if (confirm(msg)) {
		f.submit();
		return true;
	} else {
		return false;
	}
}

function otherOption(theSelect) {
	var description = prompt('Please enter the new option:', '');
	if (description != null) {
		theSelect.options[0].text = description;
		theSelect.options[0].value = description;
		theSelect.options[0].selected = true;
	}
}	
 
