var cambioPrecio;
var winPlaylist;

//funciones usadas en el front
function feedsLabel(){
    window.open('getFeeds.aspx?label='+document.getElementById('cmbLabels').value,'feeds');
    Lightbox.hideBox();
}
function feedsDj(){
    window.open('getFeeds.aspx?dj='+document.getElementById('cmbDjs').value,'feeds');
    Lightbox.hideBox();
}

function showAlert(strUrl, width, height){
    try{
        if(document.getElementById('box')!=null){
            document.getElementById('box').style.background = "url(images/bg_gral.gif)";
        }
        Lightbox.showBoxByAJAX(strUrl, width, height);
    }catch(err){
        setTimeout("showAlert('"+strUrl+"',"+ width +", "+height+")",1000);
    }
}

var bLoading = false;
function showLoading(){
    if(!bLoading){
        try{
            document.getElementById('box').style.background = "url(images/blank.gif)";
            Lightbox.showBoxImage('images/loading.gif');
            bLoading = true;
        }catch(err){
            setTimeout("showLoading()",1000);
        }
    }
}
function showAlertPL(strTexto){
    try{
        winPlaylist.showAlert(strTexto);
    }catch(err){
    }
}

function hideAlert(){
    try{
        document.getElementById('box').style.background = "url(images/bg_gral.gif)";
        bLoading = false;
        Lightbox.hideBox();
    }catch(err){
        setTimeout("hideAlert()",1500);
    }
}
function openPlaylist(rep){
    if(rep==undefined){
        rep = 0;
    }
   if(winPlaylist==null || winPlaylist==undefined){
       winPlaylist = window.open ("player/player.aspx?rep=" + rep, "winPlaylist","location=no,status=no,scrollbars=no, width=365,height=355");
       if (winPlaylist==null || typeof(winPlaylist)=="undefined"){
            showAlert('Alertas.aspx?nro=7&m=16', 400, 210);
       }
       try{
            wimpy_pause();
       }catch(err){
       }
       bAbierto = false;
    }else{
        winPlaylist.focus();
        bAbierto = true;
    }
}
var bAbierto = false; //variabla para saber si la playlista ya estaba abierta de antes
function agregar(url, cant, posicion, id, tipo_precio,bounded, titulo, delay){
    var bAgrego = false; //flag para quitarlo si voy a volver a llamar a la fn y ya fue agregado al array
    if(delay==undefined){
        delay = 0;
    }
    try{
        if(bAbierto){
            if(id==undefined){
                id = 0;
            }
            url = url.replace("ibizadanceclub/", "");
            var bAgregar = true;
            if(winPlaylist.arrLista!=null && winPlaylist.arrLista.length>0){
                for(i=0;i<winPlaylist.arrLista.length;i++){
                    if(winPlaylist.arrLista[i].id==id && winPlaylist.arrLista[i].archivo!=''){
                        bAgregar = false;
                        posicion = i;
                        break;
                    }
                }
                if(bAgregar){
                    posicion = winPlaylist.arrLista.length;
                    winPlaylist.arrLista[posicion] = new Track(id, url, "",titulo, "", "", tipo_precio,bounded);
                    bAgrego = true;
                    //showLoading();
                    setTimeout("winPlaylist.agregar(" + posicion + ");", delay);
                }
            }else{
                winPlaylist.arrLista = new Array();
                winPlaylist.arrLista[0] = new Track(id, url, "", titulo, "", "", tipo_precio,bounded);
                bAgrego = true;
                posicion = 0;
                setTimeout("winPlaylist.agregar(0);", 500);
            }
        }
    }catch(err){
        if(cant<8){
            if(bAgrego){
                winPlaylist.arrLista.slice(posicion);
            }
            setTimeout("agregar(\""+url+"\", "+(cant+1)+", "+posicion+", "+id+", "+ tipo_precio + "," +bounded + ", "+titulo+", "+delay+");",1000);
        }
    }
}

function Track(id, archivo, artista, titulo, url, portada, tipo_precio, bounded){
    this.id = id;
    this.archivo = escape(archivo.replace("ibizadanceclub/",""));
    this.artista = (reemplazaInvalidos(artista));
    this.titulo = (reemplazaInvalidos(titulo));
    this.url = escape(url);
    this.portada = escape(portada);
    this.tipo_precio = tipo_precio;
    this.bounded = bounded;
}
function reemplazaInvalidos(strTexto){
    strTexto = strTexto.replace(/á/g,"a");                
    strTexto = strTexto.replace(/é/g,"e");                
    strTexto = strTexto.replace(/í/g,"i");                
    strTexto = strTexto.replace(/ó/g,"o");                
    strTexto = strTexto.replace(/ú/g,"u");                
    strTexto = strTexto.replace(/&/g," ");                
    strTexto = strTexto.replace(/ç/g,"c");                
    strTexto = strTexto.replace(/Ç/g,"C");                
    strTexto = strTexto.replace(/ä/g,"a");                
    return strTexto;     
}

function verNewsletter(){
    window.open('mail/2010/july/week29/index.html','news');
}
//fucniones para los banners
function forgot(){
    if(document.FormAlert.txtEmailForgot.value!=""){
	    var url = location.href;
	    var arrPrevPage = url.split('/');
	    url = arrPrevPage[arrPrevPage.length-1];

        document.Form.txtUsernameLogin.value = document.FormAlert.txtEmailForgot.value;
        document.Form.hidOrigen.value = url;
        document.Form.hidAction.value = "forgot";
        Lightbox.hideBox();
        document.Form.submit();
    }else{
        alert("You must enter your email.");
    }
}

function loadpage() { 
    index1 = 0;
    arrIndex = new Array(0,1,2,3,4);
    thetimer = setTimeout("changeimage()", 7000);
    thetimer0 = setTimeout("changeimageLat(0)", 7000);
    thetimer1 = setTimeout("changeimageLat(1)", 7000);
    thetimer2 = setTimeout("changeimageLat(2)", 7000);
    thetimer3 = setTimeout("changeimageLat(3)", 7000);
    thetimer4 = setTimeout("changeimageLat(4)", 7000);
} 
function loadpageInternas() { 
    arrIndex = new Array(0,1,2,3,4);
    thetimer0 = setTimeout("changeimageLat(0)", 7000);
    thetimer1 = setTimeout("changeimageLat(1)", 7000);
    thetimer2 = setTimeout("changeimageLat(2)", 7000);
    thetimer3 = setTimeout("changeimageLat(3)", 7000);
    thetimer4 = setTimeout("changeimageLat(4)", 7000);
} 

