function Folder(ID,parentID,Order,Level,SubFolders,EditNav,WebNav,IsUrl,IsSelected,Title,Link,Target,Html,Description,ImageReferens,LinkImageReferens){
	this.name = "folder"+ID	// Id	
	this.id = ID
	this.parentid = parentID
	this.parent =  (ID>0)? eval("folder"+parentID):null;			
	this.order = Order
	this.level = Level
	this.subfolders = SubFolders
	this.editnav = (EditNav==0||EditNav==false)? false:true
	this.webnav = (WebNav==0||WebNav==false)? false:true	
	this.isurl = (IsUrl == 0||IsUrl==false)? false:true
	this.selected = (IsSelected==0||IsSelected==false)? false:true
	this.title = Title
	this.link = Link
	this.target = Target
	this.description = Description
	this.html = Html
	this.imgRef = ImageReferens
	this.linkImgRef = LinkImageReferens		
	this.subfoldercount = 0
	this.subfolderArray = new Array();
	this.selectedfoldersArray = new Array();
	
	this.obj = this.name + "FolderObject"
	eval(this.obj + "=this")
	this.addToParent = FolderAddToParentFolder		
	this.IsParent = FolderIsParent
	this.IsChildren = FolderIsChildren
	this.getParentsArray = FolderParentsArray
	this.getChildrensArray = FolderChildrensArray
	this.getSubFoldersTree = FolderSubFoldersTree
	this.setSelectedFolders = FolderSelectedFolders
	this.getSubFoldersImages = FolderSubFoldersWithImages
	
	this.addToParent();
	this.setSelectedFolders();
	
	//Array global con todos los folder ordenados!!
	
	foldersObjArray[foldersObjArrayCount] = this
	foldersObjArrayCount++
	
	this.subFoldersHTML = ""
	this.getSubFoldersHTML = FolderSubFoldersHTML;
	this.getRegisterSubFoldersHTML = FolderRegisterSubFoldersHTML;	
	
	this.build = FoldersBuild
	this.dropdown = FolderDropDown
	this.setBgColor = FolderSetBgColor	
	this.loadLocation = FolderLoadLocation;
	
	this.show = FolderShow
	this.hide = FolderHide	
	
	this.subFoldersTopHTML = "";
	this.subFoldersSubHTML = "";
	this.getSubFoldersDropDownHTML = FolderSubFoldersDropDownHTML	
	
}

function FolderAddToParentFolder(){
	if(this.parentid>-1 && this.webnav){
		parentFolder = eval('folder'+this.parentid)
		parentFolder.subfolderArray[parentFolder.subfoldercount] = this;
		parentFolder.subfoldercount = parentFolder.subfolderArray.length;
	}
}

function FolderSelectedFolders(){
	if(this.selected==1){
		this.selectedfoldersArray = this.getParentsArray();
		this.selectedfoldersArray[this.selectedfoldersArray.length] = this;
		for(var i=0; i<this.selectedfoldersArray.length;i++){
			this.selectedfoldersArray[i].selected = true;
		}
	}
}

function FolderIsParent(oFolder){
	var vIsTrue = 0
	for (var i = oFolder.level; i > 0; i--){
		if(this.id == oFolder.parentid) {
			vIsTrue = 1;
			break
		} 
		else {
			oFolder = eval('folder'+oFolder.parentid);
		}
	}
	return (vIsTrue == 1)? true:false
}

function FolderIsChildren(oFolder){
	return oFolder.IsParent(this)
}

function FolderParentsArray(){
	var oParentsArray = new Array();
	oFolder = this
	for (var i = this.level; i > 0; i--){
		oFolder	= eval('folder' + oFolder.parentid);
		oParentsArray[i-1] = oFolder;
	} 	
	return oParentsArray;
}

function FolderChildrensArray(){}

function FoldersBuild(){
	if(this.subfolders>0) this.dropdown();
}	

