
//** Dali da izpolzwame dom ili all
var useDom=0;


 /**    променливата съдържа, кое меню в момената е селектирано */
    var selectednow = null;
var screenSize=0;

function intParams()
{
if(document.getElementById)
		{
		useDom=1;
		screenSize=window.innerHeight;
		}
	else
if(document.all)
		{
		useDom=2;
		screenSize = document.body.clientWidth + 18;
		}
}

function myGetObject (id)
{
	if (useDom==2)
		return document.all[id];
		else
		if(useDom==1)
	return document.getElementById (id);
	else
	return null;
}

function onofLayer(id,visibility)
{
	myDiv=myGetObject(id);
	if(myDiv==null) return ;
	try
	{
	myDiv.style.visibility=visibility;
	}
	catch (e)
	{
	alert('Could Not Hide/Show layer');
	}							
}


   /**
    *    Тази функция предизвиква презареждане на страницата 
    *    при промяна на размерите на броузера        
    **/
    function reDo()
    { 
        if(document.all)
        {
	       window.location.reload();
        }
        else
        {
		       window.location.replace(self.location.href); 
        }
    }

window.onresize = reDo;

function myGetX (obj)
{
	var x = 0;

	do
	{
		x += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	while (obj);
	return x;
}
function myGetY (obj)
{
	var y = 0;
	do
	{
		y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	while (obj);
	return y;
}
function myGetPosition(id)
{
obj=myGetObject(id);
if(obj==null) return;
 position=new Object();
 position.x=myGetX(obj);
 position.y=myGetY(obj);
 return position;
}
function myGetHeight (obj)
{
	var height = obj.offsetHeight;
	if (height > 0 || !myIsTRNode (obj))
		return height;
	if (!obj.firstChild)
		return 0;
	// use the first child's height
	return obj.firstChild.offsetHeight;
}

function myGetWidth (obj)
{
	var width = obj.offsetWidth;
	if (width > 0 || !myIsTRNode (obj))
		return width;
	if (!obj.firstChild)
		return 0;
	// use the first child's height
	return obj.firstChild.offsetWidth;
}

function myIsTRNode (obj)
{
	var tagName = obj.tagName;
	return tagName == "TR" || tagName == "tr" || tagName == "Tr" || tagName == "tR";
}

function do_action(act)
{
	flag = 0;
	for(i=0 ; i<document.delmov.elements.length; i++)
	{
		if(document.delmov.elements[i].type == "checkbox")
		{
			if(document.delmov.elements[i].checked)
			{
				flag = 1;
			}
		}
	}
	if(flag != 0)
	{
		document.delmov.what.value = act;
		document.delmov.submit();
	}
	else
	{
		alert("Няма нищо избрано");
	}
}

function check_all()
{

	for(i=0 ; i<document.delmov.elements.length; i++)
	{
		if(document.delmov.elements[i].type == "checkbox")
		{
			if(document.delmov.elements[i].checked)
			{
				document.delmov.elements[i].checked = false;
			}
			else
			{
				document.delmov.elements[i].checked = true;
			}
		}
	}
}

function my_menu(menuList,myName)
{
   var menus=menuList;
   var name=myName;
   var relMenus=new Array();
     /**    таймер за скриване и показване на менютата */
    var timerID = null;
    
    /**    таймер: активен или не */
    var timerOn = false;
    
    /**    стойност на таймера в милисекунди */
    var timecount = 700;
this.init=function ()
	{
	for(i=0;i<menus.length;i++)
		{
		relMenus[i]=new Object();
		relMenus[i].id=menus[i]+'_rel';
		
		pos=myGetPosition(menus[i]);
		top_position = pos.y +24;

		obj= myGetObject(relMenus[i].id);

		relMenus[i].div=obj;
		relMenus[i].div.style.visibility="hidden";
		relMenus[i].div.style.position="absolute";

		relMenus[i].div.style.left=pos.x;

		relMenus[i].div.style.top=top_position;
	
		relMenus[i].div.style.width="122px";
		relMenus[i].div.className="showSub"; 
	//	relMenus[i].div.filters[0].Apply();
		}
	}
	
this.hideAll= function ( )
		{
		for(i=0;i<menus.length;i++)
			{
				if(	relMenus[i].div.filters)
				if(	relMenus[i].div.filters[1])
				relMenus[i].div.filters[1].Apply();
			onofLayer(relMenus[i].id,"hidden");
				if(	relMenus[i].div.filters)
				if(	relMenus[i].div.filters[1])
				relMenus[i].div.filters[1].Play();
			}
		}
this.onOver= function (numMenu)
		{
		this.stopTime();
		this.hideAll();
		if(	relMenus[numMenu].div.filters)
				if(	relMenus[numMenu].div.filters[0])
				relMenus[numMenu].div.filters[0].Apply();
		onofLayer(relMenus[numMenu].id,"visible");	
		if(	relMenus[numMenu].div.filters)
		{
		if(	relMenus[numMenu].div.filters[0])
		relMenus[numMenu].div.filters[0].Play();
		}
		}
this.onOut=function ()
	{
	this.startTime();
	}
		
		  /**
    *    Чрез тази функция се активира таймера
    **/
 this.startTime=function  ( ) 
    {
        if (timerOn == false) 
        {
            timerID=setTimeout( name+".hideAll()" , timecount);
            timerOn = true;
        }
    }
    
    /**
    *    Чрез тази функция се деактивира таймера
    **/
this.stopTime=function ( ) 
    {
        if (timerOn) 
        {
            clearTimeout(timerID);
            timerID = null;
            timerOn = false;
        }
    }
}