function AttivaLogin(){
     document.getElementById('loginutente').className="visibilelogin";
     self.scrollTo(0, 0);
}
function AnnullaLogin(){
     document.getElementById('loginutente').className="nascosto";	
}

function AnnullaLoginFromPost(){
     window.close();
}

function ForgotPwFromPost(idlang){
     window.close();
     var language=new Array("it", "uk");
     var larghezza = screen.width; 
     var altezza = screen.height;
     var param="width="+larghezza+",height="+altezza;
     window.open('http://www.radiostar.it/forgot_password.php?lang='+language[idlang],'_newtab');
}

function AccountNew(idlang){
     window.close();
     var language=new Array("it", "uk");
     var larghezza = screen.width; 
     var altezza = screen.height;
     var param="width="+larghezza+",height="+altezza;
     window.open('http://www.radiostar.it/registrati_new.php?lang='+language[idlang],'_newtab');
}


function ApriDivCommenti(idpubblicato){

     var nomecommento='commentapost'+idpubblicato;
     var altezzacorpo=0;
     var incval=60;
     var nomecampoinc='totcommenti'+idpubblicato;
     var altezzacorpo=parseInt(document.getElementById('valaltezzacorpo').value, 10);
     if (document.getElementById(nomecommento).className=='apricommento'){
         document.getElementById(nomecommento).className='chiudicommento';
         document.getElementById('commentoalpost'+idpubblicato).className='commentopost';
         //document.getElementById('commentoalpost'+idpubblicato).value='scrivi un commento';
         incval=incval+(Number(document.getElementById(nomecampoinc).value)*30);
         altezzacorpo=altezzacorpo-incval;
         document.getElementById('corpoprincipale').style.height=altezzacorpo+'px';
         document.getElementById('valaltezzacorpo').value=altezzacorpo+'px';
         document.getElementById(nomecommento).style.height=incval+'px';
     }else{
         incval=incval+(Number(document.getElementById(nomecampoinc).value)*30);
         document.getElementById(nomecommento).className='apricommento';
         altezzacorpo=altezzacorpo+incval;
         document.getElementById('corpoprincipale').style.height=altezzacorpo+'px';
         document.getElementById('valaltezzacorpo').value=altezzacorpo+'px';
         if ((document.getElementById('validagg').value!=0)){
             var oldidagg= document.getElementById('validagg').value;
             document.getElementById('validagg').value=0;
             window.clearTimeout(oldidagg);
         }
         document.getElementById('tastoaggiornabacheca').className="tastoaggbacheca";
         document.getElementById(nomecommento).style.height=incval+'px';
     }
     
     
}


function ApriDivCondividi(idpubblicato){
	var iduser = "";
        var tpuser = "";	
        var jsel = document.createElement("SCRIPT");
	url = document.location.href;
	xend = url.lastIndexOf("/") + 1;
	var base_url = url.substring(0, xend);
	url = 'http://www.radiostar.it/incnuovi/getpostbacheca.php?idp='+idpubblicato+'&idu='+iduser+'&tpu='+tpuser;
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild (jsel);	
	document.getElementById('contentsharepost').className="visibilelogin";
	self.scrollTo(0, 0);
}

function ApriDivShareAmici(idpubblicato){
	var iduser = "";
        var tpuser = "";
	var jsel = document.createElement("SCRIPT");
	url = document.location.href;
	xend = url.lastIndexOf("/") + 1;
	var base_url = url.substring(0, xend);
	url = 'http://www.radiostar.it/incnuovi/sharepostbacheca_amici.php?idp='+idpubblicato+'&idu='+iduser+'&tpu='+tpuser;
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild (jsel);	
	document.getElementById('contentshareamici').className="visibilelogin";
	self.scrollTo(0, 0);
}

function ApriDivShareFanclub(idpubblicato){
	var iduser = "";
        var tpuser = "";
	var jsel = document.createElement("SCRIPT");
	url = document.location.href;
	xend = url.lastIndexOf("/") + 1;
	var base_url = url.substring(0, xend);
	url = 'http://www.radiostar.it/incnuovi/sharepostbacheca_fanclub.php?idp='+idpubblicato+'&idu='+iduser+'&tpu='+tpuser;
	jsel.type = 'text/javascript';
	jsel.src = url;
	document.body.appendChild (jsel);	
	document.getElementById('contentsharefanclub').className="visibilelogin";
	self.scrollTo(0, 0);
}