function FolderSubFoldersHTML(bBottom){
	var tableHeight = 20;
	var tableWidth = 20;
	var tdHeight = 16	
	var sClass = "";
	var sBgImg = "";	
	var sLeftBg = "";
	var sMiddleLeftBg = "";
	var sMiddleRightBg = "";
	var sRightBg = "";	
	var sTarget = "";
	this.subFoldersHTML = "";
	
	if(this.level==0){}
	else{
		if(this.level==0){
			if(this.subfolders>0){
				tdHeight = 16;
				sStartTable = '<table cellpadding="0" cellspacing="0" border="0" height="'+tdHeight+'"><tr>';
				for(var i=0; i< (this.subfolderArray.length); i++) {
					sRight = '<td width="3" bgcolor="#FFFFFF"></td>';
					sImgLInk = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? "_on":"_off";
					sImgFn = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? '':' onmouseover="changeImage(\''+this.subfolderArray[i].name+'\',\''+this.subfolderArray[i].linkImgRef+'\',\'_off\')"  onmouseout="changeImage(\''+this.subfolderArray[i].name+'\',\''+this.subfolderArray[i].linkImgRef+'\',\'_on\')"';					
					this.subFoldersHTML = this.subFoldersHTML + '<td id="'+this.subfolderArray[i].name+'" nowrap align="center" height="'+tdHeight+'"><a href="javascript:'+this.subfolderArray[i].name+'.loadLocation()"'+sImgFn+'><img name="'+this.subfolderArray[i].name+'" src="'+this.subfolderArray[i].linkImgRef+sImgLInk+'.jpg" alt="' + this.subfolderArray[i].title + '" border="0" height="'+tdHeight+'"></a></td>'+sRight;					
				}
				sEndTable = "</tr></table>";
				this.subFoldersHTML = sStartTable + this.subFoldersHTML + sEndTable;
			}	
		}
		else{
			if(this.level==1){
				if(this.subfolders>0){
					if(bBottom){
						sStartTable = '<table cellpadding="0" cellspacing="0" border="0" height="'+tdHeight+'"><tr>';
						for(var i=0; i< this.subfolderArray.length; i++) {
							sLeft = (i>0)? '<td class="BottomMenu">&nbsp;|&nbsp;</td>':'';
							sClass = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? 'BottomMenuSelected':'BottomMenu'; 
							this.subFoldersHTML = this.subFoldersHTML + sLeft + '<td nowrap align="center" height="'+tdHeight+'"><a href="javascript:'+this.subfolderArray[i].name+'.loadLocation()" class="'+sClass+'">' + this.subfolderArray[i].title.toUpperCase() + '</a></td>';
						}
						sEndTable = "</tr></table>"
					}
					else{
						tdHeight = 11;
						sStartTable = '<table cellpadding="0" cellspacing="0" border="0" height="'+tdHeight+'"><tr>';
						for(var i=0; i< this.subfolderArray.length; i++) {
							sLeft = (i>0)? '<td class="topmenuSeparator"></td>':'';
							this.subFoldersHTML = this.subFoldersHTML + sLeft + '<td id="'+this.subfolderArray[i].name+'" nowrap align="center" height="'+tdHeight+'"><a href="javascript:'+this.subfolderArray[i].name+'.loadLocation()"><img name="'+this.subfolderArray[i].name+'" src="'+this.subfolderArray[i].linkImgRef+'" alt="' + this.subfolderArray[i].title + '" border="0" height="'+tdHeight+'"></a></td>';					
						}
						sEndTable = "</tr></table>"					
					}
					this.subFoldersHTML = sStartTable + this.subFoldersHTML + sEndTable;
					
					//alert(this.subFoldersHTML)
				}			
			}
			else{
				if(this.subfolders>0){
					tdWidth = 145;
					sStartTable = '<table cellpadding="0" cellspacing="0" border="0" width="'+tdWidth+'">';
					this.subFoldersHTML = this.subFoldersHTML + '<tr><td width="15"><img src="images/pixel.gif" width="15" height="5" alt="" border="0"></td><td width="'+(tdWidth-25)+'"><img src="images/pixel.gif" width="'+(tdWidth-25)+'" height="1" alt="" border="0"></td><td width="10" rowspan="'+this.subfolderArray.length+'"><img src="images/pixel.gif" width="10" height="1" alt="" border="0"></td></tr>'
					for(var i=0; i< this.subfolderArray.length; i++) {
						sClass = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? 'MenuSelected':'Menu'; 
						this.subFoldersHTML = this.subFoldersHTML + '<tr><td valign="top" width="15" style="padding-top: 5px;"><img src="media/site/redpil.gif" width="6" height="8" alt="" border="0"></td><td align="left" width="'+(tdWidth-25)+'" class="'+sClass+'" onmouseover="this.className=\''+sClass+'Hover\'" onmouseout="this.className=\''+sClass+'\'"><a href="javascript:'+this.subfolderArray[i].name+'.loadLocation()">' + this.subfolderArray[i].title.toUpperCase() + '</a></td></tr>';
						
						/*
						if(this.subfolderArray[i].subfolders>0&&this.subfolderArray[i].selected) {
							for(var j=0; j< this.subfolderArray[i].subfolderArray.length; j++) {
								if(this.subfolderArray[i].subfolderArray[j]!=null){
									sSubTarget = (this.subfolderArray[i].subfolderArray[j].target!="")? ' target="'+this.subfolderArray[i].subfolderArray[j].target+'"':'';
									sSubClass = (this.subfolderArray[i].subfolderArray[j].selected)? "SubMenuSelected":"SubMenu";
									sStyle = (j==(this.subfolderArray[i].subfolderArray.length-1))?  '':''; //' style="border-bottom: 1px solid #666666"':'';
									this.subFoldersHTML = this.subFoldersHTML + '<tr><td align="left" width="'+tdWidth+'" class="'+sSubClass+'" '+sStyle+' onmouseover="this.className=\''+sSubClass+'Hover\'" onmouseout="this.className=\''+sSubClass+'\'"><a href="javascript:'+this.subfolderArray[i].subfolderArray[j].name+'.loadLocation()">' + this.subfolderArray[i].subfolderArray[j].title + '</a></td></tr>';
									
								}
							}
						}	
						*/		
						if(i<this.subfolderArray.length-1) this.subFoldersHTML = this.subFoldersHTML + '<tr><td colspan="2" height="1" class="ligthdarkContent"><img src="images/pixel.gif" width="1" height="1" alt="" border="0"></td></tr>'
						if(i==this.subfolderArray.length-1) this.subFoldersHTML = this.subFoldersHTML + '<tr><td colspan="2" height="2"><img src="images/pixel.gif" width="1" height="2" alt="" border="0"></td></tr>'			
					}
					sEndTable = "</table>"
					//alert(this.subFoldersHTML)
					this.subFoldersHTML = sStartTable + this.subFoldersHTML + sEndTable;					
				}				
			}		
		}
	}
	//alert(this.subFoldersHTML)
	return this.subFoldersHTML
}		

