/**********************************************************
 * funzioni di codifica e decodifica
 * *****************************************************/
var Base64 = {

    // private property
    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

    // public method for encoding
    encode : function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;

        input = Base64._utf8_encode(input);

        while (i < input.length) {

            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);

            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }

            output = output +
            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

        }

        return output;
    },

    // public method for decoding
    decode : function (input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;

        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

        while (i < input.length) {

            enc1 = this._keyStr.indexOf(input.charAt(i++));
            enc2 = this._keyStr.indexOf(input.charAt(i++));
            enc3 = this._keyStr.indexOf(input.charAt(i++));
            enc4 = this._keyStr.indexOf(input.charAt(i++));

            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;

            output = output + String.fromCharCode(chr1);

            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }

        }

        output = Base64._utf8_decode(output);

        return output;

    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}


/*****************************************************************************************
*	FUNZIONI PER FAR MUOVERE LO SPAN ATTENDEREP PREGO CON LA PAGINA (anche quando sgrullo)
******************************************************************************************/
function setVariables(){
	if (navigator.appName == "Netscape") {
		if (parseInt(navigator.appVersion) >= 5){
			v=".top=";
			h=".left=";
			dS="document.getElementById(\"";sD="\").style";
			y="window.pageYOffset";
			x="window.pageXOffset";
		}
		else {
			v=".top=";
			h=".left=";
			dS="document.";
			sD="";
			y="window.pageYOffset";
			x="window.pageXOffset";
		}
	}
	else {
	//ENTRO QUI
		h=".pixelLeft=";
		v=".pixelTop=";
		dS="";
		sD=".style";
		y="document.body.scrollTop";
		x="document.body.scrollLeft";
	}
	checkLocationA()
}

movex=0,movey=0,xdiff=0,ydiff=0,ystart=0,xstart=0
var elFake ;


function checkLocation(){
	object="obj";
	yy=eval(y);
	xx=eval(x);
	ydiff=ystart-yy;
	xdiff=xstart-xx;

	if ((ydiff<(-1))||(ydiff>(1))) {
		movey=Math.round(ydiff/10) ;
		ystart-=movey ;
	}
	if ((xdiff<(-1))||(xdiff>(1))) {
		movex=Math.round(xdiff/10) ;
		xstart-=movex ;
	}

	if (ystart>=10){

		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length ;
		var altro_div = null ;


		for(r=0;r<nu;r++){
			if("loading" == alldiv[r].getAttribute('id')){
				altro_div = alldiv[r].getAttribute('id');
			}
		}

		elFake = document.getElementById(altro_div).style ;
		var newY = ystart + ((screen.height) / 2) - 150 ;
		eval("elFake"+".top="+newY) ;

	}
	else {
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length ;
		var altro_div = null ;


		for(r=0;r<nu;r++){
			if("loading" == alldiv[r].getAttribute('id')){
				altro_div = alldiv[r].getAttribute('id');
			}
		}

		elFake = document.getElementById(altro_div).style ;
		var newY = ((screen.height) / 2) - 150 ;
		eval("elFake"+".top="+newY) ;
	}


	var alldiv = document.body.getElementsByTagName("DIV");
	nu = alldiv.length ;
	var altro_div = null ;


	for(r=0;r<nu;r++){
		if("loading" == alldiv[r].getAttribute('id')){
			altro_div = alldiv[r].getAttribute('id');
		}
	}

	elFake = document.getElementById(altro_div).style ;
	var newX = xstart ;
	//eval("elFake"+".left="+newX) ;

	setTimeout("checkLocation()",10);
}

function checkLocationA(){
	ystart=eval(y);
	xstart=eval(x);
}



/********************************************************************************************/



function formValidator() {



	var sw = 0 ;
	var msg = "" ;

	// Email Checker
	if(document.theForm.email.value != document.theForm.email_confirm.value) {
		sw = 1 ;
		msg += "Email address is different to the confirm email field.\n" ;
	}
	
	if (document.theForm.email.value == 0) {
		sw = 1 ;
		msg += "Please enter your email address.\n" ;

	} else if (document.theForm.email.value.indexOf("@") < 0) {
		sw = 1 ;
		msg += "Incorrect email address. Please re-enter.\n" ;
	} else if (document.theForm.email.value.indexOf(".") < 0) {
		sw = 1 ;
		msg += "Incorrect email address. Please re-enter.\n" ;
	} else if (document.theForm.email.value.indexOf(" ") >= 0) {
		sw = 1 ;
		msg += "Incorrect email address. Please re-enter.\n" ;
	}
	// First Name Checker
	/*if (document.theForm.nome.value == 0) {
		sw = 1 ;
		msg += "Please enter your first name.\n" ;
	}
	// Last Name Checker
	if (document.theForm.cognome.value == 0) {
		sw = 1 ;
		msg += "Please enter your last name.\n" ;
	}*/
	// NICK Checker
	if (document.theForm.nick.value == 0) {
		sw = 1 ;
		msg += "Please enter your nick name.\n" ;
	} else if (document.theForm.nick.value.indexOf(" ") >= 0) {
		sw = 1 ;
		msg += "Incorrect nick. Please re-enter.\n" ;
	} else if (document.theForm.nick.value.indexOf("@") > 0) {
		sw = 1 ;
		msg += "Incorrect nick. Please re-enter.\n" ;
	} else if (document.theForm.nick.value.indexOf(".") > 0) {
		sw = 1 ;
		msg += "Incorrect nick. Please re-enter.\n" ;
	}


	// passwd Checker
	if (document.theForm.passwd.value == 0) {
		sw = 1 ;
		msg += "Please enter your password.\n" ;
	}
	// passwd Checker
	if (document.theForm.confirmpasswd.value == 0) {
		sw = 1 ;
		msg += "Please enter your confirm password.\n" ;
	}

	// Password Checker
	if (document.theForm.passwd.value.indexOf(" ") >= 0) {
		sw = 1 ;
		msg += "Space is not ALLOWED for password. Please re-enter.\n" ;
	} else if (document.theForm.passwd.value != document.theForm.confirmpasswd.value) {
		sw = 1 ;
		msg += "Password do not matched. Please re-enter..\n" ;
	}


	// Gender Check
	/*myOption = -1;
	for (i=0; i<document.theForm.sex.length; i++) {
		if (document.theForm.sex[i].checked) {
			myOption = i;
		}
	}
	if (myOption == -1) {
		sw = 1 ;
		msg += "Please select your gender.\n" ;
	}*/



	// TOS check
	if (!document.theForm.check_terms.checked) {
		sw = 1 ;
		msg += "Please check the agree to our terms box.\n" ;
	}
	// TOS check
	if (!document.theForm.check_policy.checked) {
		sw = 1 ;
		msg += "Please check the policy box.\n" ;
	}

	///alert(sw+"|"+msg) ;

	/* result */
	if (sw == 1) {
		alert(msg) ;
		return false ;
	} else {
		return true ;
	}
}


function checkSendZimpled() {
	var sw = 0 ;
	var msg = "" ;

	 
	 
	if (document.form.price.value < 1) {
		sw = 1 ;
		msg += "The minimum price is 1 euro.\n" ;
	}
	 
	if (document.form.paypal_account.value == 0) {
		sw = 1 ;
		msg += "Please enter your paypal account.\n" ;
	}
	
	if (sw == 1) {
		alert(msg) ;
		return false ;
	} else {
		return true ;
	}
	
}