function AnnullaShareFanclub(){
    document.getElementById('contentsharefanclub').className="nascosto";
    document.getElementById('sharefanclub').innerHTML="<br><br><br><input id='msgwaitlink' class='waitlink' value='"+document.getElementById('msgwaitinglink').value+"' readonly>";
}


function AnnullaShareAmici(){
    document.getElementById('contentshareamici').className="nascosto";
    document.getElementById('shareamici').innerHTML="<br><br><br><input id='msgwaitlink' class='waitlink' value='"+document.getElementById('msgwaitinglink').value+"' readonly>";
}

function AnnullaSharePost(){
    document.getElementById('contentsharepost').className="nascosto";
    document.getElementById('sharepost').innerHTML="<br>";
    document.getElementById('commentocondividi').value==''
    document.getElementById('commentocondividi').className='commento';    
}



function puliscicampo(valcommento){
     if (document.getElementById('commento').value==valcommento){
         document.getElementById('commento').value='';
         document.getElementById('commento').className="commentoutente";
     }
}

function puliscilink(){
     if (document.getElementById('vallink').value=='http://'){
         document.getElementById('vallink').value='';
         document.getElementById('vallink').className="commentoutente";
     }
}

function puliscicommentocondividi(){
    if (document.getElementById('commentocondividi').value==document.getElementById('valcommentoshare').value){
        document.getElementById('commentocondividi').value='';
        document.getElementById('commentocondividi').className="commentoutente";
    }
}
function puliscicommentocondividi_amici(){
    if (document.getElementById('commentocondividiamici').value==document.getElementById('valcommentoshare').value){
        document.getElementById('commentocondividiamici').value='';
        document.getElementById('commentocondividiamici').className="commentoutente";
    }
}

function puliscicommentocondividi_fanclub(){
    if (document.getElementById('commentocondividifanclub').value==document.getElementById('valcommentoshare').value){
        document.getElementById('commentocondividifanclub').value='';
        document.getElementById('commentocondividifanclub').className="commentoutente";
    }
}


function AttivaDivGen(nomeelemento, nomeclasse){
     document.getElementById(nomeelemento).className=nomeclasse;	
}

function ChiudiDivGen(nomeelemento){
     document.getElementById(nomeelemento).className="nascosto";	
}

function ApriFotoBacheca(linkfoto, idartista, tpuser, idfan, provdafan){
        
     var x = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
     var y = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight; 
     var hx=x/2;
     var hy=y/2;
     var a=screen.width;  //Inserire i valori per il resize
     var b=screen.height;  //della finestra popup a=x; b=y;
     var ha=a/2;
     var hb=b/2;
     var dx=hx-ha;
     var dy=(hy-hb)-20;
     var param="width="+a+",height="+b+",left="+dx+",top="+dy+",screenX="+dx+",screenY="+dy+",resizable=no";
     
     window.open('/incnuovi/viewfotouser.php?fotouserattiva='+linkfoto+'&nw='+screen.width+'&nh='+screen.height+'&idfan='+idfan+'&provdafan='+provdafan+'&idmembro='+idartista+'&tpuser='+tpuser,'',param);
}






