// *****************************************************************
// eBD GUI.
// ObjectManager.js
// *****************************************************************
var mac = (navigator.appVersion.indexOf("Mac")!==-1) ? true : false;
function ObjectManager(home,target)
{
	this.list = new Array;
	
	this.jomateix = 'objmanager';	// El nom d'instancia de l'objecte
	this.objeto = 'carpeta'; //Tipo de objeto (carpeta, foto, ...)
	this.selection_active=true;
	this.objcount = 0; //Numero de registros del list = list.length
	this.home = home;
	this.idtarget = target; //identificador del contenedor donde se carga el objectManager
	this.target = null;
	if(this.idtarget != null){this.target = document.getElementById(this.idtarget);}
	this.literal1_obj1 = 'Object'; //Numero de registros del objectManager en singular
	this.literal2_obj1 = 'Objects'; //Numero de registros del objectManager en plural
	this.literal_y = 'and';
	this.literal1_obj2 = 'Object'; //Numero de registros del objectManager en singular
	this.literal2_obj2 = 'Objects'; //Numero de registros del objectManager en plural
	this.literales_pagina = new Array; //Array con los literales de la paginacion
	this.literal_error_pagina = 'Página inexistente'
	this.literal_volver = 'back';
	this.literal_tipo_mias = 'Mias';
	this.literal_tipo_he = 'He compartido';
	this.literal_tipo_mehan = 'Me han compartido';
	this.literal_comentarios = 'Comentarios';
	
	this.cols_to_show = 0; //Numero de columnas por defecto que se visualizan
	this.filas = 0; //Numero de filas por defecto que se visualizan (por defecto sin paginacion)
	this.paginacion = false; //Indica si se hace paginacion o no.
	this.registro_actual = 0; //Primer registro que se cuenta en la paginacion actual del objeto
	this.pagina_actual = 1; //Pagina que se esta visualizando
	this.total_carpetas = 0; //Indica el numero total de registros obtenidos para calcular el total de paginas de la paginacion
	this.total_fotos = 0; //Indica el numero total de fotos que tiene el usuario segun su consulta
	this.todos_ids = ""; //Guarda un string con todos los ids separados por comas obtenidos en la consulta, sin la paginacion para la opcion de seleccionarlos todos
	this.todos_nombres = ""; //Guarda un string con todos los nombres de las fotos separados por comas obtenidos en la consulta, sin la paginacion para la opcion de seleccionarlos todos
	this.columns = new Array();
	this.aligns = new Array();
	this.sizes = new Array();
	this.show_totals = true;
	this.href = null; //enlace al que se envia cuando se apreta al titulo
	this.nombre_carpeta_select = null; //Se guarda el nombre de una  sola carpeta, la que se ha seleccionado para poder mostrarlo en el dialogo de cambiar nombre
	this.descripcion_carpeta_select = null; //Se guarda la descripcion de la carpeta que se ha seleccionado para poder mostrarlo en el dialogo de cambiar nombre
	this.idfoto_carpeta_select = null; //Se guarda el id de la carpeta que se ha seleccionado para poder compararlo a la hora de cambiar la portada
	this.volver = false; //Boton de volver a la pantalla anterior
	this.select_all = false; // Indica si estan todos los registros seleccionados
		
	this.setObjeto = ObjectManager_setObjecto;
	this.getObjeto = ObjectManager_getObjecto;
	this.addObject = ObjectManager_addObject;
	this.setLiterals = ObjectManager_setLiterals;
	this.setLiteralErrorPagina = ObjectManager_setLiteralErrorPagina;
	this.setLiteralesPaginacion = ObjectManager_setLiteralesPaginacion;
	this.getLiteralFoto = ObjectManager_getLiteralFoto;
	this.getLiteralFotos = ObjectManager_getLiteralFotos;
	this.setColumns = ObjectManager_setColumns;
	this.setAligns = ObjectManager_setAligns;
	this.setSizes = ObjectManager_setSizes;
	this.paint = ObjectManager_paint;
	this.repintar = repintar_objmanager;
	this.paintMultiple = ObjectManager_paintMultiple;
	this.getSelected = ObjectManager_getSelected;
	this.modificar_todos_seleccionados = ObjectManager_modificar_todos_seleccionados;
	this.setSelect_all = ObjectManager_setSelect_all;
	this.getSelect_all = ObjectManager_getSelect_all;
	this.getTodos_ids = ObjectManager_getTodos_ids;
	this.getTodos_nombres = ObjectManager_getTodos_nombres;
	this.getNombresSelected = ObjectManager_getNombresSelected;
	this.countSelected = ObjectManager_count_Selected;
	this.clicked = ObjectManager_clicked;
	this.clear = ObjectManager_clear;
	this.setSelectionActive = ObjectManager_setSelectionActive;
	this.showTotals = ObjectManager_showTotals;
	this.setPaginacion = ObjectManager_setPaginacion;
	this.getPaginacion = ObjectManager_getPaginacion;
	this.setPaginaActual = ObjectManager_setPaginaActual;
	this.getPaginaActual = ObjectManager_getPaginaActual;
	this.getFilas = ObjectManager_getFilas;
	this.setFilas = ObjectManager_setFilas;
	this.setColstoShow = ObjectManager_setColstoShow;
	this.getColstoShow = ObjectManager_getColstoShow;
	this.getRegistrosPagina = ObjectManager_registros_pagina;
	this.setTotalObjetos = ObjectManager_setTotalObjetos;
	this.getTotalObjetos = ObjectManager_getTotalObjetos;
	this.setHref = ObjectManager_setHref;
	this.mostrarPaginacion = ObjectManager_mostrarPaginacion;
	this.paginaSiguiente = ObjectManager_paginaSiguiente;
	this.paginaAnterior = ObjectManager_paginaAnterior;
	this.paginaInicio = ObjectManager_paginaInicio;
	this.paginaFin = ObjectManager_paginaFin;
	this.paginaIr = ObjectManager_paginaIr;
	this.getNombreCarpetaSelect = ObjectManager_getNombreCarpetaSelect;
	this.getDescripcionCarpetaSelect = ObjectManager_getDescripcionCarpetaSelect;
	this.getIdFotoCarpetaSelect = ObjectManager_getIdFotoCarpetaSelect;
	this.setVolver = ObjectManager_setVolver;
	this.getVolver = ObjectManager_getVolver;
	this.setLiteralVolver = ObjectManager_setLiteralVolver;
	this.setLiteralesTipo = ObjectManager_setLiteralesTipo;
	this.paintBlog = ObjectManager_paintBlog;
	this.paintBlogFolder = ObjectManager_paintBlogFolder;
	this.getJomateix = ObjectManager_getJomateix;
	this.setJomateix = ObjectManager_setJomateix;
	this.mostrarPaginacionBlogFolder = ObjectManagermostrarPaginacionBlogFolder;
}

