



addMensaje = function(mensaje, clase)
{
 if (clase === undefined) clase = 'error';

 var div = $('#'+this.id);
 if (!fcexist('#'+this.id+' div.'+clase))
 {
 $(div).append('<div class="'+clase+' uno"></div>');
 $(div).children('div.'+clase).append('<ul></ul>');
 } else {
 if ($('#'+this.id+' div.'+clase+' ul li').length == 1)
 {
 $('#'+this.id+' div.'+clase).removeClass('uno');
 $('#'+this.id+' div.'+clase).addClass('dos');
 }
 }

 div = $('#'+this.id+' div.'+clase+' ul');
 $(div).append('<li>'+mensaje+'</li>');
}
reset = function()
{
 var div = $('#'+this.id);
 $(div).empty();
}

Mensaje = function(id_mensaje) 
{
 if(fcexist("#"+id_mensaje))
 {
 this.id = id_mensaje;
 this.addMensaje = addMensaje;
 this.reset = reset;
 } else {
 alert("Mensaje('"+id_mensaje+"') no encontrado.");
 }
}

function fcexist (id_o_class_jquery)
{
 if( $(id_o_class_jquery).length > 0 )
 return true;
 else 
 return false;
}




$(function() {
 function Paginador($el, opt)
 {
 var self = this;
 
 
 function gotopage(pagina, evt)
 {
 opt.pagina = pagina;
 dibujar_links();
 var continuePropagation = opt.callback(pagina);
 if (!continuePropagation) {
 if (evt.stopPropagation) {
 evt.stopPropagation();
 }
 else {
 evt.cancelBubble = true;
 }
 }
 return continuePropagation;
 }

 
 function dibujar_links()
 {
 
 var clickhandler = function (pagina)
 {
 return function(evt) { return gotopage(pagina, evt); }
 }

 
 var addElement = function (pagina, texto)
 {
 var elemento;
 if (pagina == opt.pagina || pagina <= 0 || pagina > opt.paginas)
 {
 elemento = $('<span class="current">'+texto+'</span>');
 } else {
 elemento = $('<a>'+texto+'</a>')
 .attr('href', opt.href+'&pagina='+pagina)
 .bind('click', clickhandler(pagina));
 }
 $el.append(elemento);
 $el.append(' ');
 }

 $el.empty();

 
 
 

 
 var digitos = String(opt.pagina).length;
 var links = opt.links;
 if (digitos > 2)
 links = links - digitos + 2;

 
 var inicio = Math.floor(opt.pagina-(links/2))+1;
 if(inicio <= opt.links_extremos) inicio = parseInt(opt.links_extremos) + 1;
 var fin = inicio + parseInt(links) - 1;
 if (fin > opt.paginas)
 {
 fin = opt.paginas;
 inicio = fin - links + 1;
 if (inicio < 1) inicio = 1;
 }

 
 addElement(opt.pagina-1, '&laquo; Atr&aacute;s');

 var freno, i;
 
 if (inicio > 1 && opt.links_extremos > 0)
 {

 if (inicio > opt.links_extremos)
 freno = opt.links_extremos;
 else
 freno = inicio;

 for (i = 1; i <= freno; i++)
 addElement(i, i);

 if (inicio > opt.links_extremos + 1)
 $el.append('<span>...</span> ');
 }

 
 for (i = inicio; i <= fin; i++)
 addElement(i, i);

 
 if (fin < opt.paginas && opt.links_extremos > 0)
 {
 if (fin < (opt.paginas - opt.links_extremos))
 {
 $el.append('<span>...</span> ');
 freno = opt.paginas - opt.links_extremos + 1;
 } else
 freno = fin + 1;

 for (i = freno; i <= opt.paginas; i++)
 addElement(i, i);
 }

 
 addElement(opt.pagina+1, 'Siguiente &raquo;');

 
 }

 
 $.extend(self,
 {
 setPaginas: function(paginas, redibujar)
 {
 opt.paginas = paginas;
 if (redibujar !== false)
 dibujar_links();
 return self;
 }
 }); 

 
 var datos = $el.find('div').html();
 datos = datos.split(',');
 opt.pagina = parseInt(datos[1]);
 opt.paginas = parseInt(datos[2]);
 opt.links = parseInt(datos[3]);
 opt.links_extremos = parseInt(datos[4]);
 opt.href = datos[5];

 dibujar_links();
 }

 jQuery.fn.paginador = function(opt)
 {
 
 var el = this.eq(typeof opt == 'number' ? opt : 0).data('paginador');
 if (el) { return el; }
 
 opt = $.extend({
 pagina: 1,
 paginas: 1,
 links: 10,
 links_extremos: 2,
 href: '',
 callback:function(){ return false; }
 },opt||{});

 this.each(function() {
 el = new Paginador($(this), opt);
 
 $(this).data('paginador', el);
 });

 return el;
 }

});




$(document).ready( function()
{
 $('#estrella_uno').fadeTo("fast", 0.01);
 $('#estrella_dos').fadeTo("fast", 0.01);

 $('a.uno').hover(function(){
 $('#estrella_uno').fadeTo("fast", 1);
 }, function(){
 $('#estrella_uno').fadeTo("fast", 0.01);
 });
 $('a.dos').hover(function(){
 $('#estrella_dos').fadeTo("fast", 1);
 }, function(){
 $('#estrella_dos').fadeTo("fast", 0.01);
 });

 if ($('#subetufoto'))
 {
 
 subra = function ()
 {
 if ( $('#subetufoto').css('text-decoration') == 'none')
 $('#subetufoto').css('text-decoration', 'underline');
 else
 $('#subetufoto').css('text-decoration', 'none');
 setTimeout('subra()', 500);
 }
 subra();
 }

});