function prenotaFocus1()
{
	document.getElementById('prenota_focus5').focus();
}

function prenotaFocus2()
{
	document.getElementById('prenota_nome').focus();
}


// JavaScript Document
function corsoSceltoPrenota(corso)
{
	switch(corso)
	{
		//SPECIALISTICI ANNUALI
		case '01': label = "Pubblicit&agrave; 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&agrave; e Grafica"; break;
		case '07': label = "Grafica + Web Design"; break;
		case '08': label = "Pubblicit&agrave; + Fotografia"; break;
		case '09': label = "Grafica + Fotografia"; break;
		case '10': label = "Pubblicit&agrave; + 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 Art Director"; break;
		//AUTORIZZATI
		case 'a1': label = "Grafico Pubblicitario Regionale"; break;
		case 'b1': label = "Web Design Regionale"; break;
	}
	
	return label;
}
function settaPrenota(valore)
{
	document.getElementById('richiesta_prenota').value = valore;
	document.getElementById('numero_corso_scelto').innerHTML = document.getElementById('richiesta_prenota').value+" ";
	document.getElementById('nome_corso_scelto').innerHTML = corsoSceltoPrenota(document.getElementById('richiesta_prenota').value);
	
	jQuery("#prenota_contenitore").stop().animate({
				left: '-825px'
				},
				{ 
					duration: 1000, 
					specialEasing: {
						left: 'easeOutQuad'
					},
					complete: prenotaFocus2
				});
	
}



