function searchSuggest() {
	if (document.search.q.value == '') {
		var div = document.getElementById('SearchSuggestContainer');
		div.innerHTML = '';
		document.getElementById("SearchSuggestContainer").removeAttribute("style");
	}
	else if (document.search.q.value != '') {
        var httpRequest;

        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            httpRequest = new XMLHttpRequest();
            if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
            }
        } 
        else if (window.ActiveXObject) { // IE
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                } 
                catch (e) {
                           try {
                                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                               } 
                             catch (e) {}
                          }
                                       }

        if (!httpRequest) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
		
		// Form Variables Translated to JS
		// Search Parameters
		var c = 'getProductHeaderLabels';
		
		// Establish URL to API
		var query='?c=' + c;
		var url='http://' + document.domain + '/service';
		url=url+query;
		url=url+"&sid="+Math.random();

		
		// Send Request to API
		httpRequest.onreadystatechange = function() { alertProductHeaderSuggestContents(httpRequest); };
        httpRequest.open('GET', url, true);
        httpRequest.send('');
    }

    function alertProductHeaderSuggestContents(httpRequest) {

		try {
        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {

		// Eval Statement
		var myProduct = eval('(' + httpRequest.responseText + ')');
		//var myProductReturn = searchReq.responseText.split("\n");
		
		// Whether to Escape the Contents of the Query
		// var qstr = escape(document.getElementById('q').value);
		var qstr = document.search.q.value;
		
		// Establish div/span id name
		var div = document.getElementById('SearchSuggestContainer');
		div.innerHTML = '';
		
		// If No Input, Then Stop Script
		if (qstr == '') {
		return false;
		}
		
		// Set Border Attribute
		document.getElementById("SearchSuggestContainer").setAttribute("style","border: 0px solid #000000");
		document.getElementById("SearchSuggestContainer").style.cssText = "border: 1px solid #000000";
		
		// Establish j as First Result Found
		j=0;
		
		// Loop through Product Headings
		for (var i=0; i<myProduct.results.length; i++) {

		// Number of Results to Display (j = Results - 1)
		if (j==19) {
			break;
		}

		// Match Query to Headings
		if ((myProduct.results[i].match(new RegExp('\\b' + qstr + '', 'i'))) != null) {

		// Increment j
		j++;
		
		// Build our element string
		var result = '<div onmouseover="javascript:suggestOver(this);" ';
		result += 'onmouseout="javascript:suggestOut(this);" ';
		result += 'onclick="javascript:setSearch(this.innerHTML);" ';
		result += 'class="suggest_link">' + myProduct.results[i] + '</div>';
		div.innerHTML += result;
		}
		}
		if (result==undefined) {
		document.getElementById("SearchSuggestContainer").removeAttribute("style");
		}
		
            } else {
                //alert('There was a problem with the request.');
            }
        }
		}
		catch( e ) {
            alert('Caught Exception: ' + e.description);
        }
    }
	}
	
	// Mouseover Function
	function suggestOver(div_value) {
	div_value.className = 'suggest_link_over';
	}
	
	// Mouseout Function
	function suggestOut(div_value) {
	div_value.className = 'suggest_link';
	}

	// Click Function
	function setSearch(value) {
	// Take away HTML spaces and & if there are any and set value as q
	value = value.replace(/&nbsp;/," ");
	document.search.q.value = value.replace(/&amp;/,"&");
	// Reset Container
	document.getElementById('SearchSuggestContainer').innerHTML = '';
	document.getElementById("SearchSuggestContainer").removeAttribute("style");
	}
	
	// Arrow Functions
	/*function arrowControl(e) {
		var KeyID = (window.event) ? event.keyCode : e.keyCode;
		switch(KeyID) {
			case 13: // Enter
            qstr = '';
            return false;
            break;
			case 27: // Escape
            qstr = '';
            return false;
            break;
			case 38: // Arrow Up
			arrowup(%1\$s, %2\$s);
            return false;
      		break;
	        case 40: // Arrow Down
			arrowdown(%1\$s, %2\$s);
            return false;
      		break;
			default: // Other
      		break;
		}
		return true;
	}*/

