function listiniFocus1()
{
	document.getElementById('listini_focus5').focus();
}

function listiniFocus2()
{
	document.getElementById('nome').focus();
}


// JavaScript Document
function settaListino(valore)
{
	document.getElementById('richiesta_listini').value = valore;
	jQuery("#listini_contenitore").stop().animate({
				left: '-825px'
				},
				{ 
					duration: 1000, 
					specialEasing: {
						left: 'easeOutQuad'
					},
					complete: listiniFocus2
				});
	
}

function corsoScelto(corso)
{
	switch(corso)
	{
		//SPECIALISTICI ANNUALI
		case '01': label = "Pubblicità e Marketing"; break;
		case '02': label = "Grafica Pubblicitaria"; break;
		case '03': label = "Web Design"; break;
		case '04': label = "Fotografia Pubblicitaria"; break;
		case '05': label = "Grafica 3D Maya"; break;
		//COORDINATI ANNUALI
		case '06': label = "Pubblicità e Grafica"; break;
		case '07': label = "Grafica Web Design"; break;
		case '08': label = "Pubblicità Fotografia"; break;
		case '09': label = "Grafica Fotografia"; break;
		case '10': label = "Pubblicità Graf Foto"; break;
		//SPECIALISTICI AVANZATI
		case '11': label = "Grafica Editoriale"; break;
		case '12': label = "Copywriter"; break;
		case '13': label = "ActionScript"; break;
		case '14': label = "Web Content Manager"; break;
		case '15': label = "Programmazione Php"; break;
		//BIENNALI
		case '16': label = "Tecnico Pubblicitario"; break;
		case '17': label = "Web Expert"; break;
		//AUTORIZZATI
		case 'a1': label = "Grafico Pubblicitario"; break;
		case 'b1': label = "Web Design"; break;
	}
	
	return label;
}


