  /* ************************************************************************************************	*/
  /* MENU CONTROL v.5.5														*/
  /* MJ ROSSI: 2008														*/
  /* ************************************************************************************************	*/
  
  /* ******************************************************	*/
  /* HIGHLIGHTS: 								*/
  /* * CONVERTED THIS ONE TO A CLASS				*/
  /* ******************************************************	*/
  
function dropDownMenu(pName) {
	/* NAMING CONVENTION: mnu{pName} */
	this.name 			= pName;
	this.submenu 		= new Array();
	this.menu 			= new Array();
	this.menuPrevClass 	= new Array();
	this.clearingTO	 	= 0;
	
	/* FUNCTION HOLDER */
	if(!window.FUNCHLD) window.FUNCHLD = new Array();
	var thisInd = window.FUNCHLD.length;
	FUNCHLD[thisInd] = this;
	
	/* GLOBALS */
	var par = parent.par;
 
	// SHOW MENU
	this.mnuShow = function (objId, hovNme, posx, posy, deg) {
		// SHOW THE MENU
		// DO COMMAND SUITABLE FOR BROWSERS
		if (_appl.indexOf("Microsoft")>= 0) {
			cliHeight=document.body.clientHeight, scrTop=document.body.scrollTop;
			cliWidth=document.body.clientWidth, scrLeft=document.body.scrollLeft;}
		else {
			cliHeight=window.innerHeight, scrTop=window.pageYOffset;
			cliWidth=document.body.clientWidth, scrLeft=window.pageXOffset;}

		var obj = document.getElementById(objId);
				
		// FOR THE MENU
		this.mnuHighlight(hovNme, deg, null, obj);
		
		// FOR THE SUBMENU
		if(this.submenu[deg]!=obj) {
			if(this.submenu[deg]) {
				x = deg;
				do {
					this.hideSubMenu(this.submenu[deg]);
					this.submenu[deg] = null;
					x++;
				} while (this.submenu[x]);
			}
		}
		
		this.showSubMenu(obj);
		if(posy+obj.offsetHeight > scrTop+cliHeight)
			{posy=(scrTop+cliHeight)-obj.offsetHeight;}
		if(posx+obj.offsetWidth > scrLeft+cliWidth)
			{posx=(scrLeft+cliWidth)-obj.offsetWidth;}
	
		// position the menu
		obj.style.left=""+posx+"px";
		obj.style.top=""+posy+"px";
		
		// 07-11-2008 FIX THE CRAZY IE BUG ON THE HIGHLIGHT PROBLEMS. IE SUCKS!
		// ALLOW ONLY THOSE WIDTH Lst CLASS TO BE CHANGED
		if(window.IS_IE) {
			// SET ALL THEIR WIDTH TO auto
			var t_objSibling = obj.firstChild;
			// ALL SIBLINGS MUST HAVE IDENTICAL WIDTH
			do {
				if((" "+t_objSibling.className+" ").indexOf(" Lst ")>=0) {
					t_objSibling.style.width = "auto";
				}
			} while (t_objSibling = t_objSibling.nextSibling);

			// RETURN, SET THE WIDTH OF EACH CHILD
			var t_objSibling = obj.firstChild;
			// ALL SIBLINGS MUST HAVE IDENTICAL WIDTH
			do {
				if((" "+t_objSibling.className+" ").indexOf(" Lst ")>=0) {
					var t_width = t_objSibling.offsetWidth;
					t_objSibling.style.width = "" + t_width + "px";
				}
			} while (t_objSibling = t_objSibling.nextSibling);
		}
		
		this.submenu[deg] = obj;
	}
	
	this.mnuHighlight = function(obj, deg, opt, subMenuObj) {
		// HIGHLIGHT THE MENU
		// SCRIPT FOR STRIPTEXT STARTS
		// SET PREVIOUS CLASS TO PAST OBJECT
		if(this.menu[deg]) {
			this.menu[deg].className = this.menuPrevClass[deg];
			this.menu[deg] = null;
		}
		if(this.submenu[deg]!=subMenuObj) 
			this.mnuDoFade(deg);
		
		// CLEAR TIMEOUT
		clearTimeout(this.clearingTO);
		
		// FOR THE CURRENT OBJECT
		if(!opt) {
			var t_string=obj.className;
			if( !(t_strnew=t_string.replace("Cur", "")) ) t_strnew=t_string;
			// SCRIPT FOR STRIPTEXT ENDS
			
			this.menuPrevClass[deg] = obj.className;
			obj.className = t_strnew + " Hov";
			this.menu[deg] = obj;
		}
	}
	
	this.mnuFadeNow = function(deg) {
		// FADE THE MENU
		var name = "mnu" + this.name;
		this.clearingTO = setTimeout("FUNCHLD["+thisInd+"].mnuDoFade(0);", 1000);
		if(this.menu[deg] && !this.submenu[deg]) {
			this.mnuDoFade(deg, 1);
		}
	}
	
	this.mnuDoFade = function(deg, opt) {
		// FADE THE MENU - ACTUAL
		if(this.menu[deg]) {
			this.menu[deg].className = this.menuPrevClass[deg];
			this.menu[deg] = null;
		}
		if(!opt) {
			x = deg;
			while (this.submenu[x]) {
				this.hideSubMenu(this.submenu[x]);
				this.submenu[x] = null;
				
				if(this.menu[x]) {
					this.menu[x].className = this.menuPrevClass[x];
					this.menu[x] = null;
				}
				x++;
			} ;
		}
	}
	
	
	if(!par) var par='.';
	this.t_start=0;
	
	
	//WRITE SUBMENU
	this.createMenu = function(rowmode, smmode, lvl, mlink, label, elemdeep, callsm) {
		var label;
		var t_defclass;
		var name = "mnu" + this.name;
		
		/* PARAMETERS */
		/* 
		   smmode 	= TRUE IF THE MENU ITEM HAS SUBMENU
		   rowmode 	= IF THE MENU ITEM HAS A ROW
		   elemdeep	= ON NO-ROW MODE, 1 MEANS THE LINK WILL OPEN IN NEW WINDOW
				  ON ROW MODE.. redundant in new version
		*/
		
		/* START THE PROCESS */
		if(this.t_start==0) 
			t_defclass="Lst LstSpec"; 
		else 
			t_defclass="Lst";

		// CLICK MENU
		if(smmode==0) { //CLICK MENU
			document.writeln('<DIV CLASS="'+ t_defclass+'" ' +
				'ONMOUSEOVER="' + name + '.mnuHighlight(this,'+lvl+');" ' +
				'ONMOUSEOUT="' + name + '.mnuFadeNow('+lvl+');" ' + '>');
				if(mlink!=null) {
					if(elemdeep==0 || !elemdeep) 
						document.writeln('<A HREF="' +mlink+ '">');
					else if(elemdeep==1) 
						document.writeln('<A HREF="' +mlink+ '" TARGET=_blank>');
		    		}
				document.writeln(label);
			document.writeln('</A></DIV>');
	
		}
		// ITEM THAT WILL SPAWN SUBMENU
		if(smmode==1) {
			t_defclass+= " LstMnued ";
			document.writeln('<DIV CLASS="'+ t_defclass+'" ' +
				'ONMOUSEOVER="' + name + '.mnuShow(\'msub'+ (lvl+1)+'_'+callsm +'\' ,this, '+
					(rowmode==0 ?
						'(eval(RetRoot(this, \'offsetLeft\')) + this.offsetWidth), ' +
						'(eval(RetRoot(this, \'offsetTop\'))) ,'+lvl+');" '
					:
						'(eval(RetRoot(this, \'offsetLeft\'))), ' +
						'(eval(RetRoot(this, \'offsetTop\')) + this.offsetHeight) ,'+lvl+');" ' 
					) +
				'ONMOUSEOUT="' + name + '.mnuFadeNow('+lvl+', 1);">'
			);
				document.writeln(
					"<SPAN CLASS='rightArr'>></SPAN>" +
					"<A HREF='#' ONCLICK='return false;'>" + 
						label + 
					"</A>");
			document.writeln('</DIV>');
		}
		// DIVIDER
		if (smmode==2 && rowmode==0) 
			document.writeln('<DIV CLASS="divider"></DIV>');
		// SUBHEADER
		if (smmode==3 && rowmode==0) {
			document.writeln('<DIV CLASS="Lst subHdr" ' +
				' ONMOUSEOVER="' + name + '.mnuHighlight(null,'+ lvl +',1);" '+
				' ONMOUSEOUT="' + name + '.mnuFadeNow('+lvl+', 1);">'+
					"<A HREF='#' ONCLICK='return false;'>" + label + "</A>" +
				'</DIV>'
			);
		}
		if(this.t_start==0) 
			this.t_start=1;
	}
	this.startSubMenu = function(isfloat, name, lvl) {
	  this.t_start=0;
		document.writeln('<DIV CLASS="subMnu" '+
			(isfloat ? 'ID="msub'+lvl+'_'+name+'" STYLE="Display:none;"' : "") +
			'>');
	}
	this.endSubMenu = function(isfloat) {
		document.writeln('</DIV>');
	}
	
	
	this.chooseMenu  = function(name) {
		//CHOOSE MENU SHORTCUT
		if(document.getElementById(name)) {
		document.getElementById(name).className="Lst Cur";
		//	document.getElementById(name+"_s").innerHTML="<IMG SRC='"+par+"/images/this-CurAr.gif' WIDTH=12 HEIGHT=15'>";
		}
	 }
	 
	 
	 /* DO ANIMATION */
	 this.showSubMenu = function (pObj) {
		 pObj.style.display = "";
	 }
	 this.hideSubMenu = function (pObj) {
		 pObj.style.display = "none";
	 }

}

