var BM2={
//////////////////////////////////////
// kell hozzá: BM2_almenuk[] tömb!!!
//////////////////////////////////////
menuDelay: 500,
ani_speed: 10, //(kisebb szám=gyorsabb)
ani_time: 20, //(kisebb szám=gyorsabb)
//////////////////////////////////////
rejtID: null,
timerOn : false,
next:"",
activ_menuItem:"",
offsw: 0,
offsh: 0,
temp_hided_selbox:new Array(),
//////////////////////////////////////

mutat: function(id){
	if(this.timerOn==true)
	{
		this.next=id;
	}
	else
	{
		this.next="";
		this.hideAll();
		this.showDiv(id);
		this.activ_menuItem=id;
	}		
},

rejt_delayed: function(){
	this.hideAll();
	this.next_mutat();
	this.timerOn = false;
	this.rejtID=null;
},

rejt: function(){
	if (this.timerOn == false)
	{
		this.timerOn = true;
		this.rejtID=setTimeout( "BM2.rejt_delayed()", this.menuDelay);
	}
},

next_mutat: function(){
	this.hideAll();
	if(this.next!="")
	{
		this.showDiv(this.next);
		this.activ_menuItem=this.next;
	}
},

showDiv: function(id){
	var obj;
	if(document.all && !window.opera)
	{
		obj=document.all[id];
	}
	else
	{
		obj=document.getElementById(id)
	}
	
	if(this.activ_menuItem!=id || this.next=="")
	{
		obj.style.display='block';
		this.get_offsw(id);
		this.get_offsh(id);
		obj.style.width="0";
		obj.style.height="0";
		this.mutat_ani(id);
	}
	else
	{
		obj.style.display='block';
	}

	//hide and save selectboxes in IE4-6:
	if(document.all && !window.opera && typeof document.body.style.maxHeight == "undefined")
	{
		var selects = document.all.tags('select');
		var i;
		var sl=selects.length;
		for(i=0;i<sl;i++)
		{
			if(selects[i].style.visibility!="hidden" && selects[i].style.display!="none")
			{
				selects[i].style.visibility="hidden"
				this.temp_hided_selbox.push(selects[i]);
			}
		}//end for		
	}
},

get_offsw: function(id){
	if(document.all && !window.opera)
	{
		if(document.all(id).offsetWidth)
		{
			this.offsw=document.all(id).offsetWidth
		}
	}			
	else
	{
		if(document.getElementById(id).offsetWidth)
		{
			this.offsw=document.getElementById(id).offsetWidth
		}
	}
},

get_offsh: function(id){
	if(document.all && !window.opera)
	{
			if(document.all(id).offsetHeight)
			{
				this.offsh=document.all(id).offsetHeight
			}
	}
	else
	{
			if(document.getElementById(id).offsetHeight)
			{
				this.offsh=document.getElementById(id).offsetHeight
			}
	}
},

mutat_ani: function(id){
	var elm;
	if(document.all && !window.opera)
  	{
		elm=document.all[id];
  	}
	else
  	{
		elm=document.getElementById(id);
  	}

  	if (parseInt(elm.style.width,10) < this.offsw || parseInt(elm.style.height,10) < this.offsh)
	{
    		if (parseInt(elm.style.width,10) < this.offsw )
    		{
    			elm.style.width = (parseInt(elm.style.width,10)+(this.offsw/this.ani_speed) )+"px";
    		}
    		if (parseInt(elm.style.height,10) < this.offsh)
    		{
    			elm.style.height = (parseInt(elm.style.height,10)+(this.offsh/this.ani_speed))+"px";
    		}
    		var aniID = setTimeout('BM2.mutat_ani("'+id+'")',this.ani_time);
    	}	
  	else
  	{
  		clearTimeout(aniID);
  	}
},

hideAll: function(){
	if(BM2_almenuk.length>0)
	{
		var i;
		var il=BM2_almenuk.length
		for (i=0;i<il;i++)
		{
			if(document.all && !window.opera)
			{
				var obj=document.all[BM2_almenuk[i]];
			}
			else
			{
				var obj=document.getElementById(BM2_almenuk[i])
			}			
			obj.style.display='none';
		}
	}
	
	//Show hided selectboxes in IE4-6:
	if(document.all && !window.opera && typeof document.body.style.maxHeight == "undefined")
	{
		var i;
		var sl=this.temp_hided_selbox.length;
		for(i=0;i<sl;i++)
		{
			this.temp_hided_selbox[i].style.visibility="visible"
		}		
		
	}
	
	//empty array
	this.temp_hided_selbox.splice(0,this.temp_hided_selbox.length) 	
},

hideAllDiv:function ()
{
	this.next="";
}

}//end class














//***** FLOATINGDIV *********

