
/*
//update suggest window postion if window size changes
window.onresize = moveElement;

// GLOBALS, mostly GUI elements
var queryInterval;
var suggestHolder;
var searchBox;
var suggestedProducts;
var queryBuffer;
var focusFlag;


// CONSOLE & GLOBALS FOR TESTING QUERYS & RESPONSES
//var responseCount = 0;
//var queryCount = 0;
//var popCon = window.open("","","");


// load GUI objects into global variables for global reference
function assignItems(){
suggestHolder = document.getElementById("suggest-holder");
searchBox = document.getElementById("searchBox");
suggestedProducts = document.getElementById("suggested-products");
	queryBuffer = document.getElementById("queryBuffer");
// clears query buffer, to ensure a page refesh still returns search results
//queryBuffer.value=document.getElementById("queryBuffer").value;
// ensure everything is flagged and loaded by quickly firing off the sequence on load/assign
//searchBox.blur();
}


// create XMLHttpRequest object
function createXMLHttp(){
// test creating object in Moz+Others
if (typeof XMLHttpRequest != "undefined"){
	// if usable, use it
	return new XMLHttpRequest();
//else test for windows compatability
}else if (window.ActiveXObject){
//if IE compatable, construct array of all possible version types
var aVersions = [ "MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp" ];

//loop through versions starting newest first and attempt to create the object
for (var i = 0; i<aVersions.length; i++){
	try {
		// Build Object using IE method
		var dataConnection = new ActiveXObject(aVersions[i]);
		// Exit function, return object;
		return dataConnection;
	} catch (oError) {
		// DO NOTHING
	}
}
}
// if it can't create either object, inform end user of error
throw new Error("XMLhttp object could not be created, some functionality will/may be lost");
}





// Position the suggest box below the Search textfield
function moveElement(){
// POSITION THE SUGGESTION BOX BASED ON THE PIXEL PLACEMENT OF THE SEARCH FIELD
if (!searchBox.x){
	// USE OBJECT DETECTION TO FIGURE OUT IF USING IE, IF USING IE, USE IE PROPERTIES
    xPos = searchBox.offsetLeft;
    tempEl = searchBox.offsetParent;
      	while (tempEl != null) {
          xPos += tempEl.offsetLeft;
          tempEl = tempEl.offsetParent;
      	}
	  }else{
	  // ELSE USE MOZILLA COMPATABLE PROPERTIES
	  	xPos = searchBox.x;
	  }  
suggestHolder.style.left = xPos-298+"px";
}






// used in conjunction with setInterval call, tests buffers and throttles queries, builds and completes AJAX calls
function prepContent(){

if(searchBox.value != ""){
suggestHolder.style.display = "block";

if(searchBox.value != queryBuffer.value){
	
	// get and encode variable value
	var searchText = encodeURI(searchBox.value);
	
	//create url for AJAX call
	var compiledURL = "http://cableorganizer.com/pm5/suggest/query.php?searchTerms="+searchText;
	
	//create XMLHTTPrequest Object
	var getProducts = createXMLHttp();
	
	//load request for server
	getProducts.open("get",compiledURL,true);
	
	queryBuffer.value = searchBox.value;
	
	//WRITE TO POPUP FOR QUERY TESTING PURPOSES & QUERY TRACKER
	//queryCount = queryCount+1;
	//popCon.document.write("query #:"+queryCount+" for "+searchBox.value+"<br>");
	
	getProducts.onreadystatechange = function () {
		
		if (getProducts.readyState == 4){
				
			if (getProducts.status == 200){
				if (getProducts.responseText == 0){
				
				// RESPONSE TRACKER
				//responseCount = responseCount+1;
				//popCon.document.write("response #:"+responseCount+"<br>");
				
				suggestedProducts.innerHTML = "<div id=\"warning\">your search was either too broad or narrow;<br>try refining your search a bit more...<br>Try adding more letters and detail or reducing some.<br><strong><br>(e.g \"Pat\" returns different results than \"Patch\")<br><br></strong></div>";
				document.getElementById("processingData").style.display = "none";
				}else{
				
				//RESPONSE TRACKER
				//responseCount = responseCount+1;
				//popCon.document.write("response #:"+responseCount+"<br>");
				
				suggestedProducts.innerHTML = getProducts.responseText;
				document.getElementById("processingData").style.display = "none";
				}
			}else{
				// inform user of error
				alert ("An Error Occured : \n" + getProducts.statusText);
				}
			}
			
		}
	// SEND request
	getProducts.send(null);
	document.getElementById("processingData").style.display = "block";
}
	
}else{
suggestHolder.style.display = "none";
}




}





function focusFlager(flag){
this.flag = flag;

	if(flag == true){
		focusFlag = flag;
		if (searchBox.value != ""){
		suggestHolder.style.display = "block";
		moveElement();
		}
		startInterval(true);
	}else if(flag == false){
		focusFlag = flag;
		setTimeout('checkForHide()',100)
	}

}


function checkForHide(){
	if(focusFlag == true){
		suggestHolder.style.display = "block";
	}else if(focusFlag == false){
		suggestHolder.style.display = "none";
	}
}


function checkFocus(){
if (focusFlag == true){
		if (searchBox.value != ""){
		suggestHolder.style.display = "block";
			moveElement();
		}
		prepContent();
}else{
startInterval(false);
}
}

function startInterval(flag){
this.flag = flag;

	if(flag == true){
		checkInterval = setInterval('checkFocus()',700);
	}else if(flag == false || flag != true){
		clearInterval(checkInterval);
	}

}



function submitSearch(){
document.searchSite.submit();
}


*/