function ObjectManager_getJomateix(){
	return this.jotameix;
}

function ObjectManager_setJomateix(nom){
	this.jomateix = nom;
}

function ObjectManager_setObjecto(valor)
{
/* Actualizamos el tipo de objeto que es para tratarlo de una manera u otra */
	this.objeto = valor;
}
function ObjectManager_getObjecto()
{
	return this.objeto;
}
function ObjectManager_setPaginacion(valor){
/* Indica si hay paginacion o no */
	this.paginacion = valor;
}

function ObjectManager_getPaginacion(){
	return this.paginacion;
}

function ObjectManager_setLiteralErrorPagina(valor)
{
/* Mensaje de error cuando el usuario introduce una pagina que no existe*/
	this.literal_error_pagina = valor;
}

function ObjectManager_setLiteralesPaginacion(pagina,inicio,anterior1,anterior2,siguiente1,siguiente2,fin,ir_a)
{
	this.literales_pagina[0] = pagina;
	this.literales_pagina[1] = inicio;
	this.literales_pagina[2] = anterior1;
	this.literales_pagina[3] = anterior2;
	this.literales_pagina[4] = siguiente1;
	this.literales_pagina[5] = siguiente2;
	this.literales_pagina[6] = fin;
	this.literales_pagina[7] = ir_a;
}

function ObjectManager_setPaginaActual(valor){
/* Pagina actual  */
	this.registro_actual = valor;
}

function ObjectManager_getPaginaActual(){
	return this.registro_actual;
}


function ObjectManager_setTotalObjetos(tcarpetas,tfotos,tids,todos_nombres)
{
/* numero total de objetos sin hacer la paginacion, para calcular las paginas */
	this.total_carpetas = tcarpetas;
	this.total_fotos = tfotos; 
	this.todos_ids = tids; 
	this.todos_nombres = todos_nombres; 
}

function ObjectManager_getTotalObjetos()
{
	return this.total_carpetas;
}

function ObjectManager_setColstoShow(num){
	this.cols_to_show = num;
}

function ObjectManager_getColstoShow(num){
	this.cols_to_show = num;
}

function ObjectManager_setColstoShow(num){
	this.cols_to_show = num;
}

function ObjectManager_getFilas(){
	return this.filas;
}

function ObjectManager_setFilas(num){
	this.filas = num;
}

function ObjectManager_setSelectionActive(bool)
{ this.selection_active=bool; }

function ObjectManager_setColumns()
{
	this.columns=new Array();
	for (var i=0; i < ObjectManager_setColumns.arguments.length; i++)
    { this.columns[i] = ObjectManager_setColumns.arguments[i]; }
}

function ObjectManager_setAligns()
{
	this.aligns=new Array();
	for (var i=0; i < ObjectManager_setAligns.arguments.length; i++)
    { this.aligns[i] = ObjectManager_setAligns.arguments[i]; }
}

function ObjectManager_setSizes()
{
	this.sizes=new Array();
	for (var i=0; i < ObjectManager_setSizes.arguments.length; i++)
    { this.sizes[i] = ObjectManager_setSizes.arguments[i]; }
}

function ObjectManager_setHref(href)
{
	this.href = href;
}
function ObjectManager_showTotals(b)
{ 
	this.show_totals=b; 
}

