// *****************************************************************
// eBD GUI.
// ObjectItemCarpetas.js
// *****************************************************************

var eBDObjectItemCarpetasID=0;
function ObjectItemCarpetas(name,descripcion,sel_name,ico,posicion,id_foto,href,clase_href,fecha_cre,totalfotos,tipo,clase1,clase2,id_carpeta,carpeta_actual) 
{
	this.type = 'object';
	this.idwidget = eBDObjectItemCarpetasID++;
	this.name = name;
	this.descripcion = descripcion;
	this.sel_name = sel_name;
	this.ico = ico;
	this.posicion = posicion; //La foto de la portada es Vertical (V) u horizontal (H)
	this.href = href;
	this.id_foto = id_foto;
	this.clase_href = clase_href;
	this.target = null;
	this.columns = new Array();
	this.fecha_cre = fecha_cre;
	this.totalfotos = totalfotos;
	this.tipo = tipo; //indica si la carpeta es de tipo mis carpetas (mias), yo he compartido (he_compartido), me han compartido (me_comparte), del blog publicas (blog_publica), del blog privadas (blog_privada) u otras (todas)
	this.baseclass = clase1;
	this.classselected = clase2;
	this.id_carpeta = id_carpeta;
	this.carpeta_actual = carpeta_actual;
		
	this.opened=false;
	this.selected=false;
	this.active=false;
	this.actual_folder=false;
	
	this.setClass = ObjectItemCarpetas_setClass;
	this.getHTML = ObjectItemCarpetas_getHTML;
	this.getIdFoto = ObjectItemCarpetas_getIdFoto;
	this.getMultipleHTML = ObjectItemCarpetas_getMultipleHTML;
	this.setSelected = ObjectItemCarpetas_setSelected;
	this.repaint = ObjectItemCarpetas_repaint;
	this.addColumnHTML = ObjectItemCarpetas_addColumnHTML;
	this.setTarget = ObjectItemCarpetas_setTarget;
	this.getTotalFotos = ObjectItemCarpetas_getTotalFotos();
	this.getHTML_Blog = ObjectItemCarpetas_getHTML_Blog;
}

function ObjectItemCarpetas_setTarget(t)
{ this.target=t; }

function ObjectItemCarpetas_setClass(baseclass) 
{ this.baseclass = baseclass; }

function ObjectItemCarpetas_getIdFoto() {
	return this.id_foto;
}

function ObjectItemCarpetas_addColumnHTML(html)
{ this.columns[this.columns.length] = html; }

function ObjectItemCarpetas_setSelected(b,tr) {
	this.selected=b;
	if (this.selected && this.tr == null)
	{ this.tr = tr; }
	this.repaint();	
}

function ObjectItemCarpetas_repaint() {
	if (this.tr != null)
	{		
		if (this.selected)
		{ this.tr.className = this.classselected; }
		else
		{ this.tr.className = this.baseclass; }
	}
}

function ObjectItemCarpetas_getMultipleHTML(home,cols,aligns,actived)
{
	var str = "<td class=\"objectManager_rowcell\"";
	str += "><span class=\"objectManager_text\">";

	if (this.tab > 0)
        {
                var l = this.tab * 20;
                str += "<img src=\"" + home + "images/point.gif\" alt=' ' height=1 width=\"" + l + "\">";
        }


	str+="<table border=0 cellspacing=0 cellpadding=0><tr>";
	str += "<TD><INPUT TYPE=CHECKBOX NAME="+this.ico+"></TD>";
	str += "<td bgcolor=\""+this.ico+"\"> <img border=0 src=\""+home+"images/preview_color.gif\" alt='' width=16 heighy=16 class='objectManager_ico'> </td>";
        //str += "<img border=0 src=\"" + home + this.ico + "\" alt='' width=16 height=16 class='objectManager_ico'>";
	str+="<td>";

	if (this.href != null) {
        	str += "<a class=\"objectManager_link\" href=\"" + this.href + "\" ";
        	if (this.target != null)
        	{ str += " target=\"" + this.target + "\" "; }
		str += ">" + this.name + "</a>";
	}
        else { str += this.name  }

        if (this.text != null && this.text != '') {
                str+=" ("+this.text+")</span></td></tr></table>"
        }
        else {str += "</span></td></tr></table>" }

	return str;
}

function ObjectItemCarpetas_getTotalFotos() {
	return this.totalfotos;
} 
	
