function init () {
	loadContent("pid=0");
	updateSearch("", "", 1);
}

function sites_init () {
	sites_loadContent("pid=0");
}

function GetXmlHttpObject () {
	var xmlHttp = null;
	try { // Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	} catch (e) { // Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function sites_loadContent (url) {
	xmlHttp3 = GetXmlHttpObject();
	if (xmlHttp3 == null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	url = "sites_content.php?" + url + "&ran=" + Math.random ();
	xmlHttp3.onreadystatechange = sites_stateChanged;
	xmlHttp3.open("GET",url,true);
	xmlHttp3.send(null);
} 

function sites_stateChanged () { 
	if (xmlHttp3.readyState == 4) { 
		document.getElementById("album").innerHTML = xmlHttp3.responseText;
	}
}

function loadContent (url) {
	xmlHttp1 = GetXmlHttpObject();
	if (xmlHttp1 == null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
/*	try {
		str = document.getElementById("searchBox").value;
	} catch (e) {
		str = "";
	}*/
	url = "content.php?" + url + "&ran=" + Math.random ()// + "&str=" + str;
	xmlHttp1.onreadystatechange = stateChanged;
	xmlHttp1.open("GET",url,true);
	xmlHttp1.send(null);
} 

function stateChanged () { 
	if (xmlHttp1.readyState == 4) { 
		document.getElementById("album").innerHTML = xmlHttp1.responseText;
	}
}

function updateSearch (str, ost, clr) {
	xmlHttp2 = GetXmlHttpObject();
	if (xmlHttp2 == null) {
		alert ("Your browser does not support AJAX!");
		return;
	} 
	var url = "search.php?str=" + str + "&ost=" + ost + "&clr=" + clr + "&ran=" + Math.random ();
//	alert ("search.php?str=" + str + "&ost=" + ost + "&clr=" + clr + "&ran=" + Math.random ());
//	var url = "search.php?str=" + str + "&pid=" + pid + "&sid=" + sid + "&ran=" + Math.random ();
	xmlHttp2.onreadystatechange = searchStateChanged;
	xmlHttp2.open("GET",url,true);
	xmlHttp2.send(null);
	loadContent("str=" + str);
}

function searchStateChanged () { 
	if (xmlHttp2.readyState == 4) { 
		document.getElementById("searchTerms").innerHTML = xmlHttp2.responseText;
	}
}