function FolderRegisterSubFoldersHTML(iUserLevel){
	tdWidth = 194;
	sStartTable = '<table cellpadding="0" cellspacing="0" border="0" width="'+tdWidth+'">';
	for(var i=0; i< this.subfolderArray.length; i++) {
		sClass = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? 'MenuSelected':'Menu'; 
		if(parseInt(iUserLevel)==parseInt(this.subfolderArray[i].html)||parseInt(iUserLevel)<parseInt(this.subfolderArray[i].html)){
			this.subFoldersHTML = this.subFoldersHTML + '<tr><td align="left" width="'+tdWidth+'" class="'+sClass+'" onmouseover="this.className=\''+sClass+'Hover\'" onmouseout="this.className=\''+sClass+'\'"><a href="javascript:'+this.subfolderArray[i].name+'.loadLocation()">' + this.subfolderArray[i].title + '</a></td></tr>';
			if(this.subfolderArray[i].subfolders>0&&this.subfolderArray[i].selected) {
				for(var j=0; j< this.subfolderArray[i].subfolderArray.length; j++) {
					if(this.subfolderArray[i].subfolderArray[j]!=null){
						sSubTarget = (this.subfolderArray[i].subfolderArray[j].target!="")? ' target="'+this.subfolderArray[i].subfolderArray[j].target+'"':'';
						sSubClass = (this.subfolderArray[i].subfolderArray[j].selected)? "SubMenuSelected":"SubMenu";
						sStyle = (j==(this.subfolderArray[i].subfolderArray.length-1))?  ' style="border-bottom: 1px solid #666666"':'';
						this.subFoldersHTML = this.subFoldersHTML + '<tr><td align="left" width="'+tdWidth+'" class="'+sSubClass+'" '+sStyle+' onmouseover="this.className=\''+sSubClass+'Hover\'" onmouseout="this.className=\''+sSubClass+'\'"><a href="javascript:'+this.subfolderArray[i].subfolderArray[j].name+'.loadLocation()">' + this.subfolderArray[i].subfolderArray[j].title + '</a></td></tr>';
						
					}
				}
			}
		}						
	}
	sEndTable = "</table>"
	this.subFoldersHTML = sStartTable + this.subFoldersHTML + sEndTable;			
}