function ObjectItemCarpetas_getHTML(home,cols,aligns,actived) {
//	var str = "<tr class=\"" + this.baseclass + "\"";
	//if(actived){str += " onmousedown=\"return objmanager.clicked(event," + this.idwidget + ",this);\"";}
	
	var literal_fotos; 
	var foto_carpeta;
	var top = 28; //Top horizontal por defecto
	var str='';
	var texto_cortado = dividir(this.name,19); //corta el nombre de la carpeta si este es muy largo
	
	if (this.totalfotos != 1)
	{
		literal_fotos = objmanager.getLiteralFotos();
	}else
	{
		literal_fotos = objmanager.getLiteralFoto();
	}
	str += '<td class="'+this.baseclass+'" align="center" onclick="objmanager.clicked(event,' + this.idwidget + ',this);">';
	if (this.id_foto != 0)
	{
		if (this.posicion == "V")
			top = 18;
		//Tipo de carpeta, Vertidal u Horizontal y color del borde segn sea compartida, mis carpetas o me han compartido
		/* Ya no est�esta opcion
		if (this.tipo == "mias" && this.posicion == "H")
			foto_carpeta = "carpeta_h_negre.gif";
		if (this.tipo == "mias" && this.posicion == "V")
			foto_carpeta = "carpeta_v_negre.gif";
		*/
		if ((this.tipo == "todas" || this.tipo == "blog_publica" || this.tipo == "blog_privada") && this.posicion == "H")
			foto_carpeta = "carpeta_h_gris.gif";
		if ((this.tipo == "todas" || this.tipo == "blog_publica" || this.tipo == "blog_privada") && this.posicion == "V")
			foto_carpeta = "carpeta_v_gris.gif";
		if (this.tipo == "yo_compartido" && this.posicion == "H")
			foto_carpeta = "carpeta_h_verd.gif";
		if (this.tipo == "yo_compartido" && this.posicion == "V")
			foto_carpeta = "carpeta_v_verd.gif";
		if (this.tipo == "me_comparten" && this.posicion == "H")
			foto_carpeta = "carpeta_h_blau.gif";
		if (this.tipo == "me_comparten" && this.posicion == "V")
			foto_carpeta = "carpeta_v_blau.gif";
		if (this.actual_folder && this.posicion == "V")
			foto_carpeta = "carpeta_v_vermell.gif";
		if (this.actual_folder && this.posicion == "H")
			foto_carpeta = "carpeta_h_vermell.gif";

		str += '<div style="background:url(/imgfiles/Imagenes_mi_dichis/carpetas/'+foto_carpeta+') center no-repeat;width:100px;height:109px;" onDblClick="abrir_dialogo(\'espere_abrir\',\'contenedor_esperar\',300,100,null);redirigir_dobleclick(\''+this.href+'\');">';
		str += '<img src="'+this.ico+'" style="padding-top:'+top+'px;" alt="'+this.name+'"></div>';
	}
	else
	{
		//No tiene portada
		if (this.tipo == "todas" || this.tipo == "blog_publica" || this.tipo == "blog_privada")
			foto_carpeta = "carpeta_simple.gif";
		if (this.tipo == "he_compartido")
			foto_carpeta = "carpeta_simple_verd.gif";
		if (this.tipo == "me_comparten")
			foto_carpeta = "carpeta_simple_blau.gif";
		if (this.actual_folder)
			foto_carpeta = "carpeta_simple_vermell.gif";
		
		str += '<div style="background:url(/imgfiles/Imagenes_mi_dichis/carpetas/'+foto_carpeta+') center no-repeat;width:100px;height:109px;"></div>';
	}
	if (this.totalfotos > 0)
		str += '<a href="'+this.href+'" class="'+this.clase_href+'">'+texto_cortado+'</a>';
	else
		str += '<span style="color: #333333;font: bold 11px Arial;">'+texto_cortado+'</span>';
        
    if (this.tipo == "blog_publica")
	{
		str += '<br><span class="blog_carpeta_publica">'+this.fecha_cre+'</span>';
	}
	else if (this.tipo == "blog_privada")
	{
		str += '<br><span class="blog_carpeta_privada">'+this.fecha_cre+'</span>';
	}
	else
	{
		str += '<br><font style="font: normal 9px Arial;color:#333333;">'+this.fecha_cre+'&nbsp;&nbsp;('+this.totalfotos+' '+literal_fotos+')';
	}
//	str += '<br>'+this.tipo;
	str += '</td>';
	
	return str;
}


function ObjectItemCarpetas_getHTML_Blog(home,cols,aligns,actived) {
	
	var literal_fotos; 
	var foto_carpeta;
	var top = 28; //Top horizontal por defecto
	var str='';
	var texto_cortado = dividir(this.name,19); //corta el nombre de la carpeta si este es muy largo
	
	if (this.totalfotos != 1)
	{
		literal_fotos = objmanager_folders.getLiteralFotos();
	}else
	{
		literal_fotos = objmanager_folders.getLiteralFoto();
	}
	str += '<td align="center" onclick="objmanager.clicked(event,' + this.idwidget + ',this);">';
	if (this.id_foto != 0)
	{
		if (this.posicion == "V")
			top = 18;
		
		if (this.posicion == "H") {
			if (this.carpeta_actual != 1) {
				foto_carpeta = "carpeta_h_gris.gif";
			} else {
				foto_carpeta = "carpeta_h_blog.gif";
			}
		}
		if (this.posicion == "V") {
			if (this.carpeta_actual != 1) {
				foto_carpeta = "carpeta_v_gris.gif";
			} else {
				foto_carpeta = "carpeta_v_blog.gif";
			}
		}
		str += '<div style="background:url(/imgfiles/Imagenes_mi_dichis/carpetas/'+foto_carpeta+') center no-repeat;width:100px;height:109px;">';
		str += '<img src="'+this.ico+'" style="padding-top:'+top+'px;" alt="'+this.name+'"></div>';
	}
	else
	{
		foto_carpeta = "carpeta_simple.gif";
		str += '<div style="background:url(/imgfiles/Imagenes_mi_dichis/carpetas/'+foto_carpeta+') center no-repeat;width:100px;height:109px;"></div>';
	}
	if (this.totalfotos > 0) {
		str += '<a href="'+this.href+'" class="linkBlogFolder">'+texto_cortado+'</a>';
		str += '<br><span class="txtBlogFolder">'+this.fecha_cre+'&nbsp;&nbsp;('+this.totalfotos+' '+literal_fotos+')</span>';
	}
	else
	{	str += '<span class="nolinkBlogFolder">'+texto_cortado+'</span>'; }
	str += '</td>';
	
	return str;
}

