function PopupWindow(myURL, myHeight, myWidth) {
	var w_options="alwaysLowered=yes,toolbar=no,menubar=0,scrollbars=yes,resizable=no,status=no,location=no,height=" + myHeight + ",width=" + myWidth;
	var w_name="copywin3";
	w_win=window.open(myURL, w_name, w_options);
}

function privacy() {
javascript:PopupWindow('privacy.txt','500','700');
}

			
function goToByScroll(id){
      $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

function drawVisualization() {
// Some raw data (not necessarily accurate)

var countries =
  ['Accessi Unici', 'Contatti'];

var months = ['2004/05', '2005/06', '2006/07', '2007/08', '2008/09'];
var productionByCountry = [[165, 135, 157, 139, 136],
						   [938, 1120, 1167, 1110, 691]];

// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Month');
for (var i = 0; i < countries.length; ++i) {
  data.addColumn('number', countries[i]);
}
data.addRows(months.length);
for (var i = 0; i < months.length; ++i) {
  data.setCell(i, 0, months[i]);
}
for (var i = 0; i < countries.length; ++i) {
  var country = productionByCountry[i];
  for (var month = 0; month < months.length; ++month) {
	data.setCell(month, i + 1, country[month]);
  }
}
// Create and draw the visualization.
var ac = new google.visualization.AreaChart(document.getElementById('visualization'));
ac.draw(data, {
  title : 'Monthly Coffee Production by Country',
  isStacked: true,
  width: 600,
  height: 400,
  vAxis: {title: "Cups"},
  hAxis: {title: "Month"}
});
}

function fade(eid)
 {
   var TimeToFade = 1000.0;
   var element = document.getElementById(eid);
   if(element == null)
     return;
    
   if(element.FadeState == null)
   {
     if(element.style.opacity == null 
        || element.style.opacity == '' 
        || element.style.opacity == '1')
     {
       element.FadeState = 2;
     }
     else
     {
       element.FadeState = -2;
     }
   }
     
  if(element.FadeState == 1 || element.FadeState == -1)
   {
     element.FadeState = element.FadeState == 1 ? -1 : 1;
     element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
   }
   else
   {
     element.FadeState = element.FadeState == 2 ? -1 : 1;
     element.FadeTimeLeft = TimeToFade;
     setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
   }  
 }

function animateFade(lastTick, eid)
 {  
   var TimeToFade = 1000.0;
   var curTick = new Date().getTime();
   var elapsedTicks = curTick - lastTick;
   
  var element = document.getElementById(eid);
  
   if(element.FadeTimeLeft <= elapsedTicks)
   {
     element.style.opacity = element.FadeState == 1 ? '1' : '0';
     element.style.filter = 'alpha(opacity = ' 
        + (element.FadeState == 1 ? '100' : '0') + ')';
     element.FadeState = element.FadeState == 1 ? 2 : -2;
	
	//Se l'elemento ha raggiunto opacitā 0 cancellalo
	if ( element.style.opacity == 0){
	 element.style.display = "none";
	 }

     return;
   }
  
   element.FadeTimeLeft -= elapsedTicks;
   var newOpVal = element.FadeTimeLeft/TimeToFade;
   if(element.FadeState == 1)
     newOpVal = 1 - newOpVal;
 
  element.style.opacity = newOpVal;
   element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
   
  setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
 }

function diminuisciOpacita(id){
var val = document.getElementById(id).style.opacity * 100;

val = val - 100;

cambiaOpacita(id,val);

if(val>0){ //se l'immagine non č completamente invisibile
   var t=setTimeout("diminuisciOpacita();", 50);
	} else {
	//Quando ha finito fai scomparire l'oggetto
	document.getElementById(id).style.display = "none";
	}

}

//Cambia la provincia e oscura la cittā quando viene cambiata la regione (nel pannello artisti)
function cambiatoLuogo(azione) {

//document.getElementById('regione_app').style.display = "block";
//document.getElementById('provincia_app').style.display = "block";

if (azione == 2) {
	document.getElementById('div_citta_app').style.display = "none";
	campi = "?azione="+azione+"&id="+document.getElementById('regione_app').options[document.getElementById('regione_app').selectedIndex].value;
	}

if (azione == 3) {
	document.getElementById('div_citta_app').style.display = "block";
	campi = "?azione="+azione+"&id="+document.getElementById('provincia_app').options[document.getElementById('provincia_app').selectedIndex].value;
	}

httpObject = getHTTPObject();


if (httpObject != null) {
	httpObject.open("GET", "luoghi_ajax.php"+campi, true);
	httpObject.send(null);
	httpObject.onreadystatechange = setOutputLuoghi;
	}

}

// Genera l'output per il div che contiene la select per i luoghi nel pannello degli artisti
function setOutputLuoghi(){
if(httpObject.readyState == 4){

		var update = new Array(); 

		//alert(httpObject.responseText);
		
		if(httpObject.responseText.indexOf('|' != -1)) { 
			update = httpObject.responseText.split('|',2);
			document.getElementById(update[0]).innerHTML = update[1];
		} 
	}
}

//Play/stop sound
function playSound(soundcode) {
 document.getElementById("sound").innerHTML=
 "<embed style='visibility:hidden; width:0px; height:0px;' src=\"http://www.oldschool.it/artisti/"+soundcode+"/demo.mp3\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
 }
function stopSound() {
 document.getElementById("sound").innerHTML=
 "";
 }


// Get the HTTP Object
function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
alert("Your browser does not support AJAX.");
return null;
}
}

