var turl = "";
// JavaScript Document
$(function(){
	//ticker
	/*
	$.get(
		"ajaxnews.html", {}, function(data)
		{
			$("#comentarios").append(data).find("ul").newsTicker();
		}
	)	
	*/
	//$("#comentarios").newsTicker(); 
	
	$('#boton_deja_mensaje').click(function(){
		$('#contenedor_comentarios').hide();
		$('#form_mensaje').show(function(){
			$('#form_mensaje').css('display', 'table-cell')	;
			$('#mensaje').focus();
		});
	});
	
	$('#boton_cancelar_menjsaje').click(function(){

		$('#form_mensaje').hide();
		$('#contenedor_comentarios').show();
	});
		

	$('#boton_ok_menjsaje').click(function(){
		if($('#nombre').val() != '' && $('#mensaje').val() != '')  {
			$('#error_mensaje').html('Aguantá un castaña');
			$('#boton_ok_menjsaje').hide();
			$('#boton_cancelar_menjsaje').hide();			
			 $.ajax({
			   type: "POST",
			   url: "_include/mensaje.inc.php",
			   data: "nick="+$('#nombre').val()+"&mensaje="+$('#mensaje').val(),
			   success: function(msg){
				$('#error_mensaje').html('Tu mensaje lo chequeará Barney y luego será publicado');
				setTimeout("$('#form_mensaje').hide(); $('#contenedor_comentarios').show();",2000);
				
			   }
			 });
		} else {
			$('#error_mensaje').html('Dejá tu nombre y un mensaje');
		}
		
		

	});

	//abrirPopup("Chupame los 2", "popup.html", 600, 420);

	$("body").append("<div class=\"overlay\" id=\"overlay_generico\"><div class=\"contentWrap\"></div></div>");
	
	$("#overlay_generico").overlay({ 

 
		expose: { 
			color: '#000000', 
			loadSpeed: 200, 
			opacity: 0.7 
		}, 
		effect: 'apple', 

        onBeforeLoad: function() { 

            var wrap = this.getContent().find("div.contentWrap"); 
            wrap.load(turl);
        }
    });	


	
	//openOverlay("popup.html");
	
});

function abrirPopup(titulo, url, ancho, alto, params){
	//if(no_detener_video == undefined) 
		//$('#video').html('<img src="img/selecciona.png" width="800" height="600" border="0" />');
	tb_show(titulo, url+'?width='+ancho+'&height='+alto+'&'+params);	
	
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
function valmsg(my)
{
	if(my.value.trim() == my.defaultValue)
		my.value = ''
	else if(my.value.trim()=='')
		my.value = my.defaultValue
	return false
}

function validarRecomendar(formData, jqForm, options) { 
	email_remitente = $('#email_remitente').val();
	email = $('#email').val();
	
	var errores = '';
	var re  = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

	if (!re.test(email_remitente)) 
		errores += 'No ingresaste tu e-mail\n';	

	if (!re.test(email)) 
		errores += 'No ingresaste e-mail de tu amigo\n';	
	

	if(errores != ''){ 
		alert('Se produjeron los siguientes errores:\n'+errores)
		return false;
	}else{
		$('#boton_enviar').attr({disabled: 'disabled'});
		$('#progreso').show();
		return true; 	
	}
} 
 
function respuestaRecomendar(responseText)  {
    $('#progreso').hide();
	if(responseText.substr(0, 2) == 'OK'){
		alert('Se envió el video a tu amigo');
		tb_remove();
	} else {
		alert('Se produjo un error');
		$('#boton_enviar').attr({disabled: ''});
	}
	
	
}

function validarBajar(formData, jqForm, options) { 
	email = $('#email').val();
	
	var errores = '';
	var re  = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;

	if (!re.test(email)) 
		errores += 'No ingresaste tu e-mail\n';	

	if(errores != ''){ 
		alert('Se produjeron los siguientes errores:\n'+errores)
		return false;
	}else{
		$('#boton_enviar').attr({disabled: 'disabled'});
		$('#progreso').show();
		return true; 	
	}
} 
 
function respuestaBajar(responseText)  {
    $('#progreso').hide();
	if(responseText.substr(0, 2) == 'OK'){
		alert('Se envió a tu e-mail el link para bajarte el disco');
		tb_remove();
	} else {
		alert('Se produjo un error');
		$('#boton_enviar').attr({disabled: ''});
	}
	
	
}

function respuestaInscribite(responseText)  {
    $('#progreso').hide();
	if(responseText.substr(0, 2) == 'OK'){
		alert('Te vamos a llenar la casilla de mierda. Jodete por maraca');
		tb_remove();
	} else {
		alert('Se produjo un error');
		$('#boton_enviar').attr({disabled: ''});
	}
	
	
}

function abrirFoto(i){
	abrirPopup(titulo_foto, '_scripts/fotos.php?i='+i, ancho_foto+20, alto_foto+50, "")

}

function siguienteFoto(){
	foto_actual++;
	abrirFoto(foto_actual);
}

function verFotos(){
	foto_actual = 1;
	abrirPopup(titulo_primera_foto, '_scripts/fotos.php?i='+foto_actual, ancho_primera_foto+20, alto_primera_foto+50, "")
}

function verLetras(){
	comingSoon();
}


function abrirInscribite(){
	abrirPopup('Imbscribite ya!', 'inscribite.php', 400, 200, '')
}

function comingSoon(){
	abrirPopup("Esta sección estará próximamente disponible", 'comingsoon.html', 400, 200, "")
}

function abrirIntegrantes(){
	abrirPopup("Integrantes", 'integrantes.php', 600, 400, "")
}

var openOverlay = function(url) { 
	turl = url;
    $("#overlay_generico").overlay().load();
}
