function Folder(ID,parentID,Order,Level,SubFolders,EditNav,WebNav,IsUrl,IsSelected,Title,Link,Target,Html,Description){
	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.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.addToParent();
	this.setSelectedFolders();
	
	//Array global con todos los folder ordenados!!
	
	foldersObjArray[foldersObjArrayCount] = this
	foldersObjArrayCount++
	
	this.subFoldersHTML = ""
	this.getSubFoldersHTML = FolderSubFoldersHTML	
	
	this.build = FoldersBuild
	this.activate = FoldersActivate
	this.setBgColor = FolderSetBgColor	
	this.loadLocation = FolderLoadLocation
	
}

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(){

}		

function FolderSubFoldersHTML(){
	var tableHeight = 30;
	var tableWidth = (this.level==2)? 118:118;
	var sSeparatorWidth = 118;
	var sSeparatorHeight = 1;	
	var tdWidth = 4
	var tdHeight = 16	
	var sClass = "leftMenu";
	var sSubClass = "leftSubMenu";	
	var sTDClass = "menuTD";
	var sExtraTDClass = "bgColorE";
	var sTarget = "";
	var sSubTarget = "";	
	//oFolder = (oFolder==null)? this:oFolder
	if(this.subfolders>0){
		var sStartTable = '<table cellpadding="0" cellspacing="0" border="0" width="'+tableWidth+'"  class="bgColorD">';
		var sTopSeparator = '<tr><td width="1" class="bgColorA"><img src="/images/pixel.gif" alt="" border="0" width="1"></td><td width="14" class="bgColorA"><img src="/images/pixel.gif" alt="" border="0" width="14" height="1"></td><td height="'+sSeparatorHeight+'" width="'+(sSeparatorWidth-1)+'" class="bgColorA"><img src="/images/pixel.gif" alt="" border="0" width="'+(tableWidth-16)+'" height="'+sSeparatorHeight+'"></td><td width="1" class="bgColorA"><img src="/images/pixel.gif" alt="" border="0" width="1"></td></tr>';	
		var sBottomSeparator = '<tr><td height="'+sSeparatorHeight+'" width="'+sSeparatorWidth+'" colspan="4" class="bgColorF"><img src="/images/pixel.gif" alt="" border="0" width="'+sSeparatorWidth+'" height="'+sSeparatorHeight+'"></td></tr>';	
		var sExtraSeparator = '<tr class="'+sExtraTDClass+'"><td height="'+sSeparatorHeight+'" width="'+sSeparatorWidth+'" colspan="4"><img src="/images/pixel.gif" alt="" border="0" width="'+sSeparatorWidth+'" height="'+sSeparatorHeight+'"></td></tr>';	
		var sVspace = (this.level==0)? 0:(this.level==1)? (3*sSeparatorHeight+tdHeight)*(this.order-1):(3*sSeparatorHeight+tdHeight)*(this.order-1)+(3*sSeparatorHeight+tdHeight)*(this.parent.order-1);
		var sTableVSpace = (sVspace==0)? '':'<img src="/images/pixel.gif" alt="" border="0" height="'+sVspace+'" width="'+sSeparatorWidth+'">'
		for(var i=0; i< this.subfolderArray.length; i++) {
			if(this.subfolderArray[i]!=null){
				sClass = (this.subfolderArray[i].selected)? "leftMenuSelected":"leftMenu";
				sTDClass = (this.subfolderArray[i].selected)? "bgColorF":"menuTD";
				sTarget = (this.subfolderArray[i].target!="")? ' target="'+this.subfolderArray[i].target+'"':'';
				sEvent = (this.subfolderArray[i].selected)? '':' onmouseover="" onmouseout=""';
				sImage = (this.subfolderArray[i].selected)? this.subfolderArray[i].html + '_on.gif':this.subfolderArray[i].html + '_off.gif';
				this.subFoldersHTML = this.subFoldersHTML + sTopSeparator +'<tr class="'+sTDClass+'"><td width="1" class="bgColorA"><img src="/images/pixel.gif" alt="" border="0" width="1"></td><td width="14" align="center"><img src="'+hostPath+'/images/puntos.gif" width="8" height="14" alt="" border="0"></td><td id="'+this.subfolderArray[i].name+'" height="'+tdHeight+'" width="'+(tableWidth-16)+'" valign="middle"><p><a href="'+hostPath+this.subfolderArray[i].link+'" class="'+sClass+'" '+sTarget+sEvent+'>' + this.subfolderArray[i].title + '</a></p></td><td width="1" class="bgColorF"><img src="/images/pixel.gif" alt="" border="0" width="1"></td></tr>'+sBottomSeparator+sExtraSeparator+'\n';
			}
			if(i<this.subfolderArray.length-1) this.subFoldersHTML = this.subFoldersHTML;
		}
		var sEndTable = '</table>';
		this.subFoldersHTML = sTableVSpace + sStartTable + this.subFoldersHTML + sEndTable;
		//alert(this.subFoldersHTML)
	}
	return this.subFoldersHTML
}		