function changeCountry() {
	country = document.theForm.country;

	var countyDropdown = document.getElementById('countyDropdown');
	var cityDropdown = document.getElementById('cityDropdown');
	var regionDropdown = document.getElementById('regionDropdown');

	if (document.theForm.country.value=='IE') {
		countyDropdown.style.display = '';
		if (cityDropdown) cityDropdown.style.display='none';
		if (regionDropdown) regionDropdown.style.display='none';
	} else if (document.theForm.country.value=='JP') {
		countyDropdown.style.display='none';
		if (cityDropdown) cityDropdown.style.display='';
		if (regionDropdown) regionDropdown.style.display='';
	} else {
		countyDropdown.style.display='none';
		if (cityDropdown) cityDropdown.style.display='none';
		if (regionDropdown) regionDropdown.style.display='none';
	}
}

function DropDownSelect(obj, val) {
	var i;
	var len = obj.options.length;
	for (i=0; i<len; i++) {
		if (obj.options[i].value == val) {
			obj.selectedIndex = i;
			break;
		}
	}
}

/*****************************************************
*	Form di registrazione
*******************************************************/
function showProvince(nation_code) {

	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX('./ajax/ajax.php?action=showProvince&nation_code='+nation_code) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = document.getElementById('TrRegionDropdown') ;
				elem.style.display = '' ;

				var elem = document.getElementById('TdLeftRegionDropdown') ;
				elem.style.display = '' ;

				var elem = document.getElementById('TrRightRegionDropdown') ;
				elem.style.display = '' ;

				var elem = document.getElementById('province') ;
				elem.innerHTML = html ;
			}

		} else {
			//alert ("") ;
		}
	}
	,1) ;

}

function showProvinceEditProfile(nation_code) {

	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX('../../ajax/ajax.php?action=showProvince&nation_code='+nation_code) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = document.getElementById('TrRegionDropdown') ;
				elem.style.display = '' ;

				var elem = document.getElementById('TdLeftRegionDropdown') ;
				elem.style.display = '' ;

				var elem = document.getElementById('TrRightRegionDropdown') ;
				elem.style.display = '' ;

				var elem = document.getElementById('province') ;
				elem.innerHTML = html ;
			}

		} else {
			//alert ("") ;
		}
	}
	,1) ;

}


/********************************************************/

function downloadFile(id_song) {

	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX('../ajax/ajax.php?action=downloadFile&id_song='+id_song) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var arr = html.split("|") ;

				var file_location = arr[0] ;
				var file_name = arr[1] ;
				var counter = arr[2] ;

				var elem = document.getElementById('downloadFileHits_'+id_song) ;
				elem.innerHTML = counter ;


				location.href= file_location + "/" + file_name ;

			}

		} else {
			//alert ("") ;
		}
	}
	,1) ;
}


function addTextPicture(id_pic) {
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;

	eval("text = document.addText_"+id_pic+".text.value ;") ;

	ajaxObj.runAJAX('../../ajax/ajax.php?action=addTextPicture&id_pic='+id_pic+"&text="+text) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = eval("document.getElementById('output_"+id_pic+"') ;") ;
				elem.innerHTML = html ;
			}

		} else {
			//alert ("") ;
		}
	}
	,1) ;
}

function setPrimaryPic(id_pic) {
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX('../../ajax/ajax.php?action=setPrimaryPic&id_pic='+id_pic) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = eval("document.getElementById('output_"+id_pic+"') ;") ;
				elem.innerHTML = html ;
			}

		} else {
			//alert ("") ;
		}
	}
	,1) ;
}



function checkFormUploadSong() { 
	var swKO = 0 ;
	var msg = "" ;


	// sezione campi obbligatori
	if (document.form.titolo.value == "" ) {
	msg += "Title missing.\n" ;
	swKO = 1 ;
	}



	if (document.form.genre_1.value == "" ) {
	msg += "Genre missing.\n" ;
	swKO = 1 ;
	}
	
	 
	
	 
		
	// se remix nn faccio questo controllo 
	if(document.form.remix.value != 1) {
		if (document.form.song_type.value != 0 ) {
			if (document.form.strum_1.value == "" ) {
			msg += "You have to choose at least 1 instrument.\n" ;
			swKO = 1 ;
			}
		}
	}

	 
	
	 
 
	if (swKO == 1) {
		alert(msg);
		return false ;
	}
	else {
		return true ;
	}
}


function showHint(idHint) {
	var ajaxObj = new ClassAJAX() ;
	ajaxObj.setExecute(true) ;
	ajaxObj.setElement('hintContainer') ;

	ajaxObj.runAJAX ('../../ajax/ajax.php?action=hintShow&idHint='+idHint) ;

	var elem = document.getElementById('hintContainer') ;
	elem.style.display = 'inline' ;




	if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }


	l = (myWidth - 400) / 2 ;
	t = (myHeight - 150) / 2 ;

	elem.style.top = t ;
	elem.style.left = l ;


}

function openHint(idHint) {

	//eval("setTimeout('showHint("+idHint+")',900)" ) ;

}


function closeHint(idHint) {
var elem = document.getElementById('hintContainer') ;
	elem.style.display = 'none' ;
}

function updateListenStatusSong(id_song_z) {

	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX('../../ajax/ajax.php?action=updateListenStatusSong&id_song_z='+id_song_z) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);

			}

		} else {

		}
	}
	,1) ;
}


function appicciaTr(livello,id,classO) {


	//ottengo la riga da spegnare
	rigaDaSpegnere=eval("document.form.rigaOn"+livello+".value ;" );

	//alert(rigaDaSpegnere);
	if (rigaDaSpegnere) {
		eval("document.getElementById('"+rigaDaSpegnere+"').className=document.form.classOriginale"+livello+".value ;" ) ;
	}
	//setto la classe orig in hidden
	eval("document.form.classOriginale"+livello+".value=classO;" ) ;

	//setto ID in hidden
	eval("document.form.rigaOn"+livello+".value=id ;" ) ;

	document.getElementById(id).className='TblLinkHI' ;


	// vado stutando gli hidden che senno fanno mucche di bucchini
	if(livello == 1){
		document.form.classOriginale2.value="" ;
		document.form.rigaOn2.value="" ;
		document.form.classOriginale3.value="" ;
		document.form.rigaOn3.value="" ;
	}

	if(livello == 2){
		document.form.classOriginale3.value="" ;
		document.form.rigaOn3.value="" ;
	}


}


function vediLivello2(id_song_t,webpath,code_user) {

	var url = "" ;

	var elemento = document.getElementById("livello2");

	// accendo l'elemento selezionato e spengo tutti quelli superiori che nn ci intaressano
	document.getElementById("livello2").style.display = "" ;
	document.getElementById("livello3").style.display = "none" ;
	document.getElementById("livello4").style.display = "none" ;

	var nome = "" ;
	var valore = "" ;

	url  = webpath + "/ajax/ajax.php?" ;
	url += "&id_song_t="+id_song_t ;
	url += "&action=performer" ;
	url += "&livello=2" ;
	url += "&code_user="+code_user ;


	/*
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(true) ;
	ajaxObj.setElement("livello2") ;
	ajaxObj.runAJAX(url) ;
	*/
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				var elem = document.getElementById('livello2') ;
				elem.innerHTML="" ;
				elem.innerHTML=html ;

			}

		} else {

		}
	}
	,1) ;

}

