var BR_VER="Unknown";

function detVer() {
	var detVer="Unknown";
	if (document.layers) {
		detVer="NSOld";
	} else if ((!document.all)&&(window.scrollY||(window.scrollY==0))) {
		detVer="NSNew";
	} else if (document.all&&(document.body.scrollTop||(document.body.scrollTop==0))) {
		detVer="IENew";
	} else if (document.all) {
		detVer="Opera";
	}
	return detVer;
}

function onSmImClick(strImSrc) {
	BR_VER=detVer();
	if ((BR_VER=="Unknown")||(BR_VER=="NSOld")||(BR_VER=="Opera")) {
		if (screen.availWidth&&screen.availHeight) {
			showBigImInDivOrWin(strImSrc, Math.floor(screen.availWidth*3/4), Math.floor(screen.availHeight*3/4));
		} else {
			showBigImInDivOrWin(strImSrc, 640, 480);
		}
	} else {
		if (document.images["bigImImg"]) {
			if (document.getElementById("waitDiv").style.visibility!="visible") {
				preShow();
				document.images["bigImImg"].src=strImSrc;
			} else {
				alert("previous image slide is not shown yet");
			}
		} else {
			showBigImInDivOrWin(strImSrc, 640, 480);
		}
	}
}

function showBigImDiv(strImSrc) {
	BR_VER=detVer();
	if ((BR_VER=="NSNew")||(BR_VER=="IENew")) {
		var theImSrc2=document.images["bigImImg"].src;
		var theImSrc2su=theImSrc2.substr(theImSrc2.length-9, 9);
		theImSrc2su=theImSrc2su.toUpperCase();
		if ((strImSrc!="http://universum-a.ru/images/dot.gif")&&(strImSrc!="/images/dot.gif")&&(theImSrc2!="http://universum-a.ru/images/dot.gif")&&(theImSrc2!="/images/dot.gif")&&(theImSrc2su!="dot.GIF")) {
			var doMark=false;
			if (document.images["bigImImg"]) {
				var intImWidth=document.images["bigImImg"].width;
				var intImHeight=document.images["bigImImg"].height;
				doMark=true;
			} else {
				var intImWidth=640;
				var intImHeight=480;
				doMark=true;
			}
			if (doMark) {
				showBigImInDivOrWin(strImSrc, intImWidth, intImHeight);
			}
		}
	}
}