function FolderSubFoldersTree(oFolder){}

function FolderFoldersTree(oFolder, vStartLevel){}

function FolderSubFoldersWithImages(){}

//DropDown Metoder
function FolderDropDown(){
	if (is.ns) {
		if (is.ns4) {
			this.css = eval("document.Box_"+this.parentid+".document.Ilayer_"+this.id+".document."+this.name)
			this.elm = this.event = this.css
			this.doc = this.css.document
		}
		else {
			this.elm = document.getElementById(this.name)
			this.css = this.elm.style
			this.doc = document
		}
		this.x = (is.ns4)? this.css.left:parseInt(this.css.left)
		this.absx = (is.ns4)? this.css.pageX:parseInt(this.elm.offsetLeft)+parseInt(this.elm.offsetParent.offsetLeft)+ parseInt(this.elm.offsetParent.offsetParent.offsetLeft);
		
		this.y = (is.ns4)? this.css.top:parseInt(this.css.top)
		this.absy = (is.ns4)? this.css.pageY:parseInt(this.elm.offsetTop)
		this.w = (is.ns5)? this.elm.offsetWidth:this.css.clip.width
		this.h = (is.ns5)? this.elm.offsetHeight:this.css.clip.height
	}
	else {
		this.elm = this.event = document.all[this.name]
		this.css = (is.ie4)? document.all[this.name].style:document.getElementById(this.name).style
		this.doc = document
		this.x = this.elm.offsetLeft
		this.absx = (is.ie4)? this.elm.offsetLeft+ this.elm.offsetParent.offsetLeft + this.elm.offsetParent.offsetParent.offsetLeft:this.elm.offsetLeft + this.elm.offsetParent.offsetLeft+ this.elm.offsetParent.offsetParent.offsetLeft;
		this.y = this.elm.offsetTop
		this.absy = (is.ie4)? this.elm.offsetTop+ this.elm.offsetParent.offsetTop + this.elm.offsetParent.offsetParent.offsetTop:this.elm.offsetParent.offsetParent.offsetParent.offsetTop;
		this.cy = this.elm.clientTop
		this.p = 	this.elm.offsetParent
		this.w = (is.ie4)? this.css.pixelWidth : this.elm.offsetWidth
		this.h = (is.ie4)? this.css.pixelHeight : this.elm.offsetHeight
	}
}

function FolderSubFoldersTopHTML(){}		

