// 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 filterQuery()
{
	var parentframe = 'index.htm';

	if (parent.location.href == self.location.href)
	{
		var current = window.self.location.pathname;
		current.replace(/x/, "");
		window.location.replace (parentframe + '?' + current);
	}
	
	document.body.style.cursor='wait';
	
	ajaxPost = xmlhttpPost();
	if(!ajaxPost)
	{
		alert('Error setting up XMLHttpRequest');
	}

    ajaxPost.xmlHttpReq.open('POST', 'process_digital_shop_filter.php', true);
    ajaxPost.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    
	ajaxPost.xmlHttpReq.onreadystatechange = function() 
	{
        if (ajaxPost.xmlHttpReq.readyState == 4) 
		{
            updateFilterQuery(ajaxPost.xmlHttpReq.responseText);
        }
    }
    
	ajaxPost.xmlHttpReq.send(getPostString());
	
}


function getPostString() 
{
    var artist = document.filter.artist.value;
    var order = document.filter.order.value;
	
   	postString = 'order=' + escape(order) + '&' + 'artist=' + escape(artist);

    return postString;
}

function updateFilterQuery(str)
{
    document.getElementById("filter_results").innerHTML = str;
	document.body.style.cursor='auto';
}