// Genera l'output per gli artisti
function setOutput(){
if(httpObject.readyState == 4){

		var update = new Array(); 
		
		//Solo in caso di test ($op = 919) allora fai vedere l'alert con l'errore sql o php
		if (document.getElementById('search_test').value == 919){
		alert(httpObject.responseText);
		}
		
		if(httpObject.responseText.indexOf('|' != -1)) { 
			update = httpObject.responseText.split('|',9);
			document.getElementById(update[0]).innerHTML = update[1];
			document.getElementById('search_menu_generi_out').innerHTML = update[2];
			document.getElementById('search_result_out').innerHTML = update[3];
			document.getElementById('pagine_out').innerHTML = update[4];
			document.getElementById('pagine_bottom_out').innerHTML = update[5];
			document.getElementById('schede_sponsorizzate_out').innerHTML = update[6];
			document.getElementById('search_menu_luogo_out').innerHTML = update[7];
			document.getElementById('search_menu_voci_out').innerHTML = update[8];
			document.getElementById('loading_out').innerHTML = "";
			document.getElementById('loading_bottom_out').innerHTML = "";
			document.body.style.cursor='default';
		} 
	}
}

// Trova Generi Musicali per la select a seconda del tipo artista selezionato in home
function elaboraRicercaGeneri(){
	httpObject = getHTTPObject();
	
	var campiricerca = "?ok=1";
	var x = document.getElementById('select_home_tipo_artista').selectedIndex;
	campiricerca += "&tipo_artista="+document.getElementById('select_home_tipo_artista').options[x].value;
	
	if (httpObject != null) {
		httpObject.open("GET", "generi_musicali_ajax.php"+campiricerca, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutputSelect;
	}
}

// Genera l'output per la select_home_genere_musicale
function setOutputSelect(){
if(httpObject.readyState == 4){

	document.getElementById('label_select').innerHTML = httpObject.responseText;
	//alert(httpObject.responseText);
	}
}

function settaRicerca(tipo, genere) {
	if(tipo !== 0) {
		var tipo_ricercato = "";
		for (i = 0; i < document.ricerca_tipi.length; i++)
		{
			tipo_ricercato = document.ricerca_tipi[i].id.substr(4,2);
			if (tipo_ricercato==tipo){
				document.ricerca_tipi[i].checked = true;
			} else {
				document.ricerca_tipi[i].checked = false;
			}
			
		}
	}
	if(genere !== 0) {
		var genere_ricercato = "";
		for (ii = 0; ii < document.ricerca_generi.length; ii++)
		{
			genere_ricercato = document.ricerca_generi[ii].id.substr(6,2);
			if (genere_ricercato==genere){
				document.ricerca_generi[ii].checked = true;
			} else {
				document.ricerca_generi[ii].checked = false;
			}
		}
	}
}


function selectAllCheck(field) {

for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function deselectAllCheck(field) {

for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}

function clickMaschio() {
	if(document.getElementById('voce_maschile').checked==true) {
	document.getElementById('senza_voce').checked=false;
	document.getElementById('tutti_voce').checked=false;
	}
	if(document.getElementById('voce_maschile').checked==false && document.getElementById('voce_femminile').checked==false) {
	document.getElementById('senza_voce').checked=true;
	}
}
function clickFemmina() {
	if(document.getElementById('voce_femminile').checked==true) {
	document.getElementById('senza_voce').checked=false;
	document.getElementById('tutti_voce').checked=false;
	}
	if(document.getElementById('voce_maschile').checked==false && document.getElementById('voce_femminile').checked==false) {
	document.getElementById('senza_voce').checked=true;
	}
}

function clickSenza() {
	if(document.getElementById('senza_voce').checked==true) {
	document.getElementById('voce_maschile').checked=false;
	document.getElementById('voce_femminile').checked=false;
	document.getElementById('tutti_voce').checked=false;
	}
	if(document.getElementById('senza_voce').checked==false) {
	document.getElementById('voce_maschile').checked=true;
	document.getElementById('voce_femminile').checked=true;
	}
}

function clickTutti() {
	if(document.getElementById('tutti_voce').checked==true) {
	document.getElementById('voce_maschile').checked=false;
	document.getElementById('voce_femminile').checked=false;
	document.getElementById('senza_voce').checked=false;
	}
	if(document.getElementById('tutti_voce').checked==false) {
	document.getElementById('voce_maschile').checked=true;
	document.getElementById('voce_femminile').checked=true;
	document.getElementById('senza_voce').checked=false;
	}
}

// Trova Artista a seconda dei filtri
function elaboraRicerca(pagina){
httpObject = getHTTPObject();
if (httpObject != null) {

//Setto una clessidra
document.body.style.cursor='wait';
var loading = "<img src='img/loading.gif'><br><p class='text_bold'>Ricerca Schede</p>";
//document.getElementById('schede_sponsorizzate_out').innerHTML = "";
//document.getElementById('pagine_out').innerHTML = "<table><tr><td width='22'><img id='button_indietro' border='0' src='img/button_freccia_indietro_off.png'></td><td width='22'><img width='22' alt='Pagina 1' id='button_1' border='0' src='img/button_page/button_current_1.png'></td><td width='22'><img id='button_avanti' border='0' src='img/button_freccia_avanti_off.png'></td></tr></table>";
//document.getElementById('pagine_bottom_out').innerHTML = "<table><tr><td width='22'><img id='button_indietro_bottom' border='0' src='img/button_freccia_indietro_off.png'></td><td width='22'><img width='22' alt='Pagina 1' id='button_1_bottom' border='0' src='img/button_page/button_current_1.png'></td><td width='22'><img id='button_avanti_bottom' border='0' src='img/button_freccia_avanti_off.png'></td></tr></table>";
//document.getElementById('schede_sponsorizzate_out').innerHTML = "<p class='text_bold'>Attendere:</p><table width='622' border='0'><tr><td align='center' height='22' style=\"background: transparent url(img/artist_result_header.png) no-repeat center top;\"><table width='590' border='0'><tr><td align='left'><p class='text_title_result'>Ricerca in corso...</p></td></tr></table></td></tr><tr><td align='center' height='7' style=\"background: transparent url(img/artist_result_line.png) no-repeat center top;\"></td></tr><tr><td align='center' height='140' bgcolor='white' valign='bottom'>"+loading+"</td></tr><tr><td align='center'height='15' style=\"background: transparent url(img/artist_result_footer.png) no-repeat center bottom;\"></td></tr><tr><td align='center'height='20'></td></tr></table>";


document.getElementById('loading_out').innerHTML = "<img src='img/loading.gif' title='Ricerca schede...' height='22'>";
document.getElementById('loading_bottom_out').innerHTML = "<img src='img/loading.gif' title='Ricerca schede...' height='22'>";



var myform = document.ricerca;
var campiricerca = "?ok=1";
for(var i=0;i<myform.length;++i) {
	if(myform.elements[i].type=='checkbox') {
	//myform.elements[i].checked=false;
	campiricerca += "&"+myform.elements[i].id+"="+myform.elements[i].checked;

	}
}
var myform_tipi = document.ricerca_tipi;
for(var ii=0;ii<myform_tipi.length;++ii) {
	if(myform_tipi.elements[ii].type=='checkbox') {
	//myform_tipi.elements[i].checked=false;
	campiricerca += "&"+myform_tipi.elements[ii].id+"="+myform_tipi.elements[ii].checked;

	}
}

var myform_generi = document.ricerca_generi;
for(var iii=0;iii<myform_generi.length;++iii) {
	if(myform_generi.elements[iii].type=='checkbox') {
	//myform_tipi.elements[i].checked=false;
	campiricerca += "&"+myform_generi.elements[iii].id+"="+myform_generi.elements[iii].checked;

	}
}

campiricerca += "&ricerca_regioni="+document.getElementById('ricerca_regioni').value;
campiricerca += "&ricerca_provincie="+document.getElementById('ricerca_provincie').value;



var ordinamento = document.getElementById('ordinamento').options[document.getElementById('ordinamento').selectedIndex].value;
var artistiperpagina = document.getElementById('num').options[document.getElementById('num').selectedIndex].value;


//voce_maschile="+document.getElementById('voce_maschile').checked
httpObject.open("GET", "search_engine_ajax.php"+campiricerca+"&ord="+ordinamento+"&num="+artistiperpagina+"&pag="+pagina, true);
httpObject.send(null);
httpObject.onreadystatechange = setOutput;
}
}

// Popola le select dei Luoghi in base alla selezione delle regioni e provincie
function elaboraLuoghi(action){
httpObject = getHTTPObject();
	if (httpObject != null) {
	
	document.body.style.cursor='wait';
	
	//Se l'action č 1 setta il codice regione e svuota la citta, se č 2 setta il codice provincia
	if (action == 1) {codice = document.getElementById('regioni').value; document.getElementById('citta_out').innerHTML = '<select class=\'select_richiesta\' id=\'citta\' name=\'citta\'><option value = \'\' ></option></select>';}
	if (action == 2) {codice = document.getElementById('provincie').value;}
	
	
	httpObject.open("GET", "elabora_luoghi_ajax.php?action="+action+"&cod="+codice, true);
	httpObject.send(null);
	httpObject.onreadystatechange = setOutputLuoghi;
	}
}

// Genera l'output per il pannello artista
function setOutputLuoghi(){
if(httpObject.readyState == 4){

		var update = new Array(); 

		//alert(httpObject.responseText);
		
		if(httpObject.responseText.indexOf('|' != -1)) { 
			update = httpObject.responseText.split('|',2);
			document.getElementById(update[0]).innerHTML = update[1];
			document.body.style.cursor='default';
			
		} 
	}
}

// Genera l'output per il pannello artista
function setOutputArtista(){
if(httpObject.readyState == 4){

		var update = new Array(); 

		//alert(httpObject.responseText);
		
		if(httpObject.responseText.indexOf('|' != -1)) { 
			update = httpObject.responseText.split('|',4);
			document.getElementById(update[0]).innerHTML = update[1];
			document.body.style.cursor='default';
			
			//Se c'č bisogno di visualizzare un grafico esegui la funzione
			if (update[3] == 1) {
				drawVisualization();
				document.getElementById('test').innerHTML = "<img src=\'http://chart.apis.google.com/chart?chxl=1:|0|1|2|3|4|5&chxp=1,0,1,2,3,4,5&chxr=0,1,9|1,0,5&chxs=0,676767,11.5,0,lt,676767&chxt=x,y&chs=440x220&cht=lxy&chco=3399CC,FF0000&chds=0,5,0,5,0,5,0,5&chd=t:-1|0,0,0,0,1,2,0,0,0|-1|0,0,0,0,0,1,0,0,0&chdl=Accessi|Contatti&chdlp=b&chg=0,20&chls=1|1&chma=5,5,5,25&chtt=Ottobre+2011\' width=\'440\' height=\'220\' alt=\'Ottobre 2011\'>";
				}
			
			//Se c'č stato un messaggio, cancellalo dopo tot secondo diminuendo l'opacitā
			if (update[2] != "") {setTimeout("fade(\"messaggio\");", 1000);}
		} 
	}
}

// Apri il pannello artista richiesto
function elaboraPannelloArtista(azione,parametri){
	httpObject = getHTTPObject();
	
	//Se č stato premuto salva (parametri == "&mod=1") aggiungi ai parametri i valori dei campi
	if (parametri != null) {
	parametri += "&codice_artista="+document.getElementById('codice_artista_app').value;
	parametri += "&nome="+document.getElementById('nome_app').value;
	parametri += "&descrizione="+document.getElementById('descrizione_app').value;
	parametri += "&service="+document.getElementById('service_app').value;
	parametri += "&prezzo="+document.getElementById('prezzo_app').value;
	parametri += "&tipo="+document.getElementById('tipo_app').options[document.getElementById('tipo_app').selectedIndex].value;
	parametri += "&citta="+document.getElementById('citta_app').options[document.getElementById('citta_app').selectedIndex].value;
	parametri += "&genere="+document.getElementById('genere_app').options[document.getElementById('genere_app').selectedIndex].value;
	parametri += "&genere_testuale="+document.getElementById('genere_testuale_app').value;
	parametri += "&telefono="+document.getElementById('telefono_app').value;
	parametri += "&cellulare="+document.getElementById('cellulare_app').value;	
	}
	
	if (httpObject != null) {
		httpObject.open("GET", "pannello_artisti_ajax.php?azione="+azione+parametri, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutputArtista;
	}
}

var httpObject = null;

//Controlla la validitā della email
function isEmail(string) {
if (string.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) != -1)
return 1;
else
return 0;
}

//Validazione e invio Modulo Richiesta nella Scheda Artista
function invioRichiesta() {
	var nome = document.modulo_richiesta.nome.value;
	var cognome = document.modulo_richiesta.cognome.value;
	var telefono = document.modulo_richiesta.telefono.value;
	var email = document.modulo_richiesta.email.value;
	var tipo_evento = document.modulo_richiesta.tipo_evento.options[document.getElementById('tipo_evento').selectedIndex].value;
	
	var regione = document.modulo_richiesta.regioni.options[document.getElementById('regioni').selectedIndex].value;
	var provincia = document.modulo_richiesta.provincie.options[document.getElementById('provincie').selectedIndex].value;
	var citta = document.modulo_richiesta.citta.options[document.getElementById('citta').selectedIndex].value;
	
	var giorno_evento = document.modulo_richiesta.giorno_evento.options[document.getElementById('giorno_evento').selectedIndex].value;
	var mese_evento = document.modulo_richiesta.mese_evento.options[document.getElementById('mese_evento').selectedIndex].value
	var anno_evento = document.modulo_richiesta.anno_evento.options[document.getElementById('anno_evento').selectedIndex].value;
	var come_saputo = document.modulo_richiesta.come_saputo.options[document.getElementById('come_saputo').selectedIndex].value;
	var note = document.getElementById('note').value;
	
	var tipo_richiesta = document.modulo_richiesta.tipo_richiesta.value;
	
	if ((tipo_richiesta == 2) || (tipo_richiesta == 3)) {
		var artista_pagante = document.modulo_richiesta.artista_pagante.value;
		var id_artista = document.modulo_richiesta.id_artista.value;
	}
	
	var campi = "?id_artista="+id_artista+"&nome="+nome+"&cognome="+cognome+"&telefono="+telefono+"&email="+email+"&tipo_evento="+tipo_evento+"&giorno_evento="+giorno_evento+"&mese_evento="+mese_evento+"&anno_evento="+anno_evento+"&come_saputo="+come_saputo+"&artista_pagante="+artista_pagante+"&tipo_richiesta="+tipo_richiesta+"&note="+note+"&regione="+regione+"&provincia="+provincia+"&citta="+citta;
	
        if ((nome == "") || (nome == "undefined") || (nome == " ")) {
           alert("Inserire un Nome.");
		   document.modulo_richiesta.nome.focus();
        }
		else if ((cognome == "") || (cognome == "undefined") || (cognome == " ")) {
           alert("Inserire un Cognome.");
		   document.modulo_richiesta.cognome.focus();
        }
        else if ((telefono == "") || (telefono == "undefined") || (telefono == " ")) {
           alert("Inserire un Telefono.");
		   document.modulo_richiesta.telefono.focus();
        }
        else if ((email == "") || (email == "undefined") || (email == " ")) {
           alert("Inserire una E-mail.");
		   document.modulo_richiesta.email.focus();
        }
		else if (isEmail(document.modulo_richiesta.email.value) == 0){
		   alert("Inserire una E-mail valida.");
		   document.modulo_richiesta.email.focus();
		}
        else if ((tipo_evento == "") || (tipo_evento == "undefined") || (tipo_evento == " ")) {
           alert("Inserire un Tipo di Evento.");
		   document.modulo_richiesta.tipo_evento.focus();
        }
        else if ((regione == "") || (regione == "undefined") || (regione == " ")) {
           alert("Inserire una Regione.");
		   document.modulo_richiesta.regione.focus();
        }
        else if ((provincia == "") || (provincia == "undefined") || (provincia == " ")) {
           alert("Inserire una Provincia.");
		   document.modulo_richiesta.provincia.focus();
        }
        else if ((citta == "") || (citta == "undefined") || (citta == " ")) {
           alert("Inserire una Cittā.");
		   document.modulo_richiesta.citta.focus();
        }
        else if ((giorno_evento == "") || (giorno_evento == "undefined") || (giorno_evento == " ")) {
           alert("Inserire un Giorno.");
		   document.modulo_richiesta.giorno_evento.focus();
        }
        else if ((mese_evento == "") || (mese_evento == "undefined") || (mese_evento == " ")) {
           alert("Inserire un Mese.");
		   document.modulo_richiesta.mese_evento.focus();
        }
        else if ((anno_evento == "") || (anno_evento == "undefined") || (anno_evento == " ")) {
           alert("Inserire un Anno.");
		   document.modulo_richiesta.anno_evento.focus();
        }
        else if ((come_saputo == "") || (come_saputo == "undefined") || (come_saputo == " ")) {
           alert("Inserire come ha trovato il sito.");
		   document.modulo_richiesta.come_saputo.focus();
        }
		else if (!document.modulo_richiesta.privacy.checked){
			alert("Devi leggere e accettare le condizioni sulla privacy.");
			document.modulo_richiesta.privacy.focus();
		}
 else {
	invioMailModuloRichiesta(campi);
        }
}

//Invia la mail relativa al modulo di richiesta artista
function invioMailModuloRichiesta(campi){
	httpObject = getHTTPObject();
	
	if (httpObject != null) {
		httpObject.open("GET", "invia_richiesta_ajax.php"+campi, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutputModuloRichiesta;
	}
}

// Genera l'output per il modulo di richiesta artista
function setOutputModuloRichiesta(){
if(httpObject.readyState == 4){

	var update = new Array(); 

	//alert(httpObject.responseText);
	
	if(httpObject.responseText.indexOf('|' != -1)) { 
		update = httpObject.responseText.split('|',2);
	}

	//Codice senza split
	//document.getElementById('modulo_richiesta_out').innerHTML = httpObject.responseText;
	
	document.getElementById('modulo_richiesta_out').innerHTML = update[0];
	
	//alert(httpObject.responseText);
	
	//Redirect alla pagina di ringraziamento a seconda se č una richiesta di artista o contatto normale
	location.href = update[1];
	
	}
}

//Salvo i dati statistici delle ricerche in home page e poi invio il modulo di ricerca
function invioRicercaHomePage(){
	httpObject = getHTTPObject();
	
	var tipo_artista = document.ricerca_home.select_home_tipo_artista.options[document.getElementById('select_home_tipo_artista').selectedIndex].value
	var genere_musicale = document.ricerca_home.select_home_genere_musicale.options[document.getElementById('select_home_genere_musicale').selectedIndex].value
	var regione = document.ricerca_home.select_home_luogo_evento.options[document.getElementById('select_home_luogo_evento').selectedIndex].value
	var tipo_evento = document.ricerca_home.select_home_tipo_evento.options[document.getElementById('select_home_tipo_evento').selectedIndex].value
	
	//$oper=1 č per le ricerche della home page
	var campi = "?oper=1&tipo_artista="+tipo_artista+"&genere_musicale="+genere_musicale+"&regione="+regione+"&tipo_evento="+tipo_evento;
	
	if (httpObject != null) {
		httpObject.open("GET", "salva_ricerca_ajax.php"+campi, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutputRicercaHomePage;
	}
}

// Genera l'output dopo aver salvato i dati statistici delle ricerche in home page
function setOutputRicercaHomePage(){
if(httpObject.readyState == 4){

	//alert(httpObject.responseText);
	document.ricerca_home.submit();
	
	}
}

//Validazione e invio Modulo Richiesta nella Scheda Artista
function invioLogin() {
	var login = document.modulo_login.login.value;
	var psw = document.modulo_login.psw.value;
	

        if ((login == "") || (login == "undefined") || (login == " ")) {
           alert("Inserire una E-Mail.");
		   document.modulo_login.login.focus();
        }
		else if ((psw == "") || (psw == "undefined") || (psw == " ")) {
           alert("Inserire una Password.");
		   document.modulo_login.psw.focus();
        }
		else if (isEmail(document.modulo_login.login.value) == 0){
		   alert("Inserire una E-mail valida.");
		   document.modulo_login.login.focus();
		}
 else {
	document.modulo_login.submit();
        }
}

//Validazione e invio Modulo Iscrizione Artista
function invioIscrizioneArtista() {
	var nome = document.modulo_iscrizione_artista.nome_contatto.value;
	var cognome = document.modulo_iscrizione_artista.cognome_contatto.value;
	
	var regioni = document.modulo_iscrizione_artista.regioni.options[document.getElementById('regioni').selectedIndex].value;
	var provincie = document.modulo_iscrizione_artista.provincie.options[document.getElementById('provincie').selectedIndex].value;
	var citta = document.modulo_iscrizione_artista.citta.options[document.getElementById('citta').selectedIndex].value;
	
	var giorno_nascita = document.modulo_iscrizione_artista.giorno_nascita.value;
	var mese_nascita = document.modulo_iscrizione_artista.mese_nascita.value;
	var anno_nascita = document.modulo_iscrizione_artista.anno_nascita.value;
	
	var telefono = document.modulo_iscrizione_artista.telefono.value;
	var cellulare = document.modulo_iscrizione_artista.cellulare.value;
	var email = document.modulo_iscrizione_artista.email.value;
	
	var come_saputo = document.modulo_iscrizione_artista.come_saputo.options[document.getElementById('come_saputo').selectedIndex].value;
	
	var password = document.modulo_iscrizione_artista.password.value;
	var password_controllo = document.modulo_iscrizione_artista.password_controllo.value;
	
	var nome_artistico = document.modulo_iscrizione_artista.nome_artistico.value;
	var select_tipo_artista = document.modulo_iscrizione_artista.select_tipo_artista.options[document.getElementById('select_tipo_artista').selectedIndex].value;
	var select_genere_musicale = document.modulo_iscrizione_artista.select_genere_musicale.options[document.getElementById('select_genere_musicale').selectedIndex].value;
	var numero_componenti = document.modulo_iscrizione_artista.numero_componenti.value;
	var select_service_audio = document.modulo_iscrizione_artista.select_service_audio.options[document.getElementById('select_service_audio').selectedIndex].value;
	var prezzo = document.modulo_iscrizione_artista.prezzo.value;
	var descrizione = document.getElementById('descrizione').value;
	
	var foto_banner = document.modulo_iscrizione_artista.foto_banner.value;
	var demo_audio = document.modulo_iscrizione_artista.demo_audio.value;
	
	//var note = document.getElementById('note').value;
	
	if ((nome == "") || (nome == "undefined") || (nome == " ")) {
	   alert("Inserire un Nome.");
	   document.modulo_iscrizione_artista.nome_contatto.focus();
	}
	else if ((cognome == "") || (cognome == "undefined") || (cognome == " ")) {
	   alert("Inserire un Cognome.");
	   document.modulo_iscrizione_artista.cognome_contatto.focus();
	}
	else if ((regioni == "") || (regioni == "undefined") || (regioni == " ")) {
	   alert("Inserire una Regione di residenza.");
	   document.modulo_iscrizione_artista.regioni.focus();
	}
	else if ((provincie == "") || (provincie == "undefined") || (provincie == " ")) {
	   alert("Inserire una Provincia di residenza.");
	   document.modulo_iscrizione_artista.provincie.focus();
	}
	else if ((citta == "") || (citta == "undefined") || (citta == " ")) {
	   alert("Inserire una Cittā di residenza.");
	   document.modulo_iscrizione_artista.citta.focus();
	}
	else if ((giorno_nascita == "") || (giorno_nascita == "undefined") || (giorno_nascita == " ")) {
	   alert("Inserire un Giorno di nascita.");
	   document.modulo_iscrizione_artista.giorno_nascita.focus();
	}
	else if ((mese_nascita == "") || (mese_nascita == "undefined") || (mese_nascita == " ")) {
	   alert("Inserire un Mese di nascita.");
	   document.modulo_iscrizione_artista.mese_nascita.focus();
	}
	else if ((anno_nascita == "") || (anno_nascita == "undefined") || (anno_nascita == " ")) {
	   alert("Inserire un Anno di nascita.");
	   document.modulo_iscrizione_artista.anno_nascita.focus();
	}
	else if ((telefono == "") || (telefono == "undefined") || (telefono == " ")) {
	   alert("Inserire un Telefono.");
	   document.modulo_iscrizione_artista.telefono.focus();
	}
	else if ((cellulare == "") || (cellulare == "undefined") || (cellulare == " ")) {
	   alert("Inserire un Cellulare.");
	   document.modulo_iscrizione_artista.cellulare.focus();
	}
	else if ((email == "") || (email == "undefined") || (email == " ")) {
	   alert("Inserire una E-mail.");
	   document.modulo_iscrizione_artista.email.focus();
	}
	else if (isEmail(document.modulo_iscrizione_artista.email.value) == 0){
	   alert("Inserire una E-mail valida.");
	   document.modulo_iscrizione_artista.email.focus();
	}
	else if ((come_saputo == "") || (come_saputo == "undefined") || (come_saputo == " ")) {
	   alert("Inserire come hai trovato il sito.");
	   document.modulo_iscrizione_artista.come_saputo.focus();
	}
	else if ((password == "") || (password == "undefined") || (password == " ")) {
	   alert("Inserire una Password.");
	   document.modulo_iscrizione_artista.password.focus();
	}
	else if ((password_controllo == "") || (password_controllo == "undefined") || (password_controllo == " ")) {
	   alert("Inserire nuovamente la Password.");
	   document.modulo_iscrizione_artista.password_controllo.focus();
	}
	else if (password != password_controllo) {
	   alert("Le Password inserite non corrispondono.");
	   document.modulo_iscrizione_artista.password.focus();
	}
	else if ((nome_artistico == "") || (nome_artistico == "undefined") || (nome_artistico == " ")) {
	   alert("Inserire il Nome Artistico.");
	   document.modulo_iscrizione_artista.nome_artistico.focus();
	}
	else if ((select_tipo_artista == "") || (select_tipo_artista == "undefined") || (select_tipo_artista == " ")) {
	   alert("Inserire il Tipo Artista.");
	   document.modulo_iscrizione_artista.select_tipo_artista.focus();
	}
	else if ((select_genere_musicale == "") || (select_genere_musicale == "undefined") || (select_genere_musicale == " ")) {
	   alert("Inserire il Genere Musicale.");
	   document.modulo_iscrizione_artista.select_genere_musicale.focus();
	}
	else if ((numero_componenti == "") || (numero_componenti == "undefined") || (numero_componenti == " ")) {
	   alert("Inserire il Numero Componenti in numeri.");
	   document.modulo_iscrizione_artista.numero_componenti.focus();
	}
	else if ((select_service_audio == "") || (select_service_audio == "undefined") || (select_service_audio == " ")) {
	   alert("Inserire se si č in possesso o meno di Service Audio.");
	   document.modulo_iscrizione_artista.select_service_audio.focus();
	}
	else if ((prezzo == "") || (prezzo == "undefined") || (prezzo == " ")) {
	   alert("Inserire il Cachet Minimo che percepite.");
	   document.modulo_iscrizione_artista.prezzo.focus();
	}
	else if ((descrizione == "") || (descrizione == "undefined") || (descrizione == " ")) {
	   alert("Inserire la Descrizione dell'Artista.");
	   document.modulo_iscrizione_artista.descrizione.focus();
	}
	else if ((foto_banner == "") || (foto_banner == "undefined") || (foto_banner == " ")) {
	   alert("Inserire una Foto Principale. (Dimensioni minime: 850x267px, Peso Massimo: 500 Kb, Formato: .jpg)");
	   document.modulo_iscrizione_artista.foto_banner.focus();
	}
	else if ((demo_audio == "") || (demo_audio == "undefined") || (demo_audio == " ")) {
	   alert("Inserire un Demo Audio. (Durata massima: 5 minuti, Peso Massimo: 5 Mb, Formato: .mp3)");
	   document.modulo_iscrizione_artista.demo_audio.focus();
	}
	else if (!document.modulo_iscrizione_artista.privacy.checked){
		alert("Devi leggere e accettare le condizioni sulla privacy.");
		document.modulo_iscrizione_artista.privacy.focus();
	}
 else {
	document.modulo_iscrizione_artista.submit();
        }
}


//Funzione tooltip per immagini ricerca
var tooltip=function(){
 var id = 'tt';
 var top = 3;
 var left = 3;
 var maxw = 550;
 var speed = 10;
 var timer = 20;
 var endalpha = 100;
 var alpha = 0;
 var tt,t,c,b,h;
 var ie = document.all ? true : false;
 return{
  show:function(v,w){
   if(tt == null){
    tt = document.createElement('div');
    tt.setAttribute('id',id);
    t = document.createElement('div');
    t.setAttribute('id',id + 'top');
    c = document.createElement('div');
    c.setAttribute('id',id + 'cont');
    b = document.createElement('div');
    b.setAttribute('id',id + 'bot');
    tt.appendChild(t);
    tt.appendChild(c);
    tt.appendChild(b);
    document.body.appendChild(tt);
    tt.style.opacity = 0;
    tt.style.filter = 'alpha(opacity=0)';
    document.onmousemove = this.pos;
   }
   tt.style.display = 'block';
   c.innerHTML = v;
   tt.style.width = w ? w + 'px' : 'auto';
   if(!w && ie){
    t.style.display = 'none';
    b.style.display = 'none';
    tt.style.width = tt.offsetWidth;
    t.style.display = 'block';
    b.style.display = 'block';
   }
  if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
  h = parseInt(tt.offsetHeight) + top;
  clearInterval(tt.timer);
  tt.timer = setInterval(function(){tooltip.fade(1)},timer);
  },
  pos:function(e){
   var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
   var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
   tt.style.top = (u - h) + 'px';
   tt.style.left = (l + left) + 'px';
  },
  fade:function(d){
   var a = alpha;
   if((a != endalpha && d == 1) || (a != 0 && d == -1)){
    var i = speed;
   if(endalpha - a < speed && d == 1){
    i = endalpha - a;
   }else if(alpha < speed && d == -1){
     i = a;
   }
   alpha = a + (i * d);
   tt.style.opacity = alpha * .01;
   tt.style.filter = 'alpha(opacity=' + alpha + ')';
  }else{
    clearInterval(tt.timer);
     if(d == -1){tt.style.display = 'none'}
  }
 },
 hide:function(){
  clearInterval(tt.timer);
   tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
  }
 };
}();