/*******************************************************************
*					PARTE PRODUCER
*******************************************************************/

function appicciaTrProducer(formName, livello,id,classO) {

	//ottengo la riga da spegnare
	eval("rigaDaSpegnere=document."+formName+".rigaOnProducer"+livello+".value ;" );

	//alert(rigaDaSpegnere);
	if (rigaDaSpegnere) {
		eval("document.getElementById('"+rigaDaSpegnere+"').className=document."+formName+".classOriginaleProducer"+livello+".value ;" ) ;
	}
	//setto la classe orig in hidden
	eval("document."+formName+".classOriginaleProducer"+livello+".value=classO;" ) ;

	//setto ID in hidden
	eval("document."+formName+".rigaOnProducer"+livello+".value=id ;" ) ;

	document.getElementById(id).className='TblLinkHI' ;


	// vado stutando gli hidden che senno fanno mucche di bucchini
	if(livello == 1){
		eval("document."+formName+".classOriginaleProducer2.value='' ;") ;
		eval("document."+formName+".rigaOnProducer2.value='' ;") ;
		eval("document."+formName+".classOriginaleProducer3.value='' ;") ;
		eval("document."+formName+".rigaOnProducer3.value='' ;") ;
	}

	if(livello == 2){
		eval("document."+formName+".classOriginaleProducer3.value='' ;") ;
		eval("document."+formName+".rigaOnProducer3.value='' ;") ;
	}


}


function vediLivelloProducer2(tabName, id_song_t, step, webpath,code_user) {

	var url = "" ;

	var elemento = document.getElementById("livelloProducer2");

	// accendo l'elemento selezionato e spengo tutti quelli superiori che nn ci intaressano
	document.getElementById("livelloProducer2").style.display = "" ;
	document.getElementById("livelloProducer3").style.display = "none" ;
	document.getElementById("livelloProducer4").style.display = "none" ;

	var nome = "" ;
	var valore = "" ;

	url  = webpath + "/ajax/ajax.php?" ;
	url += "&id_song_t="+id_song_t ;
	url += "&action=producerTab" ;
	url += "&code_user="+code_user ;



	switch(tabName) {
		case "works" :
		url += "&tabAction=work" ;
		break ;
		case "archive" :
		url += "&tabAction=archive" ;
		break ;
	}

	url += "&step=" + step ;
	url += "&livello=2" ;

	/*
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(true) ;
	ajaxObj.setElement("livelloProducer2") ;
	ajaxObj.runAJAX(url) ;
	*/
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);



				var elem = document.getElementById('livelloProducer2') ;

				elem.innerHTML=html ;


			}

		} else {

		}
	}
	,1) ;
}


function vediLivelloProducer3(tabName, id_song_t,id_strumento, step, webpath,anchor) {

	var url = "" ;

	var elemento = document.getElementById("livelloProducer2");

	// accendo l'elemento selezionato e spengo tutti quelli superiori che nn ci intaressano
	document.getElementById("livelloProducer3").style.display = "" ;
	document.getElementById("livelloProducer4").style.display = "none" ;


	var _url = "" ;

	var nome = "" ;
	var valore = "" ;

	url  = webpath + "/ajax/ajax.php?" ;
	url += "&id_song_t="+id_song_t ;
	url += "&id_strumento="+id_strumento ;
	url += "&action=producerTab" ;
	url += "&tabAction=work" ;
	url += "&step=" + step ;
	url += "&livello=3" ;
	url += _url ;


	/*
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(true) ;
	ajaxObj.setElement("livelloProducer3") ;
	ajaxObj.runAJAX(url) ;
	*/
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				var elem = document.getElementById('livelloProducer3') ;
				elem.innerHTML="" ;
				elem.innerHTML=html ;

				location.href='#'+anchor ;

			}

		} else {

		}
	}
	,1) ;

}

function stuta(livello,nome) {

	switch(livello) {

		case "2" :
		document.getElementById(nome+"2").style.display = "none" ;
		document.getElementById(nome+"3").style.display = "none" ;
		document.getElementById(nome+"4").style.display = "none" ;

		document.getElementById(nome+"2").innerHTML = '' ;
		document.getElementById(nome+"3").innerHTML = '' ;
		document.getElementById(nome+"4").innerHTML = '' ;
		break ;

		case "3" :
		document.getElementById(nome+"3").style.display = "none" ;
		document.getElementById(nome+"4").style.display = "none" ;

		document.getElementById(nome+"3").innerHTML = '' ;
		document.getElementById(nome+"4").innerHTML = '' ;
		break ;

		case "4" :
		document.getElementById(nome+"4").style.display = "none" ;

		document.getElementById(nome+"4").innerHTML = '' ;
		break ;
	}
}


function downloadScore (webpath,url) {

	var elem = document.getElementById('downloadScore');
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	//ajaxObj.runAJAX('/ajax/ajax.php?'+url) ;
	ajaxObj.runAJAX(webpath+'/ajax/ajax.php?'+url) ;
	//alert(webpath+'/ajax/ajax.php?'+url);
	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);


				var myWidth = 0, myHeight = 0;
				if( typeof( window.innerWidth ) == 'number' ) {
					//Non-IE
					myWidth = window.innerWidth;
					myHeight = window.innerHeight;
				} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
					//IE 6+ in 'standards compliant mode'
					myWidth = document.documentElement.clientWidth;
					myHeight = document.documentElement.clientHeight;
				} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
					//IE 4 compatible
					myWidth = document.body.clientWidth;
					myHeight = document.body.clientHeight;
				}

				var scrOfX = 0, scrOfY = 0;
				if( typeof( window.pageYOffset ) == 'number' ) {
					//Netscape compliant
					scrOfY = window.pageYOffset;
					scrOfX = window.pageXOffset;
				} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
					//DOM compliant
					scrOfY = document.body.scrollTop;
					scrOfX = document.body.scrollLeft;
				} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
					//IE6 standards compliant mode
					scrOfY = document.documentElement.scrollTop;
					scrOfX = document.documentElement.scrollLeft;
				}

				//var l =( (myWidth - elem.style.width.substr(0,elem.style.width.length - 2)) / 2 ) - (elem.style.width.substr(0,elem.style.width.length - 2) / 2) ;
				var l = (myWidth - elem.style.width.substr(0,elem.style.width.length - 2)) / 2 ;
				var t = scrOfY + ((myHeight - elem.style.height.substr(0,elem.style.height.length - 2)) / 2) ;

				elem.innerHTML = '' ;
				elem.style.display = '' ;


				elem.style.top = t ;
				elem.style.left = l ;

				elem.innerHTML = html ;

			}

		} else {

		}
	}
	,1) ;

}