function ObjectManager_setLiterals(literal1_carpetas,literal2_carpetas,y,literal1_fotos,literal2_fotos)
{
	this.literal1_obj1=literal1_carpetas;
	this.literal2_obj1=literal2_carpetas;
	this.literal_y = y;
	this.literal1_obj2=literal1_fotos;
	this.literal2_obj2=literal2_fotos;
}

function ObjectManager_getLiteralFoto()
{
	return this.literal1_obj2;
}

function ObjectManager_getLiteralFotos()
{
	return this.literal2_obj2;
}

function ObjectManager_getNombreCarpetaSelect()
{
/* Devuelve el nombre de la carpeta que se ha seleccionarlo para poder mostrarlo en el dialogo de cambiar nombre */
	return this.nombre_carpeta_select;
} 

function ObjectManager_getDescripcionCarpetaSelect()
{
/* Devuelve la descripcion de la carpeta seleccionada */
	return this.descripcion_carpeta_select;
}
function ObjectManager_getIdFotoCarpetaSelect()
{
/* Guarda el id de la foto que se selecciona */
	return this.idfoto_carpeta_select;
}

function ObjectManager_addObject(o)
{
	var cl = (this.list.length % 2 == 0) ? 'objectManager_row1' : 'objectManager_row2';
	//o.setClass(cl);
	this.objcount++;
	this.list[this.list.length] = o;
}

function ObjectManager_clicked(e,id,tr)
{
	if (this.selection_active)
	{
		for (i in this.list)
		{
			if (this.list[i].idwidget == id)
			{ 
				if (this.select_all && this.list[i].selected == true)
				{
					document.getElementById('seleccionar_todos_id').checked = false;
					this.select_all = false;
				}
					
				this.list[i].setSelected(!this.list[i].selected,tr); 
			
				this.nombre_carpeta_select = this.list[i].name;
				this.idfoto_carpeta_select = this.list[i].id_foto;
				this.descripcion_carpeta_select = this.list[i].descripcion;
			}
			else
			{
				if ((mac && !e.metaKey) || (!mac && !e.ctrlKey)) // si no esta el CTRL, deselecciono los demas
				{ this.list[i].setSelected(false); }
			}
		}
	}
	e.cancelBubble = true;
	return false;
}

function repintar_objmanager(objetos)
{
/* Crea cada item del objeto*/

	this.clear();

	if (this.objeto == 'carpeta' || this.objeto == 'colecciones')
	{
		for (i=0; i<objetos.length; i++)
		{
			var o = new ObjectItemCarpetas(objetos[i].NOMBRE,objetos[i].DESCRIPCION,objetos[i].ID_CARPETA,objetos[i].PATH_FOTO,objetos[i].V_H,objetos[i].ID_FOTO,objetos[i].HREF,'nombre_objeto',objetos[i].FECHA_CREACION,objetos[i].N_FOTOS,objetos[i].TIPO,'td_normal','td_selec');
			this.addObject(o);	
		}
	}
	if (this.objeto == 'carpetaBlog')
	{
		for (i=0; i<objetos.length; i++)
		{
			var o = new ObjectItemCarpetas(objetos[i].NOMBRE,objetos[i].DESCRIPCION,objetos[i].ID_CARPETA,objetos[i].PATH_FOTO,objetos[i].V_H,objetos[i].ID_FOTO,objetos[i].HREF,'nombre_objeto',objetos[i].FECHA_CREACION,objetos[i].N_FOTOS,objetos[i].TIPO,'td_normal','td_selec',objetos[i].ID_CARPETA,objetos[i].CARPETA_ACTUAL);
			this.addObject(o);
		}
	}
	if (this.objeto == 'foto' || this.objeto == 'foto_guardar_compartida' || this.objeto == 'fotoBlog' || this.objeto == 'fotos_pack')
	{
		var literal_tipo;
		
		for (i=0; i<objetos.length; i++)
		{
			switch (objetos[i].TIPO)
			{
				case "mias":
					literal_tipo = this.literal_tipo_mias;
					break;
				case "he_compartido":
					literal_tipo = this.literal_tipo_he;
					break;
				case "me_comparten":
					literal_tipo = this.literal_tipo_mehan;
					break;
				default:
					literal_tipo = this.literal_tipo_mias;
			}
			var o = new ObjectItemFotos(objetos[i].NOMBRE,objetos[i].DESCRIPCION,objetos[i].ID_FOTO,objetos[i].PATH_FOTO,objetos[i].V_H,objetos[i].ID_FOTO,objetos[i].HREF,'nombre_objeto',objetos[i].FECHA_SUBIDA,objetos[i].N_COMENTARIOS,objetos[i].TIPO,'td_normal_f','td_selec_f',literal_tipo,this.literal_comentarios,objetos[i].PUBLICA, objetos[i].PUBLICA_ALT);
			this.addObject(o);	
			if (this.objeto == 'fotoBlog' && objetos[i].HREF_CREAR != null)
			{
				o.literal_crear_producto = objetos[i].LITERAL_CREAR;
				o.href_crear = objetos[i].HREF_CREAR;
			}
		}
	}
	if (this.objeto == 'colecciones_foto')
	{
		for (i=0; i<objetos.length; i++)
		{
			var o = new ObjectItemFotos(objetos[i].NOMBRE,objetos[i].DESCRIPCION,objetos[i].ID_FOTO,objetos[i].PATH_FOTO,objetos[i].V_H,objetos[i].ID_FOTO,objetos[i].HREF,'nombre_objeto',objetos[i].FECHA_SUBIDA,objetos[i].PRECIO,objetos[i].TIPO,'td_normal_f','td_selec_f',literal_tipo);
			this.addObject(o);
		}
	}
	
	if (this.objeto == 'fondos_blog')
	{
		for (i=0; i<objetos.length; i++)
		{
			var o = new ObjectItemFotos(objetos[i].NOMBRE,objetos[i].DESCRIPCION,objetos[i].ID_FOTO,objetos[i].PATH_FOTO,objetos[i].V_H,objetos[i].ID_FOTO,null,'nombre_objeto',null,null,null,'td_normal_f','td_selec_f',null,null);
			this.addObject(o);
		}
	}
	
	if (this.objeto != 'carpetaBlog' && this.objeto != 'fotoBlog') 
		this.paint();
	else if (this.objeto == 'carpetaBlog')
		this.paintBlogFolder();
	else if (this.objeto == 'fotoBlog')
		this.paintBlog();
}