var FLOATINGDIV={
/////////////////////
fm_id : 'floatdiv', 	//Az úszó div id-je
fromTop: 190, 		//távolság (és indítás) az ablak felső részétől)
fromLeft: 0, 		//távolság (és indítás) az ablak (menü div) bal szélétől)
////////////////////
target_x : 0,
target_y : 0,
fm_shift_x : "",
fm_shift_y : "",
fm_next_x : "",
fm_next_y : "",
has_inner : typeof(window.innerWidth) == 'number',
has_element : document.documentElement && document.documentElement.clientWidth,
floating_menu : "",
move: false,

move_menu: function(){

   if(this.move==true)
   {
	var scroll_y = this.has_inner ? pageYOffset : this.has_element ? document.documentElement.scrollTop : document.body.scrollTop;
	
	var scroll_x = this.has_inner ? pageXOffset : this.has_element ? document.documentElement.scrollLeft : document.body.scrollLeft;
	
	if(scroll_y>this.fromTop)
	{
        	this.floating_menu.style.left =(this.fm_next_x) + 'px';
        	this.floating_menu.style.top = (this.fm_next_y - this.fromTop)+'px';

	}
	
	else if(scroll_x>this.fromLeft)
	{
        	this.floating_menu.style.left = (this.fm_next_x - this.fromLeft) +'px';
        		
        	if( (scroll_y - this.fm_next_y)>this.fromTop)
        	{        		
        		this.floating_menu.style.top = this.fm_next_y  + 'px';
        	}
        	else
        	{
        		this.floating_menu.style.top = 0;
        	}
   	}

	else
	{
        	this.floating_menu.style.top = 0;
        	this.floating_menu.style.left = 0;
	}
   }	
   else
   {
   	return;
   }
},

compute_shifts: function(){

   if(this.move==true)
   {

	this.fm_shift_x = this.has_inner ? pageXOffset : this.has_element ? document.documentElement.scrollLeft : document.body.scrollLeft;
    	if (this.target_x < 0)
    	{
    		this.fm_shift_x += this.has_inner ? window.innerWidth : this.has_element ? document.documentElement.clientWidth : document.body.clientWidth;
    	}
    	this.fm_shift_y = this.has_inner ? pageYOffset : this.has_element ? document.documentElement.scrollTop : document.body.scrollTop;
       	if (this.target_y < 0)
    	{
        	this.fm_shift_y += this.has_inner ? window.innerHeight : this.has_element ? document.documentElement.clientHeight : document.body.clientHeight;
	}
   }
   else
   {
   	return;
   }

},

float_menu: function(){
   if(this.move==true)
   {
	var step_x, step_y;
    	this.compute_shifts();
    	step_x = (this.fm_shift_x + this.target_x - this.fm_next_x) * .07;
    	if (Math.abs(step_x) < .5)
    	{
        	step_x = this.fm_shift_x + this.target_x - this.fm_next_x;
        }
    	step_y = (this.fm_shift_y + this.target_y - this.fm_next_y) * .07;
    	if (Math.abs(step_y) < .5)
    	{
        	step_y = this.fm_shift_y + this.target_y - this.fm_next_y;
        }
    	if (Math.abs(step_x) > 0 || Math.abs(step_y) > 0)
    	{
        	this.fm_next_x += step_x;
        	this.fm_next_y += step_y;
        	this.move_menu();
    	}
    	var timerID=setTimeout('FLOATINGDIV.float_menu()', 20);
   }
   else
   {
   	return;
   }  
},


windowSize: function()
{
  	var myWidth = 0, myHeight = 0;
  	if( typeof( window.innerWidth ) == 'number' )
  	{
    		//Non-IE
   	 	myWidth = window.innerWidth;
    		myHeight = window.innerHeight;
  	}
  	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
 	{
    		//IE 6+ in 'standards compliant mode'
    		myWidth = document.documentElement.clientWidth;
    		myHeight = document.documentElement.clientHeight;
  	}
  	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
  	{
    		//IE 4 compatible
    		myWidth = document.body.clientWidth;
    		myHeight = document.body.clientHeight;
  	}
  	return {w:myWidth, h:myHeight}
},

getScrollerWidth: function ()
{
    	var scr = null;
    	var inn = null;
   	var wNoScroll = 0;
   	var wScroll = 0;
    	scr = document.createElement('div');
   	scr.style.position = 'absolute';
   	scr.style.top = '-1000px';
   	scr.style.left = '-1000px';
    	scr.style.width = '100px';
    	scr.style.height = '50px';
    	scr.style.overflow = 'hidden';
    	inn = document.createElement('div');
    	inn.style.width = '100%';
    	inn.style.height = '200px';
    	scr.appendChild(inn);
    	document.body.appendChild(scr);
    	wNoScroll = inn.offsetWidth;
    	scr.style.overflow = 'auto';
    	wScroll = inn.offsetWidth;
    	document.body.removeChild(document.body.lastChild);
    	return (wNoScroll - wScroll);
},


start: function(){

	if(document.getElementById)
	{
		this.floating_menu=document.getElementById(this.fm_id)
	}
	else if(document.all)
	{
		this.floating_menu=document.all[this.fm_id]
	}
	else
	{
		return;
	}
	
	//Csak akkor induljon, ha az ablak magassága nagyobb, mint a menü magassága
	if( this.floating_menu.offsetHeight < (this.windowSize().h - this.getScrollerWidth()) )
	{
		this.move=true;
		this.compute_shifts();
    		this.fm_next_x = this.fm_shift_x + this.target_x;
    		this.fm_next_y = this.fm_shift_y + this.target_y;
    		this.move_menu();
		this.float_menu();
	}
	else
	{
		this.target_x = 0;
		this.target_y = 0;
		this.fm_shift_x = "";
		this.fm_shift_y = "";
		this.fm_next_x = "";
		this.fm_next_y = "";
        	this.floating_menu.style.top = 0;
       	 	this.floating_menu.style.left = 0;
		this.fm_shift_x=0;
		this.fm_shift_y=0;
		this.fm_next_x =0;
		this.fm_next_y =0;
		
		this.move=false;
	}

}

}//end class

//////////////////////////////