function openDett(webpath, divname, url) {

	var elem = document.getElementById(divname);

	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX('/ajax/ajax.php?'+url) ;
	//ajaxObj.runAJAX(webpath+'/ajax/ajax.php?'+url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);


				var myWidth = 0, myHeight = 0;
				if( typeof( window.innerWidth ) == 'number' ) {
					//Non-IE
					myWidth = window.innerWidth;
					myHeight = window.innerHeight;
				} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
					//IE 6+ in 'standards compliant mode'
					myWidth = document.documentElement.clientWidth;
					myHeight = document.documentElement.clientHeight;
				} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
					//IE 4 compatible
					myWidth = document.body.clientWidth;
					myHeight = document.body.clientHeight;
				}

				var scrOfX = 0, scrOfY = 0;
				if( typeof( window.pageYOffset ) == 'number' ) {
					//Netscape compliant
					scrOfY = window.pageYOffset;
					scrOfX = window.pageXOffset;
				} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
					//DOM compliant
					scrOfY = document.body.scrollTop;
					scrOfX = document.body.scrollLeft;
				} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
					//IE6 standards compliant mode
					scrOfY = document.documentElement.scrollTop;
					scrOfX = document.documentElement.scrollLeft;
				}



				//var l =( (myWidth - elem.style.width.substr(0,elem.style.width.length - 2)) / 2 ) - (elem.style.width.substr(0,elem.style.width.length - 2) / 2) ;
				var l = (myWidth - elem.style.width.substr(0,elem.style.width.length - 2)) / 2 ;
				var t = scrOfY + ((myHeight - elem.style.height.substr(0,elem.style.height.length - 2)) / 2) ;



				elem.innerHTML = '' ;
				elem.style.display = '' ;


				elem.style.top = t ;
				elem.style.left = l ;

				elem.innerHTML = html ;

				/*var centraObj = new ClassCentraOggetti();
				centraObj.setDivname(divname) ;
				centraObj.setVariables() ;
				centraObj.checkLocation() ;*/

			}

		} else {

		}
	}
	,1) ;

}

function closeDiv(divname) {

	var elem = document.getElementById(divname);
	elem.style.display = 'none' ;
}

function toggleDisplay(fO){

	var ns4 = (document.layers);
	var ie4 = (document.all && !document.getElementById);
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);


	if(ie5 || ns6){
		if (document.getElementById(fO).style.display=="none") {
		document.getElementById(fO).style.display="inline";
		}else{
		document.getElementById(fO).style.display="none";
		}
	}

	if(ie4){
		if (document.all[fO].style.display=="none") {
		document.all[fO].style.display="inline";
		}else{
		document.all[fO].style.display="none";
		}
	}
}

function switchSrcArrow(fO, idImg, webpath) {

	var ns4 = (document.layers);
	var ie4 = (document.all && !document.getElementById);
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);

	var img = document.getElementById(idImg) ;

	if(ie5 || ns6){
		if (document.getElementById(fO).style.display=="none") {

			img.src=webpath+"/img/bottomArrow.gif" ;
		}
		else {
			img.src=webpath+"/img/topArrow.gif" ;
		}
	}

	if(ie4){
		if (document.all[fO].style.display=="none") {
			img.src=webpath+"/img/bottomArrow.gif" ;
		}else{
			img.src=webpath+"/img/topArrow.gif" ;
		}
	}

}


function showHide(webpath,td,code_user,td_display) {

	var url = webpath ;
	url  = "/ajax/ajax.php?" ;
	url += "&action=showHide" ;
 	url += "&code_user=" + code_user ;
 	url += "&td_display=" + td_display ;
 	url += "&td=" + td ;


		var ajaxObj = new ClassAJAX();

		ajaxObj.setExecute(false) ;
		ajaxObj.setReturn(true) ;
		ajaxObj.runAJAX (url) ;

		var html = "" ;
		var htmlOld = "" ;

		myInterval = window.setInterval(
		function() {
			htmlOld = html ;
			html = ajaxObj.getHtml() ;
			if (html != false) {

				if (htmlOld == html) {

					window.clearInterval(myInterval);

					toggleDisplay(td);


				/*var elem = document.getElementById('debug') ;
				elem.style.display = "" ;
				elem.innerHTML = html ;*/
				}
			}
		}
		,1) ;

}




function selectAll() {
	for(i=0 ;i<document.inbox.elements.length; i++) {
		nn = document.inbox.elements[i].name.substr(0,8) ;
		if (nn == "message_") {
			if(document.inbox.elements[i].checked == true) {
				document.inbox.elements[i].checked=false ;
			} else {
				document.inbox.elements[i].checked=true ;
			}
		}
	}
}


function selectAllBoard() {
	for(i=0 ;i<document.board.elements.length; i++) {
		nn = document.board.elements[i].name.substr(0,8) ;
		if (nn == "message_") {
			if(document.board.elements[i].checked == true) {
				document.board.elements[i].checked=false ;
			} else {
				document.board.elements[i].checked=true ;
			}
		}
	}
}



function setCommercial(sw) {

	var lista_tr = document.getElementsByTagName("DIV");

	for(i=0; i < lista_tr.length; i++) {

		if(document.getElementsByTagName("DIV")[i].id.substr(0,9) == "tipo_wav_") {
			ttId = document.getElementsByTagName("DIV")[i].id ;
			if(sw == 0 ){
				document.getElementById(ttId).style.display = "none" ;
			} else {
				document.getElementById(ttId).style.display = "" ;
			}
		}
	}
}


function setMultiForDrums(num) {

//alert(eval("document.form.strum_"+num+"[document.form.strum_"+num+".selectedIndex].value"));
	if (eval("document.form.strum_"+num+"[document.form.strum_"+num+".selectedIndex].value") == 13 ) { // DRUMS
		eval("document.form.tipo_wav_"+num+"[3]=new Option(\"multiple tracks for drums\", \"4\", false) ;") ;
	}
}

function setMultiForDrumsEdit() {
	// oggi 25 ott 2008 batteria = 13
 
	if (document.form.id_strumento[document.form.id_strumento.selectedIndex].value == 13 ) { // DRUMS
		document.form.tipo_wav[3]=new Option("multiple tracks for drums", "4") ;
	}
}








function viewProfileTab(webpath,tabAction) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?" ;
	url += "&action=edit_profile" ;
	url += "&tabAction="+tabAction ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	//ajaxObj.setLoading(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = document.getElementById('profile-container') ;
				elem.innerHTML=html ;

			}

		} else {

		}
	}
	,1) ;



	url  = webpath + "/ajax/ajax.php?" ;
	url += "&action=edit_profile_punti" ;
	url += "&tabAction="+tabAction ;

	var ajaxObj1 = new ClassAJAX();
	ajaxObj1.setExecute(false) ;
	ajaxObj1.setLoading(false) ;
	ajaxObj1.setReturn(true) ;
	ajaxObj1.runAJAX(url) ;

	var html1 = "" ;
	var htmlOld1 = "" ;

	myInterval1 = window.setInterval(
	function() {
		htmlOld1 = html1 ;
		html1 = ajaxObj1.getHtml() ;
		if (html1 != false) {

			if (htmlOld1 == html1) {

				window.clearInterval(myInterval1);

				var elem1 = document.getElementById('profilepunti-container') ;
				elem1.innerHTML=html1 ;

			}

		} else {

		}
	}
	,1) ;
}





function viewPerformerTab(webpath,tabAction,code_user) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?" ;
	url += "&action=performerTab" ;
	url += "&tabAction="+tabAction ;
	url += "&code_user="+code_user ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);



				var elem = document.getElementById('performer-container') ;

				elem.innerHTML=html ;


			}

		} else {

		}
	}
	,1) ;
}


function viewProducerTab(webpath,tabAction,code_user) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?" ;
	url += "&action=producerTab" ;
	url += "&tabAction="+tabAction ;
	url += "&code_user="+code_user ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);



				var elem = document.getElementById('producer-container') ;

				elem.innerHTML=html ;


			}

		} else {

		}
	}
	,1) ;
}


