$(document).ready(function(){
	$('ul#cab').innerfade({speed: 2000, timeout: 15000, type: 'sequence', containerheight: '158px'});
	$('ul#cab').addClass('mostrar');
	Shadowbox.init({
		handleOversize:     "drag",
		continuous:			"true",
		displayCounter:		"true",
		slideshowDelay:		8,
		continuous: 		"true"
	});
	
	/* Mostrar/Ocultar */
	$('.boton-mostrar').click(
		function() {	
			var ocultar = $(this);
			var capa = $(this).attr("id").substring(1,$(this).attr("id").length);
			if ($(this).html() == 'Mostrar') {
				$('div#contenidos div.ocultar').not('#'+capa).slideUp('slow', function() {
					$('div#'+capa).slideDown('slow');
					$('.boton-mostrar').html('Mostrar');
					$(ocultar).html('Ocultar');
					/*destino = $('#1'+capa).offset().top;
					$("html:not(:animated),body:not(:animated)").delay(1000).animate({ scrollTop: destino}, 1000 );*/
				});
			}
			else {
				$('div#'+capa).slideUp('slow');
				$(ocultar).html('Mostrar');
			}
		}
	);
	$('.verEmoticonos').click(function() {
		$(this).fadeOut(200, function() {
			$('.smileys').fadeIn(500);
		});
	});
	
	$('.foro').hover(function () {
		$('.admin-foro', this).fadeIn(300);
	}, function() {
		$('.admin-foro', this).fadeOut(300);
	});
});

function favoritos(titulo,url) {
	if (window.sidebar) {
		window.sidebar.addPanel(titulo, url,"");
	} else if(document.all) {
		window.external.AddFavorite( url, titulo);
	} else if(window.opera && window.print) {
		return true;
	}
	else {
		alert("Presiona Ctrl+D para agregar a favoritos");
	}
}

function limita(obj,elEvento, maxi) {
  var elem = obj;
 
  var evento = elEvento || window.event;
  var cod = evento.charCode || evento.keyCode;
 
  if(cod == 37 || cod == 38 || cod == 39
  || cod == 40 || cod == 8 || cod == 46)
  {
	return true;
  }
 
  if(elem.value.length < maxi) {
	return true;
  }
  return false;
}
 
function cuenta(obj,evento,maxi,div) {
	var elem = obj.value;
	var info = document.getElementById(div);
	info.innerHTML = maxi-elem.length;
}

$('.dir_mail').each(function(){
	$('.dir_mail').html($('.dir_mail').html().replace('#NOSPAM#','@').replace('#C#','').replace('#P#','.'));
});

function emoticon(cod) {
	document.formulario.contenido.value = jQuery.trim(document.formulario.contenido.value)+cod;
	$(".wysiwyg").cleditor()[0].updateFrame();
}