function ObjectManager_paint()
{
	var literal_carpetas = (this.objcount == 1) ? this.literal1_obj1 : this.literal2_obj1;
	var literal_fotos = (this.total_fotos == 1) ? this.literal1_obj2 : this.literal2_obj2;
	var str= " ";
	var j = 1; //contador del numero de columnas

	str += "<div style='background: url(/imgfiles/Imagenes/punts_discontinuos.gif) repeat-x;height:1px;width:100%;overflow:hidden;'></div>";
	str += "<font style='color:#999999;font:normal 9px 'Verdana';'><img src='/imgfiles/Imagenes/fletxa_miscarpetas.gif'> ";
	if (this.objeto == 'carpeta' || this.objeto == 'colecciones')
		str += this.total_carpetas +" "+ literal_carpetas +" "+ this.literal_y +" "+ this.total_fotos +" "+ literal_fotos;
	if (this.objeto == 'foto' || this.objeto == 'colecciones_foto' || this.objeto == 'foto_guardar_compartida' || this.objeto == 'fotoBlog' || this.objeto == 'fondos_blog' || this.objeto == 'fotos_pack')
		str += this.total_fotos +" "+ literal_fotos;
	str	+= "</font>";
	str += "<table cellspacing=6 acellpadding=5 border='0' width='571' id='objectManager_table'>";
	str += "<tr>";
	
	
	for (i in this.list)
	{ 
		str += this.list[i].getHTML(this.home,0,this.aligns,this.selection_active);
		if (j == this.cols_to_show) //Distribucion de las columnas
		{
			str += "</tr><tr>";
			j = 0;
		}
		j++;
	}
	//Acabar de rellenar
	while (j <= this.cols_to_show)
	{
		str += '<td></td>';
		j++;
	}
	str += "</tr>";
	str += "</table>";
	//Boton volver a la pagina anterior
	if (this.volver)
	{
		str += "<div style='border-top: 1px solid #D4D3D1;width:100%;margin: 0 0 20px 0;'>";
		str += "<div class='boton_volver_fondo'><a href='javascript:history.go(-1);' class='boton_volver_letra'>"+this.literal_volver+"</a></div></div>";
	}

	str += "<div style='background: url(/imgfiles/Imagenes/punts_discontinuos.gif) repeat-x;height:1px;width:100%;overflow:hidden;'></div>";

	if (this.paginacion && this.objcount > 0)
	{
		str += this.mostrarPaginacion();
	}
	if(this.target != null)
	{
		this.target.innerHTML=str;
	}
	else
	{
		document.write(str);
	}
}

function ObjectManager_paintBlogFolder() {
	var literal_carpetas = (this.objcount == 1) ? this.literal1_obj1 : this.literal2_obj1;
	var literal_fotos = (this.total_fotos == 1) ? this.literal1_obj2 : this.literal2_obj2;
	var str= " ";
	var j = 1; //contador del numero de columnas

	str += "<div class='contBlogFolders'>";


	str += "<table cellspacing=6 acellpadding=5 border='0' id='objectManager_"+this.objeto+"_table'>";
	str += "<tr>";
	
	
	for (i in this.list)
	{ 
		str += this.list[i].getHTML_Blog(this.home,0,this.aligns,this.selection_active);
		if (j == this.cols_to_show) //Distribucion de las columnas
		{
			str += "</tr><tr>";
			j = 0;
		}
		j++;
	}
	//Acabar de rellenar
	while (j <= this.cols_to_show)
	{
		str += '<td></td>';
		j++;
	}
	str += "</tr>";
	str += "</table>";

	str += "</div>";

	if (this.paginacion && this.objcount > 0)
	{
		str += "<div class='paginacion_carpetas_blog'>"+this.mostrarPaginacionBlogFolder()+"</div>";
	}

	if(this.target != null)
	{
		this.target.innerHTML=str;
	}
	else
	{
		document.write(str);
	}
}


