var xmlHttp = createXMLHttpObj();
function createXMLHttpObj()
{
	var xmlHttp;
	if (window.ActiveXObject)
	{
		try
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp = false;
		}
	}
	else
	{
		try
		{
			xmlHttp = new XMLHttpRequest();
		}
		catch (e)
		{
			xmlHttp = false;
		}
	}
	if (!xmlHttp)
		alert("Ошибка создания XMLHttpRequest");
	else
		return xmlHttp;
}
var gPage;
var gId;
var gParam;
var gVal;
function show_page(page, param, val) {
	
	if (typeof page != 'undefined') 
		gPage = page;
	if (typeof param != 'undefined' && typeof val != 'undefined') {
		gParam = param;
		gVal = val;
	}
	else 
		gParam = false;
		
	document.getElementById("loading").style.display = "block";
	document.getElementById("loading").style.height = document.getElementById("content").offsetHeight + "px";
	document.getElementById("loading").style.width = document.getElementById("content").offsetWidth + "px";
	
	add = "";
	if (gParam != false) add="&"+gParam+"="+gVal;
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
		xmlHttp.open("GET", gPage+"?ajax=Y"+add, true);
		xmlHttp.onreadystatechange = handleServerResponse;
		xmlHttp.send(null);
	}
	else {
		setTimeout("show_page()", 500);
	}
}
function handleServerResponse() {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			document.getElementById("content").innerHTML = xmlHttp.responseText;
			document.getElementById("loading").style.display = "none";
			/*responds[gPage] = xmlHttp.responseText;*/
		}
	}
}
function show_desc(id) {
	document.getElementById(id).style.display = "block";
}
function close_desc(id) {
	document.getElementById(id).style.display = "none";
}
function show_img(id) {
	if (typeof id != 'undefined') 
		gId = id;
	document.getElementById("loading").style.display = "block";
	document.getElementById("loading").style.height = document.getElementById("big").offsetHeight + "px";
	document.getElementById("loading").style.width = document.getElementById("big").offsetWidth + "px";
	document.getElementById("loading").style.margin = "105px 0 0 0";
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
		xmlHttp.open("GET", "/ru/gallery/ajax.php"+"?ajax=Y&id="+gId, true);
		xmlHttp.onreadystatechange = handleServerResponse_img;
		xmlHttp.send(null);
	}
	else {
		setTimeout("show_img()", 500);
	}
}
function handleServerResponse_img() {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			document.getElementById("big").innerHTML = xmlHttp.responseText;
			document.getElementById("loading").style.display = "none";
			document.getElementById("loading").style.margin = "0";
			/*responds[gPage] = xmlHttp.responseText;*/
		}
	}
}
function check(oThis, word) {
	if (oThis.value == word) oThis.value="";
}
function show_map() {
	document.getElementById("map").style.display = "block";
}
function close_map() {
	document.getElementById("map").style.display = "none";
}
