/* HIDE AND SHOW FUNCTIONS */

function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}

function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}



/* ROLLOVER IMAGE FUNCTIONS */
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_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;
}



/* FORM VALIDATION */
function checkit() {
  var error = "";
  if(document.quick_form.name.value == '') {
    error = "Please tell us your name \n";
	document.getElementById("name").style.background="#ffafaf";
  } else {
	  document.getElementById("name").style.background="#ffffff";
	}
  if (document.quick_form.phone.value == '') {
    error += "Please enter a phone number where we can reach you \n";
	document.getElementById("phone").style.background="#ffafaf";
  } else {
	  document.getElementById("phone").style.background="#ffffff";
	}
  if (document.quick_form.email.value == '') {
    error += "Please enter a valid email address \n";
	document.getElementById("email").style.background="#ffafaf";
  } else {
	  document.getElementById("email").style.background="#ffffff";
	}
  if(error != "") {
  	alert(error);
	return false;
  }  else {
	  document.getElementById("quick_form").style.display="none";
	  document.getElementById("thanks").style.display="block";
      return true;
	 }
}


/* IE NAV FIX */
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


/* STRING FORMAT */
function addCommas(strValue) {
  var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})');

  //check for match to search criteria
  while(objRegExp.test(strValue)) {
  //replace original string with first group match,
  //a comma, then second group match
    strValue = strValue.replace(objRegExp, '$1,$2');
  }
  document.editcase_form.amount.value = strValue;
}