function FolderSubFoldersTree(oFolder){
	var tableWidth = 170;
	var tdWidth = 4
	var sClass = "leftMenu";
	var sSubClass = "leftSubMenu";	
	var sTDClass = "menuTD";
	var sTarget = "";
	var sSubTarget = "";	
	oFolder = (oFolder==null)? this:oFolder
	if(oFolder.subfolders>1){
		var sSeparator = '<tr><td colspan="2" height="3"><img src="images/pixel.gif" width="10" height="3" alt=""border="0"></td></tr>';	
		var sStartTable = '<table cellpadding="0" cellspacing="0" border="0" width="'+tableWidth+'">';
			for(var i=0; i< oFolder.subfolderArray.length-1; i++) {
				if(oFolder.subfolderArray[i]!=null){
					sClass = (oFolder.subfolderArray[i].selected)? "leftMenuSelected":"leftMenu";
					sTDClass = (oFolder.subfolderArray[i].selected)? "menuTDSelected":"menuTD";
					sTarget = (oFolder.subfolderArray[i].target!="")? ' target="'+oFolder.subfolderArray[i].target+'"':'';
					oFolder.subFoldersHTML = oFolder.subFoldersHTML + '<tr><td id="'+oFolder.subfolderArray[i].name+'" height="26" class="'+sTDClass+'" colspan="2" background="../images/menuBG.jpg" valign="middle"><p class="pleftMenu"><a href="/'+oFolder.subfolderArray[i].link+'" class="'+sClass+'" '+sTarget+'>' + oFolder.subfolderArray[i].title + '</a></p></td></tr>\n';
				}
				if(oFolder.subfolderArray[i].subfolders>0&&oFolder.subfolderArray[i].selected) {
					for(var j=0; j< oFolder.subfolderArray[i].subfolderArray.length; j++) {
						if(oFolder.subfolderArray[i].subfolderArray[j]!=null){
							sSubTarget = (oFolder.subfolderArray[i].subfolderArray[j].target!="")? ' target="'+oFolder.subfolderArray[i].subfolderArray[j].target+'"':'';
							sSubClass = (oFolder.subfolderArray[i].subfolderArray[j].selected)? "leftSubMenuSelected":"leftSubMenu";
							oFolder.subFoldersHTML = sSeparator + oFolder.subFoldersHTML + '<tr><td width="'+tdWidth+'" height="18" valign="middle" align="right"><p class="pleftsubmenu"><img src="images/small_flor.jpg" height="18" width="17" alt="" border="0" hspace="3"></p></td><td id="'+oFolder.subfolderArray[i].subfolderArray[j].name+'" class="'+sSubClass+'" height="14" width="120"><a href="/'+oFolder.subfolderArray[i].subfolderArray[j].link+'" class="'+sSubClass+'" '+sTarget+'>' + oFolder.subfolderArray[i].subfolderArray[j].title + '</a></td></tr>';
						}
					}
				}
				oFolder.subFoldersHTML = oFolder.subFoldersHTML + sSeparator;
			}
			var sEndTable = '</table>';
			oFolder.subFoldersHTML = sStartTable + oFolder.subFoldersHTML + sEndTable;
	}

	return oFolder.subFoldersHTML

}

function FolderLoadLocation(){
	if(this.link!="") document.location.href =  this.link;
}

function FolderSetBgColor(vColor){
	if(!this.selected){
		if (is.ns){
			if (is.ns4) this.css.bgColor = vColor;
			else this.css.backgroundColor = vColor;
		} 
		else{
			this.css.backgroundColor = vColor;
		}
	}
}

function FoldersActivate(){
	if (is.ns) {
		if (is.ns4) {
			this.css = eval("document.Ilayer_"+this.id+".document."+this.name)
			this.elm = this.event = this.css
			this.doc = this.css.document
		}
		else if (is.ns5) {
			this.elm = document.getElementById(this.name)
			this.css = this.elm.style
			this.doc = document
		}
	}
	else {
		this.elm = this.event = (is.ie4)? document.all[this.name]:document.getElementById(this.name)
		this.css = this.elm.style;
		this.doc = document
	}
}

