



function check_login()
{
	with (document.login)
	{
		var check=false;
		var Txt="";

		if(user.value=="0" || user.value.length==0)
		{
			check=true;
			Txt="Inserisci un nome valido!\n";
		}
		if(pwd.value=="0" || pwd.value.length==0)
		{
			check=true;
			Txt = Txt + "Inserisci una password valida!";
		}
		if(pwd.value != repwd.value)
		{
			check=true;
			Txt = Txt + "Verifica che le due password corrispondano";
		}
		if (check)
		{
			alert(Txt);
			return false
		}
	}
}

function check_up()
{
	with (document.upload)
	{
		var check=false;
		var Txt="";

		if(mp3.value.length==0)
		{
			check=true;
			Txt = "Selezionare prima un file!";
		}
		if (check)
		{
			alert(Txt);
			return false
		}
	}
}

function check_commenti()
{
	
}

// orologino js
function mytime()
{
	var x=new Date();
	h=x.getHours();
	m=x.getMinutes();
	s=x.getSeconds();
	if(s<=9) s="0"+s;
	if(m<=9) m="0"+m;
	if(h<=9) h="0"+h;
	time=h+":"+m+":"+s;
	document.getElementById('orologio').innerHTML=time;
	setTimeout("mytime()",1000);
}

function showGenere(sel,alias)
{
	var check = document.getElementById('checkGenere').value;
	
	if(check!=sel)
	{
		var ajax = new sack();
		ajax.method = 'POST';
		ajax.setVar("genere", sel);
		ajax.requestFile = 'home_ajax.php';
		ajax.element = 'foo2';
		ajax.onLoading = whenLoading;
		ajax.onCompletion = end;
		ajax.runAJAX();
		
		// apro le ultime 5 e le random per il genere scelto
		var ajax2 = new sack();
		ajax2.method = 'POST';
		ajax2.setVar("randomSong", sel);
		ajax2.requestFile = 'home_ajax.php';
		ajax2.element = 'showSongList';
		ajax2.onLoading = whenLoading;
		ajax2.onCompletion = end;
		ajax2.runAJAX();
		
		if(check)document.getElementById('gen_'+check).style.backgroundImage="url(images/"+check+".png)";
		document.getElementById('checkGenere').value=alias;
		document.getElementById('gen_'+alias).style.backgroundImage="url(images/"+alias+"2.gif)";
		document.getElementById('gen_'+alias).onmouseout="";
		document.getElementById('gen_'+alias).onmouseover="";
		
		// nascondo le info sull'artista ormai perso
		document.getElementById('info_artista').innerHTML='';
	}
}

function showSong(sel,gen)
{
	var ajax = new sack();
	ajax.method = 'POST';
	ajax.setVar("song", sel);
	ajax.setVar("id_gen", gen);
	ajax.requestFile = 'home_ajax.php';
	ajax.element = 'showSongList';
	ajax.onLoading = whenLoading;
	ajax.onCompletion = end;
	ajax.runAJAX();
	
	// visualizzo le informazioni sull'artista selezionato
	var ajax2 = new sack();
	ajax2.method = 'POST';
	ajax2.setVar("artista", sel);
	ajax2.requestFile = 'home_ajax.php';
	ajax2.element = 'info_artista';
	ajax2.onLoading = whenLoading;
	ajax2.onCompletion = end;
	ajax2.runAJAX();
}

function showSong2(sel,gen,lima,limb,num)
{
	if(!lima)var lima="";
	if(!limb)var limb="";
	if(!num)var num="";
	
	var ajax = new sack();
	ajax.method = 'POST';
	ajax.setVar("song", sel);
	ajax.setVar("id_gen", gen);
	ajax.setVar("limita", lima);
	ajax.setVar("limitb", limb);
	ajax.setVar("numResults", num);
	ajax.requestFile = 'home_ajax.php';
	ajax.element = 'showSongList';
	ajax.onLoading = whenLoading;
	ajax.onCompletion = end;
	ajax.runAJAX();
}

function openSong(sel,avatar)
{
	var check = document.getElementById('songSelected').value;
	
	if(check=="@close@")
	{
		document.getElementById('songSelected').value = '';
	}else if(check!=sel)
	{
		if(avatar=="on")
			document.getElementById('avatarID').value=avatar;
		
		var ajax = new sack();
		ajax.method = 'POST';
		ajax.setVar("openSong", sel);
		ajax.requestFile = 'home_ajax.php';
		ajax.element = 'openSong'+sel;
		ajax.onLoading = whenLoading;
		ajax.onCompletion = end;
		ajax.runAJAX();
		
		if(check>0)rigeneraSong(check);
		document.getElementById('songSelected').value = sel;
		document.getElementById('openSong'+sel).className = 'song2';
	}
}