function changePageProducer(webpath,_url) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?" ;
	url += _url ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);



				var elem = document.getElementById('producer-container') ;

				elem.innerHTML=html ;


			}

		} else {

		}
	}
	,1) ;
}


function changePagePerformer(webpath,_url) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?" ;
	url += _url ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);



				var elem = document.getElementById('performer-container') ;

				elem.innerHTML=html ;


			}

		} else {

		}
	}
	,1) ;
}

/*
	estenzioni sul caricamento degli score
*/

    function LimitAttach(numfile) {
		extArray = new Array(".mid", ".pdf", ".txt", ".jpg", ".gif", ".png",".doc",".rtf");

		allowSubmit = true;


		for(i=1;i<numfile;i++) {
			file = eval('document.form.strumDoc_'+i+'.value ;') ;
			ext = file.slice(file.indexOf(".")).toLowerCase();


				if (ext == ".mid" || ext == ".pdf" || ext == ".txt" || ext == ".jpg" || ext == ".gif" || ext == ".png" || ext == ".doc" || ext == ".rtf"  ) {

				} else {
					allowSubmit = false; alert(ext+"KO");
				}

		}


		if (allowSubmit) {
			return true;
		} else {
			alert("Please only upload files that end in types:  "
			+ (extArray.join("  ")) + "\nPlease select a new "
			+ "file to upload and submit again.");
			return false;
		}

    }




/********************************************************************
*	BUBBLE
*********************************************************************/
this.st = 0 ;
this.text = "" ;
this.POSIX = 0 ;
this.POSIY = 0 ;


function Bubble () {

	// FADE IN
	this.showBubble = function () {

			this.showBubbleMs('bubble','0') ;

	};

	this.showBubbleMsTime = function (objId, msTime) {

		var bubble = new Bubble() ;
		bubble.showBubbleMs(objId,msTime) ;
	}

	this.showBubbleMs = function (objId, msTime) {

		if (msTime <= 45) {
			msTime += 1
			window.setTimeout(this.showBubbleMsTime,100, objId, msTime);
		}
		else {
			var elem = document.getElementById("bubble") ;
			//elem.style.display='' ;

			document.getElementById('bubble_tooltip_content').style.height="auto";
			// match box models
			if (document.all) {
			var realHeight = document.getElementById('bubble_tooltip_content').offsetHeight+10;
			var realWidth = document.getElementById('bubble_tooltip_content').offsetWidth+10;
			}
			else {
			var realHeight = document.getElementById('bubble_tooltip_content').offsetHeight;
			var realWidth = document.getElementById('bubble_tooltip_content').offsetWidth;
			}

			/***********************/

			//window.innerHeight
			//document.body.offsetHeight
			//window.pageYOffset

			//setto la Y

			var totPageHeight = document.body.offsetHeight ;
			var totWndHeight = window.innerHeight ;
			var yPosixScroll = window.pageYOffset ;

			var yStart = yPosixScroll ;
			var yEnd = yStart + totWndHeight ;

			var mouseYPos = (POSIY - yStart) ;
			var hDiv = realHeight ;

			if ( (mouseYPos + hDiv + 10) > totWndHeight ) {
				//apro sopra
				var YDiv = (yStart + mouseYPos) - hDiv - 60 ;
			}
			else {
				//apro sotto
				var YDiv = yStart + mouseYPos ;
			}

			//setto la X

			var totWndWidth = window.innerWidth ;
			if ( (POSIX + realWidth + 10) > totWndWidth) {
				//apro a sx
				var XDiv = POSIX - realWidth - 60 ;
			}
			else {
				// apro a dx
				var XDiv = POSIX  ;
			}

			elem.style.top = YDiv + 'px';
			elem.style.left = XDiv + 'px';

			/************************/
			var elem = document.getElementById("bubble") ;
			elem.style.display='' ;

			this.fadeIn('bubble',10) ;
		}
	};

	this.fadeInTime = function (objId,opacity) {
		var bubble = new Bubble() ;
		bubble.fadeIn (objId,opacity) ;
	}

	this.fadeIn = function(objId,opacity) {

		if(!document.getElementById) return;
		obj = document.getElementById(objId);
		if(opacity <= 100){
	  		this.setOpacity(obj,opacity);
	  		opacity += 10;
	  		window.setTimeout(this.fadeInTime, 30, objId,opacity);
	  	}
	};

	// FADE OUT
	this.hideBubble = function () {
		this.hideBubbleMs('bubble','0') ;

	};

	this.hideBubbleMs = function (objId, msTime) {

		if (msTime <= 0) {
			msTime += 1
			this.hideBubbleMs(objId, msTime) ;
		}
		else {
			var elem = document.getElementById("bubble") ;
			this.fadeOut('bubble',90) ;
		}
	};

	this.fadeOutTime = function (objId,opacity) {
		var bubble = new Bubble() ;
		bubble.fadeOut (objId,opacity) ;
	}

	this.fadeOut = function (objId,opacity) {

		if(!document.getElementById) return;
		obj = document.getElementById(objId);
		if(opacity >= 0){
	  		this.setOpacity(obj,opacity);
	  		opacity -= 10;
	  		window.setTimeout(this.fadeOutTime, 30, objId,opacity);
	  	}
	};

	this.setOpacity = function (obj,opacity) {
		opacity=(opacity==100) ? 99.999 : opacity;
		obj.style.MozOpacity = opacity/100;
	}

}
// fine classe

function getEvent(e) {

	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;

	if (e.pageX || e.pageY) {
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		posx = e.clientX;
		posy = e.clientY;
	}

	this.POSIX = posx ;
	this.POSIY = posy ;

}


function addText() {

	var textElem = document.getElementById("bubble_tooltip_content") ;
	textElem.innerHTML=this.text ;

}

function showBubbleStart() {


	if (this.st == 0) {
		addText() ;

		var bubble = new Bubble() ;
		bubble.showBubble() ;

		//window.setTimeout(addText,100) ;

	}
	else {
		var elem = document.getElementById("bubble") ;
		elem.style.display="none" ;
	}
}
function showBubbleFunc (webpath, time, hintId) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?action=getHint&id_hint="+hintId ;

	var ajaxObj = new ClassAJAX();
	//ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				this.text=html ;


			}

		} else {

		}
	}
	,1) ;


	if (time == 500) {
		this.st = 0 ;
	}

	if (this.st == 0) {
		window.setTimeout(showBubbleStart,10);
	}
	else {
		hideBubbleFunc();
	}
}

function hideBubbleFunc () {

	this.st = 1 ;
	//var bubble = new Bubble() ;
	//bubble.hideBubble() ;
	var elem = document.getElementById("bubble") ;
	elem.style.display='none' ;
}

/********************************************************************
*	FINE BUBBLE
*********************************************************************/


function setSongTitle(title, spanId) {

	var el = document.getElementById(spanId) ;
	el.innerHTML = '' ;
	el.innerHTML = title ;
}

function showContentsProducer(webpath,id_song_t,divName,divIcon) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?action=showContentsProducer&id_song_t="+id_song_t ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				var el = document.getElementById(divName) ;
				el.style.display='none' ;
				el.innerHTML = html ;

				myInterval1 = window.setInterval(
				function() {
					window.clearInterval(myInterval1);
					el.style.display='' ;
					var demo = new AutoAccordion($$('.handle', 'accordion'), $$('.drawer', 'accordion'));

					showIconSetProducer(webpath,id_song_t,divIcon) ;

				}
				,1000) ;

			}

		} else {

		}
	}
	,1) ;

}

