var get = function(id) { return document.getElementById(id); }

function cmsSwitch() {
	if(event.keyCode == 123) document.location.href = admin_uri;
}

function zoom(link, title)
{
    var win = window.open('','preview','width=50,height=50,left=0,top=0,screenX=0,screenY=0,resizable=no,scrollbar=no,status=no,menubar=no,titlebar=no,location=no,scrolling=no');
    var winDoc = win.document;
    var content = '<html><head><title>' + title + '</title>' + 
    '<style>body{overflow: auto; padding:0; margin:0}img{border:0;}div{padding:5px; margin: 0 5px;}*div{padding:5px; margin: 0 5px;}html>body div {padding:0px 5px; margin: 0 5px;}</style>' + '</head><body><div><a href="javascript:self.close()">' +
    '<img alt="' + title + '" id="image" title="Закрыть" src="' + link + '" /></a></div></body></html>';
    win.document.write(content);
    winDoc.body.onload = function() {
			var obj = winDoc.getElementById('image');
			var w = obj.width, h = obj.height;
			
			var iHeight= document.body.clientHeight, iWidth = self.innerWidth;
			var left = (self.opera ? iWidth : screen.availWidth)/2 - w/2;
			var top = (self.opera ? iHeight : screen.availHeight)/2 - h/2;

			win.resizeTo(w+25, h+80);
			
			win.moveTo(left, top);
    }
    win.onload = winDoc.body.onload; // special for Mozilla
    // !!! Important statement: popup onload won't execute without it!
    win.document.close();
    win.focus();
}


function photo(url, comment) {
	var w = 800;
	var h = 600;

	var z_window = window.open('about:blank', z_window, 'left=' + ((screen.width - w)/2) + ',top=' + ((screen.height - h)/2 - 50) + ',width=' + (w+20) + ',height=' + (h+80));
	z_window.document.write('<title>Zoom</title><body style="margin:0px;cursor:pointer;font-family:arial;font-size:12px" onClick="window.close()">');
	z_window.document.write('<table width="100%" height="100%"><tr><td align="center" valign="center" style="font-family:arial;font-size:12px">');
	z_window.document.write('<img src="/thumb/' + w + 'x' + h + 'xNormal/' + url + '"><p>' + comment + '</p></td></tr></table></body>');
	z_window.focus();
}