/* ABSOLUTE PARENT RETURNER */
/* ABSOLUTE PARENT RETURNER */
if(!this.RetRoot) {
	function RetRoot(pObj, pEnd, pTarget) {
		/* RETURN THE PARENT OF THE object */
		var str = "";
		var strWhole = "0";
		var isTerminate;
		var x = 0;
		
		if(!pTarget) pTarget = document.body;

		/* NOW, THIS IS WHAT THIS WILL DO... THE OFFSETPARENT WILL GO ON 
		   UNTIL IT ENCOUNTERS pTarget */
		do {
			/* SAVE PREVIOUS DATA */
			str = "";
			
			/* COMBINE OFFSETPARENT */
			for (var y=0; y<x; y++) {
				if(str) str += ".";
				str+= "offsetParent"; 
			}
			
			/* COMBINE THE FINAL OBJECT */
			if(str) var parObj = eval("pObj." + str);
			strWhole += " + pObj." + 
				(str ? str + "." : "") + 
				pEnd;
			
			// CHECK IF THE OBJECT IS NOW ON PARENT
			if(parObj == pTarget) break;
			x++;
		} while (!isTerminate);
		
		/* RETURN */
		return eval(strWhole);
	}
}

/* CLASSIC RETPAR */
function RetPar(frste, num, ende) {
	var str="";
	for(var x=0;x<num;x++) {
		str+=frste;
		for (var y=0;y<x;y++) {
			str+=".offsetParent"; 
		}
		str+= ende + "+"; 
	}
	return str + "0";
}