function ObjectManager_paintBlog() {

	var literal_carpetas = (this.objcount == 1) ? this.literal1_obj1 : this.literal2_obj1;
	var literal_fotos = (this.total_fotos == 1) ? this.literal1_obj2 : this.literal2_obj2;
	var str= " ";
	var j = 1; //contador del numero de columnas

	str += "<table cellspacing=6 acellpadding=5 border='0' id='objectManager_"+this.objeto+"_table'>";
	str += "<tr>";
	
	
	if (document.form1.tipo_vista.value != 'miniaturas') {
	
	   for (i in this.list)
		{ 
			str += this.list[i].getHTML_Blog(this.home,0,this.aligns,this.selection_active);
			if (j == this.cols_to_show) //Distribucion de las columnas
			{
				str += "</tr><tr>";
				j = 0;
			}
			j++;
		}
	} else {
	   for (i in this.list)
		{ 
			str += this.list[i].getHTML_BlogMini(this.home,0,this.aligns,this.selection_active);
			if (j == this.cols_to_show) //Distribucion de las columnas
			{
				str += "</tr><tr>";
				j = 0;
			}
			j++;
		}	
	}
		
	//Acabar de rellenar
	while (j <= this.cols_to_show)
	{
		str += '<td></td>';
		j++;
	}
	str += "</tr>";
	str += "</table>";
	if (this.objeto == 'fotoBlog') {
		str += "<div style='background: url(/imgfiles/Imagenes/punts_discontinuos.gif) repeat-x;height:1px;width:100%;overflow:hidden;'></div>";
	}
	if (this.paginacion && this.objcount > 0)
	{
		str += "<br>" + this.mostrarPaginacion();
	}
	//Boton volver a la pagina anterior
	if (this.volver)
	{
		str += "<div style='border-top: 1px solid #D4D3D1;width:100%;margin: 0 0 20px 0;'>";
		str += "<div class='boton_volver_fondo'><a href='javascript:history.go(-1);' class='boton_volver_letra'>"+this.literal_volver+"</a></div></div>";
	}
	if(this.target != null)
	{
		this.target.innerHTML=str;
	}
	else
	{
		document.write(str);
	}
}


function ObjectManager_mostrarPaginacion()
{
/* Botones de paginacion  */
	var num_pag = 0; //Numero de paginas
	var str= " ";
		
	if (this.filas > 0)
	{
		num_pag = Math.ceil(this.total_carpetas/(this.cols_to_show * this.filas));

		if (num_pag > 1)
		{
				str += "<br><div align='center' class='pagDichis'>"+this.literales_pagina[0] +" "+ this.pagina_actual + " / " + num_pag;
				str += "&nbsp;&nbsp;&#124;&nbsp;&nbsp;<img src='/imgfiles/Imagenes/paginacion/paginacio_ant1.gif' alt='' onClick='"+this.jomateix+".paginaInicio();' style='cursor:pointer;' class='icono_off' onMouseOver=\"this.className='icono_on'\";' onMouseOut=\"this.className='icono_off'\";' alt='"+this.literales_pagina[1]+"' title='"+this.literales_pagina[1]+"'>";
				str += "&nbsp;&nbsp;<a href='javascript:"+this.jomateix+".paginaAnterior();' onMouseOver=\"document.getElementById('ant2').className='icono_on'\";' onMouseOut=\"document.getElementById('ant2').className='icono_off'\";'><img src='/imgfiles/Imagenes/paginacion/paginacio_ant2.gif' id='ant2' alt='"+this.literales_pagina[2]+"' title='"+this.literales_pagina[2]+"' border='0' class='icono_off' onMouseOver=\"this.className='icono_on'\";' onMouseOut=\"this.className='icono_off'\";'>&nbsp;&nbsp;"+this.literales_pagina[3] + "</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:"+this.jomateix+".paginaSiguiente();' onMouseOver=\"document.getElementById('sig2').className='icono_on'\";' onMouseOut=\"document.getElementById('sig2').className='icono_off'\";'>"+this.literales_pagina[4];
				str += "&nbsp;&nbsp;<img src='/imgfiles/Imagenes/paginacion/paginacio_sig2.gif' alt='"+this.literales_pagina[5]+"' title='"+this.literales_pagina[5]+"' border='0' id='sig2' class='icono_off' onMouseOver=\"this.className='icono_on'\";' onMouseOut=\"this.className='icono_off'\";'></a>";
				str += "&nbsp;&nbsp;<img src='/imgfiles/Imagenes/paginacion/paginacio_sig1.gif' alt='' onClick='"+this.jomateix+".paginaFin();' style='cursor:pointer;' class='icono_off' onMouseOver=\"this.className='icono_on'\";' onMouseOut=\"this.className='icono_off'\";' alt='"+this.literales_pagina[6]+"' title='"+this.literales_pagina[6]+"'>&nbsp;&nbsp;";
				str += this.literales_pagina[7] + "&nbsp;<input type='text' size='4' name='ir_a' value='#' onFocus='this.select();' onKeyPress='if (es_enter(this,event))"+this.jomateix+".paginaIr(document.form1.ir_a.value);' class='pagDichisInput'>&nbsp;";
				str += "<span class='flecha_ir_a' onClick='"+this.jomateix+".paginaIr(document.form1.ir_a.value);'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>";
				str += "</div>";
		}
	}
		return str;
}

