function sendAjaxRequest(action, id_content)
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			//document.getElementById('ajax_activity_indicator').style.visibility = "hidden";
		}
	}
	xmlHttp.open("POST","../classes/class_user_input.php",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

	var content = 	"action="+action+
					"&id_content="+id_content;
					
	xmlHttp.send(content);
	//document.getElementById('ajax_activity_indicator').style.visibility = "visible";
}

/* By Peter A. Bromberg, Ph.D. http://www.eggheadcafe.com/articles/20020107.asp */
function PageQuery(q) 
{
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	
	this.keyValuePairs = new Array();
	if(q)
	{
		for(var i=0; i < this.q.split("&").length; i++)
		{
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	
	this.getValue = function(s) 
	{
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			if(this.keyValuePairs[j].split("=")[0] == s)
			return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	
	this.getParameters = function() 
	{
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) 
		{
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	
	this.getLength = function() { return this.keyValuePairs.length; }
}

/* By Peter A. Bromberg, Ph.D. http://www.eggheadcafe.com/articles/20020107.asp */
function queryString(key)
{
	var page = new PageQuery(window.location.search);
	return unescape(page.getValue(key));
}

/**
*
*  Javascript string replace
*  http://www.webtoolkit.info/
*
**/
// standart string replace functionality
function str_replace(haystack, needle, replacement) 
{
	var temp = haystack.split(needle);
	return temp.join(replacement);
}
 
// needle may be a regular expression
function str_replace_reg(haystack, needle, replacement) 
{
	var r = new RegExp(needle, 'g');
	return haystack.replace(r, replacement);
}


function setDropdownLists()
{
	var search_term = str_replace(queryString('search_term'), '+', ' ');
	var qualification = str_replace(queryString('qualification'), '+', ' ');
	var delivery_method = str_replace(queryString('delivery_method'), '+', ' ');
	var provider = str_replace(queryString('provider'), '+', ' ');
	var location = str_replace(queryString('location'), '+', ' ');
	
	var select_qualification = document.getElementById('select_qualification');
	var select_delivery_method = document.getElementById('select_delivery_method');
	var select_provider = document.getElementById('select_provider');
	var select_location = document.getElementById('select_location');
	
	document.getElementById('search_box_search_term').text = search_term;

	if(qualification != 'false' || qualification != 'select_any')
	{
		for(i = 0; i < select_qualification.length; i++)
		{
			if(select_qualification.options[i].value == unescape(qualification)) select_qualification.options[i].selected = true;
		}
	}
	
	if(delivery_method != 'false' || delivery_method != 'select_any')
	{
		for(i = 0; i < select_delivery_method.length; i++)
		{
			if(select_delivery_method.options[i].value == delivery_method) select_delivery_method.options[i].selected = true;
		}
	}
	
	if(provider != 'false' || provider != 'select_any')
	{
		for(i = 0; i < select_provider.length; i++)
		{
			if(select_provider.options[i].value == provider) select_provider.options[i].selected = true;
		}
	}
	
	if(location != 'false' || location != 'select_any')
	{
		for(i = 0; i < select_location.length; i++)
		{
			if(select_location.options[i].value == location) select_location.options[i].selected = true;
		}
	}
}
