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.getSubFolders = FolderSubFolders	
	
	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 tableWidth = 20;
	var tdHeight = 16	
	var sClass = "";
	var sBgImg = "";	
	var sLeftBg = "";
	var sMiddleLeftBg = "";
	var sMiddleRightBg = "";
	var sRightBg = "";	
	var sTarget = "";
	this.subFoldersHTML = "";
	switch(this.level){
		case 0:
			this.subFoldersHTML = '';
			for(var i=0; i< this.subfolderArray.length; i++) {
				this.subFoldersHTML = this.subFoldersHTML + '<a title="'+this.subfolderArray[i].title+'" href="'+hostPath+'/'+this.subfolderArray[i].link+'"><img src="'+this.subfolderArray[i].linkImgRef+'" alt="'+this.subfolderArray[i].title+'" border="0" style="margin: 2px 5px 0 0; " /></a>';
			}
		break
		case 1:
			if(this.subfolders>0){
				this.subFoldersHTML = '';
				for(var i=0; i< this.subfolderArray.length; i++) {
					if(this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID))){
						this.subFoldersHTML = this.subFoldersHTML + '<div class="MenuSelectedClass"><a title="'+this.subfolderArray[i].title+'" href="'+hostPath+'/'+this.subfolderArray[i].link+'">'+this.subfolderArray[i].title+'</a></div><div style="float: left;"><img src="media/design/menuSeparator.gif" width="2" height="35" alt=""></div>';
					}
					else{
						this.subFoldersHTML = this.subFoldersHTML + '<div class="MenuClass"><a title="'+this.subfolderArray[i].title+'" href="'+hostPath+'/'+this.subfolderArray[i].link+'">'+this.subfolderArray[i].title+'</a></div><div style="float: left;"><img src="media/design/menuSeparator.gif" width="2" height="35" alt=""></div>';
					}
				}
			}	
		break	
		case 2:
			if(this.subfolders>0){
				this.subFoldersHTML = '';
				for(var i=0; i< this.subfolderArray.length; i++) {
					if(this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID))){
						this.subFoldersHTML = this.subFoldersHTML + '<div class="subMenuSelectedClass"><a title="'+this.subfolderArray[i].title+'" href="'+hostPath+'/'+this.subfolderArray[i].link+'">'+this.subfolderArray[i].title+'</a></div>';
					}
					else{
						this.subFoldersHTML = this.subFoldersHTML + '<div class="subMenuClass"><a title="'+this.subfolderArray[i].title+'" href="'+hostPath+'/'+this.subfolderArray[i].link+'">'+this.subfolderArray[i].title+'</a></div>';
					}
				}
			}
		break	
		case 3:
			if(this.subfolders>0){
				this.subFoldersHTML = '';
				for(var i=0; i< this.subfolderArray.length; i++) {
					if(this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID))){
						this.subFoldersHTML = this.subFoldersHTML + '<div class="subMenuSelectedClass"><a title="'+this.subfolderArray[i].title+'" href="'+hostPath+this.subfolderArray[i].link+'">'+this.subfolderArray[i].title+'</a></div>';
					}
					else{
						this.subFoldersHTML = this.subFoldersHTML + '<div class="subMenuClass"><a title="'+this.subfolderArray[i].title+'" href="'+hostPath+this.subfolderArray[i].link+'">'+this.subfolderArray[i].title+'</a></div>';
					}
				}
			}
			
		break				
	}
	//alert(this.subFoldersHTML)
	return this.subFoldersHTML
}		

function FolderSubFolders(){
	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++) {
			sRightBg = '<td><img src="media/site/pixel.gif" width="10" height="1"></td>';
			sClass = (this.subfolderArray[i].selected==1||this.subfolderArray[i].IsParent(eval("folder"+currentFolderID)))? 'GalleryMenuSelected':'GalleryMenu'; 
			this.subFoldersHTML = this.subFoldersHTML + '<td id="'+this.subfolderArray[i].name+'" nowrap align="left" height="'+tdHeight+'" class="TD'+sClass+'" onclick="'+this.subfolderArray[i].name+'.loadLocation()" onmouseover="this.style.backgroundColor=\'#034EA2\'" onmouseout="this.style.backgroundColor=\'\'"><a href="javascript:'+this.subfolderArray[i].name+'.loadLocation()" class="'+sClass+'">&nbsp;&raquo;' + this.subfolderArray[i].title + '&nbsp;</a></td>';
		}
		sEndTable = "</tr></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(sCase=="top"){
		sTable = '<table border="0" cellpadding="0" cellspacing="0" height="18"><tr><td width="5"></td>'
		for(var i=0; i< this.subfolderArray.length; i++) {
			this.subFoldersSubHTML = this.subFoldersSubHTML + '<td height="18" width="'+(this.subfolderArray[i].w)+'" class="TopDDTD" onclick="javascript:'+this.subfolderArray[i].name+'.loadLocation()" onmouseover="fnToggle(\''+this.subfolderArray[i].name+'\'); " onmouseout="fnToggle(\''+this.subfolderArray[i].name+'\'); "><img src="'+emptyImg+'" border="0" alt="'+this.subfolderArray[i].title+'" width="'+(this.subfolderArray[i].w)+'" height="18"></td><td width="2"></td>'
		}
		var eTable = '</table>';
		sLayer = '<div id="'+this.name+'DDBox" style="position: absolute; left: 0px; top: '+(TopFolderStartTop)+'px; height: 20px;">';
		sEndLayer = '</div>'
		this.subFoldersSubHTML = sLayer + sTable + this.subFoldersSubHTML + eTable + sEndLayer;
		//alert(this.subFoldersSubHTML)
	}
	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)
				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()');
	}