function ObjectManagermostrarPaginacionBlogFolder() {

/* Botones de paginacion  */
	var num_pag = 0; //Numero de paginas
	var str= " ";
	
	num_pag = Math.ceil(this.total_carpetas/(this.cols_to_show * this.filas));
	
	if (num_pag > 1)
	{
		str += "<div align='center' class='pagDichis'>"+this.literales_pagina[0] +" "+ this.pagina_actual + " / " + num_pag + '<br>';
		str += "&nbsp;&nbsp;<a href='javascript:"+this.jomateix+".paginaAnterior();' onMouseOver=\"document.getElementById('antfolder').className='icono_on'\";' onMouseOut=\"document.getElementById('antfolder').className='icono_off'\";'><img src='/imgfiles/Imagenes/paginacion/paginacio_ant2.gif' id='antfolder' alt='"+this.literales_pagina[2]+"' border='0' onMouseOver=\"document.getElementById('antfolder').className='icono_on'\";' onMouseOut=\"document.getElementById('antfolder').className='icono_off'\";' class='icono_off'>&nbsp;&nbsp;"+this.literales_pagina[3] + "</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:"+this.jomateix+".paginaSiguiente();' onMouseOver=\"document.getElementById('sigfolder').className='icono_on'\";' onMouseOut=\"document.getElementById('sigfolder').className='icono_off'\";'>"+this.literales_pagina[4];
		str += "&nbsp;&nbsp;<img src='/imgfiles/Imagenes/paginacion/paginacio_sig2.gif' id='sigfolder' alt='"+this.literales_pagina[5]+"' border='0' class='icono_off' onMouseOver=\"document.getElementById('sigfolder').className='icono_on'\";' onMouseOut=\"document.getElementById('sigfolder').className='icono_off'\";'></a>";
		str += "</div>";
	}
	return str;
}

function ObjectManager_paginaSiguiente()
{
	/* Al darle al boton correspondiente calcula la pagina SIGUIENTE de carpetas a mostrar y llama a mostrar las carpetas */

	if (this.pagina_actual < Math.ceil(this.total_carpetas/(this.cols_to_show * this.filas)))
	{
		this.registro_actual = this.registro_actual + this.getRegistrosPagina();
		this.pagina_actual = this.pagina_actual + 1;
		switch (this.objeto)
		{
			case "carpeta": 
				getCarpetas(document.form1.ordenacion.value,document.form1.tipo.value,this.registro_actual);
			break;
			case "foto": 
				getFotos(document.form1.ordenacion.value,document.form1.tipo.value,document.form1.id.value,this.registro_actual,document.form1.palabra_busc.value);
			break;
			case "foto_guardar_compartida":
				getFotosCompartidas(document.form1.ids.value,this.registro_actual,document.form1.id_compartir.value);
			break;
			case "fotos_pack":
				get_fotos_pack(document.form1.id.value,'fotos',this.registro_actual);
			break;
			case "colecciones":
				getColecciones(document.form1.ordenacion.value,this.registro_actual);
			break;
			case "colecciones_foto": 
				getFotos(document.form1.ordenacion.value,document.form1.id.value,this.registro_actual);
			break;
			case "carpetaBlog":
				getCarpetasBlogFront(this.registro_actual,document.form1.id_cliente.value);
			break;
			case "fotoBlog":
				getFotosBlogFront(document.form1.tipo_vista.value,document.form1.id_cliente.value,document.form1.id_carpeta.value,this.registro_actual);
			break;
			case "fondos_blog":
				get_fondos_blog(this.registro_actual);
			break;
		}
	}
}

function ObjectManager_paginaAnterior()
{
/* Al darle al boton correspondiente calcula la pagina ANTERIOR de carpetas a mostrar y llama a mostrar las carpetas */

	if (this.pagina_actual > 1)
	{
		this.registro_actual = this.registro_actual - this.getRegistrosPagina();
		this.pagina_actual = this.pagina_actual - 1;
		switch (this.objeto)
		{
			case "carpeta": 
				getCarpetas(document.form1.ordenacion.value,document.form1.tipo.value,this.registro_actual);
			break;
			case "foto": 
				getFotos(document.form1.ordenacion.value,document.form1.tipo.value,document.form1.id.value,this.registro_actual,document.form1.palabra_busc.value);
			break;
			case "foto_guardar_compartida":
				getFotosCompartidas(document.form1.ids.value,this.registro_actual,document.form1.id_compartir.value);
			break;
			case "fotos_pack":
				get_fotos_pack(document.form1.id.value,'fotos',this.registro_actual);
			break;
			case "colecciones":
				getColecciones(document.form1.ordenacion.value,this.registro_actual);
			break;
			case "colecciones_foto": 
				getFotos(document.form1.ordenacion.value,document.form1.id.value,this.registro_actual);
			break;
			case "carpetaBlog":
				getCarpetasBlogFront(this.registro_actual,document.form1.id_cliente.value);
			break;
			case "fotoBlog":
				getFotosBlogFront(document.form1.tipo_vista.value,document.form1.id_cliente.value,document.form1.id_carpeta.value,this.registro_actual);
			break;
			case "fondos_blog":
				get_fondos_blog(this.registro_actual);
			break;
		}
		
		
	}
}

