function NavigateThrough (event)
{
	if (!document.getElementById) return;
	if (window.event) event = window.event;
	if (event.ctrlKey)
	{
		var link = null;
		var href = null;
		switch (event.keyCode ? event.keyCode : event.which ? event.which : null)
		{
			case 0x25:
				link = document.getElementById ('PrevLink');
				break;
			case 0x27:
				link = document.getElementById ('NextLink');
				break;
			case 0x26:
				link = document.getElementById ('UpLink');
				break;
			case 0x28:
				link = document.getElementById ('DownLink');
				break;
			case 0x24:
				href = '/';
				break;
		}

		if (link && link.href) document.location = link.href;
		if (href) document.location = href;
	}			
}
document.onkeydown = NavigateThrough;


 function OpenImagePopup(imgPath, metaTitle, metaDescription, metaKeywords, imgAlt) {
 	
    var win = window.open('','preview',
    'width=50,height=50,left=0,top=0,screenX=0,screenY=0,resizable=1,scrollbar=0,status=0');
  
    var winDoc = win.document;
    
    var content = '<html><head><title>' + metaTitle + '</title>' +
    				'<META name="Description" content="' + metaDescription + '">' +
					'<META name="Keywords" content="' + metaKeywords + '">' +
    			  '<style>body{overflow: hidden;margin:0;}img{border:0;}</style>' +
    			  '</head><body><a href="javascript:self.close()">' +
    			  '<img alt="' + imgAlt + '" id="image" src="' + imgPath + '" /></a></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+10, h+86);
    	console.log(w, h);
    	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();
}
