var curSM;				//текущее подменю
var cusSSM;				//текущее под-подменю
var closeTimer;			//таймер, закрывающий подменю
var loginID;			//id таблицы авторизации
//----------------------------------------------------------------
//инициализация вспомогательных переменных
function Init(){
	curSM=null;
	curSSM=null;
	closeTimer=null;
	document.onClick=closeAllMenus;
}
//----------------------------------------------------------------
//реакция на перемещение мышА над пунктом меню
function MenuMouseOver(src){
	dropCloseTimer();
	focusItem(src);
var sm=document.getElementById(src.id+"_SM");
	if(sm!=null){
		if(curSM==null||curSM.id!=sm.id){
			closeMenu(curSM);
			curSM=null;
			closeMenu(curSSM);
			curSSM=null;
			sm.style.display="";
			curSM=sm;
		}
	}else if(curSM!=null&&curSM.id!=src.id+"_SM"){
		closeMenu(curSM);
		curSM=null;
	}
}
//----------------------------------------------------------------
//реакция на уход мышА с пункта меню
function MenuMouseOut(src){
	blurItem(src);
	closeTimer=window.setTimeout(closeAllMenus,750);
}
//----------------------------------------------------------------
//перемещение над пунктом подменю
function sMenuMouseOver(src){
	dropCloseTimer();
//подсвечиваем пункт меню
	focusItem(src);
var ssm=document.getElementById(src.id+"_SM");
	if(ssm!=null){
		if(curSSM==null||curSSM.id!=ssm.id){
			ssm.style.display="";
			closeMenu(curSSM);
			curSSM=ssm;
		}
	}else if(curSSM&&curSSM.id!=src.id+"_SM"){
		closeMenu(curSSM);
		curSSM=null;
	}
}
//----------------------------------------------------------------
//уход с пункта подменю
function sMenuMouseOut(src){
	blurItem(src);
}
//----------------------------------------------------------------
//подсветка пункта
function focusItem(src){
	if(src.className.indexOf("_HL")<0)
		src.className+="_HL";
}
//----------------------------------------------------------------
//выключение подсветки
function blurItem(src){
	src.className=src.className.substring(0,src.className.length-3);
}
//----------------------------------------------------------------
//сброс таймера деактивации
function dropCloseTimer(){
	if(closeTimer!=null){
		window.clearTimeout(closeTimer);
		closeTimer=null;
	}
}
//----------------------------------------------------------------
//закрываем меню
function closeMenu(src){
	if(src!=null)
		src.style.display="none";
}
//----------------------------------------------------------------
//закрываем все меню
function closeAllMenus(){
	closeMenu(curSM);
	curSM=null;
	closeMenu(curSSM);
	curSSM=null;
}
//----------------------------------------------------------------
//смена текущей страницы
function changePage(URL){
	closeAllMenus();
	window.navigate(URL);
}
//----------------------------------------------------------------
//отображение окна опросов
function Polling(){
	showModalDialog("pages/polling.aspx","","dialogWidth=300px;dialogHeight=400px;center=yes;border=thin;maximize=no;minimize=no;help=no;");
}
//----------------------------------------------------------------
function addMatch(){
	closeAllMenus();
	window.open("pages/matchfrm.aspx","AddMatch","center=yes;width=515;height=210");
}
//----------------------------------------------------------------
function addTechicalResults(){
	closeAllMenus();
	window.open("pages/technicalresultsfrm.aspx","TechnicalResults","width=570,height=350");
}
//----------------------------------------------------------------
function addTeamStuff(){
	closeAllMenus();
	window.open("pages/playerfrm.aspx","TeamStaffs","width=570,height=475");
}
//----------------------------------------------------------------
function processTeamStuff(){
	closeAllMenus();
	window.open("pages/teamtotalstaff.aspx","TeamTotalStaff","width=530,height=485");
}
//----------------------------------------------------------------
function addTeam(){
	closeAllMenus();
	window.open("pages/teamfrm.aspx","Teams","width=790,height=640");
}
//----------------------------------------------------------------
function newsProcessing(){
	closeAllMenus();
	window.open("pages/newsprocessing.aspx","Teams","width=790,height=640");
}
//----------------------------------------------------------------
function controlArticles(){
	closeAllMenus();
	window.open("pages/articlescontrolfrm.aspx?siteID=1", "Articles", "width=790,height=620");
}
//----------------------------------------------------------------
function controlNews(){
	closeAllMenus();
	window.open("pages/newscontrolfrm.aspx?siteID=1", "News", "width=700,height=560");
}
//----------------------------------------------------------------
function controlTransfers(TeamID){
	closeAllMenus();
	window.open("pages/transfers.aspx?team=" + TeamID, "Transfers", "width=720,height=520");
}
//----------------------------------------------------------------
function controlAnnounces(){
	closeAllMenus();
	window.open("pages/announcescontrolfrm.aspx", "News", "width=700,height=560");
}
//----------------------------------------------------------------
function showLogin(objectId){
/*
	document.all[objectId].style.left=(document.body.clientWidth-200)/2;
	document.all[objectId].style.visibility='visible';
	document.all['lIO_tbLogin'].value = '';
	document.all['lIO_tbLogin'].focus();
	document.all['lIO_tbPwd'].value = '';
	loginID=objectId;
*/	
}
//----------------------------------------------------------------
function hideLogin(objectId){
/*
	document.all[objectId].style.visibility='hidden';
	document.all['lIO_tbLogin'].value = '_';
	document.all['lIO_tbPwd'].value = '_';
*/
}
//----------------------------------------------------------------
function resizing(){
	if(document.all[loginID])
		document.all[loginID].style.left=(document.body.clientWidth-200)/2;
}
//----------------------------------------------------------------
function startRedirectTimer(){
	window.setInterval("decCnt()", 1000, "JavaScript");
	decCnt();
}
//----------------------------------------------------------------
function showErrorMsg(){
	alert("Неверная пара логин/пароль. Попробуйте ещё раз.");
}