
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function doMenu(item) {
 obj=document.getElementById(item);
 col=document.getElementById("x" + item);
 //colb=document.getElementById("y" + item);
 if (obj.style.display=="none") {
  obj.style.display="block";
  col.innerHTML="less info";
  document.getElementById("y" + item).style.display="none";

 // colb.innerHTML="";
 }
 else {
  obj.style.display="none";
  col.innerHTML="more info";
  document.getElementById("y" + item).style.display="block";
// colb.innerHTML=lesstext;
 }
}
function collapse(item) {
obj=document.getElementById(item);
obj.style.display="none";
}

function confirmdelete(id,item,yr,mo,dy) {
	var c = confirm("Are you sure you want to delete this " + item + "?")
	if (c) {

		window.location.href = "process/delete.php?id="+id+"&date="+yr+"-"+mo+"-"+dy
	}
}


function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function GetSelectValue(FieldName) {
	// Usage Ex: GetSelectValue('document.FOO.FOOFIELD');
	var UserPicked=eval(FieldName + ".selectedIndex");
	var ReturnValue=eval(FieldName + ".options[UserPicked].value");
	return(ReturnValue);
}



function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}

function addslashes(str) {
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\0/g,'\0');
str=str.replace(/\\\\/g,'\\');
return str;
}


function UnCheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}

function get_check_value()
{
var c_value = "";
for (var i=0; i < document.form1.whichChild.length; i++)
   {
   if (document.form1.whichChild[i].checked)
      {
      c_value = c_value + document.form1.whichChild[i].value + "\n";
      }
   }
   return c_value;
}


function get_checked_value(field)
{
var fieldToCheck = eval(field)
var c_value = "";
for (var i=0; i < fieldToCheck.length; i++)
   {
   if (fieldToCheck[i].checked)
      {
      c_value = c_value + fieldToCheck[i].value + "\n";
      }
   }
   return c_value;
}



function build_vals()
{
var c_value = str;
for (var i=0; i < document.form1.whichChild.length; i++)
   {
   if (document.form1.whichChild[i].checked)
      {
      c_value = c_value + document.form1.whichChild[i].value + "\n";
      }
   }
   return c_value;
//   alert('this was called');
}


function checkdate(input){
var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
var returnval=false
if (!validformat.test(input.value))
returnval = false;
//alert("Invalid Date Format. Please correct and submit again.")
else{ //Detailed check for valid date ranges
var monthfield=input.value.split("/")[0]
var dayfield=input.value.split("/")[1]
var yearfield=input.value.split("/")[2]
var dayobj = new Date(yearfield, monthfield-1, dayfield)
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
returnval = false;
//alert("Invalid Day, Month, or Year range detected. Please correct and submit again.")
else
returnval=true
}
//if (returnval==false) input.select()
return returnval
}
