req = false;
if (window.XMLHttpRequest) {
	req = new XMLHttpRequest();
	if (req.overrideMimeType) req.overrideMimeType('text/html');
} else if (window.ActiveXObject) {
	try {
		req = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	}
}

var cursorx = 0;
var cursory = 0;
var tt = 0, op = 0;
var IE = (navigator.appVersion.indexOf("MSIE") != -1 && navigator.systemLanguage);

function HideTip(id)
{
	 document.getElementById(id).style.display='none';
}
	
function ShowTip(id)
{
	 document.getElementById(id).style.display='block';
}

function SavePos(e)
{
	if (e.pageX || e.pageY)
	{
		cursorx = e.pageX;
		cursory = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		cursorx = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
		cursory = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
	}
}
	
function ToolTip(id)
{
	if (cursorx + 150 >  document.body.clientWidth) document.getElementById(id).style.right='12px';
	else document.getElementById(id).style.left=eval(cursorx + 12)+'px';

	document.getElementById(id).style.top=eval(cursory + 12)+'px';
	ShowTip(id);
}

function Showing()
{
	op += 10;
	if(op > 100) clearTimeout(tt);
	else
	{
		if(IE) document.getElementById('bigphoto').filters.alpha.opacity=op; else { document.getElementById('bigphoto').style.opacity=op/100; document.getElementById('bigphoto').style.mozopacity=op/100; }
		tt = setTimeout("Showing()",4);
	}
}

function Closing()
{
	op -= 10;
	if(op <= 0){ clearTimeout(tt); document.getElementById('bigimg').src='/img/works/big/no.jpg'; document.getElementById('bigphoto').style.display='none'; }
	else
	{
		if(IE) document.getElementById('bigphoto').filters.alpha.opacity=op; else { document.getElementById('bigphoto').style.opacity=op/100; document.getElementById('bigphoto').style.mozopacity=op/100; }
		tt = setTimeout("Closing()",4);
	}
}

function ShowPhotoMid(id)
{
	document.getElementById('mid').src = '/img/works/mid/'+id+'.jpg';
	nowid = id;
}

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 ShowPhotoBig(id)
{
	document.getElementById('innerbig').style.marginLeft = '0px';
	document.getElementById('innerbig').style.marginTop = '0px';
	document.getElementById('bigimg').src='/img/works/big/no.jpg';
	if(id != 0) nowid = id; else id = nowid;
	if(id != 0){
		document.getElementById('bigimg').src='/img/works/big/'+id+'.jpg';
		swidth = getClientWidth(); sheight = getClientHeight();
		document.getElementById('bigphoto').style.left=Math.round((swidth-640)/2);
		document.getElementById('bigphoto').style.top=Math.round((sheight-640)/2);
		document.getElementById('bigphoto').style.display='block';
		op = 0;
		tt = setTimeout("Showing()",4);
	}
	return false;
}

function ClosePhotoBig()
{
	clearTimeout(tt);
	op = 100;
	tt = setTimeout("Closing()",4);
//	if(IE) document.getElementById('bigphoto').filters.alpha.opacity=0; else { document.getElementById('bigphoto').style.opacity=0; document.getElementById('bigphoto').style.mozopacity=0; }
	
	return false;
}

var pleft, ptop, realwidth, realheight, sleft, stop;
function ScrollPhoto()
{
	pleft = document.getElementById('bigphoto').style.left; pleft = pleft.replace('px', '');
	ptop = document.getElementById('bigphoto').style.top; ptop = ptop.replace('px', '');
	realwidth = document.getElementById('innerbig').offsetWidth;
	realheight = document.getElementById('innerbig').offsetHeight;
	if(realwidth>600){
		sleft = Math.round(((realwidth-600)/600) * (cursorx - pleft - 19));
		if(sleft>realwidth-600) sleft = realwidth-600;
		if(sleft<0) sleft = 0;
		document.getElementById('innerbig').style.marginLeft = -sleft+'px';
	}
	if(realheight>600){
		stop = Math.round(((realheight-600)/600) * (cursory - ptop - 19));
		if(stop>realheight-600) stop = realheight-600;
		if(stop<0) stop = 0;
		document.getElementById('innerbig').style.marginTop = -stop+'px';
	}
// document.getElementById("divabout").innerHTML = 'cursorx:'+cursorx+' cursory:'+cursory+' pleft:'+pleft+' ptop:'+ptop+' realwidth:'+realwidth+' realheight:'+realheight+' sleft:'+sleft+' stop:'+stop;
}

function get_about(id) {
	if(nowabout != id)
	{
	nowabout = id;
	document.getElementById("divabout").innerHTML = 'Загрузка ...';
	req.open('GET', "/get_about.php?id="+id, true);
	req.setRequestHeader("Accept-Language", "ru, en");
	req.setRequestHeader("Accept-Charset", "windows-1251;q=1, koi8-r;q=0.6, ISO-8859-5;q=0.4, ISO-8859-1;q=0.1");
	req.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
	req.send(null);
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				var resp = req.responseText;
				if (req.status == 200) document.getElementById("divabout").innerHTML = resp;
			}
		}
	}
}