// JavaScript Document


function xmlhttpPost() 
{
    var xmlHttpReq = false;
    var self = this;
    
	// Mozilla/Safari
    if (window.XMLHttpRequest) 
	{
        self.xmlHttpReq = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)     // IE
	{
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	else
	{
		return false;
	}
	
	return self;
}

function dbQuery()
{
	document.body.style.cursor='wait';
	ajaxPost = xmlhttpPost();
	if(!ajaxPost)
	{
		alert('Error setting up XMLHttpRequest');
	}

    ajaxPost.xmlHttpReq.open('POST', 'shipping_tariff_query.php', true);
    ajaxPost.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    
	ajaxPost.xmlHttpReq.onreadystatechange = function() 
	{
        if (ajaxPost.xmlHttpReq.readyState == 4) 
		{
            updatedbquery(ajaxPost.xmlHttpReq.responseText);
        }
    }
    
	ajaxPost.xmlHttpReq.send(getquerystring());
}


function getquerystring() 
{
    var location = document.filter_location.location.value;

	if(location == "United kingdom")
	{
		qstr = 'location=UK';
	}
	else if(location == "Europe")
	{
		qstr = 'location=EUR';
	}
	else
	{
		qstr = 'location=ROW';
	}	
    return qstr;
}

function updatedbquery(str)
{
    document.getElementById("filter_results").innerHTML = str;
	document.body.style.cursor='auto';
}