function changeimage(){ 
    index1 = index1 + 1
    if (index1 == listofimages.length) { 
        index1 = 0 
    } 
    document.getElementById('banner1').src = listofimages[index1].src

    thetimer = setTimeout("changeimage()", 7000);
} 
function changeimageLat(i){ 
    arrIndex[i] = arrIndex[i] + 1
    if (arrIndex[i] == listofimagesLat.length) { 
        arrIndex[i] = 0 
    } 
    if(document.getElementById('bannerLat'+i)!=null){
        document.getElementById('bannerLat'+i).src = listofimagesLat[arrIndex[i]].src
    }

    thetimer = setTimeout("changeimageLat("+i+")", 7000);
} 
function changepage() { 
    window.open(arrLocation[index1]);
} 

function changepageLat(i) { 
    window.open(arrLocationLat[arrIndex[i]]);
} 
//fin banners


//función para cambiar de idioma
function lang(idIdioma){
    document.Form.hidIdIdioma.value = idIdioma;
    document.Form.submit();
}

function logout(){
    document.Form.hidAction.value = "logout";
    document.Form.submit();
}

function login(mensaje){
    if(document.Form.txtUsernameLogin.value!="" && document.Form.txtPasswordLogin.value!=""){
        document.Form.hidAction.value = "login";
        document.Form.submit();
    }else{
        alert(mensaje);
    }
}
var bMute = false;
function mute(){
    try{
        if (!bMute) { 
            wimpy_pause();
            document.getElementById('Image15').src="images/top--36_off-tachado.gif";
            document.getElementById('Image15').onmouseover="";
            document.getElementById('Image15').onmouseout="";
        } else{                     
            wimpy_play();           
            document.getElementById('Image15').src="images/top--36.gif";
            document.getElementById('Image15').onmouseover="";
            document.getElementById('Image15').onmouseout="";
        }
        bMute = !bMute;
    }catch(err){
    }
}
function muteCls(){
    try{
        if (!bMute) { 
            wimpy_pause();
            document.getElementById('Image15').src="images/top--36_off-tachado.gif";
            document.getElementById('Image15').onmouseover="";
            document.getElementById('Image15').onmouseout="";
        } else{                     
            wimpy_play();           
            document.getElementById('Image15').src="images/top--36_cls.gif";
            document.getElementById('Image15').onmouseover="";
            document.getElementById('Image15').onmouseout="";
        }
        bMute = !bMute;
    }catch(err){
    }
}
function muteUnd(){
    try{
        if (!bMute) { 
            wimpy_pause();
            document.getElementById('Image15').src="images/top--36_off-tachado.gif";
            document.getElementById('Image15').onmouseover="MM_swapImage('sound','','images/top--36_on-tachado.gif',1)";
            document.getElementById('Image15').onmouseout="MM_swapImage('sound','','images/top--36_off-tachado.gif',1)";
        } else{                     
            wimpy_play();           
            document.getElementById('Image15').src="images/top_udg-36.gif";
            document.getElementById('Image15').onmouseover="MM_swapImage('sound','','images/top_udg_on-36.gif',1)";
            document.getElementById('Image15').onmouseout="MM_swapImage('sound','','images/top_udg-36.gif',1)";
        }
        bMute = !bMute;
    }catch(err){
    }
}
function addPlaylistSingle(){
    var arrTemas = document.getElementById('HidIdTemas').value.split('|');
    for(i=0;i<arrTemas.length;i++){
        if(arrTemas[i]!=""){
            if(i==0){
                addPlaylistTrack(arrTemas[i]);
            }else{
                setTimeout("addPlaylistTrack("+ arrTemas[i] + ")",1500);
            }
        }
    }
}
function addPlaylistTrack(id){
    simple_ajax('ajaxPlaylist.aspx','GET','idT='+id);
}
function addPlaylistAlbum(id){
    simple_ajax('ajaxPlaylist.aspx','GET','idA='+id);
}
function addPlaylistChart(id){
    simple_ajax('ajaxPlaylist.aspx','GET','idC='+id);
}
function addPlaylistComp(id){
    simple_ajax('ajaxPlaylist.aspx','GET','idComp='+id);
}
function preescuchaTrack(id){
    simple_ajax('ajaxPlaylist.aspx','GET','or=1&idT='+id);
}
function preescuchaAlbum(id){
    simple_ajax('ajaxPlaylist.aspx','GET','or=1&idA='+id);
}
function preescuchaChart(id){
    simple_ajax('ajaxPlaylist.aspx','GET','or=1&idC='+id);
}
function preescuchaComp(id){
    simple_ajax('ajaxPlaylist.aspx','GET','or=1&idComp='+id);
}
function preescuchaSingle(){
    simple_ajax('ajaxPlaylist.aspx','GET','or=1&idS='+document.getElementById('HidIdSingle').value);
}