function showArchiveProducer(webpath,divName,divIcon) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?action=showArchiveProducer" ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				var el = document.getElementById(divName) ;
				el.style.display='none' ;
				el.innerHTML = html ;
				//setTimeout("appiccia()",500) ;


				myInterval1 = window.setInterval(
				function() {
					window.clearInterval(myInterval1);
					el.style.display='' ;
					var demo = new AutoAccordion($$('.handle', 'accordion'), $$('.drawer', 'accordion'));
					
					hideIconProducer(divIcon) ;
					
				}
				,1000) ;
				

			}

		} else {

		}
	}
	,1) ;
}


function showEuroProducer(webpath,divName,divIcon) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?action=showEuroProducer" ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				var el = document.getElementById(divName) ;
				el.style.display='none' ;
				el.innerHTML = html ;
				//setTimeout("appiccia()",500) ;


				myInterval1 = window.setInterval(
				function() {
					window.clearInterval(myInterval1);
					el.style.display='' ;
					var demo = new AutoAccordion($$('.handle', 'accordion'), $$('.drawer', 'accordion'));
					
					hideIconProducer(divIcon) ;

				}
				,1000) ;

			}

		} else {

		}
	}
	,1) ;
}

function toggleColor(type, trId) {

	var trID = '' ;
	var allTr = document.body.getElementsByTagName("tr") ;
	nu = allTr.length;

	for(r=0;r<nu;r++){

		trID = allTr[r].getAttribute('id') ;
		if (trID) {
			if (trID.substr(0,5) == type+'_') {
				document.getElementById(trID).className=''	;
			}
		}
	}

	var trElem = document.getElementById(trId) ;

	if (type=='prod') {
		trElem.className='songsProducerSel'	;
	}
	else {
		trElem.className='songsPerformerSel'	;
	}



}

function resetColor(type) {
	
	var trID = '' ;
	var allTr = document.body.getElementsByTagName("tr") ;
	nu = allTr.length;

	for(r=0;r<nu;r++){

		trID = allTr[r].getAttribute('id') ;
		if (trID) {
			if (trID.substr(0,5) == type+'_') {
				document.getElementById(trID).className=''	;
			}
		}
	}	
}

function showIconSetProducer(webpath,id_song_t,divName) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?action=showIconSetProducer&id_song_t="+id_song_t ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				var el = document.getElementById(divName) ;
				el.innerHTML = html ;

			}

		} else {

		}
	}
	,1) ;

}

function hideIconProducer(divName) {
	var el = document.getElementById(divName) ;
	el.innerHTML = '' ;
}

// PERFORMER


function showContentsPerformer(webpath,id_song_t,divName,divIcon) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?action=showContentsPerformer&id_song_t="+id_song_t ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				var el = document.getElementById(divName) ;
				el.style.display='none' ;
				el.innerHTML = html ;

				myInterval1 = window.setInterval(
				function() {
					window.clearInterval(myInterval1);
					el.style.display='' ;
					var demo = new AutoAccordion($$('.handleperf', 'accordion'), $$('.drawerperf', 'accordion'));

					showIconSetPerformer(webpath,id_song_t,divIcon) ;

				}
				,1000) ;



			}

		} else {

		}
	}
	,1) ;

}


function showArchivePerformer(webpath,divName,divIcon) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?action=showArchivePerformer" ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				var el = document.getElementById(divName) ;
				el.style.display='none' ;
				el.innerHTML = html ;
				//setTimeout("appiccia()",500) ;


				myInterval1 = window.setInterval(
				function() {
					window.clearInterval(myInterval1);
					el.style.display='' ;
					var demo = new AutoAccordion($$('.handleperf', 'accordion'), $$('.drawerperf', 'accordion'));
					
					hideIconPerformer(divIcon) ;
					
				}
				,1000) ;

			}

		} else {

		}
	}
	,1) ;
}


function showEuroPerformer(webpath,divName,divIcon) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?action=showEuroPerformer" ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				var el = document.getElementById(divName) ;
				el.style.display='none' ;
				el.innerHTML = html ;
				

				myInterval1 = window.setInterval(
				function() {
					window.clearInterval(myInterval1);
					el.style.display='' ;
					var demo = new AutoAccordion($$('.handleperf', 'accordion'), $$('.drawerperf', 'accordion'));
					
					hideIconPerformer(divIcon) ;

				}
				,1000) ;

			}

		} else {

		}
	}
	,1) ;
}

function showIconSetPerformer(webpath,id_song_t,divName) {

	var url = "" ;

	url  = webpath + "/ajax/ajax.php?action=showIconSetPerformer&id_song_t="+id_song_t ;

	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				var el = document.getElementById(divName) ;
				el.innerHTML = html ;

			}

		} else {

		}
	}
	,1) ;

}

function hideIconPerformer(divName) {
	var el = document.getElementById(divName) ;
	el.innerHTML = '' ;
}


function riportaColore(nome, colore) {
	
	eval("window.opener.document.form."+nome+".value='"+colore+"'") ;
	self.close() ;	
}

function saveGenerateCode(webpath) {
	
	var url = "" ;
	
	for (i=0; i < document.form.length; i++) {
		
		url += "&" + document.form[i].name + "=" + document.form[i].value ;		
	}
	
	var ajaxObj = new ClassAJAX();
	//ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX('../../ajax/ajax.php?action=saveGenerateCode'+url) ;
	
	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				alert("@@" + html) ;
			}

		} else {

		}
	}
	,1) ;
	
}


function switchOut(obj, classe, nome) {
	
	var last = document.formTabs.last.value ;
	
	if (nome != last) {
		obj.className=classe ;		
	}
	
}

function setAllOut(ownerId) {
	
	var alldiv = document.getElementsByTagName("SPAN");
	var nu = alldiv.length;
	var curr = "" ;
	
	for (i=0; i < nu; i++) {
		
		if (alldiv[i].getAttribute('id') 
			&& alldiv[i].getAttribute('id')!= null 
			&& alldiv[i].getAttribute('id') != "null") {
			
				if (alldiv[i].getAttribute('id').substring(0,8) == "tabProf_") {
					
					if (alldiv[i].getAttribute('id') != "tabProf_"+ownerId) {
						/*curr = eval(alldiv[i].getAttribute('id'))
						curr.className = 'low' ;*/
						
						curr = document.getElementById(alldiv[i].getAttribute('id')) ;
						curr.className = 'low' ;
					}
					
				}
				
		}
	}
	
}

function setLastFather(nome) {
	
	document.formTabs.last.value = nome ;	
	
}


function formFriendValidator() {

	var sw = 0 ;
	var msg = "" ;

	// Email Checker
	if (document.theForm.email.value == 0) {
		sw = 1 ;
		msg += "Please enter your firend's email address.\n" ;

	} else if (document.theForm.email.value.indexOf("@") < 0) {
		sw = 1 ;
		msg += "Incorrect email address. Please re-enter.\n" ;
	} else if (document.theForm.email.value.indexOf(".") < 0) {
		sw = 1 ;
		msg += "Incorrect email address. Please re-enter.\n" ;
	} else if (document.theForm.email.value.indexOf(" ") >= 0) {
		sw = 1 ;
		msg += "Incorrect email address. Please re-enter.\n" ;
	}

	/* result */
	if (sw == 1) {
		alert(msg) ;
		return false ;
	} else {
		return true ;
	}
}

