var ver = VerCheck();

function VerCheck(){
	var ver = 0;
	var bName = navigator.appName;
	var bVer = parseInt(navigator.appVersion);

	if (bName == "Netscape" && bVer >= 3) ver = bVer;
	else{
		if (bName == "Microsoft Internet Explorer" && bVer >= 4) ver = bVer;
		else ver = 0;
		}
	return ver;
	}

function oImg(sDir, sFileOff, sFileOn, nW, nH, nIniState){
	if (ver){
		this.nState = nIniState;
		this.oOff = new Image(nW, nH);
		this.oOff.src = sDir + sFileOff;
		this.oOn = new Image(nW, nH);
		this.oOn.src = sDir + sFileOn;
		}
	}

function SwapImg(sName){
	if (ver){
		var oImg = eval(sName);
		if( oImg.nState ){
			document.images[sName].src = oImg.oOff.src;
			oImg.nState = 0;
			}
		else{
			document.images[sName].src = oImg.oOn.src;
			oImg.nState = 1;
			}
		}
	}

var swin;

function showwin(nW, nH, sSource, sMode, nSkip, nShiftW, nShiftH, sTitle, sWinName){
	var nL = 0;
	var nT = 0;
	var nHB = 0;
	var sPos = "";

	if( !sMode ) sMode = "pic";
	if( !nSkip ) nSkip = 0;
	if( !nShiftW ) nShiftW = 0;
	if( !nShiftH ) nShiftH = 0;
	if( !sWinName ) sWinName = "swin";
	nW = parseInt(nW);
	if( isNaN(nW) ) nW = 620;
	nH = parseInt(nH);
	if( isNaN(nH) ) nH = 460;
	nSW = nW + nSkip;
	nSH = nH + nSkip + nHB;
	if( ((nL = (screen.width - nSW) / 2 - nShiftW)) < 0 ) nL = 0;
	if( ((nT = (screen.height - nSH) / 2 + nShiftH)) < 0 ) nT = 0;
	if( ver >= 4 ) sPos = ",left=" + nL + ",top=" + nT + ",screenX=" + nL + ",screenY=" + nT;
	switch( sMode ){
		case "url":
			sParams = "width=" + nSW + ",height=" + nSH + ",menubar=no,location=no,toolbar=no,status=no,resizable=no,scrollbars=yes";
			break;
		case "pic":
		default:
			sParams = "width=" + nSW + ",height=" + nSH + ",menubar=no,location=no,toolbar=no,status=no,resizable=no,scrollbars=no";
			break;
		}
	if( swin ) swin.close();
	swin = window.open("", sWinName, sParams + sPos);
	switch( sMode ){
		case "url":
			swin.location.href = sSource;
			break;
		case "pic":
		default:
			swin.document.write("<html>\n");
			swin.document.write("<head>\n");
			swin.document.write("<title>Стена</title>\n");
			swin.document.write("<meta http-equiv='Content-Type' content='text/html; charset=windows-1251'>\n");
			swin.document.write("<link rel='stylesheet' href='libs/main.css' type='text/css'>\n");
			swin.document.write("<style>\n");
			swin.document.write("a { color: #000000; text-decoration: none; }\n");
			swin.document.write("a:visited { color: #000000; }\n");
			swin.document.write("a:active { color: #000000; }\n");
			swin.document.write("a:hover { color: #000000; }\n");
			swin.document.write("</style>\n");
			swin.document.write("</head>\n");
			swin.document.write("<body bgcolor=#e0c080 text=#000000 link=#000000 alink=#000000 vlink=#000000 marginwidth=0 marginheight=0 leftmargin=0 topmargin=0>\n");
			swin.document.write("<table width=100% height=100% border=0 cellpadding=0 cellspacing=0>\n");

			swin.document.write("<tr align=center><td>");
			swin.document.write("<a href='javascript:if( self.opener ) self.opener.focus(); self.close();'><img src='" + sSource + "' border=1 width='" + nW + "' height='" + nH + "' alt=''></a><br>");
			swin.document.write("</td></tr>\n");

			swin.document.write("</table>\n");
			swin.document.write("</body>\n");
			swin.document.write("</html>\n");
			break;
		}
	swin.focus();
	}

function GetCookieValue(nOffset){
	var nStop = document.cookie.indexOf(";", nOffset);
	if (nStop == -1) nStop = document.cookie.length;
	return unescape(document.cookie.substring(nOffset, nStop));
	}

function GetCookie(sName){
	var i = 0;
	var j = 0;
	while( i < document.cookie.length ){
		j = i + sName.length + 1;
		if( document.cookie.substring(i, j) == sName + "=" ) return GetCookieValue(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
		}
	return null;
	}  

function SetCookie(sName, sValue, dExpires, sPath, sDomain, bSecure){
	document.cookie = sName + "=" + escape(sValue) 
		+ ((dExpires == null) ? "" : ("; expires=" + dExpires.toGMTString())) 
		+ ((sPath == null) ? "" : ("; path=" + sPath)) 
		+ ((sDomain == null) ? "" : ("; domain=" + sDomain)) 
		+ ((bSecure == true) ? "; secure" : "");
	}

function GenRandStr(nChars){
	var sChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
	var sOut = "";
	for( i = 0; i < nChars; ++i ) sOut += sChars.charAt(Math.round(sChars.length * Math.random()));
	return sOut;
	}

function MarkUser(sMCName, nDays){
	var dExpires = new Date();
	dExpires = new Date(dExpires.getTime() + 86400000 * nDays);
	if( sMCValue = GetCookie(sMCName) ){
		if( sUVizits = GetCookie(sMCValue) ) SetCookie(sMCValue, ++sUVizits, dExpires);
		else SetCookie(sMCValue, 1, dExpires);
		}
	else{
		sMCValue = GenRandStr(16);
		SetCookie(sMCName, sMCValue, dExpires);
		SetCookie(sMCValue, 1, dExpires);
		}
	}