function FolderSubFoldersDropDownHTML(sCase){
	TopFolderStartTop = document.getElementById("mainTable").offsetTop + 119;		
	if(this.level==1){
		tdHeight = 18
		sLayer = '<div id="'+this.name+'DDBox" style="position: absolute; left: 0px; top: '+(TopFolderStartTop)+'px; height: 20px;">';
		sTable = '<table border="0" cellpadding="0" cellspacing="0" height="'+tdHeight+'"><tr><td width="5"></td>'
		for(var i=0; i< this.subfolderArray.length; i++) {
			sRightBg = '<td><img src="media/site/tdbgseparator.gif" width="2" height="'+tdHeight+'"></td>';
			sClass = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? 'MenuSelected':'Menu'; 
			sTdLeft = (i==0)? '':'';			
			this.subFoldersSubHTML = this.subFoldersSubHTML + '<td id="'+this.subfolderArray[i].name+'" nowrap align="center" height="'+tdHeight+'" class="TD'+sClass+'" onclick="javascript:'+this.subfolderArray[i].name+'.loadLocation()" onmouseover="fnToggle(\''+this.subfolderArray[i].name+'\'); " onmouseout="fnToggle(\''+this.subfolderArray[i].name+'\'); ">' + this.subfolderArray[i].title + '</td>' + sRightBg;
		}
		var eTable = "</tr></table>";
		sEndLayer = '</div>'
		this.subFoldersSubHTML = sLayer + sTable + this.subFoldersSubHTML + eTable + sEndLayer;
	}
	else{
		var sLayer = '<div id="'+this.name+'DDBox" style="position:absolute;  left: 0px; top: '+(TopFolderStartTop+19)+'px; visibility: hidden;">';
		var sEndLayer = '</div>';
		var sTable = sLayer + '<table cellpadding="0" cellspacing="2" border="0" class="DDTable" width="'+SubFoldersSubWidth+'"></tr>';
		for(var i=0; i< this.subfolderArray.length; i++) {
			if(this.subfolderArray[i]!=null){
				sBgColor = (this.subfolderArray[i].selected==1)? SubFoldersSubBGSelected:SubFoldersSubBGNormal;
				sClass = (this.subfolderArray[i].selected==1)? 'MenuSelected':'Menu';
				this.subFoldersSubHTML = this.subFoldersSubHTML + '<tr><td id="'+this.subfolderArray[i].name+'" class="SubTD'+sClass+'" height="16" onmouseover="if('+this.subfolderArray[i].name+'.selected!=1) this.className=\'SubTDMenuSelected\'" onmouseout="if('+this.subfolderArray[i].name+'.selected!=1) this.className=\'SubTDMenu\'" onclick="'+this.subfolderArray[i].name+'.loadLocation()"><span class="Item'+sClass+'">' + this.subfolderArray[i].title + '</span></td></tr>';
			}
		}
		var eTable = '</table>' + sEndLayer;
		this.subFoldersSubHTML = sTable + this.subFoldersSubHTML + eTable;
	}
	return this.subFoldersSubHTML;
}

	var foldersObjArray = new Array();
	var foldersObjArrayCount = 0;
	
	var currentTopFolderID = "";
	var emptyImg = hostPath + "/images/pixel.gif"
	var sHTML = "";	
	
	// BrowserCheck Object
	function BrowserCheck() {
		var u = navigator.userAgent.toLowerCase();
		this.u = u
		var b = navigator.appName
		if (b=="Netscape") this.b = "ns"
		else if (b=="Microsoft Internet Explorer") this.b = "ie"
		else this.b = b
		if(this.b=="ie" && this.u.indexOf('opera')!=-1) 
		this.b = "op"
		this.version = navigator.appVersion
		this.v = parseInt(this.version)
		this.op = (this.b=="op")
		//alert(this.op)
		this.op4 = (this.b=="op" && this.v==4)
		this.ns = (this.b=="ns" && this.v>=4)
		this.ns4 = (this.b=="ns" && this.v==4)
		this.ns5 = (this.b=="ns" && this.v==5)
		this.ie = (this.b=="ie" && this.v>=4)
		this.ie4 = (this.version.indexOf('MSIE 4')>0)
		this.ie5 = (this.version.indexOf('MSIE 5')>0)
		this.ie6 = (this.version.indexOf('MSIE 6')>0)			
		this.min = (this.ns||this.ie)
	}
	is = new BrowserCheck();
	//alert(is.b)
	
	//Netscape
	function setBgColorNS(oLayer,id,vColor){
		if(!eval("folder"+id).selected) oLayer.bgColor = vColor;
	}

function FolderSetBgColor(vColor){
	if(this.selected!=1){
		if (is.ns){
			if (is.ns4) this.css.bgColor = vColor;
			else this.css.backgroundColor = vColor;
		} 
		else{
			this.css.backgroundColor = vColor;
		}
	}
}	
	
