var get = function(id) { return document.getElementById(id); }

document.onkeydown = function cmsSwitch(event)
{
    if (!document.getElementById) 
      return;
	if (window.event) 
      event = window.event; 
	
	if (event.ctrlKey){ 
		var key = (event.keyCode ? event.keyCode : (event.which ? event.which : null) ); 
		if (!key) 
         return; 

		var link = null; 
		if (key == 37) 
			link = get('next_page'); 
		else if (key == 39) 
			link = get('previous_page'); 
		if (link && link.href) 
			document.location = link.href; 
	}else{
		switch (event.keyCode) {
			case 120: window.open('/'); break;
			case 123: document.location.href = admin_uri; break;
		}
	}
}
function zoom(src, w, h) {
	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+20));
	z_window.document.write('<title>Zoom</title><body style="margin:0px;cursor:pointer;" onClick="window.close()">');
	z_window.document.write('<table width="100%" height="100%"><tr><td align="center" valign="center">');
	z_window.document.write('<img src="' + src + '"></td></tr></table></body>');
	z_window.focus();
}

function PopUp(url) {
	var w = 897;
	var h = 581;
	var z_window = window.open(url, z_window, 'left=' + ((screen.width - w)/2) + ',top=' + ((screen.height - h)/2 - 50) + ',width=' + (w) + ',height=' + (h));
	z_window.focus();
}

function openPopup(windowName,playerPath,filePath,date,rubric,title,x,y,id){
	var name=windowName;
	switch (windowName){
		case 'photosPlayer':
			var width=Math.max(Number(x)+25, 360);
			var height=Math.max(455,Number(y)+120);
		break;
		case 'photoPlayer':
			var width=Math.max(Number(x)+25, 360);
			var height=Math.max(360,Number(y)+90);
		break;
		case 'audioPlayer':
			var width=360;
			var height=150;
		break;
		case 'videoPlayer':
			var width=Math.max(Number(x)+25, 345);
			var height=Math.max(360,Number(y)+110);
			if(x=='' || x=='0') x=320;
			if(y=='' || y=='0') y=266;
		break;
		case 'flashPlayer':
			var width=Math.max(Number(x)+25, 345);
			var height=Math.max(360,Number(y)+90);
			if(x=='' || x=='0') x=320;
			if(y=='' || y=='0') y=266;
		break;
	}
	
	var path=playerPath+"?path="+filePath+"&date="+date+"&rubric="+rubric+"&title="+title+"&x="+x+"&y="+y+"&id="+id;
	var left=(window.screen.availWidth/2)-(width/2);
	var top=(window.screen.availHeight/2)-(height/2);
	var param = "scrollbars=nos,status=no,resizable=1,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
	eval(name+'=window.open("'+path+'", "'+name+'", "'+param+'");');
	eval(name+'.focus();');
}