function ahah(url, target) {
var queryer = document.searchform.simplequerystring.value;
if ((queryer != "Search: All Digi") && (queryer != "Search: Support")) {

url = url + "?simplequerystring=" + queryer;

  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
  if (queryer == "") {
	document.getElementById('searchframe').style.top = "-1000px";
	document.getElementById('clearbtn').style.display = "none";
	} else {
	document.getElementById('searchframe').style.top = "88px";
	document.getElementById('searchframe').style.display = "";
	document.getElementById('searchframe').style.zIndex = "1107";
	document.getElementById('clearbtn').style.display = "";
	}
}
}

function ahahah(url, target) {
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
  	if (document.getElementById(target).style.display == "none") {
	document.getElementById(target).style.top = "88px";
	document.getElementById(target).style.display = "";
	document.getElementById(target).style.zIndex = "1108";
	} else {
	document.getElementById(target).style.top = "-1000px";
	document.getElementById(target).style.display = "none";
	}
}

function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML=" AHAH Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function load(name, div) {
	if (div == "searchframe") {
	if (document.forms.searchform.EQ_category.value == "support") {
	name = "/includes2/livesearch-support.jsp";
	} else {
	name = "/includes2/livesearch.jsp";
	} }
	if (div == "searchselect") {
		ahahah(name,div);
	} else {
		ahah(name,div);
	}
	return false;
}


function showhidesub(targetdiv,targetimg) {
	if (document.getElementById(targetdiv).style.display == "none") {
		document.getElementById(targetdiv).style.display = "";
		document.images[targetimg].src = "/images2/bull_home_minus.gif"
		document.images[targetimg].title = "Click to collapse sub-categories";
	} else {
		document.getElementById(targetdiv).style.display = "none";
		document.images[targetimg].src = "/images2/bull_home_plus.gif"
		document.images[targetimg].title = "Click to expand sub-categories";
	}
}

function showhideselect(selectvalue) {
	document.forms.searchform.EQ_category.value = selectvalue;
	document.getElementById('searchselect').style.top = "-1000px";
	document.getElementById('searchselect').style.display = "none";
	switchsearchdropdown();	
}

function switchsearchdropdown() {
	var thecategory = document.forms.searchform.EQ_category.value;
	var thesearchterm = document.forms.searchform.simplequerystring.value;
	if (thecategory == "support") {
		if (thesearchterm == "Search: All Digi") {
			MM_setTextOfTextfield('simplequerystring','','Search: Support');
			} else {
			MM_setTextOfTextfield('simplequerystring','',thesearchterm);
			}
		load('/includes2/livesearch-support.jsp','searchframe');
	} else {
		if (thesearchterm == "Search: Support") {
			MM_setTextOfTextfield('simplequerystring','','Search: All Digi');
			} else {
			MM_setTextOfTextfield('simplequerystring','',thesearchterm);
			}
		load('/includes2/livesearch.jsp','searchframe');
	}
}

function clearsearchform() {
	if (document.forms.searchform.EQ_category.value == "support") {
		document.searchform.simplequerystring.value='Search: Support';
	} else {
		document.searchform.simplequerystring.value='Search: All Digi';
	}
	document.getElementById('searchframe').style.top = "-1000px";
	document.getElementById('clearbtn').style.display = "none";
	switchsearchdropdown();
	}