$(document).ready(function(){
 
  $("#lnkRedEstrella").bind('mouseenter', function(){
  	$("#footer-popup-hover").fadeIn(1000);
	});
  $("#cierraBanner").click(function(){
  	$("#footer-popup-hover").fadeOut(700);
	});
});

function showAlert(strUrl, iAncho, iAlto){
	if(iAncho==undefined) iAncho = 450;
	if(iAlto==undefined) iAlto = 250;
	if(!isNaN(strUrl)) strUrl = strUrl.toString();

	if(strUrl.indexOf('.php')==-1){
		strUrl = $("#hidUrlRoot").val() +  "alertas.php?alerta=" + escape(strUrl);
	}
	
	$.colorbox({width:iAncho,height:iAlto, href:strUrl});

}

function proximamente(){
	showAlert(11);
}

function controlarSesion(strCallback){
	$.get($("#hidUrlRoot").val() + "ajaxComprobarSesion.php", { callback: strCallback },
	  function(data){
	    eval(data);
	  });

}

function mostrarLoginAjax(){
	var strEmail = "";
	if(document.getElementById('hidEmailInvitado')!=null) strEmail = "&email=" + document.getElementById('hidEmailInvitado').value + "&idp=" + $("#hidIdRegistro").val();
	showAlert($("#hidUrlRoot").val() + 'alertas.php?alerta=12' + strEmail);
}

function validaLogin(tipoLogin){
	if(tipoLogin==undefined) tipoLogin = '1';
	var frm;
	if(tipoLogin == '1'){
		frm = document.registracion;
	}else if(tipoLogin == '2'){
		frm = document.registracion2;
	}else{
		frm = document.registracionPorra;
	}
  var strError = "";
  var objCheck;

  objCheck = new check("registracion" + (tipoLogin == 'Porra' ? 'Porra' : (tipoLogin == 2 ? '2' : '')));
  objCheck.checkString("txtUsuario" + tipoLogin, "Usuario", 2, 50, false);
  objCheck.checkString("txtContrasenia" + tipoLogin, "Contraseña", 2, 50, false);
  strError = objCheck.toString();
  if (strError == "") {
		return true;
  } else {
    showAlert (strError.replace(/\n/g,'<br/>'));
    return false;
  }
}

function loginLightbox(){
	var frm = document.frmLoginLightbox;
  var strError = "";
  var objCheck;

  objCheck = new check("frmLoginLightbox");
  objCheck.checkEmail("txtUsuario3", "Usuario", 2, 150, false);
  objCheck.checkString("txtContrasenia3", "Contraseña", 2, 50, false);
  strError = objCheck.toString();
  if (strError == "") {
  	$("#hidCampoErrorLogin").html("");
    frm.hidLogin.value = 3;
    return true;
  } else {
  	$("#hidCampoErrorLogin").html(strError.replace(/\n/g,'<br/>'));
  	return false;
  }
}

function marcaEstrellas(nro, strIDImagen){
	if(strIDImagen == undefined) strIDImagen = "imgEstrella";
	for(i = 0; i<5; i++){
		if(i<=nro){
			$('#' + strIDImagen + i).attr('src', $("#hidHostRoot").val() + 'img/puntuacion.png');
		}else{
			$('#' + strIDImagen + i).attr('src', $("#hidHostRoot").val() + 'img/puntuacion_no.png');
		}
	}
}

function valorar(nro, objetoVoto, intIdRegistro){
	if(intIdRegistro==undefined) intIdRegistro = $('#hidIdRegistro').val();
	$.get($("#hidUrlRoot").val() + "ajaxValorar.php", { id: intIdRegistro, valor: nro, objeto_voto: objetoVoto },
	  function(data){
	    eval(data);
	  });
}

function dejarComentario(objetoVoto){
	showAlert($("#hidUrlRoot").val() + 'popup-comentario.php?objeto_voto=' + objetoVoto + '&id=' + $('#hidIdRegistro').val(), 450, 300);
}
function enviarComentario(){
	var frm = document.clave;
  var strError = "";
  var objCheck;

  objCheck = new check("clave");
  objCheck.checkString("txtComentario", "Comentario", 2, 1500, false);
  strError = objCheck.toString();
  if (strError == "") {
  	$("#btnEnviar").hide();
  	$("#campoErrorRecordar").html("<img src=\""+ $("#hidHostRoot").val() +"img/sexyimages/black/loading.gif\" border=\"0\" />");
		$.get($("#hidUrlRoot").val() + "ajaxComentar.php", { id: $('#hidId').val(), comentario: $('#txtComentario').val(), objeto_voto: $('#hidObjeto').val() },
		  function(data){
		    eval(data);
		  });
  } else {
  	$("#campoErrorRecordar").html(strError.replace(/\n/g,'<br/>'));
  }
  return false;
}