function addFavoritosTrack(id, player){
    if(player==undefined){
        player = 0;
    }
    simple_ajax('ajaxFavoritos.aspx','GET','idT='+id + '&player=' + player);
}
function addFavoritosAlbum(id){
    simple_ajax('ajaxFavoritos.aspx','GET','idA='+id);
}
function addFavoritosChart(id){
    simple_ajax('ajaxFavoritos.aspx','GET','idC='+id);
}
function addFavoritosComp(id){
    simple_ajax('ajaxFavoritos.aspx','GET','idComp='+id);
}
function addFavoritosSingle(){
    var arrTemas = document.getElementById('HidIdTemas').value.split('|');
    for(i=0;i<arrTemas.length;i++){
        if(arrTemas[i]!=""){
            addFavoritosTrack(arrTemas[i]);
        }
    }
}
function changeFormat(idTema, idFormato, tipo){
    //------ si es un carrito
    var idCarrito = "";
    if(document.getElementById('hidIdCarrito')!=null){
        document.getElementById('lnkBuy').href = "javascript:waitForBuy();";
        document.getElementById('Image37').src = "images/espera.gif";
        document.getElementById('Image37').onmouseover = "MM_swapImage('Image37','','images/images/espera.gif',1)";
        
        idCarrito = document.getElementById('hidIdCarrito').value;
    }
    //es para el caso que el carrito tenga una moneda distinta de la sesion
    var idMoneda = ""; 
    if(document.getElementById('hidIdMoneda')!=null){
        idMoneda = document.getElementById('hidIdMoneda').value;
    }
    //-----------------------
    var idFormatoAnt = document.getElementById('hidIdFormatoT' + idTema).value;
    //saco el color de fondo al formato anterior
    document.getElementById('tdFormatoT' + idTema + '_' + idFormatoAnt).style.backgroundColor = "#FFFFFF";
    //pongo el color de fondo al nuevo formato
    document.getElementById('tdFormatoT' + idTema + '_' + idFormato).style.backgroundColor = "#FFCCCC";
    //actualizo el id del formato nuevo
    document.getElementById('hidIdFormatoT' + idTema).value = idFormato;
    //acutalizo el precio del tema
    simple_ajax('ajaxChangeFormat.aspx','GET','idT=' + idTema + '&idF=' + idFormato + '&idM=' + idMoneda + '&idC=' + idCarrito + '&tipo=' + tipo);
}
function changeFormatAlbum(idAlbum, idFormato, tipo){
    //------ si es un carrito
    var idCarrito = "";
    if(document.getElementById('hidIdCarrito')!=null){
        document.getElementById('lnkBuy').href = "javascript:waitForBuy();";
        document.getElementById('Image37').src = "images/espera.gif";
        document.getElementById('Image37').onmouseover = "MM_swapImage('Image37','','images/images/espera.gif',1)";
        idCarrito = document.getElementById('hidIdCarrito').value;
    }
    //es para el caso que el carrito tenga una moneda distinta de la sesion
    var idMoneda = ""; 
    if(document.getElementById('hidIdMoneda')!=null){
        idMoneda = document.getElementById('hidIdMoneda').value;
    }
    //-----------------------
    var idFormatoAnt = document.getElementById('hidIdFormatoA' + idAlbum).value;
    //saco el color de fondo al formato anterior
    document.getElementById('tdFormatoA' + idAlbum + '_' + idFormatoAnt).style.backgroundColor = "#FFFFFF";
    //pongo el color de fondo al nuevo formato
    document.getElementById('tdFormatoA' + idAlbum + '_' + idFormato).style.backgroundColor = "#FFCCCC";
    //actualizo el id del formato nuevo
    document.getElementById('hidIdFormatoA' + idAlbum).value = idFormato;
    //acutalizo el precio del tema
    simple_ajax('ajaxChangeFormat.aspx','GET','idA=' + idAlbum + '&idF=' + idFormato + '&idM=' + idMoneda + '&idC=' + idCarrito + '&tipo=' + tipo);
}
function changeFormatSingle(idFormato, tipo){
    var idSingle = document.getElementById('HidIdSingle').value;
    simple_ajax('ajaxChangeFormat.aspx','GET','idS=' + idSingle + '&idF=' + idFormato + '&tipo=' + tipo);
    var idFormatoAnt = document.getElementById('hidIdFormatoS' + idSingle).value;
    //saco el color de fondo al formato anterior
    document.getElementById('tdFormatoS' + idSingle + '_' + idFormatoAnt).style.backgroundColor = "#FFFFFF";
    //pongo el color de fondo al nuevo formato
    document.getElementById('tdFormatoS' + idSingle + '_' + idFormato).style.backgroundColor = "#FFCCCC";
    //actualizo el id del formato nuevo
    document.getElementById('hidIdFormatoS' + idSingle).value = idFormato;

    /*var arrTemas = document.getElementById('HidIdTemas').value.split('|');
    for(i=0;i<arrTemas.length;i++){
        if(arrTemas[i]!=""){
            changeFormat(arrTemas[i], idFormato, tipo);
        }
    }*/
}
function changeFormatChart(idFormato, idChart){
    //------ si es un carrito
    var idCarrito = "";
    if(document.getElementById('hidIdCarrito')!=null){
        document.getElementById('lnkBuy').href = "javascript:waitForBuy();";
        document.getElementById('Image37').src = "images/espera.gif";
        document.getElementById('Image37').onmouseover = "MM_swapImage('Image37','','images/images/espera.gif',1)";
        idCarrito = document.getElementById('hidIdCarrito').value;
    }
    //es para el caso que el carrito tenga una moneda distinta de la sesion
    var idMoneda = ""; 
    if(document.getElementById('hidIdMoneda')!=null){
        idMoneda = document.getElementById('hidIdMoneda').value;
    }
    //-----------------------

    if(idChart==undefined){
        idChart = document.getElementById('hidIdChart').value;
    }
    simple_ajax('ajaxChangeFormat.aspx','GET','idCh=' + idChart + '&idF=' + idFormato + '&tipo=&idM=' + idMoneda + '&idC=' + idCarrito);
    var idFormatoAnt = document.getElementById('hidIdFormatoC' + idChart).value;
    //saco el color de fondo al formato anterior
    document.getElementById('tdFormatoC' + idChart + '_' + idFormatoAnt).style.backgroundColor = "#FFFFFF";
    //pongo el color de fondo al nuevo formato
    document.getElementById('tdFormatoC' + idChart + '_' + idFormato).style.backgroundColor = "#FFCCCC";
    //actualizo el id del formato nuevo
    document.getElementById('hidIdFormatoC' + idChart).value = idFormato;
}
function changeFormatComp(idFormato, idComp, tipo){
    if(tipo==undefined){
        tipo = 2;
    }
    //------ si es un carrito
    var idCarrito = "";
    if(document.getElementById('hidIdCarrito')!=null){
        document.getElementById('lnkBuy').href = "javascript:waitForBuy();";
        document.getElementById('Image37').src = "images/espera.gif";
        document.getElementById('Image37').onmouseover = "MM_swapImage('Image37','','images/images/espera.gif',1)";
        idCarrito = document.getElementById('hidIdCarrito').value;
    }
    //es para el caso que el carrito tenga una moneda distinta de la sesion
    var idMoneda = ""; 
    if(document.getElementById('hidIdMoneda')!=null){
        idMoneda = document.getElementById('hidIdMoneda').value;
    }
    //-----------------------

    if(idComp==undefined){
        idComp = document.getElementById('hidIdCompilation').value;
    }
    simple_ajax('ajaxChangeFormat.aspx','GET','idComp=' + idComp + '&idF=' + idFormato + '&idM=' + idMoneda + '&idC=' + idCarrito + '&tipo=' + tipo);
    var idFormatoAnt = document.getElementById('hidIdFormatoComp' + idComp).value;
    //saco el color de fondo al formato anterior
    document.getElementById('tdFormatoComp' + idComp + '_' + idFormatoAnt).style.backgroundColor = "#FFFFFF";
    //pongo el color de fondo al nuevo formato
    document.getElementById('tdFormatoComp' + idComp + '_' + idFormato).style.backgroundColor = "#FFCCCC";
    //actualizo el id del formato nuevo
    document.getElementById('hidIdFormatoComp' + idComp).value = idFormato;
}

