var Win=null;

if(document.layers) document.captureEvents(Event.KEYPRESS)
document.onkeypress=kpress; 

function kpress(e){
	key=(document.layers)?e.which:window.event.keyCode
	switch(key){
	case 104: ShowHelp(); break;
	case 113 : CloseHelp();break;
	default : GoSection(key);
	}
	
}

function GoSection(sectionNum){
	switch(sectionNum){
	case 49: document.location="http://surface.gpi.ru/html/info/"; break;
	case 50: document.location="http://surface.gpi.ru/html/science/"; break;
	case 51: document.location="http://surface.gpi.ru/html/products/"; break;	
	case 52: document.location="http://surface.gpi.ru/html/people/"; break;
	case 53: document.location="http://surface.gpi.ru/html/links/"; break;
	case 54: document.location="http://surface.gpi.ru/html/feedback/"; break;	
	default: alert("You've pressed '"+String.fromCharCode(key)+"' key \n Don't know what to do with it :)\n Try pressing 'h' for help...");
}

}

function ShowHelp(){
WinOpen("help window!", 1);
Win.focus();

}

function CloseHelp(){
WinClose();
}

function WinOpen(ref, WhatWin){
Win=window.open("../../includes/help.html",WhatWin,"width=185,height=110,screenx=-40,screeny=10,directories=no,toolbar=no,resizable=yes,menubar=no,scrollbars=no, dependent=yes");
for(i=0;i<=50;i++)Win.moveBy(5,5);
for(i=0;i<=50;i++)Win.resizeBy(0,2);
}

function WinClose(WhatWin){
if((Win != null)&&(!Win.closed)){
for(i=0;i<=50;i++)Win.resizeBy(0,-2);
for(i=0;i<=50;i++)Win.moveBy(-5,-5);
Win.close();
}else{

alert("No window to close!\n Try 'h' for help...");}

}

function killEventHandler()
{
if(document.layers) document.releaseEvents(Event.KEYPRESS)
document.onkeypress=null; 
}

function restoreEventHandler()
{
if(document.layers) document.captureEvents(Event.KEYPRESS)
document.onkeypress=kpress; 
}