function rigeneraSong(sel)
{
	var avatar = document.getElementById('avatarID').value;
	if(avatar=="on")document.getElementById('avatarID').value='';
	
	var ajax = new sack();
	ajax.method = 'POST';
	ajax.setVar("reopenSong", sel);
	ajax.setVar("avatar", avatar);
	ajax.requestFile = 'home_ajax.php';
	ajax.element = 'openSong'+sel;
	ajax.onLoading = whenLoading;
	ajax.onCompletion = end;
	ajax.runAJAX();
	
	document.getElementById('openSong'+sel).className = '';
	document.getElementById('songSelected').value = '@close@';
}

function showDir(sel,id)
{
	if(document.getElementById('tmpDir').value > 0)
	{
		document.getElementById('dir'+document.getElementById('tmpDir').value).style.display = 'none';
	}

	var ajax = new sack();
	ajax.method = 'POST';
	ajax.setVar("dir", sel);
	ajax.setVar("id", id);
	ajax.requestFile = 'home_ajax.php';
	ajax.element = 'dir'+id;
	ajax.onLoading = whenLoading;
	ajax.onCompletion = end;
	ajax.runAJAX();

	if(document.getElementById('dir'+id).style.display == 'none')document.getElementById('dir'+id).style.display = 'block';
	document.getElementById('tmpDir').value = id;
}

function showFile(sel,id)
{
	if(document.getElementById('tmpFile').value > 0)
	{
		document.getElementById(document.getElementById('tmpFile').value).style.display = 'none';
	}

	var ajax = new sack();
	ajax.method = 'POST';
	ajax.setVar("file", sel);
	ajax.requestFile = 'home_ajax.php';
	ajax.element = id;
	ajax.onLoading = whenLoading;
	ajax.onCompletion = end;
	ajax.runAJAX();

	if(document.getElementById(id).style.display == 'none')document.getElementById(id).style.display = 'block';
	document.getElementById('tmpFile').value = id;
}

function salvaVoto(sel,voto)
{
	var ajax = new sack();
	ajax.method = 'POST';
	ajax.setVar("salva_voto", sel);
	ajax.setVar("voto", voto);
	ajax.requestFile = 'home_ajax.php';
	ajax.onLoading = whenLoading;
	ajax.onCompletion = end;
	ajax.runAJAX();
	
	document.getElementById('votazione_'+sel).style.display='none';
	document.getElementById('voto_'+sel).style.display='inline-block';
						
}

function load(display)
{
	document.getElementById('load').style.display=display;
}

function whenLoading()
{
	load('block');
}

function end()
{
	load('none');
}

/**
 * verificare
 * @return
 */
function fade()
{

	window.addEvent('domready', function() {
		var status = {
			'true': 'open',
			'false': 'close'
		};

		var myVerticalSlide = new Fx.Slide('vertical_slide');

		$('v_toggle').addEvent('click', function(e){
			e.stop();
			myVerticalSlide.toggle();
		});

		// When Vertical Slide ends its transition, we check for its status
		// note that complete will not affect 'hide' and 'show' methods
		myVerticalSlide.addEvent('complete', function() {
			$('vertical_status').set('html', status[myVerticalSlide.open]);
		});
	});
}

function classificazione(sel)
{
	var valutaRow = sel;
	var valutaSplit = valutaRow.split("_");
	
	if(valutaSplit[1]==1)
	{
		document.getElementById(sel).src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_2').src = 'images/star3.gif';
		document.getElementById(valutaSplit[0]+'_3').src = 'images/star3.gif';
		document.getElementById(valutaSplit[0]+'_4').src = 'images/star3.gif';
		document.getElementById(valutaSplit[0]+'_5').src = 'images/star3.gif';
	}
	else if(valutaSplit[1]==2)
	{
		document.getElementById(valutaSplit[0]+'_1').src = 'images/star2.png';
		document.getElementById(sel).src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_3').src = 'images/star3.gif';
		document.getElementById(valutaSplit[0]+'_4').src = 'images/star3.gif';
		document.getElementById(valutaSplit[0]+'_5').src = 'images/star3.gif';

	}
	else if(valutaSplit[1]==3)
	{
		document.getElementById(valutaSplit[0]+'_1').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_2').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_3').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_4').src = 'images/star3.gif';
		document.getElementById(valutaSplit[0]+'_5').src = 'images/star3.gif';
	}
	else if(valutaSplit[1]==4)
	{
		document.getElementById(valutaSplit[0]+'_1').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_2').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_3').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_4').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_5').src = 'images/star3.gif';
	}
	else if(valutaSplit[1]==5)
	{
		document.getElementById(valutaSplit[0]+'_1').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_2').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_3').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_4').src = 'images/star2.png';
		document.getElementById(valutaSplit[0]+'_5').src = 'images/star2.png';
	}

	document.getElementById('val').value = valutaSplit[1];
}