function changeFormatAlbumClassic(idAlbum, idFormato, tipo){
    //------ si es un carrito
    var idCarrito = "";
    if(document.getElementById('hidIdCarrito')!=null){
        idCarrito = document.getElementById('hidIdCarrito').value;
    }
    //es para el caso que el carrito tenga una moneda distinta de la sesion
    var idMoneda = ""; 
    if(document.getElementById('hidIdMoneda')!=null){
        idMoneda = document.getElementById('hidIdMoneda').value;
    }
    //-----------------------
    var idFormatoAnt = document.getElementById('hidIdFormatoA' + idAlbum).value;
    //saco el color de fondo al formato anterior
    document.getElementById('tdFormatoA' + idAlbum + '_' + idFormatoAnt).style.backgroundColor = "#FFFFFF";
    //pongo el color de fondo al nuevo formato
    document.getElementById('tdFormatoA' + idAlbum + '_' + idFormato).style.backgroundColor = "#71a302";
    //actualizo el id del formato nuevo
    document.getElementById('hidIdFormatoA' + idAlbum).value = idFormato;
    //acutalizo el precio del tema
    simple_ajax('ajaxChangeFormat.aspx','GET','idA=' + idAlbum + '&idF=' + idFormato + '&idM=' + idMoneda + '&idC=' + idCarrito + '&tipo=' + tipo);
}
function changeFormatClassic(idTema, idFormato, tipo){
    //------ si es un carrito
    var idCarrito = "";
    if(document.getElementById('hidIdCarrito')!=null){
        document.getElementById('lnkBuy').href = "javascript:waitForBuy();";
        document.getElementById('Image37').src = "images/espera.gif";
        document.getElementById('Image37').onmouseover = "MM_swapImage('Image37','','images/images/espera.gif',1)";
        
        idCarrito = document.getElementById('hidIdCarrito').value;
    }
    //es para el caso que el carrito tenga una moneda distinta de la sesion
    var idMoneda = ""; 
    if(document.getElementById('hidIdMoneda')!=null){
        idMoneda = document.getElementById('hidIdMoneda').value;
    }
    //-----------------------
    var idFormatoAnt = document.getElementById('hidIdFormatoT' + idTema).value;
    //saco el color de fondo al formato anterior
    document.getElementById('tdFormatoT' + idTema + '_' + idFormatoAnt).style.backgroundColor = "#FFFFFF";
    //pongo el color de fondo al nuevo formato
    document.getElementById('tdFormatoT' + idTema + '_' + idFormato).style.backgroundColor = "#71a302";
    //actualizo el id del formato nuevo
    document.getElementById('hidIdFormatoT' + idTema).value = idFormato;
    //acutalizo el precio del tema
    simple_ajax('ajaxChangeFormat.aspx','GET','idT=' + idTema + '&idF=' + idFormato + '&idM=' + idMoneda + '&idC=' + idCarrito + '&tipo=' + tipo);
}

function changeFormatAlbumHardcore(idAlbum, idFormato, tipo){
    //------ si es un carrito
    var idCarrito = "";
    if(document.getElementById('hidIdCarrito')!=null){
        idCarrito = document.getElementById('hidIdCarrito').value;
    }
    //es para el caso que el carrito tenga una moneda distinta de la sesion
    var idMoneda = ""; 
    if(document.getElementById('hidIdMoneda')!=null){
        idMoneda = document.getElementById('hidIdMoneda').value;
    }
    //-----------------------
    var idFormatoAnt = document.getElementById('hidIdFormatoA' + idAlbum).value;
    //saco el color de fondo al formato anterior
    document.getElementById('tdFormatoA' + idAlbum + '_' + idFormatoAnt).style.backgroundColor = "#FFFFFF";
    //pongo el color de fondo al nuevo formato
    document.getElementById('tdFormatoA' + idAlbum + '_' + idFormato).style.backgroundColor = "#40547c";
    //actualizo el id del formato nuevo
    document.getElementById('hidIdFormatoA' + idAlbum).value = idFormato;
    //acutalizo el precio del tema
    simple_ajax('ajaxChangeFormat.aspx','GET','idA=' + idAlbum + '&idF=' + idFormato + '&idM=' + idMoneda + '&idC=' + idCarrito + '&tipo=' + tipo);
}
function changeFormatHardcore(idTema, idFormato, tipo){
    //------ si es un carrito
    var idCarrito = "";
    if(document.getElementById('hidIdCarrito')!=null){
        document.getElementById('lnkBuy').href = "javascript:waitForBuy();";
        document.getElementById('Image37').src = "images/espera.gif";
        document.getElementById('Image37').onmouseover = "MM_swapImage('Image37','','images/images/espera.gif',1)";
        
        idCarrito = document.getElementById('hidIdCarrito').value;
    }
    //es para el caso que el carrito tenga una moneda distinta de la sesion
    var idMoneda = ""; 
    if(document.getElementById('hidIdMoneda')!=null){
        idMoneda = document.getElementById('hidIdMoneda').value;
    }
    //-----------------------
    var idFormatoAnt = document.getElementById('hidIdFormatoT' + idTema).value;
    //saco el color de fondo al formato anterior
    document.getElementById('tdFormatoT' + idTema + '_' + idFormatoAnt).style.backgroundColor = "#FFFFFF";
    //pongo el color de fondo al nuevo formato
    document.getElementById('tdFormatoT' + idTema + '_' + idFormato).style.backgroundColor = "#40547c";
    //actualizo el id del formato nuevo
    document.getElementById('hidIdFormatoT' + idTema).value = idFormato;
    //acutalizo el precio del tema
    simple_ajax('ajaxChangeFormat.aspx','GET','idT=' + idTema + '&idF=' + idFormato + '&idM=' + idMoneda + '&idC=' + idCarrito + '&tipo=' + tipo);
}