function controllaFormPrenota()
{
	var errore = false;
	var messaggio_errore = "LA PAGINA RIPORTA I SEGUENTI ERRORI\n";
	messaggio_errore += "\n_________________________________________\n\n";

	//-----nome
	if(document.getElementById('prenota_nome').value == document.getElementById('prenota_nome').alt)
	{
		messaggio_errore += "\n- completare campo nome";
		errore = true;
	}
	//-----cognome
	if(document.getElementById('prenota_cognome').value == document.getElementById('prenota_cognome').alt)
	{
		messaggio_errore += "\n- completare campo cognome";	
		errore = true;
	}
	//-----telefono
	if(document.getElementById('prenota_telefono').value == document.getElementById('prenota_telefono').alt)
	{
		messaggio_errore += "\n- completare campo di telefono";
		errore = true;
	}
	//-----cellulare
	if(document.getElementById('prenota_cellulare').value == document.getElementById('prenota_cellulare').alt)
	{
		messaggio_errore += "\n- completare campo di cellulare";
		errore = true;
	}
	//-----mail
	if(document.getElementById('prenota_mail').value == document.getElementById('prenota_mail').alt)
	{
		messaggio_errore += "\n- completare campo email";
		errore = true;
	}
	else
	{
		avviso_mail = controllaMail(document.getElementById('prenota_mail').value);
		if(avviso_mail != 0)
		{
			if(avviso_mail == 1)
			{
				messaggio_errore += "\n- email non valida";
				errore = true;
			}
		}	
	}
	//-----parere
	if(document.getElementById('prenota_parere').value == "parere")
	{
		messaggio_errore += "\n- completare campo parere";
		errore = true;
	}
	//-----conosciuto ilas
	if(document.getElementById('prenota_conosciutoIlas').value == -1)
	{
		messaggio_errore += "\n- selezionare in che modo si e' conosciuto Ilas";
		errore = true;
	}
	//-----privacy
	if(document.getElementById('prenota_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_prenota =  new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			// code for IE6, IE5
			var xmlHttp_prenota =  new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		/*							*/
		//============================
		/*							*/
		my_prenota_nome = document.getElementById('prenota_nome').value;
		my_prenota_cognome = document.getElementById('prenota_cognome').value;
		my_prenota_telefono = document.getElementById('prenota_telefono').value;
		my_prenota_cellulare = document.getElementById('prenota_cellulare').value;
		my_prenota_mail = document.getElementById('prenota_mail').value;
		my_prenota_parere = document.getElementById('prenota_parere').value;
		my_prenota_corso = document.getElementById('prenota_corso').value;
		my_prenota_conosiuto = document.getElementById('prenota_conosciutoIlas').value;
		corso = document.getElementById('richiesta_prenota').value;
		
		
		
		var parametri_prenota = "";
		parametri_prenota += "nome="+my_prenota_nome;
		parametri_prenota += "&cognome="+my_prenota_cognome;
		parametri_prenota += "&email="+my_prenota_mail;
		parametri_prenota += "&telefono="+my_prenota_telefono;
		parametri_prenota += "&cellulare="+my_prenota_cellulare;
		parametri_prenota += "&parere="+my_prenota_parere;
		parametri_prenota += "&corso="+corso;
		parametri_prenota += "&conosciutoIlas="+my_prenota_conosiuto;
		parametri_prenota += "&dadove=testata";
		
		
		
		
		jQuery("#prenota_contenitore").stop().animate({
													left: '-1650px'
													},
													{ 
														duration: 1000, 
														specialEasing: {
															left: 'easeOutQuad'
														},
														complete: prenotaFocus1
													});
		
		//invio i dati alla pagina
		xmlHttp_prenota.open('GET', 'testata_nuova_html/invio-prenota.php?'+parametri_prenota, true);
		//quando i dati sono arrivati eseguo la funzione per cambiare il valore
		xmlHttp_prenota.onreadystatechange = function()
									{
										if (xmlHttp_prenota.readyState==4)
										{
											jQuery("#prenota_contenitore").delay(2000).animate({
													left: '-2475px'
													},
													{ 
														duration: 1000, 
														specialEasing: {
															left: 'easeOutQuad'
														}
													});
										}									
									}
		
		xmlHttp_prenota.send(null);	
	}
}

function azzeraFormPrenota()
{
	document.getElementById('prenota_nome').value = document.getElementById('prenota_nome').alt;
	document.getElementById('prenota_cognome').value = document.getElementById('prenota_cognome').alt;
	document.getElementById('prenota_telefono').value = document.getElementById('prenota_telefono').alt;
	document.getElementById('prenota_cellulare').value = document.getElementById('prenota_cellulare').alt;
	document.getElementById('prenota_mail').value = document.getElementById('prenota_mail').alt;
	document.getElementById('prenota_parere').value = document.getElementById('prenota_parere').alt;
	document.getElementById('prenota_corso').value = "";
	document.getElementById('prenota_conosciutoIlas').value = -1;
	document.getElementById('richiesta_prenota').value = "";
	document.getElementById('prenota_accetto').checked = false;
	jQuery("#prenota_scroll").css("top","0px");
	jQuery("#prenota_privacy_testo").css("top","0px");
	jQuery("#prenota_selezione1").css("top","0px");
	jQuery("#Base").removeClass('prenota_supplementari_hover').addClass('prenota_supplementari_a');
	jQuery("#Intermedio").removeClass('prenota_supplementari_hover').addClass('prenota_supplementari_a');
	jQuery("#Avanzato").removeClass('prenota_supplementari_hover').addClass('prenota_supplementari_a');
	jQuery("#Mattutina").removeClass('prenota_supplementari_hover').addClass('prenota_supplementari_a');
	jQuery("#Pomeridiana").removeClass('prenota_supplementari_hover').addClass('prenota_supplementari_a');	
}

function settaScrollPrenota()
{
	jQuery("#prenota_scroll").draggable({ axis: 'y', containment: 'parent', opacity: 0.35,
							   drag: function(event, ui) 
									{
										var textTop = ((jQuery("#prenota_privacy_testo").height() - jQuery("#prenota_privacy_textbox").height()+20)* ui.position.top) / (jQuery("#prenota_scroll_area").height() - jQuery("#prenota_scroll").height() );
	
										jQuery("#prenota_privacy_testo").stop().animate({
											top: textTop * -1 + 'px'
										  },
											{ 
												duration: 500, 
												specialEasing: {
													top: 'easeOutQuad'
												}
											} );
									}
		});	
}