function fbs_click(u,t) {
    if(!u)u=location.href;
    if(!t)t=document.title;
    
    window.open('http://www.facebook.com/sharer.php?u=' +
         encodeURIComponent(u) +
         '&t=' +
         encodeURIComponent(t),
         ' sharer', 'toolbar=0, status=0, width=626, height=436');
    return false;
}

function checkitAll(num,bool) 
{
	bool = !bool ? true : false;
	for(var i=1; i<=num; i++)
	{
		document.getElementById(i).checked = bool;
	}
}

function checkitArtist(num,sel)
{
	for(var i=1; i<=num; i++)
	{
		document.getElementById('art_'+i).options[sel].selected = 'true';
	}
}

function setTitle(title,val)
{
	document.getElementById('titolo_'+val).style.display='none';
	document.getElementById('new_titolo_'+val).style.display='block';
	
	document.getElementById('title_'+val).focus();
	document.getElementById('title_'+val).value=title;
}

function saveTitle(new_tit,old_tit,val)
{
	if(new_tit!=old_tit)
	{
		var ajax = new sack();
		ajax.method = 'POST';
		ajax.setVar("title", new_tit);
		ajax.setVar("song_id", val);
		ajax.requestFile = 'home_ajax.php';
		ajax.onLoading = whenLoading;
		ajax.onCompletion = end;
		ajax.runAJAX();
	}
	
	document.getElementById('new_titolo_'+val).style.display = 'none';
	document.getElementById('titolo_'+val).style.display = 'block';
	document.getElementById('titolo_'+val).innerHTML = new_tit;
}

function disp_name(art)
{
	var len = art.length;
	if(len > 0)
	{ 
		document.getElementById('artist_name').innerHTML = '<a class="artist_name">'+art+'</a>';
	}else{
		document.getElementById('artist_name').innerHTML = '';
	}
}


// google +1
window.___jsl=window.___jsl||{};
window.___jsl.h=window.___jsl.h||'r;gc\/22224365-adc8a19e';
window.___gpq=[];
window.gapi=window.gapi||{};
window.gapi.plusone=window.gapi.plusone||(function(){
  function f(n){return function(){window.___gpq.push(n,arguments)}}
  return{go:f('go'),render:f('render')}})();