function showBigImInDivOrWin(strImSrc, intImWidth, intImHeight) {
	BR_VER=detVer();
	var theScrollY=0;
	var theScrollX=0;
	if (BR_VER=="NSNew") {
		theScrollY=parseInt(window.scrollY);
		theScrollX=parseInt(window.scrollX);
	} else if (BR_VER=="IENew") {
		theScrollY=parseInt(document.body.scrollTop);
		theScrollX=parseInt(document.body.scrollLeft);
	}
	var avWidth=640;
	if (BR_VER=="NSOld"||BR_VER=="NSNew"||BR_VER=="Opera") {
		avWidth=window.innerWidth;
	} else if (BR_VER=="IENew") {
		avWidth=document.body.clientWidth;
	}
	var avHeight=480;
	if (BR_VER=="NSOld"||BR_VER=="Opera") {
		avHeight=screen.availHeight;
	} else if (BR_VER=="NSNew") {
		avHeight=window.innerHeight;
	} else if (BR_VER=="IENew") {
		avHeight=document.body.clientHeight;
	}
		var posX=(avWidth-(intImWidth))/2+theScrollX;
		if (posX<theScrollX) {posX=theScrollX}
		var posY=(avHeight-(intImHeight))/2+theScrollY;
		if (posY<theScrollY) {posY=theScrollY}
	if (BR_VER=="NSNew"||BR_VER=="IENew") {
		document.getElementById("waitdiv").style.left="-1000";
		document.getElementById("waitdiv").style.top="-1000";
		document.getElementById("waitdiv").style.visibility="hidden";
		var imDiv=document.getElementById("bigImDiv");
		imDiv.style.left=posX;
		imDiv.style.top=posY;
		if (document.getElementById("searchsort")) {document.getElementById("searchsort").style.visibility="hidden";}
		imDiv.style.visibility="visible";
	} else if (BR_VER=="NSOld") {
		var imNeoVin=window.open("", "ourBigImWin", "left="+posX+",top="+posY+",width="+(intImWidth+28)+",height="+(intImHeight+28)+",directories=no,location=no,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no,scrollbars=yes");	
		imNeoVin.document.open();
		imNeoVin.document.writeln("<HTML><BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 onClick='self.close();'>");
		imNeoVin.document.writeln("<TABLE WIDTH='100%' HEIGHT='100%' BORDER='0' CELLPADDING='10' CELLSPACING='0' BORDERCOLOR='#d19640' BGCOLOR='#063322' ALIGN='center' VALIGN='middle' STYLE='border-style:double;border-width:6px;border-color:#d19640;'><TR><TD WIDTH='100%' HEIGHT='100%' ALIGN='center' VALIGN='middle'><A HREF='' onClick='self.close(); return false;'><IMG ID='bigImImg' BORDER='0' SRC='"+strImSrc+"' alt=''></A></TD></TR></TABLE>");
		imNeoVin.document.writeln("</BODY></HTML>");
		imNeoVin.document.close();
	} else if (BR_VER=="Opera") {
		var tmpImg=new Image;
		tmpImg.src=strImSrc;
		var imNeoVin=window.open("", "ourBigImWin", "left="+posX+",top="+posY+",width="+(intImWidth+28)+",height="+(intImHeight+28)+",directories=no,location=no,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no,scrollbars=yes");	
		imNeoVin.document.open();
		imNeoVin.document.writeln("<HTML><BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 BGCOLOR='#063322' onClick='self.close();'>");
		imNeoVin.document.writeln("<IMG ID='bigImImg' BORDER='0' SRC='"+tmpImg.src+"'>");
		imNeoVin.document.writeln("</BODY></HTML>");
		imNeoVin.document.close();
		imNeoWin.title=" ";
	} else {
		alert("Sorry, but we can't detect your browser version and/or capabilities to display image.");
	}
}

function hideBigImInDiv() {
	var imDiv=document.getElementById("bigImDiv").style;
	imDiv.visibility="hidden";
	imDiv.left=-1000;
	imDiv.top=-1000;
        if (document.getElementById("searchsort")) {document.getElementById("searchsort").style.visibility="inherit";}
}

function preShow() {	
	var BR_VER="Unknown";
	if (document.layers) {
		BR_VER="NSOld";
	} else if ((!document.all)&&(window.scrollY||(window.scrollY==0))) {
		BR_VER="NSNew";
	} else if (document.all&&(document.body.scrollTop||(document.body.scrollTop==0))) {
		BR_VER="IENew";
	} else if (document.all) {
		BR_VER="Opera";
	}
	var theScrollY=0;
	var theScrollX=0;
	if (BR_VER=="NSNew") {
		theScrollY=parseInt(window.scrollY);
		theScrollX=parseInt(window.scrollX);
	} else if (BR_VER=="IENew") {
		theScrollY=parseInt(document.body.scrollTop);
		theScrollX=parseInt(document.body.scrollLeft);
	}
	if ((BR_VER=="NSNew")||(BR_VER=="IENew")) {
		var avWidth=640;
		var avHeight=480;
		if (BR_VER=="NSOld"||BR_VER=="Opera") {
			avHeight=screen.availHeight;
		} else if (BR_VER=="NSNew") {
			avHeight=window.innerHeight;
		} else if (BR_VER=="IENew") {
			avHeight=document.body.clientHeight;
		}
		var posX=Math.floor((avWidth/2)+theScrollX);
		if (posX<theScrollX) {posX=theScrollX}
		var posY=Math.floor((avHeight/2)+theScrollY);
		if (posY<theScrollY) {posY=theScrollY}
		document.getElementById("waitdiv").style.left=posX;
		document.getElementById("waitdiv").style.top=posY;
		document.getElementById("waitdiv").style.visibility="visible";
	}
}