function ObjectManager_paginaInicio()
{
/* PRIMERA pagina */

	this.registro_actual = 0;
	this.pagina_actual = 1;
	switch (this.objeto)
	{
		case "carpeta": 
			getCarpetas(document.form1.ordenacion.value,document.form1.tipo.value,this.registro_actual);
		break;
		case "foto": 
			getFotos(document.form1.ordenacion.value,document.form1.tipo.value,document.form1.id.value,this.registro_actual,document.form1.palabra_busc.value);
		break;
		case "foto_guardar_compartida":
			getFotosCompartidas(document.form1.ids.value,this.registro_actual,document.form1.id_compartir.value);
		break;
		case "fotos_pack":
				get_fotos_pack(document.form1.id.value,'fotos',this.registro_actual);
		break;
		case "colecciones":
			getColecciones(document.form1.ordenacion.value,this.registro_actual);
		break;
		case "colecciones_foto": 
			getFotos(document.form1.ordenacion.value,document.form1.id.value,this.registro_actual);
		break;
		case "fotoBlog":
			getFotosBlogFront(document.form1.tipo_vista.value,document.form1.id_cliente.value,document.form1.id_carpeta.value,0);
		break;
		case "fondos_blog":
			get_fondos_blog(this.registro_actual);
		break;
	}
}

function ObjectManager_paginaFin()
{
/* uLTIMA pagina */

	if (this.total_carpetas % this.getRegistrosPagina() == 0)
		this.registro_actual = this.total_carpetas - this.getRegistrosPagina();
	else
		this.registro_actual = this.total_carpetas - (this.total_carpetas % this.getRegistrosPagina());
	this.pagina_actual = Math.ceil(this.total_carpetas/(this.cols_to_show * this.filas));
	switch (this.objeto)
	{
		case "carpeta": 
			getCarpetas(document.form1.ordenacion.value,document.form1.tipo.value,this.registro_actual);
		break;
		case "foto": 
			getFotos(document.form1.ordenacion.value,document.form1.tipo.value,document.form1.id.value,this.registro_actual,document.form1.palabra_busc.value);
		break;
		case "foto_guardar_compartida":
			getFotosCompartidas(document.form1.ids.value,this.registro_actual,document.form1.id_compartir.value);
		break;
		case "fotos_pack":
			get_fotos_pack(document.form1.id.value,'fotos',this.registro_actual);
		break;
		case "colecciones":
			getColecciones(document.form1.ordenacion.value,this.registro_actual);
		break;
		case "colecciones_foto": 
			getFotos(document.form1.ordenacion.value,document.form1.id.value,this.registro_actual);
		break;
		case "fotoBlog":
			getFotosBlogFront(document.form1.tipo_vista.value,document.form1.id_cliente.value,document.form1.id_carpeta.value,this.registro_actual);
		break;
		case "fondos_blog":
			get_fondos_blog(this.registro_actual);
		break;
	}
}

function ObjectManager_paginaIr(pagina)
{
/* Va a una pagina concreta */

	pagina = parseInt(pagina);
	if (pagina <= Math.ceil(this.total_carpetas/(this.cols_to_show * this.filas)))
	{
		this.registro_actual = pagina * this.getRegistrosPagina() - this.getRegistrosPagina();
		this.pagina_actual = pagina;
		switch (this.objeto)
		{
			case "carpeta": 
				getCarpetas(document.form1.ordenacion.value,document.form1.tipo.value,this.registro_actual);
			break;
			case "foto": 
				getFotos(document.form1.ordenacion.value,document.form1.tipo.value,document.form1.id.value,this.registro_actual,document.form1.palabra_busc.value);
			break;
			case "foto_guardar_compartida":
				getFotosCompartidas(document.form1.ids.value,this.registro_actual,document.form1.id_compartir.value);
			break;
			case "fotos_pack":
				get_fotos_pack(document.form1.id.value,'fotos',this.registro_actual);
			break;
			case "colecciones":
				getColecciones(document.form1.ordenacion.value,this.registro_actual);
			break;
			case "colecciones_foto": 
				getFotos(document.form1.ordenacion.value,document.form1.id.value,this.registro_actual);
			break;
			case "fotoBlog":
				getFotosBlogFront(document.form1.tipo_vista.value,document.form1.id_cliente.value,document.form1.id_carpeta.value,this.registro_actual);
			break;
			case "fondos_blog":
				get_fondos_blog(this.registro_actual);
			break;
		}
	}
	else
	{
		alerta(this.literal_error_pagina);
		document.form1.ir_a.select();
	}
}