function openHomeuser(webpath,nick) {
	
	wnd = window.open(webpath+"/"+nick,"homeuser");
	wnd.focus();	
}


function xuploadWaiting() {
	
	/*var l = (window.innerWidth - 365) / 2 ;
	var t = (window.innerHeight - 118) / 2 ;
	
	var arrayPageSize = getPageSize();
	var w = arrayPageSize[0] ;
	var h = arrayPageSize[1] ;
	*/
	var bodyPage = parent.document.getElementById("body") ;
	alert(bodyPage) ;
	/*
	var divNode = parent.createElement('div') ;
	
	divNode.setAttribute('id', "xuploadWaiting") ;	
	divNode.style.display="" ;
	divNode.style.backgroundImage="url(./img/griglia.gif)" ;
	divNode.style.position="absolute" ;
	divNode.style.width=w+"px" ;
	divNode.style.height=h+"px";
	
	divNode.style.zIndex="91";	
	divNode.style.top = "0px" ;
	divNode.style.left = "0px" ;
			
	divNode.innerHTML = '<div id="xuploadWaiting_inner" style="position:absolute; left:'+l+'px; top:'+t+'px; width:365px; height:118px; background-image:url(./img/xupload.gif)"></div>' ;
							
					
	bodyPage.appendChild(divNode) ;	
	*/
}


function xuploadWaitingClose() {
	var bodyPage = document.getElementById("body") ;
	bodyPage.removeChild('xuploadWaiting') ;	
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function popup(url_pagina,w,h,sw_scroll) {

	  l = (screen.width - w) / 2;
	  t = (screen.height - h) / 2;
	
	  wnd = window.open(url_pagina,"wnd","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+sw_scroll+", resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
	  wnd.focus();		

}



function writeSafari() {
	var d, dom, ie, ie4, ie5x, moz, mac, win, lin, old, ie5mac, ie5xwin, op;

	d = document;
	n = navigator;
	na = n.appVersion;
	nua = n.userAgent;
	win = ( na.indexOf( 'Win' ) != -1 );
	mac = ( na.indexOf( 'Mac' ) != -1 );
	lin = ( nua.indexOf( 'Linux' ) != -1 );
	
	if ( !d.layers ){
		dom = ( d.getElementById );
		op = ( nua.indexOf( 'Opera' ) != -1 );
		konq = ( nua.indexOf( 'Konqueror' ) != -1 );
		saf = ( nua.indexOf( 'Safari' ) != -1 );
		moz = ( nua.indexOf( 'Gecko' ) != -1 && !saf && !konq);
		ie = ( d.all && !op );
		ie4 = ( ie && !dom );
	
		/*
		ie5x tests only for functionality. ( dom||ie5x ) would be default settings. 
		Opera will register true in this test if set to identify as IE 5
		*/
	
		ie5x = ( d.all && dom );
		ie5mac = ( mac && ie5x );
		ie5xwin = ( win && ie5x );
	}
	
	if (saf) {
		//document.write("<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td style='border:1px dashed #c9c9c9;background-color:#ffefb7;margin:4px; padding:4px;padding-left:4px; font-size:10px;'><strong>Having problems uploading? Wezimple is optimized for firefox, it\'s free <a style='color:#F06C06;' href='http://www.firefox.com' target='_blank'>download now</a></strong></td></tr></table>") ;
		
		popup('http://www.wezimple.com/popupSafari.php',470,180,1) ;
		
	}
}


function switchUploadButton(idBtn, action,webpath) {
	
	var e = document.getElementById(idBtn) ;

	switch(action) {
	
		case "over" :
		newImage = "url("+webpath+"/img/uploadOver.gif)";
		e.style.backgroundImage=newImage ;
		break ;
		
		case "out" :
		newImage = "url("+webpath+"/img/uploadOut.gif)";
		e.style.backgroundImage=newImage ;
		break ;
	}
}


function addComment(webpath,code_sender, code_receiver, defMessage, outMsg) {
	
	if (document.formBoard.canSend.value == '1' && document.formBoard.commentBox.value != "") {
		
		var commento = document.formBoard.commentBox.value ;
		
		var ajaxObj = new ClassAJAX();
		//ajaxObj.setElement('boardContent') ;
		ajaxObj.setLoading(false) ;
		ajaxObj.setExecute(false) ;
		ajaxObj.setReturn(true) ;
		ajaxObj.runAJAX(webpath+'/ajax/ajax.php?action=addComment&code_sender='+code_sender+'&code_receiver='+code_receiver+'&commentBox='+encodeURIComponent(commento)) ;
		
		var html = "" ;
		var htmlOld = "" ;
	
		myInterval = window.setInterval(
		function() {
			htmlOld = html ;
			html = ajaxObj.getHtml() ;
			if (html != false) {
	
				if (htmlOld == html) {
	
					window.clearInterval(myInterval);
					
					var out = document.getElementById('boardMsgOutput') ;
					out.innerHTML = outMsg ;
					
					var e = document.getElementById('boardContent') ;
					e.innerHTML = html ;
					document.formBoard.canSend.value='0' ;
					document.formBoard.commentBox.value = defMessage ;
					
				}
	
			} else {
	
			}
		}
		,1) ;
	}
}

function deleteBoardMessage(code_user, board,msg, outMsg, defMessage) {
	
	var boardEnc = Base64.decode(board) ;
	
	if (confirm(msg)) {
		
		var ajaxObj = new ClassAJAX();
		//ajaxObj.setElement('boardContent') ;
		ajaxObj.setLoading(false) ;
		ajaxObj.setExecute(false) ;
		ajaxObj.setReturn(true) ;
		ajaxObj.runAJAX('../../ajax/ajax.php?action=deleteBoardMessage&id='+boardEnc+'&code_user='+code_user) ;
		
		var html = "" ;
		var htmlOld = "" ;
	
		myInterval = window.setInterval(
		function() {
			htmlOld = html ;
			html = ajaxObj.getHtml() ;
			if (html != false) {
	
				if (htmlOld == html) {
	
					window.clearInterval(myInterval);
					
					var out = document.getElementById('boardMsgOutput') ;
					out.innerHTML = outMsg ;
					
					var e = document.getElementById('boardContent') ;
					e.innerHTML = html ;
					document.formBoard.canSend.value='0' ;
					
				}
	
			} else {
	
			}
		}
		,1) ;
	}
}



function addSongToHomeuser(id_song_t, id_song_z) {
		
	var ajaxObj = new ClassAJAX();
	//ajaxObj.setElement('boardContent') ;
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX('../../ajax/ajax.php?action=addSongToHomeuser&id_song_t='+id_song_t+'&id_song_z='+id_song_z) ;
	
	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				
				var elem = document.getElementById('spanRemoveHomeuser_' + id_song_z) ;
				elem.style.display = '' ;
				
				var elem = document.getElementById('spanAddHomeuser_' + id_song_z) ;
				elem.style.display = 'none' ;
				
			}

		} else {

		}
	}
	,1) ;
	
}

