var LinkDivActive = 0;
var timerOn; // Âëàä 29.10.2005
//var timeShowDiv;
var onDiv;
var timeOnDiv;
var layerRef;
var styleRef;
var showVar;
var hideVar;


dom = (document.getElementById) ? true : false;
nn4 = (document.layers) ? true : false;
ie = (document.all) ? true : false;
ie4 = ie && !dom;
Mac = (navigator.appVersion.indexOf("Mac") != -1);
ie4mac = ie4 && Mac;
opera = (navigator.userAgent.indexOf("Opera")!=-1);
Konqueror = (navigator.userAgent.indexOf("Konqueror")!=-1);


function showElem(elemId) {
if (dom) document.getElementById(elemId).style.visibility = "visible";
	else if (ie4) document.all[elemId].style.visibility = "visible";
		else if (nn4) document.layers[elemId].visibility = "show";
}

function hideElem(elemId) {
if (elemId!=null) {

if (dom) document.getElementById(elemId).style.visibility = "hidden";
	else if (ie4) document.all[elemId].style.visibility = "hidden";
		else if (nn4) document.layers[elemId].visibility = "hide";

}

}

function putElem(elemId) {
if (dom) document.getElementById(elemId).style.display = "block";
	else if (ie4) document.all[elemId].style.display = "block";
}

function removeElem(elemId) {
if (elemId!=null) {

if (dom) document.getElementById(elemId).style.display = "none";
	else if (ie4) document.all[elemId].style.display = "none";

}
}


function setLeft(elemId, x) {
 if (dom) document.getElementById(elemId).style.left = x;
	else if (ie4) document.all[elemId].style.left = x;
}



if (navigator.appName == "Netscape") {
 layerRef="document.";
 styleRef="";
 showVar="'show'";
 hideVar="'hide'";

} else {
 layerRef="document.all.";
 styleRef=".style";
 showVar="'visible'";
 hideVar="'hidden'";

}


function clientWidth(){
   return ((nn4)?window.innerWidth-16:((ie)?document.body.clientWidth:0));
}


//Divisions Show | Hide
function hideDiv(divn) {
 hideElem(divn)
 removeElem(divn)
}
function showDiv(divn) {
 showElem(divn);
 putElem(divn);
}


function showLinkDiv(divn, x) {
  timerOn=1;
  if (onDiv==divn) {
	 LinkDivActive=1;
  } else {
	  if (onDiv!=null) {
		  showLinkDiv2(divn, x);
	  } else {
		  timeOnDiv=setTimeout("showLinkDiv2('"+divn+"',"+x+")",500);
	  }
  }
}


function showLinkDiv2(divn, x) {
  if (timerOn==1) {
	x0 = Math.round((clientWidth()-970)/2);
	setLeft(divn, x + x0);

	if (timeOnDiv) clearTimeout(timeOnDiv);
	if (onDiv!=null) hideDiv(onDiv);

	showDiv(divn);
	onDiv = divn;
  }
}

function divTimer() {
 timerOn=0;
 if (onDiv!=null) timeOnDiv = setTimeout("divOut()",500);
}

function divOut() {
 if (LinkDivActive == 0) {
  hideDiv(onDiv);
  if(timerOn==0) onDiv=null;
 } 
}

function LinkDivOver() {
 LinkDivActive = 1;
 clearTimeout(timeOnDiv);
}

function LinkDivOut() {
 LinkDivActive = 0;
 if (onDiv!=null) timeOnDiv = setTimeout("divOut()",500)
}


function chgMenuStyle(obj, mode){
/*  alert('chgMenuStyle '+mode); */
  if(mode=='in'){
     // obj.className = "menu-item-selected";
  } else {
     // obj.className = 'menu-item';
  } 
}

function clickMenu(obj) {
   location.href = obj.getElementsByTagName("A")[0].href;
}

function submenu_item_over(){
	var it = event.srcElement;
	if(it.tagName=='A') {link = it.href; it = it.parentElement;} else {link = it.children(0).href}
	it.id='submenu-selected';	
	it.style.cursor = 'hand';
//        window.status = link;
	return false
}

function submenu_item_out(){
var it = event.srcElement;
if(it.tagName=='A') {link = it; it = it.parentElement;} else {link = it.children(0).href}
it.style.cursor = 'default'; 
it.id='';
return false
}

function submenu_item_click(){
	var it = event.srcElement;
  
	if(it.tagName=='A') {link = it.href;} else {link = it.children(0).href}

	location.href = link;
        
        window.status=link;
        it.style.cursor='wait'; 
        //it.parentElement.style.cursor='wait'; 
        //it.parentElement.parentElement.style.cursor='wait'; 
        document.body.style.cursor='wait';
 
       
}

// -------------------------------------
/* &#239;&#238;&#228;&#241;&#226;&#229;&#242;&#234;&#224; &#228;&#235;&#255; &#225;&#235;&#238;&#234;&#238;&#226; &#226; &#239;&#240;&#238;&#228;&#243;&#234;&#246;&#232;&#232; */

function divruler() {

 if (document.getElementById && document.createTextNode) {
  var tables=document.getElementsByTagName('div');

   for (var i=0;i<tables.length;i++){
    if(tables[i].className=='submenu-item'){

       tables[i].onmouseover=submenu_item_over;
       tables[i].onmouseout=submenu_item_out;
	   tables[i].onclick=submenu_item_click;
    }
  }
 }
}



function init(){
 return divruler();
}

function getEl(elemId){
  if (dom) return document.getElementById(elemId);
  else if (ie4) return document.all[elemId];
  else if (nn4) return document.layers[elemId];
//  else alert('')
}
