//	NOTE: value in checkbox important - also USE FIREFOX FOR DEBUGGING CONSOLE


var keyword_string;
var var_value;

keyword_string='';

function enableAjax()
{
	if (null == createXmlHttpRequest()) return;
	var ajaxTool = document.getElementById('AjaxTool');
	if (ajaxTool) ajaxTool.style.display = "block";	
}

function createXmlHttpRequest()
{
	var oHttp = null;
	try
	{
oHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(outerException)
	{
try
{
	oHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(innerException)
{	
	oHttp = null;
}
	}
	if (!oHttp && typeof XMLHttpRequest != "undefined")
	{
oHttp = new XMLHttpRequest();
	}
	return oHttp;
}

//	new form submit

function SubmitForm(keyword_string){ {

try {

   var url = "db_call.php";
   var params = "submit=yes" + keyword_string;

   http.open("POST", url, true);
   http.onreadystatechange = processResponse;

   http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   http.setRequestHeader("Content-length", params.length);
   http.setRequestHeader("Connection", "close");

   http.send(params);
}

catch(e) { alert(e); }
}

}

/*
function ajaxGetRes() {

   if(http.readyState == 4 && http.status == 200) {
      document.getElementById("resTxt").innerHTML = http.responseText;
   } else {
      document.getElementById("resTxt").innerHTML = "ajax error";
   }
}
*/


function getXHTTP() {

   var xhttp;

   try { 
      xhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
      try {
         xhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
           try {
              xhttp = new XMLHttpRequest();
           } catch (e3) {
              xhttp = false;
           }
      }
   }

   return xhttp;
}

var http = getXHTTP();


//	new form submit



function HelloWoof(keyword_string){

	//	DEBUG	alert("woofty" + keyword_string);
}



function processResponse()
{
	if (http.readyState == 4 && http.status == 200)
	{
var container = document.getElementById('result_display');
if (null == container) return;
if (http.responseText)
{
	container.innerHTML = http.responseText;
}
else
{
	container.innerHTML = "No documents matched your search.";
}
	}
}


function setFocus(focId)
{
	var target = document.getElementById(focId);
	if (null == target) return;
	target.focus();	
}
function setChecked(chkId)
{
	var target = document.getElementById(chkId);
	if (null == target) return;	
	if (!target.checked) target.checked = true;	
}
function clearText(txtId)
{
	document.getElementById(txtId).value = '';
}


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 = "";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = ""; }
else { document.getElementById(d).style.display = "none"; }
}

function ReverseContentToggle(d,e) {
if(d.length < 1) { return; }
if(e.length < 1) { return; }

if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = ""; }
else { document.getElementById(d).style.display = "none"; }

if(document.getElementById(e).style.display == "none") { document.getElementById(e).style.display = ""; }
else { document.getElementById(e).style.display = "none"; }
}



//  Variable String For Form

function BuildString(var_value, add_rem){	

	//	var 
	//	keyword_string="";
	//	var_value="";

	if(add_rem==2){

		var newKeyword_string='';
		newArray = keyword_string.split('&');
	
		for(i=0; i<newArray.length; i++) {

			if(!newArray[i].match(var_value)){
				newKeyword_string=newKeyword_string + '&' + newArray[i];
			}
		}

		keyword_string=newKeyword_string.replace('&&','&');

//	DEBUG	alert(keyword_string);

	} else if(add_rem==1){
		keyword_string=keyword_string + "&"+ var_value +"=1" ;
	} else if(add_rem==0){
		keyword_string=keyword_string.replace( "&" + var_value +"=1", "" );
	}
	
	keyword_string=keyword_string.replace('&&','&');

//	DEBUG	alert(keyword_string);

}