function addCartTrack(idTema, tipo, player){
    if(player==undefined){
        player = 0;
    }
    addCart(idTema, 0, tipo, player);
}
function addCartAlbum(idAlbum, tipo){
    addCart(0, idAlbum, tipo)
}
function addCart(idTema, idAlbum, tipo, player){
    if(player==undefined){
        player = 0;
    }
    var idFormato = 1;
    if(idTema!=0){
        if(document.getElementById('hidIdFormatoT' + idTema)!=null){
            idFormato = document.getElementById('hidIdFormatoT' + idTema).value;
        }
    }else{
        if(document.getElementById('hidIdFormatoA' + idAlbum)!=null){
            idFormato = document.getElementById('hidIdFormatoA' + idAlbum).value;
        }
    }
    //acutalizo el precio del tema
    simple_ajax('ajaxAgregarCarrito.aspx','GET','idT=' + idTema + '&idA=' + idAlbum + '&idF=' + idFormato + '&tipo=' + tipo + '&player='+player);
}
function addCartChart(idChart){
    var idFormato = document.getElementById('hidIdFormatoC' + idChart).value;
    //acutalizo el precio del tema
    simple_ajax('ajaxAgregarCarrito.aspx','GET','idC=' + idChart + '&idF=' + idFormato + '&tipo=');
}
function addCartComp(idComp, tipo){
    var idFormato = document.getElementById('hidIdFormatoComp' + idComp).value;
    //acutalizo el precio del tema
    simple_ajax('ajaxAgregarCarrito.aspx','GET','idComp=' + idComp + '&idF=' + idFormato + '&tipo=' + tipo);
}
function addCartSingle(tipo){
    var arrTemas = document.getElementById('HidIdTemas').value.split('|');
    for(i=0;i<arrTemas.length;i++){
        if(arrTemas[i]!=""){
            addCartTrack(arrTemas[i],tipo);
        }
    }
}
function marcar(idG, nroTd){
    var tds = getElementsByName_iefix('td','tdSub');
    for(i=0;i<tds.length;i++){
        if(tds[i].background=='images/sup.gif' || tds[i].background=='images/sup_off.gif'){
            tds[i].background = "images/sup_off.gif";
        }else if(tds[i].background=='images/inf.gif' || tds[i].background=='images/inf_off.gif'){
            tds[i].background = "images/inf_off.gif";
        }else{
            tds[i].background = "images/medio-03.gif";
        }
    }
    if(nroTd == 0){
        document.getElementById('tdSub'+idG+'_'+nroTd).background = "images/sup.gif";
    }else if(document.getElementById('tdSub'+idG+'_'+nroTd).background=="images/inf.gif" || document.getElementById('tdSub'+idG+'_'+nroTd).background=="images/inf_off.gif"){
        document.getElementById('tdSub'+idG+'_'+nroTd).background = "images/inf.gif";
    }else{
        document.getElementById('tdSub'+idG+'_'+nroTd).background = "images/medio.gif";
    }
}
/* ------------------ CATALOGO ----------------------- */

function catalogo(){
    document.Form.hidCantTop.value = 999999;
    document.Form.submit();
}
function top100(){
    document.Form.hidCantTop.value = 100;
    document.Form.submit();
}
function genres(){
    window.location = "top100.aspx?g=3";
}
function top100NR(){
    window.location = "top100.aspx";
}
function genresNR(){
    window.location = "new_releases.aspx?g=3";
}
function filtrarNR(nro){
    document.Form.hidFiltro.value = nro;
    document.Form.submit();
}
function genresFeatured(){
    var intIdGenero = 1;
    if(document.Form.hidIdGenero.value!="" && document.Form.hidIdGenero.value!=0){
        intIdGenero = document.Form.hidIdGenero.value;
    }
    window.location = "featured.aspx?g="+intIdGenero + "&s="+document.Form.hidIdSubgenero.value;
}
function genresTop100(){
    window.location = "top100.aspx?g="+document.Form.hidIdGenero.value + "&s="+document.Form.hidIdSubgenero.value;
}
function newReleases(){
    window.location = "new_releases.aspx?g="+document.Form.hidIdGenero.value + "&s="+document.Form.hidIdSubgenero.value;
}
/* ------------------ DETALLES ----------------------- */

