var req;
var block;

function blockLoad(params) {
	var url = "http://"+window.location.hostname+"/index.php?ajax&id="+params;
	var id = params.split("&")[0];
	block = gebi(id);
	block.innerHTML += '<span id="waitLoad">&nbsp</span>';
	loadXMLDoc(url);
}

function loadXMLDoc(url) {
    // для "родного" XMLHttpRequest
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = processReqChange;
        req.open("GET", url, true);
        req.send(null);
        
    // для версии с ActiveX
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function processReqChange() {
    // только при состоянии "complete"
    if (req.readyState == 4) {
        // для статуса "OK"
        if (req.status == 200) {
            // здесь идут всякие штуки с полученным ответом
					block.innerHTML = req.responseText;
        } else {
            alert("Не удалось получить данные:\n" +
                req.statusText);
        }
    }
}

function processStateChange(){
  if (request.readyState == 4){
	contentDiv = document.getElementById(dest);
	if (request.status == 200){
		response = request.responseText;
		contentDiv.innerHTML = response;				
	} else {
		contentDiv.innerHTML = "Error: "+request.status;
	}
  }
}		
var request;
var dest;
function loadHTML(URL, destination){
	dest = destination;
	if(window.XMLHttpRequest){
		request = new XMLHttpRequest();
		request.onreadystatechange = processStateChange;
		request.open("GET", URL, true);
		request.send(null);
	}
	else{
		if (window.ActiveXObject) {
			request = new ActiveXObject("Microsoft.XMLHTTP");
			if (!request) request = new ActiveXObject("MSxml2.XMLHTTP");
			if (request) {
				request.onreadystatechange = processStateChange;
				request.open("GET", URL, true);
				request.send();
			}
		}
	}
}

	function getClientWidth()
	{
	  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth; 
	}
	 
	function getClientHeight()
	{
	  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
	}
	function getBodyScrollTop()
	{
	  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
	}

function show(number,id,name) {
	var x,y;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight;
	if (test1 > test2) {
		x = document.body.scrollWidth;
		y = document.body.scrollHeight;
	}
	else {
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
	if(navigator.appName != "Microsoft Internet Explorer"){
		document.getElementById(name+id).style.height=y-document.body.scrollTop;
		document.getElementById(name+id).style.padding=getBodyScrollTop()+"px 0px 0px 0px";
		document.getElementById(name+id).style.width='100%';
		
		document.getElementById(name+"_"+id).style.width='100%';
		document.getElementById(name+"_"+id).style.height=y;
	}
	else{
		document.getElementById(name+id).style.height=y;
		document.getElementById(name+id).style.padding=getBodyScrollTop()+"px 0px 0px 0px";
		document.getElementById(name+id).style.width=x;
		
		document.getElementById(name+"_"+id).style.height=y;
		document.getElementById(name+"_"+id).style.width=x;
	}

	loadHTML('/photo'+number+'.php?photo='+id+'&name='+name+'&width='+getClientWidth()+'&height='+getClientHeight(),name+id);
	document.getElementById(name+id).style.display='block';	
	document.getElementById(name+"_"+id).style.display='block';		
}
