function oImg(sDir, sFileOff, sFileOn, nW, nH, nIniState) {
	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) {
	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 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;
	if( ((nL = (screen.width - nSW) / 2 + nShiftW)) < 0 ) nL = 0;
	if( ((nT = (screen.height - nSH) / 2 + nShiftH)) < 0 ) nT = 0;
	if( nSW > screen.width ) nSW = 0.99 * screen.width;
	if( nSH > screen.height ) nSH = 0.99 * screen.height;
	sPos = ",left=" + nL + ",top=" + nT + ",screenX=" + nL + ",screenY=" + nT;
	switch( sMode ) {
		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('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n');
			swin.document.write('<html xmlns="http://www.w3.org/1999/xhtml" lang="en">\n');
			swin.document.write('<head>\n');
			swin.document.write('<title>Andrea Bartelucci' + ( sTitle.length ? " &nbsp; :: " + sTitle : '' ) + '</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('</head>\n');
			swin.document.write('<body class="wpic">\n');
			swin.document.write('<table border="0" cellspacing="1" id="wcanvas"><tr><td>\n');
			swin.document.write('<table border="0" cellspacing="0" class="wpictab">\n');
			swin.document.write('<tr class="wpictab-t">\n');
			swin.document.write('<td class="left"></td>\n');
			swin.document.write('<td class="center"></td>\n');
			swin.document.write('<td class="right"></td>\n');
			swin.document.write('</tr>\n');
			swin.document.write('<tr class="wpictab-m">\n');
			swin.document.write('<td class="left"></td>\n');
			swin.document.write('<td class="center">\n');
			swin.document.write('<a href="javascript:if( self.opener ) self.opener.focus(); self.close();"><img src="' + sSource + '" width="' + nW + '" height="' + nH + '" alt="' + sTitle + '" title="' + sTitle + '"></a><br>');
			swin.document.write('</td>\n');
			swin.document.write('<td class="right"></td>\n');
			swin.document.write('</tr>\n');
			swin.document.write('<tr class="wpictab-b">\n');
			swin.document.write('<td class="left"></td>\n');
			swin.document.write('<td class="center"></td>\n');
			swin.document.write('<td class="right"></td>\n');
			swin.document.write('</tr>\n');
			swin.document.write('</table>\n');
			swin.document.write('</td></tr></table>\n');
			swin.document.write('</body>\n');
			swin.document.write('</html>\n');
			break;
	}
	swin.focus();
}

function AddBookmark(sUrl, sTitle) {
	if( window.sidebar ) { // firefox
		window.sidebar.addPanel(sTitle, sUrl, "");
	} else if( window.opera && window.print ) { // opera
		var elem = document.createElement('a');
		elem.setAttribute('href', sUrl);
		elem.setAttribute('title', sTitle);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} else if( document.all ) { // ie
		window.external.AddFavorite(sUrl, sTitle);
	}
	return false;
}