function ObjectManager_paintMultiple()
{
	var literal = (this.objcount == 1) ? this.literal1 : this.literal2;
	
	var str = "<table cellspacing=0 cellpadding=0 id='objectManager_table'>";		   

	var cols = this.columns.length;
	str += "<tr><td class=\"objectManager_headercell\">&nbsp;</td>";
	
	//Pinto las 4 columnas vacias
	for (h=0;h<3; h++)
	{
		var width = 225;
		//if (this.sizes != null && this.sizes[h] != null)
		//{ width = this.sizes[h]; }
			
		str += "<td width=\"" + width + "\" class=\"objectManager_headercell\" ";
		if (this.aligns != null && this.aligns[h] != null)
		{ str += " style=\"text-align:" + this.aligns[h] + ";\" "; }

		str += ">&nbsp;&nbsp;</td>";
	}
	
	str += "</tr>";
	
	var i=0;
	while (i<this.list.length)
	{ 	
		str+="<tr>";
		for (h=0; h<=3; h++)
		{
			if (i < this.list.length) {	
				var aux = this.list[i].getMultipleHTML(this.home,cols,this.aligns,this.selection_active);
				str += aux;
			}
			else {
				str += "<td class=\"objectManager_rowcell\">&nbsp;</td>";
			}
			i++;
		}
		str+="</tr>";
			
	}
	
	if (this.show_totals)
	{
		str += "<tr><td colspan=\"4\" class=\"objectManager_headercell\"";
		if (cols > 0)
			{ var colspan=cols+1; str += " colspan="+colspan; }
		str += "><span class=\"objectManager_text\">&nbsp;&nbsp;"
			+ this.objcount + "&nbsp;" + literal + "</span>";
			str += "</td></tr>";
	}
	str += "</table>";
	document.write(str);
}

function ObjectManager_clear()
{
	this.list = new Array;
	this.objcount = 0;
}

function ObjectManager_getSelected()
{
	var str="";
	for (i in this.list)
	{
		if (this.list[i].selected)
		{ str += this.list[i].sel_name + ","; }
	}
	//Quitamos la ultima coma
	str = str.substring(0,str.length-1);
	return str;
}

function ObjectManager_modificar_todos_seleccionados(checked)
{
	var ids;
	var i, j= 0;
	var td="";
	
	//ids = this.todos_ids.split(","); //Obtenemos los ids para updatar su seleccion
	if (checked == false)
		this.select_all = false;
	else
		this.select_all = true;
	
	//Seleccionar los que se ven
	for (i in this.list)
	{
		td = 'td_'+this.list[i].id_foto;
		//this.list[i].setSelected(!this.list[j].selected,td); 
		this.list[i].setSelected(checked,document.getElementById(td)); 
		this.nombre_carpeta_select = this.list[i].name;
		this.idfoto_carpeta_select = this.list[i].id_foto;
		this.descripcion_carpeta_select = this.list[i].descripcion;
//		this.clicked(event,this.list[i].idwidget,document.getElementById(td));
	}

	
	/*for (i=1;i<=ids.length;i++)
	{
		td = 'td_'+ids[i];
		alert(ids[i]+'\ntd--> '+td);
		
		//ids[i].setSelected(!ids[i].selected,td);
	}*/
}

function ObjectManager_setSelect_all(select)
{
/* Updata el atributo que indica si se seleccionan todos o no */
	this.select_all = select; 
}

function ObjectManager_getSelect_all()
{
/* Devuelve el atributo que indica si se seleccionan todos o no */
	return this.select_all;
}

function ObjectManager_getNombresSelected()
{
/* Nos muestra con un string el nombre de los items que se han seleccionado. Utilizado para la pantalla compartir */

	var str="";
	for (i in this.list)
	{
		if (this.list[i].selected)
		{ str += this.list[i].name + ", "; }
	}
	//Quitamos la ultima coma
	str = str.substring(0,str.length-2);
	return str;
}

function ObjectManager_getTodos_ids()
{
/* Devuelve todos los identificadores obtenidos */
	return this.todos_ids;
}

function ObjectManager_getTodos_nombres()
{
/* Devuelve los nombres de todos los objetos sin tener en cuenta la paginacion */
	return this.todos_nombres;
}

function ObjectManager_count_Selected()
{
/* Funcion que devuelve el numero de objetos que se han seleccionado*/

	var j=0;
	for (i in this.list)
	{
		if (this.list[i].selected)
		{ j++; }
	}
	return j;
}

function ObjectManager_registros_pagina()
{
/* Indica el numero de registros que aparecera en cada pagina */

	var n_registros = 0;
	
	n_registros = this.cols_to_show * this.filas;
	
	return n_registros;
}

function ObjectManager_setVolver(valor)
{
/* Cierto, aparecera el boton volver a la pagina anterior. Falso no*/

	this.volver = valor;
}

function ObjectManager_getVolver()
{
	return this.volver;
}

function ObjectManager_setLiteralVolver(valor)
{
/*Literal del boton volver*/
	this.literal_volver = valor;
} 

function ObjectManager_setLiteralesTipo(mias,he,mehan,comentarios)
{
/* Literales de me han compartido, he compartido o mias*/
	this.literal_tipo_mias = mias;
	this.literal_tipo_he = he;
	this.literal_tipo_mehan = mehan;
	this.literal_comentarios = comentarios
}

