var evt_cm = true, evt_md = true, evt_mm = true, evt_ul = true, msec = 50;
var brwObj, mouseX, mouseY, docX, docY, winObj, winPop = "popWin", winPic = "popPic";

window.onresize = resize;

brw = new Browser();

function Browser()
{
	var x, n;
	var xpl	= /MSIE ?(\d(\.[0-9]+)*)/gi;
	var nsc	= /Netscape ?(\d)?\/(\d(\.[0-9]+)*)/gi;
	var moz	= /Mozilla/gi;
	var opr	= /Opera/gi;

	this.nua	= navigator.userAgent;
	this.nav	= navigator.appVersion;
	this.ver	= (x=xpl.test(this.nua))?RegExp.$1:(n=nsc.test(this.nua))?RegExp.$2:(v=this.nav.indexOf(" "))?this.nav.substr(0,v):this.nav;
	this.dom	= document.getElementById?true:false;
	this.ie4	= !this.dom&&document.all?true:false;
	this.ie5	= x&&this.dom&&parseInt(this.ver)==5?true:false;
	this.ie6	= x&&this.dom&&parseInt(this.ver)==6?true:false;
	this.ie	= this.ie4||this.ie5||this.ie6;
	this.ns4	= !this.dom&&document.layers?true:false;
	this.ns6	= n&&this.dom&&parseInt(this.ver)==6?true:false;
	this.ns7	= n&&this.dom&&parseInt(this.ver)==7?true:false;
	this.ns	= this.ns4||this.ns6||this.ns7;
	this.op  = opr.test(this.nua)&&parseInt(this.ver)>=5?true:false;
	this.moz = !this.ie&&!this.ns&&!this.op&&moz.test(this.nua)?true:false;

	this.ok	= this.ie5||this.ie6||this.ns||this.moz;

	this.span = span;
	this.span();

	if (this.ns)	document.captureEvents(Event.MOUSEMOVE|Event.MOUSEDOWN);
	if (evt_cm)	document.oncontextmenu = contextMenu;
	if (evt_md)	document.onmousedown = mouseDown;
	if (evt_mm)	document.onmousemove = mouseMove;
	if (evt_ul)	window.onunload = unload;

	eval("brwObj = this;");

	return this;
}

function span()
{
	if (this.nua)
	{
		if (this.ns || document.body != null)
		{
			this.width	= this.ns?window.innerWidth:document.body.clientWidth;
			this.height	= this.ns?window.innerHeight:document.body.clientHeight;
		}
	}
	else if (this.css)
	{
		var moz14 = false;
		if ((brwObj.ns7 && brwObj.ver > 7) || brwObj.moz)
		{
			moz14 = true;
			cs = document.defaultView.getComputedStyle(this.element,'');
			tw = parseInt(cs.getPropertyValue('width'));
			th = parseInt(cs.getPropertyValue('height'));
		}
		if (!this.width)	this.width	= brwObj.ns4?this.css.document.width:moz14?tw:this.element.offsetWidth;
		this.height	= brwObj.ns4?this.css.document.height:moz14?th:this.element.offsetHeight;
	}
}

function contextMenu(evt)
{
	return false;
}

function mouseDown(evt)
{
	if (evt && evt.which != 1)	return false;
	return true;
}

function mouseMove(evt)
{
	if (brwObj && (brwObj.ns || brwObj.moz))
		{ docX = window.pageXOffset; docY = window.pageYOffset; mouseX = evt.pageX; mouseY = evt.pageY; }
	else
		{ docX = document.body.scrollLeft; docY = document.body.scrollTop; mouseX = event.x+docX; mouseY = event.y+docY; }
}

function resize()
{
	location.reload();
}

function unload()
{
	if (winObj && !winObj.closed)	winObj.close();
}

function openWindow(url,posX,posY,width,height,config)
{
	if (winObj && !winObj.closed)	winObj.close();

	var data = "left="+posX;
	data+= ",top="+posY;
	data+= ",width="+width;
	data+= ",height="+height;
	data+= ","+(config?config:"scrollbars=no,resizable=no");

	winObj = window.open(url,winPop,data);
	if (parseInt(navigator.appVersion) >= 4)	winObj.focus();

	return winObj;
}

function fullpicture(imgname,text)
{
  if (text!="") {
    popup=window.open("foto.php?imgname="+imgname+"&text="+text , "foto" , "width=420,height=640,screenX=50,screenY=50,left=50,top=50,scrollbars=no,status=no,toolbar=no,location=no,directories=no,resizable=no,menubar=no");
  } else {
    popup=window.open("foto.php?imgname="+imgname+"&text="+text , "foto" , "width=420,height=600,screenX=50,screenY=50,left=50,top=50,scrollbars=no,status=no,toolbar=no,location=no,directories=no,resizable=no,menubar=no");
  }
  popup.focus();
}