function detailBuySeparately(){
    document.Form.hidAction.value = "separately";
    document.Form.submit();
}
function albumsByDJ(){
    window.location = "resultados.aspx?dj=" + document.Form.hidIdDj.value + "&campo=dj&a=1";
}
function tracksByDJ(){
    window.location = "resultados.aspx?dj=" + document.Form.hidIdDj.value + "&campo=dj&t=1";
}
function tracksByLabel(){
    window.location = "resultados.aspx?la=" + document.Form.hidIdLabel.value + "&campo=label&t=1";
}
function albumsByLabel(){
    window.location = "resultados.aspx?la=" + document.Form.hidIdLabel.value + "&campo=label&a=1";
}
/* ------------------- CLASSICS ---------------------- */
function marcarCls(idG, nroTd){
    var tds = getElementsByName_iefix('td','tdSub');
    for(i=0;i<tds.length;i++){
        if(tds[i].background=='images/sup_izq_cls.gif' || tds[i].background=='images/sup_izq2_cls.gif'){
            tds[i].background = "images/sup_izq2_cls.gif";
        }else if(tds[i].background=='images/inf_izq_cls.gif' || tds[i].background=='images/inf_izq2_cls.gif'){
            tds[i].background = "images/inf_izq2_cls.gif";
        }else{
            tds[i].background = "images/medio_cls.gif";
        }
    }
    if(nroTd == 0){
        document.getElementById('tdSub'+idG+'_'+nroTd).background = "images/sup_izq_cls.gif";
    }else if(document.getElementById('tdSub'+idG+'_'+nroTd).background=="images/inf_izq2_cls.gif"){
        document.getElementById('tdSub'+idG+'_'+nroTd).background = "images/inf_izq_cls.gif";
    }else{
        document.getElementById('tdSub'+idG+'_'+nroTd).background = "images/recto_cls.gif";
    }
}
/* ------------------ CONTACT ----------------------- */

function enviarContacto(){
    if(Validar()){
        document.Form.hidAction.value = "guardar";
        document.Form.submit();
    }
}

function downloadForm(){
    window.location = 'getfile.aspx?filename=uploads/label_application_form.pdf';
}

/* ------------------ FAVORITES ----------------------- */

function deleteFavoriteTrack(idTema){
    document.Form.hidIdTema.value = idTema;
    document.Form.hidAction.value = "borrarFavorito";
    document.Form.submit();
}


/* ------------------ HOME ----------------------- */
function getSong(){
    simple_ajax('ajaxObtenerTrack.aspx','GET','');
}

//función para cambiar de destacados en la home
function verDestacados(tipo){
    if(document.Form.hidIdGenero!=null){
        document.Form.hidIdGenero.value = 0;
    }
    if(document.Form.hidIdSubgenero!=null){
        document.Form.hidIdSubgenero.value = 0;
    }
    document.Form.hidAction.value = "destacados";
    document.Form.hidTipoDestacado.value = tipo;
    if(document.getElementById('HidRegistroInicialPagTemas')) { 
        document.getElementById('HidRegistroInicialPagTemas').value = 1;
    }
    document.Form.submit();
}

function verificaBuscador(e){
    if(!e){
        e=window.event;
    }
    var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
    if(keyCode==13){
        buscar();
    }
}
function verificaLogin(e){
    if(!e){
        e=window.event;
    }
    var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
    if(keyCode==13){
        login();
    }
}
function verificaLoginPop(e){
    if(!e){
        e=window.event;
    }
    var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
    if(keyCode==13){
        loginPopup();
    }
}

function buscar(mensaje){
    if(document.getElementById('HeaderHome_txtBusqueda').value.length>=3){
        if(document.Form.hidIdDj){
            document.Form.hidIdDj.value = 0;
        }
        if(document.Form.hidSoloTemas!=null){
            document.Form.hidSoloTemas.value = 0;
            document.Form.hidSoloAlbums.value = 0;
        }
        if(document.Form.HidAbrir!=null){
            document.Form.HidAbrir.value = '';            
        }
        if(document.Form.HidIdLabel!=null){
            document.Form.HidIdLabel.value = '';            
        }
        if(document.Form.HidIdDj!=null){
            document.Form.HidIdDj.value = '';            
        }
        if(document.Form.HidAbrir!=null){
            document.Form.HidAbrir.value = '';            
        }
        document.Form.hidAction.value = "buscar";
        document.Form.action = "resultados.aspx";
        document.Form.submit();
    }else{
        alert(mensaje);
    }
}

function verNoticiasHome(intTipo){
    window.location = 'news.aspx?tn='+intTipo;
}

/* ------------------ PERSONAL ACCOUNT ----------------------- */
function habilitaNIF(){
    var frm = document.Form;
    if(frm.rbFactura_0.checked){
        document.getElementById('trNif1').style.display = '';   
        document.getElementById('trNif2').style.display = '';   
        document.getElementById('trNif3').style.display = '';   
        document.getElementById('trNif4').style.display = '';   
        frm.txtNIF.setAttribute('obligatory','true');
        frm.txtAddress.setAttribute('obligatory','true');
        frm.txtCity.setAttribute('obligatory','true');
        frm.txtZip.setAttribute('obligatory','true');
    }else{
        frm.txtNIF.value = '';
        frm.txtAddress.value = '';
        frm.txtCity.value = '';
        frm.txtZip.value = '';
        frm.txtNIF.setAttribute('obligatory','false');
        frm.txtAddress.setAttribute('obligatory','false');
        frm.txtCity.setAttribute('obligatory','false');
        frm.txtZip.setAttribute('obligatory','false');
        document.getElementById('trNif1').style.display = 'none';   
        document.getElementById('trNif2').style.display = 'none';   
        document.getElementById('trNif3').style.display = 'none';   
        document.getElementById('trNif4').style.display = 'none';
    }
}


/* ------------------ PLAYLIST ----------------------- */

function deletePlaylistTrack(idTema){
    window.opener.winPlaylist.document.Form.hidIdTema.value = idTema;
    window.opener.winPlaylist.document.Form.hidAction.value = "borrarPlaylist";
    window.opener.winPlaylist.document.Form.submit();
}
function deleteAll(){
    document.Form.hidIdTema.value = 0;
    document.Form.hidAction.value = "borrarPlaylist";
    document.Form.submit();
}
function marcaPreescucha(idTema, nro){
    var tds = getElementsByName_iefix('div','tdTrack');
    for(i=0;i<tds.length;i++){
        tds[i].className = "txt_nivel_1";
    }
    document.getElementById('tdTrack'+idTema).className = "txt_nivel_1rojo";
    simple_ajax('ajaxNroCancion.aspx','GET','nro='+nro);
}
function refrescarPlaylist(){
    var myAjax = new Ajax.Updater('div_contenido_playlist', 'ajaxTablaPlaylist.aspx', {method: 'get'});
}