function cambiarPanelProductos(nroPanel, color){

		$('.liproducto').removeClass('desymo_active');
		$('.liproducto').removeClass('giste_active');
		$('.liproducto').removeClass('sidra_active');
		$('.liproducto').removeClass('cabreiroa_active');

		$('.liproducto:eq('+ nroPanel +')').addClass(color+'_active');

		$('.DescripcionProd').hide();
		$('#idDescripcionProd'+nroPanel).fadeIn(300);
		
		$('.ImagenProd').hide();
		$('#idImagenProd'+nroPanel).fadeIn(300);		
		
	
}

function recordar(){
	var frm = document.clave;
  var strError = "";
  var objCheck;

  objCheck = new check("clave");
  objCheck.checkEmail("email", "email", 2, 255, false);
  strError = objCheck.toString();
  if (strError == "") {
  	$("#campoErrorRecordar").html("<img src=\"" + $("#hidHostRoot").val() + "img/sexyimages/black/loading.gif\" border=\"0\" />");
		return true;
  } else {
  	$("#campoErrorRecordar").html(strError.replace(/\n/g,'<br/>'));
    return false;
  }
}


function nuevaPregunta(){
	showAlert($("#hidUrlRoot").val() + 'popup-entrevista.php', 450, 350);
}

function enviarPregunta(){
	var frm = document.clave;
  var strError = "";
  var objCheck;

  objCheck = new check("clave");
  objCheck.checkCombo("cmbArtista", "Artista", false);
  objCheck.checkString("txtPregunta", "Pregunta", 2, 1000, false);
  strError = objCheck.toString();
  if (strError == "") {
  	$("#btnEnviar").hide();
  	$("#campoErrorEntrevista").html("<img src=\""+ $("#hidHostRoot").val() +"img/sexyimages/black/loading.gif\" border=\"0\" />");
	  return true;
  } else {
  	$("#campoErrorEntrevista").html(strError.replace(/\n/g,'<br/>'));
	  return false;
  }
}

function descargarArchivo(path, file){
	var n = 'f' + Math.floor(Math.random() * 99999);
	var d = document.createElement('DIV');
	d.innerHTML = '<iframe style="display:none" src="'+$("#hidUrlRoot").val()+'download.php?path=' +path+ '&file=' + file + '" id="'+n+'" name="'+n+'"></iframe>';
	document.body.appendChild(d);
}

function mostrarInfoBlog(idBlog,strRSS){
	$(".globo").hide();
	$("#infoBlog" + idBlog).show();

	if($("#entradas" + idBlog).html()==""){
		$("#entradas" + idBlog).html("<img src=\""+ $("#hidHostRoot").val() +"img/sexyimages/black/loading.gif\" border=\"0\" />");
		$("#entradas" + idBlog).load($("#hidUrlRoot").val() + "ajaxRSS.php?rss=" + strRSS);
	}
}

function ocultarInfoBlog(idBlog){
	$("#infoBlog" + idBlog).fadeOut(500);
}


function obtenerTituloLink(strTitulo){
	strTitulo = strTitulo.replace(/ /g, "-");
	strTitulo = strTitulo.replace(RegExp("'","g"), "");
	strTitulo = strTitulo.replace(/á/g,'a');
	strTitulo = strTitulo.replace(/é/g,'e');
	strTitulo = strTitulo.replace(/í/g,'i');
	strTitulo = strTitulo.replace(/ó/g,'o');
	strTitulo = strTitulo.replace(/ú/g,'u');
	strTitulo = strTitulo.replace(/Á/g,'A');
	strTitulo = strTitulo.replace(/É/g,'E');
	strTitulo = strTitulo.replace(/Í/g,'I');
	strTitulo = strTitulo.replace(/Ó/g,'O');
	strTitulo = strTitulo.replace(/Ú/g,'U');
	strTitulo = strTitulo.replace(/ñ/g,'n');
	strTitulo = strTitulo.replace(/Ñ/g,'N');
	return strTitulo;
}
$(document).ready(function(){
	//Examples of how to assign the ColorBox event to elements
	$("a[rel='galeriafotos']").colorbox({maxWidth:"600px"});

	
});

