
function createXmlHttpRequestObject()
{
	var xmlHttp;

	try
	{
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		var xmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0',
										'MSXML2.XMLHTTP.5.0',
										'MSXML2.XMLHTTP.4.0',
										'MSXML2.XMLHTTP.3.0',
										'MSXML2.XMLHTTP',
										'Microsoft.XMLHTTP');
		for(var i=0; i<xmlHttpVersions.length && !xmlHttp; i++)
		{
			try
			{
				xmlHttp = new ActiveXObject(xmlHttpVersions[i]);
			}
			catch(e) {}
		}
	}

	if(!xmlHttp)
		alert("Vissa funktioner på denna sida fungerar inte eftersom din webbläsare är för gammal.");
	else
		return xmlHttp;
}

var quicksearchReq = createXmlHttpRequestObject();

function quicksearch(str) {

	if(str.indexOf('<')>=0 || str.indexOf('>')>=0 || str.indexOf('"')>=0 || str.indexOf('/')>=0 || str.indexOf('\'')>=0)
	{
		alert("Sökningen tillåter inte specialtecken.");
		return;
	}
	else if(str.length<=0)
	{
		return;
	}
	else if(str.length>=40)
	{
		alert("Lite overkill kanske...");
		return;
	}
	else
	{
		if (quicksearchReq.readyState == 4 || quicksearchReq.readyState == 0) {
			quicksearchReq.open("GET", 'include/quicksearch.php?search=' + str, true);
			quicksearchReq.onreadystatechange = handleSearchRequest;
			quicksearchReq.send(null);
		}
	}
}

function handleSearchRequest() {
	if (quicksearchReq.readyState == 4) {
		document.getElementById('contentleft').innerHTML = quicksearchReq.responseText;
	}
}