/* ------------------ REGISTER ----------------------- */

function regContinue(){
    if(document.Form.chkAcepto.checked){
        document.Form.hidAction.value = "formulario";
        document.Form.submit();
    }else{
        alert(document.Form.hidMensaje.value);
    }
}
function regValidate(){
    if(Validar()){
        if(document.Form.txtPassword.value == document.Form.txtPassword2.value){
            document.Form.hidAction.value = "guardar";
            document.Form.submit();
        }else{
            alert(document.getElementById('hidMensajeContrasena').value);
        }
    }
}

/* ------------------ REMIX CONTEST ----------------------- */

function comprarPack(nro){
    document.Form.hidAction.value = "comprar";
    document.Form.hidNroPack.value = nro;
    document.Form.submit();
}

/* ------------------ RESULTADOS ----------------------- */

function separately(id){
    document.Form.hidIdAlbum.value = id;
    document.Form.hidAction.value = "separately";
    document.Form.submit();
}
function abrir(strAbrir){
    document.Form.HidAbrir.value = strAbrir;
    try{
        document.Form.HidRegistroInicialPagTemas.value = 0;
    }catch(err){
    
    }
    document.Form.hidSoloTemas.value = 0;
    document.Form.hidSoloAlbums.value = 0;
    document.Form.submit();
}

/* ------------------ SEPARATELY ----------------------- */

function volver(){
    document.Form.hidAction.value = "volver";
    document.Form.submit();
}

/* ------------------ SHOPPING CART ----------------------- */

function changeGlobalFormat(idFormato){
    //primero deshabilito el botón
    document.getElementById('lnkBuy').href = "javascript:waitForBy();";
    document.getElementById('Image37').src = "images/espera.gif";
    document.getElementById('Image37').onmouseover = "MM_swapImage('Image37','','images/images/espera.gif',1)";

    var idCarrito = document.getElementById('hidIdCarrito').value;
    var idMoneda = document.getElementById('hidIdMoneda').value;

    var idFormatoAnt = document.getElementById('hidIdFormatoAnterior').value;
    //saco el color de fondo al formato anterior
    document.getElementById('tdFormato_' + idFormatoAnt).style.backgroundColor = "#FFFFFF";
    //pongo el color de fondo al nuevo formato
    document.getElementById('tdFormato_' + idFormato).style.backgroundColor = "#FFCCCC";
    //actualizo el id del formato nuevo
    document.getElementById('hidIdFormatoAnterior').value = idFormato;
    
    //busco los albums y temas y si es posible les cambio el formato
    var arrTemas = document.getElementById('hidArrayTemas').value.split('|');
    for(i=0;i<arrTemas.length;i++){
        if(document.getElementById('tdFormatoT' + arrTemas[i] + '_' + idFormato)!=null){
            changeFormat(arrTemas[i], idFormato, document.getElementById('hidTipoPrecioT' + arrTemas[i]).value);
        }
    }
    var arrAlbums = document.getElementById('hidArrayAlbums').value.split('|');
    for(i=0;i<arrAlbums.length;i++){
        if(document.getElementById('tdFormatoA' + arrAlbums[i] + '_' + idFormato)!=null){
            changeFormatAlbum(arrAlbums[i], idFormato, document.getElementById('hidTipoPrecioA' + arrAlbums[i]).value);
        }
    }
    var arrCharts = document.getElementById('hidArrayCharts').value.split('|');
    for(i=0;i<arrCharts.length;i++){
        if(document.getElementById('tdFormatoC' + arrCharts[i] + '_' + idFormato)!=null){
            changeFormatChart(idFormato, arrCharts[i]);
        }
    }
    var arrCompilations = document.getElementById('hidArrayCompilations').value.split('|');
    for(i=0;i<arrCompilations.length;i++){
        if(document.getElementById('tdFormatoComp' + arrCompilations[i] + '_' + idFormato)!=null){
            changeFormatComp(idFormato, arrCompilations[i], document.getElementById('hidTipoPrecioComp' + arrCompilations[i]).value);
        }
    }
    setTimeout("cambioPrecio=1;updateTotal();",1000);
}
function changeCartCurrency(idMoneda){
    if(document.Form.hidIdMoneda.value!=idMoneda){
        document.Form.hidIdMoneda.value = idMoneda;
        document.Form.hidAction.value = "changeCartCurrency";
        document.Form.submit();
    }
}
function buyLater(idTema, idAlbum, idChart, idCompilation){
    if(idTema>0){
        document.Form.hidIdTema.value = idTema;
        Lightbox.showBoxByAJAX('Alertas.aspx?nro=5&m=5', 400, 200);
    }else if(idAlbum>0){
        document.Form.hidIdAlbum.value = idAlbum;
        Lightbox.showBoxByAJAX('Alertas.aspx?nro=5&m=6', 400, 200);
    }else if(idChart>0){
        document.Form.hidIdChart.value = idChart;
        Lightbox.showBoxByAJAX('Alertas.aspx?nro=5&m=6', 400, 200);
    }else if(idCompilation>0){
        document.Form.hidIdCompilation.value = idCompilation;
        Lightbox.showBoxByAJAX('Alertas.aspx?nro=5&m=6', 400, 200);
    }
}
function waitForBuy(){
    
}