function __bsld(){var p=window.gapi.plusone=window.googleapisv0.plusone;var f;while(f=window.___gpq.shift()){
  p[f]&&p[f].apply(p,window.___gpq.shift())}
if (gadgets.config.get("gwidget")["parsetags"]!=="explicit"){gapi.plusone.go();}}
window['___jsl'] = window['___jsl'] || {};window['___jsl']['u'] = 'https:\/\/apis.google.com\/js\/plusone.js';window['___jsl']['f'] = ['googleapis.client','plusone'];window['___lcfg'] = {"gwidget":{"parsetags":"onload"},"rpc":{"commSwf":"//xpc.googleusercontent.com/gadgets","passReferrer":"p2c:query","parentRelayUrl":"/rpc_relay.html"},"iframes":{":socialhost:":"https://apis.google.com","plusone_m":{"params":{"count":"#","url":"#","size":"#"},"url":":socialhost:/u/:session_index:/_/+1/button"},"plusone":{"params":{"count":"#","url":"#","size":"#"},"url":":socialhost:/u/:session_index:/_/+1/button"}},"googleapis.config":{"requestCache":{"enabled":true},"methods":{"chili.people.list":true,"pos.plusones.list":true,"chili.entities.starred.insert":{"cache":{"invalidates":["chili.entities.starred","chili.entitiesDefaultAcl"]}},"chili.people.get":true,"chili.entities.get":true,"pos.plusones.delete":true,"chili.entities.starred.delete":true,"chili.entities.list":true,"pos.plusones.get":true,"chili.groups.list":true,"pos.plusones.getDefaultAcl":{"cache":{"enabled":true}},"chili.entities.starred.get":true,"pos.plusones.insert":true,"chili.activities.list":true,"chili.entitiesDefaultAcl.get":true,"chili.entities.starred.list":true,"chili.activities.get":true,"chili.activities.search":true,"pos.plusones.getSignupState":true},"versions":{"chili":"v1","pos":"v1"},"rpc":"/rpc","transport":{"isProxyShared":true},"sessionCache":{"enabled":true},"proxy":"https://clients6.google.com/static/proxy.html","developerKey":"AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ","jsh":"r;gc/22224365-adc8a19e","auth":{"useInterimAuth":false}}};var jsloader=window.jsloader||{};
var gapi=window.gapi||{};
(function(){function k(){return window.___jsl=window.___jsl||{}}function n(b,c,e,a){e=p(e).join(b);a&&a.length>0&&(e+=c+p(a).join(b));return e}function r(b){for(var c={},e=0,a;a=b[e];e++)c[a]=1;return c}function p(b){var c=[],e;for(e in r(b))c.push(e);return c.sort()}function u(){var b;if((b=j.match(v))||(b=j.match(w)))try{return decodeURIComponent(b[2])}catch(c){return null}else return k().h}function l(b){m=g="";q={};i=[];h=window.console||window.opera&&window.opera.postError;j=b;if(b=u()){b=b.split(";");
g=b.shift();var c=g!=="s"&&g!=="r";m=c?b.shift():"https://ssl.gstatic.com/webclient/js";o=(c=g!=="s"&&g!=="i")&&b.shift();s=(c=g==="d")&&(b.shift()||"gcjs-3p");t=c&&b.shift()||"";if(c=g==="s"||g==="i")for(var c=0,e;e=b[c];c++){e=e.split("@");var a=q,d,f=e[0].split("!");d=f[0].split(":");f=f[1]&&f[1].split(":");d=n(":","!",d,f);a[d]=e[1]}}}var v=/\?([^&#]*&)*jsh=([^&#]*)/,w=/#([^&]*&)*jsh=([^&]*)/,x=/^https:\/\/ssl.gstatic.com\/webclient\/js(\/[a-zA-Z0-9_\-]+)*\/[a-zA-Z0-9_\-\.:!]+\.js$/,y=/^(https?:)?\/\/([^/:@]*)(:[0-9]+)?\//,
g,m,s,t,o,q,i,h,j;l(document.location.href);jsloader.load=function(b,c,e){var a;if(!b||b.length==0)h&&h.warn("Cannot load empty features.");else{var d;d=r(i);for(var f=!0,j=0,l;l=f&&b[j];j++)f=f&&d[l];(d=f)?(d="Cannot load loaded features ["+b.join(",")+"].",h&&h.warn(d)):g==="s"||g==="i"?(a=n(":","!",b,i),(d=q[a])?a=m+"/"+d+".js":(h&&h.warn("Cannot find features ["+a+"]."),a=void 0)):g==="d"?(a=m+"/"+n(":","!",b,i),a+=".js?container="+s+"&c=2&jsload=0",o&&(a+="&r="+o),t=="d"&&(a+="&debug=1")):g===
"r"||g==="f"?a=m+"/"+o+"/"+n("__","--",b,i)+".js":(d="Cannot respond for features ["+b.join(",")+"].",h&&h.warn(d))}d=c;c=e;if(a){if(e=d){if(k().c)throw"Cannot continue until a pending callback completes.";k().c=e;k().o=1}a=e=a;g==="s"||g==="r"?a=a.match(x):(d=a.match(y),(a=k().m)&&d?(d=d[2],f=d.lastIndexOf(a),a=(f==0||a.charAt(0)=="."||d.charAt(f-1)==".")&&d.length-a.length==f):a=!1);if(!a)throw"Cannot load url "+e+".";if(window.___gapisync===!0||c&&c.sync===!0)c=!0;else{c=!1;a=document.getElementsByTagName("meta");
for(d=0;f=!c&&a[d];++d)"generator"==f.getAttribute("name")&&"blogger"==f.getAttribute("content")&&(c=!0)}c?document.write('<script src="'+e+'"><\/script>'):(c=document.createElement("script"),c.setAttribute("src",e),document.getElementsByTagName("head")[0].appendChild(c));i=p(i.concat(b))}else d&&d()};jsloader.reinitialize_=function(b){l(b)}})();
gapi.load=function(a,b){jsloader.load(a.split(":"),b)};
gapi.load('googleapis.client:plusone', window['__bsld']);
