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.build = FoldersBuild
	this.dropdown = FolderDropDown
	this.setBgColor = FolderSetBgColor	
	this.loadLocation = FolderLoadLocation;
	this.getHistory = FolderHistory;		
	
	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(){
	this.dropdown();
}	

function FolderHistory(vStartLevel, sLinkClass, sSpanClass){
	var sHistoryHtml = "";
	var startlevel = (vStartLevel!=null)? vStartLevel:0;
	var linkClass = (sLinkClass!=null)? sLinkClass:"";
	var spanClass = (sSpanClass!=null)? sSpanClass:"";
	for(var i=vStartLevel; i< this.selectedfoldersArray.length-1; i++) {
		sHistoryHtml = sHistoryHtml + '<a title="'+this.selectedfoldersArray[i].description+'" href="javascript:'+this.selectedfoldersArray[i].name+'.loadLocation()" class="'+linkClass+'">' + this.selectedfoldersArray[i].title + '</a>&nbsp;&raquo; '
	}
	if(this.selectedfoldersArray.length-1>vStartLevel||this.selectedfoldersArray.length-1==vStartLevel) sHistoryHtml = sHistoryHtml + '<span class="'+spanClass+'">' + this.selectedfoldersArray[this.selectedfoldersArray.length-1].title + '</span>'
	return sHistoryHtml;
}

function FolderSubFoldersHTML(bBottom){
	var tableHeight = 20;
	var tdWidth = 140;
	var tdHeight = 18
	var sRigth = "<td height='3'></td>"	
	var sImgLInk = "";
	var sTarget = "";
	this.subFoldersHTML = "";
	if(this.level==0){
	}
	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>&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 + '</a></td>';
					}
					sEndTable = "</tr></table>"
					this.subFoldersHTML = sStartTable + this.subFoldersHTML + sEndTable;
				}
				else{
					sStartTable = '<table cellpadding="0" cellspacing="0" border="0" height="'+tdHeight+'"><tr>';
					for(var i=0; i< this.subfolderArray.length-1; i++) {
						sLeft = (i>0)? '<td width="15">&nbsp;&nbsp;</td>':'';
						sClass = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? 'TopMenuSelected':'TopMenu'; 
						sEvent = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? '':' onmouseover="this.className=\'TopMenuHoverTD\'" onmouseout="this.className=\'TopMenuTD\'"';
						this.subFoldersHTML = this.subFoldersHTML + sLeft + '<td nowrap align="center" height="'+tdHeight+'">'
						this.subFoldersHTML = this.subFoldersHTML + '<table cellpadding="0" cellspacing="0" border="0"><tr><td class="'+sClass+'TD" '+sEvent+' onclick="'+this.subfolderArray[i].name+'.loadLocation()" colspan="3" align="center" nowrap="on">';
						this.subFoldersHTML = this.subFoldersHTML + '<span class="MenuTop">' + this.subfolderArray[i].title + '</span>';
						this.subFoldersHTML = this.subFoldersHTML + '</td></tr>';
						this.subFoldersHTML = this.subFoldersHTML + '<tr><td><img src="media/site/menuLeft.gif" width="4" height="10" alt="" border="0"></td><td background="media/site/menuLeft.gif" width="95%"><img src="'+emptyImg+'" border="0" width="20" height="10" alt=""></td><td><img src="media/site/menuRight.gif" width="4" height="10" alt="" border="0"></td></tr></table>';
					}
					sEndTable = "</tr></table>"
					this.subFoldersHTML = sStartTable + this.subFoldersHTML + sEndTable;					
				}
			}		
		}
		else{
			if(this.level==2){
				if(this.subfolders>0){
					this.subFoldersHTML = '<table cellpadding="0" cellspacing="0" border="0" align="center">';
					for(var i=0; i<this.subfolderArray.length; i++) {
						sClass = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? "MenuSelected":"Menu";
						sText = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? "":"";
						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 + '<tr><td title="' + this.subfolderArray[i].title + '" id="'+this.subfolderArray[i].name+'" nowrap align="left" width="'+tdWidth+'" height="'+tdHeight+'" valign="" class="'+sClass+'TD"><a href="javascript:'+this.subfolderArray[i].name+'.loadLocation()"  class="'+sClass+'">' + sText + ' ' + this.subfolderArray[i].title + '</a></td></tr>'+sRigth;
						//if(this.subfolderArray[i].subfolders>0&&this.subfolderArray[i].selected) {
						if(this.subfolderArray[i].subfolders>0) {
							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";
									this.subFoldersHTML = this.subFoldersHTML + '<tr><td title="' + this.subfolderArray[i].subfolderArray[j].title + '" id="'+this.subfolderArray[i].subfolderArray[j].name+'" class="'+sSubClass+'TD" height="14" width="120"><a href="'+hostPath+this.subfolderArray[i].subfolderArray[j].link+'" class="'+sSubClass+'" '+sTarget+'>' + this.subfolderArray[i].subfolderArray[j].title + '</a></td></tr>'+sRigth;
								}
							}
						}
					}
					this.subFoldersHTML = this.subFoldersHTML + '</table>';
				}	
			}
			else{
				if(this.level==2){
					
				}		
			}
		}
	}
	//alert(this.subFoldersHTML)
	return this.subFoldersHTML
}		

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){}

	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)
				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"
 }

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()');
	}
