var OP=(navigator.userAgent.indexOf('Opera')!=-1);
var IE=(navigator.userAgent.indexOf('MSIE')!=-1) && !OP;
var MZ=(navigator.userAgent.indexOf('Gecko')!=-1);

//function $(id) { return document.getElementById(id); }

function getWindowW() { 
    var b=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
    return (IE)?(b.clientWidth):window.innerWidth; 
}
function getWindowH() { 
    var b=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
    return (IE)?(b.clientHeight):window.innerHeight; 
}
function getDocumentW() { return document.body.offsetWidth; }
function getDocumentH() { return document.body.offsetHeight; }
function getScrollW() { return document.documentElement.scrollWidth; }
function getScrollH() { return document.documentElement.scrollHeight; }



/* для работы анимации меню */
var menuHeight=0;
var menuStepScale=5;
var menuTimer=0;
var menuTimerTimeout=10;
var menuFirstHideTimer=0;
var menuFirstHideTimerTimeout=7*1000;
var menuObj="";
var menuLineObj="";
var menuStep=-1;
/* инициализация меню */
function menuInit() {
	menuObj=document.getElementById("Menu");
	menuLineObj=document.getElementById("MenuLine");
	menuHeight=menuLineObj.offsetHeight;
}
/* обрабатывает нажатия и определяет направление движения */
function menuMove() {
	if (!menuObj) { menuInit(); }
	currentTop=menuObj.offsetTop;
	if (menuFirstHideTimer!=0) { menuEraseFirstHideTimer(); }
	if (menuTimer==0) {
		if (currentTop==0) { menuMover(-1); }
		else { menuMover(1); }
	}
	else {
		menuEraseTimer();
		menuMover(-menuStep);
	}
}
/* производит сдвиг меню и проверяет необходимость следующего сдвига */
function menuMover(step) {
    if (!menuObj) { menuInit(); }
	menuStep=step;
	menuSetCookie(step);
	realStep=step*menuStepScale;
	currentTop=menuObj.offsetTop+realStep;
	timer=true;
	if (currentTop>0) { currentTop=0; timer=false; }
	if (currentTop<-menuHeight) { currentTop=-menuHeight; timer=false; }
	menuObj.style.top=currentTop+"px";
	if (timer) { menuSetTimer(step); }
	else { menuTimer=0; }
}
/* устанавливает следующий сдвиг */
function menuSetTimer(step) {
	menuTimer=setTimeout("menuMover("+step+")",menuTimerTimeout);
}
/* отменяет следующий сдвиг */
function menuEraseTimer() {
	clearTimeout(menuTimer);
}
/* устанавливает таймер на первое скрытие меню */
function menuSetFirstHideTimer() {
    menuFirstHideTimer=setTimeout("menuMover(-1)",menuFirstHideTimerTimeout);
}
/* убирает таймер на первое скрытие меню */
function menuEraseFirstHideTimer() {
	clearTimeout(menuFirstHideTimer);
	menuFirstHideTimer=0;
}
/* установка куки меню */
function menuSetCookie(step) {
    Now = new Date();
    cookieDate = new Date(Now.getFullYear()+1, Now.getMonth(), Now.getDate());
    document.cookie = "PsyhoHideMenu="+step+"; path=/; expires="+cookieDate+" ";
}