function FolderLoadLocation(){
	if(this.link!=""){
		var sHostPath = (this.link.slice(0,7)=="http://"||this.link.slice(0,4)=="www."||this.link.slice(0,6)=="mailto:")? "":hostPath; 
		if(this.target!=""){
			switch(this.target){
				case "_blank":
					window.open(sHostPath+this.link,"","width=490,height=500,status=no,scrollbars=yes,resizable=yes")
				break	
				case "_top":
					top.document.location.href =  sHostPath+this.link;
				break	
				case  "_self":
					self.document.location.href =  sHostPath+this.link;
				break	
				case "_parent":
					parent.document.location.href =  sHostPath+this.link;
				break	
				default:
					document.location.href =  sHostPath+this.link;
				break																	
			}
		}
		else document.location.href =  hostPath+this.link;
	}
}

	
function FolderShow(){
	if (is.ns){
		if (is.ns4){
			eval("document.Box_"+this.id+".left = "+this.absx);
			eval("document.Box_"+this.id+".visibility = 'show'");
		}
		else {
			document.getElementById(this.name+'DDBox').style.left = (this.absx+5)+'px';
			document.getElementById(this.name+'DDBox').style.visibility = "visible";
		}
	} 
	else{
		if(is.ie4){
			eval(this.name+'DDBox').style.visibility = "visible";
			eval(this.name+'DDBox').style.left = this.absx;
		}
		else {
			//alert(this.absy)
			document.getElementById(this.name+'DDBox').style.left = this.absx + 5;
			document.getElementById(this.name+'DDBox').style.visibility = "visible";
		}
	}
	if (is.ns){
	 	if(is.ns4) document.hideLayer.visibility = "show"
		else document.getElementById('hideLayer').style.visibility = "visible";
	}
	else document.all['hideLayer'].style.visibility = "visible";
	//alert(top.currentTopFolderID)
	top.currentTopFolderID = this.id
}

function FolderHide(){
	if (is.ns){
		if (is.ns4) eval("document.Box_"+this.name+".visibility = 'hide'");
		else document.getElementById(this.name+'DDBox').style.visibility = "hidden";
	} 
	else{
		if(is.ie4)	eval(this.name+'DDBox').style.visibility = "hidden";
		else document.getElementById(this.name+'DDBox').style.visibility = "hidden";
	}
}

function DynLayerGetRelativeX() {
	return (is.ns)? this.css.pageX : this.elm.offsetLeft
}

function DynLayerGetRelativeY() {
	return (is.ns)? this.css.pageY : this.elm.offsetTop
}	

	var Folder0StartTop = 20;
	var Folder0StartLeft = 300;
	var TopFolderStartTop = 148;
	var TopFolderStartLeft = 200;
	var TopFoldersHeight = 12;	
	var TopFoldersSubBGNormal = "#013366";	
	var SubFoldersSubTop = 186;
	var SubFoldersSubWidth = 160;
	var SubFoldersSubHeight = 16;
	var SubFoldersSubBorderColor = "#000000";
	var SubFoldersSubBorderWidth = 1;
	var subDivHTML = "";
	var SubFoldersSubBGNormal = "#F4F4F4";
	var SubFoldersSubBGHover = "#9ACCFF";
	var SubFoldersSubBGSelected = "#6799CC";	
	var emptyImg = hostPath + "/images/pixel.gif"
	var TopFolderWidthsArray = new Array('50','56','74','66','76','110','120','120','100');
	var SubFolderLeftsArray = new Array();
	var SubFoldersSubClass = "smPadding";
	function hideFolder(){
		if(currentTopFolderID!=""){
			eval('folder'+currentTopFolderID+'.hide()');
			currentTopFolderID = "";
			if (is.ns){
			 	if(is.ns4) document.hideLayer.visibility = "hide"
				else document.getElementById('hideLayer').style.visibility = "hidden"
			}
			 else document.all['hideLayer'].style.visibility = "hidden"
		}
	}	
	
	function showSubMenu(id){
		eval('folder'+id+'.show()');
	}