function removeSongFromHomeuser(id_song_t, id_song_z) {
	
	var ajaxObj = new ClassAJAX();
	//ajaxObj.setElement('boardContent') ;
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX('../../ajax/ajax.php?action=removeSongFromHomeuser&id_song_t='+id_song_t+'&id_song_z='+id_song_z) ;
	
	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				
				var elem = document.getElementById('spanAddHomeuser_' + id_song_z) ;
				elem.style.display = '' ;
				
				var elem = document.getElementById('spanRemoveHomeuser_' + id_song_z) ;
				elem.style.display = 'none' ;
				
			}

		} else {

		}
	}
	,1) ;

}

function removeSong_tFromHomeuser(webpath, code_user, id_song_t) {
	
	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(webpath+'/ajax/ajax.php?action=removeSong_tFromHomeuser&id_song_t='+id_song_t+'&code_user='+code_user) ;
	
	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				
				var elem = document.getElementById('divMyProject') ;
				elem.innerHTML = html ;
			}

		} else {

		}
	}
	,1) ;

}

function removeSong_zFromHomeuser(webpath, code_user, id_song_t,id_song_z) {
	
	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(webpath+'/ajax/ajax.php?action=removeSong_zFromHomeuser&id_song_t='+id_song_t+'&id_song_z='+id_song_z+'&code_user='+code_user) ;
	
	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				
				var elem = document.getElementById('divMyProject') ;
				elem.innerHTML = html ;
			}

		} else {

		}
	}
	,1) ;

}


function moveSongHomeuser(webpath, code_user, id_song_t, id_song_z, direction) {
	
	var ajaxObj = new ClassAJAX();
	ajaxObj.setLoading(false) ;
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(webpath+'/ajax/ajax.php?action=moveSongHomeuser&id_song_t='+id_song_t+'&code_user='+code_user+'&direction='+direction+'&id_song_z='+id_song_z) ;
	
	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {

			if (htmlOld == html) {

				window.clearInterval(myInterval);
				
				var elem = document.getElementById('divMyProject') ;
				elem.innerHTML = html ;
			}

		} else {

		}
	}
	,1) ;
}


function shoMore(divToHide, divToDisplay) {
	
	var e = document.getElementById(divToHide) ;
	e.style.display = 'none' ;
	
	var e = document.getElementById(divToDisplay) ;
	e.style.display = '' ;
}

function toggleAll(element) {
	var form = document.forms.openinviter, z = 0;
	for(z=0; z<form.length;z++) {

		if(form[z].type == 'checkbox') {
			form[z].checked = element.checked;
		}
	}
}

function _riportaIndirizziEmail() {
	
	var form = document.forms.openinviter
	var countarr ;
	var count ;
	var emails ;
	var ok = false;
	
	try {
	
		for(z=0; z<form.length;z++) {

			if(form[z].type == 'checkbox' && form[z].checked) {
			
				if (form[z].name.substring(0,6) == "check_") {
				
					countarr = form[z].name.split("_") ;
					
					count = countarr[1] ;
					
					emails = eval("document.openinviter.name_"+count+".value;") ;
					
					try {
						
						
						if (window.opener.document.theForm.email.value != "") {
							window.opener.document.theForm.email.value = window.opener.document.theForm.email.value + ', ' +emails ;
						}
						else {
							window.opener.document.theForm.email.value = emails ;
						}
						ok = true ;
						
					}catch(ee) {}
				}
			}
		}
	}
	catch(e) {}
	
	if (ok) {
		self.close() ;
	}
	
}


function riportaIndirizziEmail() {
	
	var form = document.forms.openinviter
	var countarr ;
	var count ;
	var emails ;
	var emailsString = "" ;
	var ok = false;
	
	try {
	
		for(z=0; z<form.length;z++) {

			if(form[z].type == 'checkbox' && form[z].checked) {
			
				if (form[z].name.substring(0,6) == "check_") {
				
					countarr = form[z].name.split("_") ;
					
					count = countarr[1] ;
					
					emails = eval("document.openinviter.name_"+count+".value;") ;
					
					
					if (emailsString != "") {
						emailsString = emailsString + ', ' + emails ;
					}
					else {
						emailsString = emails ;
					}
					
					ok = true ;
				}
			}
		}
	}
	catch(e) {}
	
	if (ok) {
		
		try {						
						
			if (window.opener.document.theForm.email.value != "") {
				var oldValue = window.opener.document.theForm.email.value ;
				window.opener.document.theForm.email.value = emailsString + ', ' + oldValue ;
			}
			else {
				window.opener.document.theForm.email.value = emailsString ;
			}
			ok = true ;
			
		}catch(ee) {}
		
		self.close() ;
	}
	
}


function getURL(uri) {
	uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
	uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
	uri.path = ''; 
	var pos = uri.dom.indexOf('\/'); 
	if (pos > -1) {
		uri.path = uri.dom.substr(pos+1); 
		uri.dom = uri.dom.substr(0,pos);
	}
	uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
	pos = uri.page.indexOf('?');
	if (pos > -1) {
		uri.page = uri.page.substring(0, pos);
	}
	pos = uri.page.indexOf('#');
	if (pos > -1) {
		uri.page = uri.page.substring(0, pos);
	}
	uri.ext = ''; pos = uri.page.indexOf('.');
	if (pos > -1) {
		uri.ext =uri.page.substring(pos+1); 
		uri.page = uri.page.substr(0,pos);
	}
	uri.file = uri.page;
	if (uri.ext != '') uri.file += '.' + uri.ext;
	if (uri.file == '') uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	return uri;
}

		function pbar() {
			setTimeout("pbarOK()", 1500);

		}
		
			function pbarOK() {
				var data = new Date();
				var timestamp = data.getTime() ;



				var uuid = document.uploadform.UPLOAD_IDENTIFIER.value ;
				
				
			var url = "./ajax/ajax.php?action=pbar&id="+uuid ;	 
			window['ajaxObj' + timestamp] = new ClassAJAX();
			window['ajaxObj' + timestamp].setExecute(false) ;
			window['ajaxObj' + timestamp].setReturn(true) ;
			window['ajaxObj' + timestamp].setLoading(false) ;
			window['ajaxObj' + timestamp].runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;
	
	window['myInterval' + timestamp] = '' ;
	window['myInterval' + timestamp] = window.setInterval(
	
	function() {
		htmlOld = html ;
		html = window['ajaxObj' + timestamp].getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(window['myInterval' + timestamp]);

				//alert(html) ;
				
				var elem = document.getElementById('uploadprogressbar') ;
				 
				var keyval = html.split(',') ;
				
				bytes_uploaded = json_decode(keyval[7]) ;
			   	bytes_total = json_decode(keyval[8]) ;
			   	files_uploaded = json_decode(keyval[9]) ;
				finename = json_decode(keyval[2]) ;

				 
				var percentage = Math.floor(100 * parseInt(bytes_uploaded) / parseInt(bytes_total));
				elem.innerHTML=percentage+"% "+files_uploaded+"|"+finename ;

				document.getElementById('bar').style.width= (percentage*4)+"px" ;
				
			}

		} else {
			
		}
	}
	,1) ; 

		setTimeout("pbarOK()", 100);
}
		
function json_decode(name) {
	var strArr = name.split(":") ;
	str = strArr[1] ;
	str = str.substring(1, str.length);
	str = str.substring(0,str.length-1);
	return str ; 
}