//collabora
function AttivaComeFunziona(idistr){
     valpathimg=document.getElementById('pathlanguage').value; 
     if (idistr==0){
	document.getElementById('divbloccocondividi').className="visibile_blocco_collabora";
        document.getElementById('comefuncondividi').className="corpocondividi";
        document.getElementById('comefuncondividi').style.backgroundImage = 'url('+valpathimg+'/bk_blocco_condividi.png)';
     }
     if (idistr==1){
	document.getElementById('divbloccocondividi').className="visibile_blocco_collabora";
        document.getElementById('condividistar').className="corpocondividi";
        document.getElementById('condividistar').style.backgroundImage = 'url('+valpathimg+'/bk_blocco_condividi.png)';
     }
     if (idistr==3){
	document.getElementById('condividistar').className="nascosto";
	document.getElementById('divbloccocondividi').className="visibile_blocco_collabora";
        document.getElementById('comefuncondividi').className="corpocondividi";
        document.getElementById('comefuncondividi').style.backgroundImage = 'url('+valpathimg+'/bk_blocco_condividi.png)';
     }     

     if (idistr==4){
	document.getElementById('divbloccoplayer').className="visibile_blocco_collabora";
        document.getElementById('comefunplayer').className="corpoplayer";
        document.getElementById('comefunplayer').style.backgroundImage = 'url(/imgn/bk_blocco_player.png)';
     }     

     if (idistr==5){
	document.getElementById('divbloccocreativelabs').className="visibile_blocco_collabora";
        document.getElementById('comefunlabs').className="creativelab";
        document.getElementById('comefunlabs').style.backgroundImage = 'url(/imgn/bk_blocco_business.png)';
     }  

     self.scrollTo(0, 0);
}
function AnnullaComeFunziona(idistr){
     if (idistr==0){	
        document.getElementById('divbloccocondividi').className="nascosto";
	document.getElementById('comefuncondividi').className="nascosto";
	document.getElementById('condividistar').className="nascosto";
     }

     if (idistr==4){	
        document.getElementById('divbloccoplayer').className="nascosto";
	document.getElementById('comefunplayer').className="nascosto";
     }
     
     if (idistr==5){	
        document.getElementById('divbloccocreativelabs').className="nascosto";
	document.getElementById('comefunlabs').className="nascosto";
     }       
}
function select_all_collabora(nomecampo){
    document.getElementById(nomecampo).select();
}

//format

function SelectFormat(selectElement){
     var idxselect = selectElement.selectedIndex;
     var valcategoria = selectElement.options[idxselect].value;
     ActPageCatFormat(valcategoria);
}

function ApriDesFormat(idformat){

     if (idformat==0){	
	document.getElementById('divbloccopck').className="visibile_blocco_collabora";
        document.getElementById('comefunzpck').className="corpobloccoformat";
        document.getElementById('comefunzpck').style.backgroundImage = 'url(/imgn/bk_logo_pck_onair.png)';
     }     
     
}

function AnnullaDesFormat(idformat){
     if (idformat==0){	
	document.getElementById('divbloccopck').className="nascosto";
        document.getElementById('comefunzpck').className="nascosto";
     } 
}






function encodeStrjs(str, tpfun){
     
     var baseChars = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/', '.',':','_',"'",'@',' ','!','','','','','','','?','&','"',"",'$','%','(',')','-','*','=')
     var baseNum = new Array('101','102','103','104','105','106','107','108','109','110','111','112','113','114','115','116','117','118','119','120','121','122','123','124','125','126','127','128','129','130','131','132','133','134','135','136','137','138','139','140','141','142','143','144','145','146','147','148','149','150','151','152','153','154','155','156','157','158','159','160','161','162','163','164','165','166','167','168','169','170','171','172','173','174','175','176','177','178','179','180','181','182','183','184','185','186','187','188')
     if (tpfun==0){var i =0 ;var str_return="";for (i=0; ( (i<str.length) ); i++) {for (x=0; ( (x<baseChars.length) ); x++) {if (str.substr(i,1)==baseChars[x]){str_return=str_return+baseNum[x];break;}}}}
     if (tpfun==1){var i =0 ;var str_return="";for (i=0; ( (i<str.length) ); i++) {for (x=0; ( (x<baseNum.length) ); x++) {if (str.substr(i,3)==baseNum[x]){str_return=str_return+baseChars[x];i=i+2;break;}}}}return str_return;
}

function AllungaDes(id){
    
    document.getElementById('valatt'+id).innerHTML="<font style='font-family: Arial, Helvetica, sans-serif;font-size:12px;color:#ffffff;'>"+document.getElementById('allatt'+id).value+"</font>";
    document.getElementById('valatt'+id).className="divdesattivitaauto";
    var altezzacorpo=parseInt(document.getElementById('valaltezzacorpo').value, 10);
    var incval=350;
    altezzacorpo=altezzacorpo+incval;
    document.getElementById('corpoprincipale').style.height=altezzacorpo+'px';
    document.getElementById('valaltezzacorpo').value=altezzacorpo+'px';
    if ((document.getElementById('validagg').value!=0)){
        var oldidagg= document.getElementById('validagg').value;
        document.getElementById('validagg').value=0;
        window.clearTimeout(oldidagg);
    }
    
}
