/* BUSCADOR ******************************/
function limpiarCasilla(texto,div){
	if(div.value==texto) div.value="";
}
function completarCasilla(texto,div){
	if(div.value=="") div.value=texto;
}
/*****************************************/

/* DESTACAR RANKING **********************/
function destacar(obj){
	obj.className+=' hover';
}
function restaurar(obj){
	obj.className=obj.className.substr(0,obj.className.length-6);
}
/*****************************************/

/* POPUP *********************************/
function popup(swf,ancho,alto){
	var posx=(screen.width/2)-(ancho/2);
	var posy=(screen.height/2)-(alto/2);
	window.open(swf,'popup','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+ancho+',height='+alto+',top='+posy+',left='+posx);
}
/*****************************************/

/* SUSCRIBIRSE POR EMAIL *****************/
function feed(email){
	if(validaMail(email)){ window.open('http://www.feedburner.com/fb/a/emailverifySubmit?feedId=1778064&email='+email, 'popupwindow', 'scrollbars=yes,width=550,height=520'); }
	else{ alert('Por favor, ingresa una dirección de correo válida.'); }
}
/*****************************************/

/* VALIDAR *******************************/
function comentar(){
	ok=1;
	errores = new Array();
	if(!validacion_simple("comentario_autor","")){ ok=0; errores.push("Debes escribir tu nombre."); }
	if(!valida_mail("comentario_email")){ ok=0; errores.push("Debes ingresar tu email."); }
	if(!validacion_simple("comentario_texto","")){ ok=0; errores.push("Debes escribir un comentario."); }
	
	if(ok==0){ mostrar_errores(errores); }
	else{ document.comentario.submit(); }
}

function enviar_mensaje(){
	ok=1;
	errores = new Array();
	if(!validacion_simple("nombre","")){ ok=0; errores.push("Debes escribir tu nombre."); }
	if(!valida_mail("mail")){ ok=0; errores.push("Debes ingresar tu email."); }
	if(!validacion_simple("mensaje","")){ ok=0; errores.push("Debes escribir un mensaje."); }
	
	if(ok==0){ mostrar_errores(errores); }
	else{ document.mensaje.submit(); }
}

function validacion_simple(id,min_digitos){
	var ok=1;
	casilla=document.getElementById(id);

	if(min_digitos!=""){
		if(casilla.value.length<min_digitos) { ok=0; }
	}
	else{
		if(casilla.value.length<1) { ok=0; }
	}
	
	return ok;
}

function valida_mail(id){
	casilla=document.getElementById(id);
	var ok=1;
	var es_email=/^(.+\@.+\..+)$/;
	if(!es_email.test(casilla.value)) { ok=0; }
	
	return ok;
}

function validaMail(dato){
	var ok=1;
	var es_email=/^(.+\@.+\..+)$/;
	if(!es_email.test(dato)) { ok=0; }
	
	return ok;
}

function mostrar_errores(error){
	txt="Por favor, revisa los siguientes datos:\n\n";
	for(i=0;i<error.length;i++){
		txt=txt+"- "+error[i]+"\n";
	}
	alert(txt);
}
/*****************************************/

/* FIX PARA EXPLORER 6 *******************/
function PNG_loader() {
	for(var i=0; i<document.images.length; i++) {
		var img = document.images[i];
		var imgName = img.src.toUpperCase();
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG" && img.className=="img_puesto") {
		 var imgID = (img.id) ? "id='" + img.id + "' " : "";
		 var imgClass = (img.className) ? "class='" + img.className + "' " : "";
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
		 var imgStyle = "display:inline-block;" + img.style.cssText;
		 if (img.align == "left") imgStyle += "float:left;";
		 if (img.align == "right") imgStyle += "float:right;";
		 if (img.parentElement.href) imgStyle += "cursor:hand;";
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
		 img.outerHTML = strNewHTML;
		 i--;
		}
	}
}
if(window.attachEvent) window.attachEvent("onload",PNG_loader);
/*****************************************/

/* NICESCROLL ****************************/
var ubicacionActual=-1, destino, velocidad, t;
function niceScroll(dest, vel){
	if(!vel){ vel=10; }
	destino=dest;
	velocidad=vel;
	ir();
}
function ir(){
	donde=findPos(document.getElementById(destino),'y');
	if(navigator.appName=="Netscape"){ ubi=window.pageYOffset; }
	else{ ubi=document.documentElement.scrollTop; }
	if((ubi>donde || ubi<donde) && ubicacionActual!=ubi){
		ubicacionActual=ubi;
		dest=ubicacionActual+((donde-ubicacionActual)/8);
		window.scroll(0,dest);
		setTimeout(ir,velocidad);
	}
	else{
		ubicacionActual=-1;
	}
}
function findPos(obj) {
	var curTop=0;
	if (obj.offsetParent) {
		curTop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curTop += obj.offsetTop;
		}
	}
	return curTop;
}
/*****************************************/