function buyLaterConfirm(){
    document.Form.hidAction.value = "buyLater";
    document.Form.submit();
}
function deleteProduct(idTema, idAlbum, idChart, idCompilation){
    if(idTema>0){
        document.Form.hidIdTema.value = idTema;
        Lightbox.showBoxByAJAX('Alertas.aspx?nro=6&m=7', 400, 210);
    }else if(idAlbum>0){
        document.Form.hidIdAlbum.value = idAlbum;
        Lightbox.showBoxByAJAX('Alertas.aspx?nro=6&m=8', 400, 210);
    }else if(idChart>0){
        document.Form.hidIdChart.value = idChart;
        Lightbox.showBoxByAJAX('Alertas.aspx?nro=6&m=8', 400, 210);
    }else if(idCompilation>0){
        document.Form.hidIdCompilation.value = idCompilation;
        Lightbox.showBoxByAJAX('Alertas.aspx?nro=6&m=8', 400, 210);
    }else{
        Lightbox.showBoxByAJAX('Alertas.aspx?nro=6&m=15', 400, 210);
    }
}
function deleteProductConfirm(){
    document.Form.hidAction.value = "deleteProduct";
    document.Form.submit();
}
function buyCart(){
    document.Form.hidAction.value = "buy";
    document.Form.submit();
}
function updateTotal(){
    if(cambioPrecio==1){
        var fltTotal = 0;
        var idMoneda = document.getElementById('hidIdMoneda').value;

        //busco los albums y temas y si es posible les cambio el formato
        var arrTemas = document.getElementById('hidArrayTemas').value.split('|');
        for(i=0;i<arrTemas.length;i++){
            if(document.getElementById('contenedorPrecioT' + arrTemas[i])!=null){
                arrPrecio = document.getElementById('contenedorPrecioT' + arrTemas[i]).innerHTML.split(' ');
                for(j=0;j<arrPrecio.length;j++){
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('<STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('<STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('</STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('</STRONG>','');
                    if(!isNaN(parseFloat(arrPrecio[j].replace(',','.')))){
                        fltTotal += parseFloat(arrPrecio[j].replace(',','.'));
                        break;
                    }
                }
            }
        }
        var arrAlbums = document.getElementById('hidArrayAlbums').value.split('|');
        for(i=0;i<arrAlbums.length;i++){
            if(document.getElementById('contenedorPrecioA' + arrAlbums[i])!=null){
                arrPrecio = document.getElementById('contenedorPrecioA' + arrAlbums[i]).innerHTML.split(' ');
                for(j=0;i<arrPrecio.length;j++){
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('<STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('<STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('</STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('</STRONG>','');
                    if(!isNaN(parseFloat(arrPrecio[j].replace(',','.')))){
                        fltTotal += parseFloat(arrPrecio[j].replace(',','.'));
                        break;
                    }
                }
            }
        }
        var arrCharts = document.getElementById('hidArrayCharts').value.split('|');
        for(i=0;i<arrCharts.length;i++){
            if(document.getElementById('contenedorPrecioC' + arrCharts[i])!=null){
                arrPrecio = document.getElementById('contenedorPrecioC' + arrCharts[i]).innerHTML.split(' ');
                for(j=0;i<arrPrecio.length;j++){
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('<STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('<STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('</STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('</STRONG>','');
                    if(!isNaN(parseFloat(arrPrecio[j].replace(',','.')))){
                        fltTotal += parseFloat(arrPrecio[j].replace(',','.'));
                        break;
                    }
                }
            }
        }
        var arrCompilations = document.getElementById('hidArrayCompilations').value.split('|');
        for(i=0;i<arrCompilations.length;i++){
            if(document.getElementById('contenedorPrecioComp' + arrCompilations[i])!=null){
                arrPrecio = document.getElementById('contenedorPrecioComp' + arrCompilations[i]).innerHTML.split(' ');
                for(j=0;i<arrPrecio.length;j++){
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('<STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('<STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('</STRONG>','');
                    arrPrecio[j] = arrPrecio[j].toUpperCase().replace('</STRONG>','');
                    if(!isNaN(parseFloat(arrPrecio[j].replace(',','.')))){
                        fltTotal += parseFloat(arrPrecio[j].replace(',','.'));
                        break;
                    }
                }
            }
        }
        document.getElementById('divTotal').innerHTML = roundNumber(fltTotal, 2).toString().replace('.',',');
        document.getElementById('hidTotal').value = roundNumber(fltTotal, 2).toString().replace('.',',');
        cambioPrecio = 0;
        document.getElementById('lnkBuy').href = "javascript:buyCart();";
        document.getElementById('Image37').src = "images/btn_download_off.gif";
        document.getElementById('Image37').onmouseover = "MM_swapImage('Image37','','images/btn_download_on.gif',1)";
    }else{
        setTimeout("updateTotal()",800);
    }
}

var x="1";
var isBack;
function handleBackButton(){
   isBack = (x != document.Form._a1.value);
   document.Form._a1.value=2;
   document.Form._a1.defaultValue=2;
   if(isBack){
       document.Form.hidAction.value = "";
       document.Form.submit();
   }
}
/* ------------------------ UNDERGROUND ---------------------------*/
function marcarUnd(idG, nroTd){
    var tds = getElementsByName_iefix('td','tdSub');
    for(i=0;i<tds.length;i++){
        if(tds[i].background=='images/sup_izq_udg.gif' || tds[i].background=='images/sup_izq2_udg.gif'){
            tds[i].background = "images/sup_izq2_udg.gif";
        }else if(tds[i].background=='images/inf_izq_udg.gif' || tds[i].background=='images/inf_izq2_udg.gif'){
            tds[i].background = "images/inf_izq2_udg.gif";
        }else{
            tds[i].background = "images/medio_udg.gif";
        }
    }
    if(nroTd == 0){
        document.getElementById('tdSub'+idG+'_'+nroTd).background = "images/sup_izq_udg.gif";
    }else if(document.getElementById('tdSub'+idG+'_'+nroTd).background=="images/inf_izq2_udg.gif"){
        document.getElementById('tdSub'+idG+'_'+nroTd).background = "images/inf_izq_udg.gif";
    }else{
        document.getElementById('tdSub'+idG+'_'+nroTd).background = "images/recto_udg.gif";
    }
}


function roundNumber(numero, intDecimales) {
	var rlength = intDecimales; 
	if (numero > 8191 && numero < 10485) {
		//numero = numero-5000;
		var newnumber = Math.round(numero*Math.pow(10,rlength))/Math.pow(10,rlength);
	} else {
		var newnumber = Math.round(numero*Math.pow(10,rlength))/Math.pow(10,rlength);
	}
	return newnumber;
}

function forward(){
    if(Validar()){
        document.Form.hidAction.value = "enviar";
        document.Form.submit();
    }
}