
function getHTTPObject()

{

   if( window.ActiveXObject ) return new ActiveXObject("Microsoft.XMLHTTP");

   else if( window.XMLHttpRequest ) return new XMLHttpRequest();

   else {

      alert("Your browser does not support AJAX.");

      return null;

   }

}   

 

// Change the value of the outputText field

function updateShippingDiv()

{

    if( httpObject.readyState == 4 ) {

        document.getElementById('shippinginfo').innerHTML = httpObject.responseText;

    }

}

 

// Implement business logic    

function toggleShipping( state )

{    

    httpObject = getHTTPObject();

    if( httpObject != null ) {

        httpObject.open("GET", "toggle_shipping.php?state="+state, true);

        httpObject.send(null); 

        httpObject.onreadystatechange = updateShippingDiv;

    }

}

function displayQuickSearchResults()
{
    if( httpObject.readyState == 4 ) {
     	document.getElementById('search-results').style.display = "block";
        document.getElementById('search-results').innerHTML = httpObject.responseText;
    }
 
}

function quickSearch( input )
{
 	var search = input.value;
 	//document.write("search: "+search+"<bR>");
 	
 	if( search.length > 1 ) {
		httpObject = getHTTPObject();
	    if( httpObject != null ) {
	        httpObject.open("POST", "http://localhost/shop/_search.php?search="+search, true);
	        httpObject.send(null); 
	        httpObject.onreadystatechange = displayQuickSearchResults;
	    }
	} else {
		httpObject = null
		document.getElementById('search-results').innerHTML = "";
	}
}

/*******************************************************************************************/

 

var httpObject = null;