function controllaForm()
{
	var errore = false;
	var messaggio_errore = "LA PAGINA RIPORTA I SEGUENTI ERRORI\n";
	messaggio_errore += "\n_________________________________________\n\n";
	//-----nome
	if(document.getElementById('nome').value == document.getElementById('nome').alt)
	{
		messaggio_errore += "- completare campo nome";
		errore = true;
	}
	//-----cognome
	if(document.getElementById('cognome').value == document.getElementById('cognome').alt)
	{
		messaggio_errore += "\n- completare campo cognome";	
		errore = true;
	}
	//-----mail
	if(document.getElementById('mail').value == document.getElementById('mail').alt)
	{
		messaggio_errore += "\n- completare campo email";
		errore = true;
	}
	//-----verifica
	if(document.getElementById('verifica_mail').value == document.getElementById('verifica_mail').alt)
	{
		messaggio_errore += "\n- completare campo di verifica email";
		errore = true;
	}
	else
	{
		if(document.getElementById('mail').value != document.getElementById('verifica_mail').value)
		{
			messaggio_errore += "\n- le email inserite non corrispondono";
			errore = true;
		}
	}
	//-----parere
	if(document.getElementById('parere').value == "parere")
	{
		messaggio_errore += "\n- completare campo parere";
		errore = true;
	}
	//-----privacy
	if(document.getElementById('accetto').checked == false)
	{
		messaggio_errore += "\n- accettare la privacy";	
		errore = true;
	}
	
	messaggio_errore += "\n_________________________________________";
	
	if(errore == true)
	{
		alert(messaggio_errore);
	}
	else
	{
		//-----creazione oggetto
		if (window.XMLHttpRequest)
		{
			// code for IE7+, Firefox, Chrome, Opera, Safari
			var xmlHttp =  new XMLHttpRequest();
		}
		if (window.ActiveXObject)
		{
			// code for IE6, IE5
			var xmlHttp =  new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		corso = document.getElementById('richiesta_listini').value;
		
		if(corso == "tutti")
		{

			risponditore = "corso01_09_10@corsoilas.com";
			risponditore += ", corso02_09_10@corsoilas.com";
			risponditore += ", corso03_09_10@corsoilas.com";
			risponditore += ", corso04_09_10@corsoilas.com";
			risponditore += ", corso05_09_10@corsoilas.com";
			risponditore += ", corso06_09_10@corsoilas.com";
			risponditore += ", corso07_09_10@corsoilas.com";
			risponditore += ", corso08_09_10@corsoilas.com";
			risponditore += ", corso09_09_10@corsoilas.com";
			risponditore += ", corso10_09_10@corsoilas.com";
			risponditore += ", corso11_09_10@corsoilas.com";
			risponditore += ", corso12_09_10@corsoilas.com";
			risponditore += ", corso13_09_10@corsoilas.com";
			risponditore += ", corso14_09_10@corsoilas.com";
			risponditore += ", corso15_09_10@corsoilas.com";
			risponditore += ", corso16_09_10@corsoilas.com";
			risponditore += ", corso17_09_10@corsoilas.com";
			risponditore += ", corsoa1_09_10@corsoilas.com";
			risponditore += ", corsob1_09_10@corsoilas.com";
			
			
			
			document.getElementById('risponditore').value = risponditore;
			
			
			label = "Tutti i corsi";
			
			document.getElementById('corso').value = label;
			
			/*							*/
			//============================
			/*							*/
			my_nome = document.getElementById('nome').value;
			my_cognome = document.getElementById('cognome').value;
			my_mail = document.getElementById('mail').value;
			my_parere = document.getElementById('parere').value;
			my_corso = document.getElementById('corso').value;
			my_risponditore = document.getElementById('risponditore').value;
			
			var parametri = "";
			parametri += "nome="+my_nome;
			parametri += "&cognome="+my_cognome;
			parametri += "&email="+my_mail;
			parametri += "&parere="+my_parere;
			parametri += "&corso="+my_corso;
			parametri += "&risponditore="+my_risponditore;
			parametri += "&conosciutoIlas=non presente nel form";
			
			jQuery("#listini_contenitore").stop().animate({
													left: '-1650px'
													},
													{ 
														duration: 1000, 
														specialEasing: {
															left: 'easeOutQuad'
														},
														complete: listiniFocus1
													});
			
			//invio i dati alla pagina
			xmlHttp.open('GET', 'testata_nuova_html/invio-listini.asp?'+parametri, true);
			//quando i dati sono arrivati eseguo la funzione per cambiare il valore
			xmlHttp.onreadystatechange = function()
										{
											if (xmlHttp.readyState==4)
											{
												jQuery("#listini_contenitore").delay(2000).animate({
													left: '-2475px'
													},
													{ 
														duration: 1000, 
														specialEasing: {
															left: 'easeOutQuad'
														}
													});
											}
										
										}
			xmlHttp.send(null);	
			
		}
		else
		{
			risponditore = "corso"+corso+"_09_10@corsoilas.com";
			document.getElementById('risponditore').value = risponditore;
			
			label = corsoScelto(corso);
			
			document.getElementById('corso').value = label;
			
			/*							*/
			//============================
			/*							*/
			my_nome = document.getElementById('nome').value;
			my_cognome = document.getElementById('cognome').value;
			my_mail = document.getElementById('mail').value;
			my_parere = document.getElementById('parere').value;
			my_corso = document.getElementById('corso').value;
			my_risponditore = document.getElementById('risponditore').value;
			
			var parametri = "";
			parametri += "nome="+my_nome;
			parametri += "&cognome="+my_cognome;
			parametri += "&email="+my_mail;
			parametri += "&parere="+my_parere;
			parametri += "&corso="+my_corso;
			parametri += "&risponditore="+my_risponditore;
			parametri += "&conosciutoIlas=non presente nel form";
			
			jQuery("#listini_contenitore").stop().animate({
													left: '-1650px'
													},
													{ 
														duration: 1000, 
														specialEasing: {
															left: 'easeOutQuad'
														}
													});
			
			//invio i dati alla pagina
			xmlHttp.open('GET', 'testata_nuova_html/invio-listini.asp?'+parametri, true);
			//quando i dati sono arrivati eseguo la funzione per cambiare il valore
			xmlHttp.onreadystatechange = function()
										{
											if (xmlHttp.readyState==4)
											{
												jQuery("#listini_contenitore").delay(2000).animate({
													left: '-2475px'
													},
													{ 
														duration: 1000, 
														specialEasing: {
															left: 'easeOutQuad'
														}
													});
											}
										
										}
			xmlHttp.send(null);	
			
			/*							*/
			//============================
			/*							*/
			
			//document.getElementById('form_invia_listini').submit();
		}
	}
}

function azzeraFormListini()
{
	document.getElementById('nome').value = document.getElementById('nome').alt;
	document.getElementById('cognome').value = document.getElementById('cognome').alt;
	document.getElementById('mail').value = document.getElementById('mail').alt;
	document.getElementById('parere').value = "parere";
	document.getElementById('corso').value = "";
	document.getElementById('risponditore').value = "";
	document.getElementById('accetto').checked = false;
	jQuery("#listini_scroll").css("top","0px");
	jQuery("#listini_privacy_testo").css("top","0px");
}

function settaScrollListini()
{
	jQuery("#listini_scroll").draggable({ axis: 'y', containment: 'parent', opacity: 0.35,
							   drag: function(event, ui) 
									{
										var textTop = ((jQuery("#listini_privacy_testo").height() - jQuery("#listini_privacy_textbox").height()+20)* ui.position.top) / (jQuery("#listini_scroll_area").height() - jQuery("#listini_scroll").height() );
	
										jQuery("#listini_privacy_testo").stop().animate({
											top: textTop * -1 + 'px'
										  },
											{ 
												duration: 500, 
												specialEasing: {
													top: 'easeOutQuad'
												}
											} );
									}
		});	
}