﻿function cargarPortada(nuevaURL)
{
    $.ajax({
        success:function(request){
            $('#portada').html(request);
            reemplazarFuentes();
            fancyseba();
        },
        url:nuevaURL,
        cache: false
    })
}

function mostrarResultadoBusqueda(pagina)
{
    $parametro = jQuery.trim( $('#parametro').attr("value") );
    if ($parametro != "" && $parametro != "Busqueda")
    {
//        var url = 'Busqueda.aspx?p=' + $("#parametro").val() +
//	                           '&t=' + $("#titulo").is(':checked') +
//	                           '&al=' + $("#album").is(':checked') +
//	                           '&ar=' + $("#artista").is(':checked') +
//	                           '&ip=5' +
//	                           '&pg=' + pagina +
//	                           '&bi=true';

        var url = 'Busqueda.aspx?p=' + $("#parametro").val() +
	                           '&t=true' +
	                           '&al=true' +
	                           '&ar=true' +
	                           '&ip=5' +
	                           '&pg=' + pagina +
	                           '&bi=true';
        cargarPortada(url);
    }
}

function reemplazarFuentes()
{
    Cufon.replace('h2', { fontFamily: 'Bauhaus 93' });
}

function fancyseba()
{
    $("a.coverlink").fancybox({
        'hideOnContentClick': false
    });
    $("a.lyricslink").fancybox({
        'hideOnContentClick': false,
        'frameWidth': 300,
        'frameHeight': 450
    });
    $("a.votarlink").fancybox({
        'hideOnContentClick': false,
        'frameWidth': 200,
        'frameHeight': 80
    });
    $("a.gusta").fancybox({
        'hideOnContentClick': false,
        'frameWidth': 200,
        'frameHeight': 40
    });
}

function popitupGusta(url,top,left,width,height)
{
	gustaWindow = window.open(url,'name','top=' + top + ',left=' + left + ',width=' + width +  ',height=' + height);
	
	if (window.focus)
	    gustaWindow.focus();
	return false;
}

function popitupLyrics(url,top,left,width,height)
{
	lyricsWindow = window.open(url,'name','top=' + top + ',left=' + left + ',width=' + width +  ',height=' + height);
	
	if (window.focus)
	    lyricsWindow.focus();
	return false;
}

function ticker()
{
    if ($(".cancionTitulo").width() > 20)
        $("ul#ticker").liScroll({travelocity: 0.02}); 
}


//function gusta(id, opcion)
//{
//    var xmlhttp;
//    if (window.XMLHttpRequest)
//        xmlhttp=new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
//    else        
//        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // code for IE6, IE5
//    
//    xmlhttp.onreadystatechange=function()
//    {
//    //if(xmlhttp.readyState==4)
//        //document.myForm.time.value=xmlhttp.responseText;
//    }
//    
//    xmlhttp.open("GET","Gusta.aspx?id=" + id + "&opcion=" + opcion,true);
//    xmlhttp.send(null);
//}
