// Questa funzione mostra e nasconde i menu della barra di navigazione
window.onload=showMenu;
function showMenu(id)
{
	var d = document.getElementById(id);
	for (var i = 1; i<=10; i++)
	{
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
	if (d) {d.style.display='block';}
}
//	fine showMenu


// Questa funzione apre una finestra popup con la biografia di un docente
function apriBiografia (theDocente)
{
	myPage = "Docenti/" + theDocente + "_ita.htm";
	
	myWind = window.open(myPage, "Biografia", "toolbar=no,directories=no,menubar=no,scrollbars=yes,width=540,height=400");
}
// fine apriBiografia


// Questa funzione riporta true se la form riempita dall'utente è valida
function controllaFormPreiscrizioneLB (theForm)
{
	if (theForm.nome.value == "")
	{
		alert("Sorry! \n\nThe name inserted is not valid, please insert it again.");
		theForm.nome.focus();
		return (false);
	}
	
	if (theForm.cognome.value == "")
	{
		alert("Sorry! \n\nThe surname inserted is not valid, please insert it again.");
		theForm.cognome.focus();
		return (false);
	}
	
	if (theForm.cittadinanza.value == "")
	{
		alert("Sorry! \n\nThe nationality inserted is not valid, please insert it again.");
		theForm.cittadinanza.focus();
		return (false);
	}
	
	if (theForm.luogodinascita.value == "")
	{
		alert("Sorry! \n\nThe place of birth inserted is not valid, please insert it again.");
		theForm.luogodinascita.focus();
		return (false);
	}
	
	if ((theForm.nascitagiorno.value == "") || (theForm.nascitamese.value == "") || (theForm.nascitaanno.value == ""))
	{
		alert("Sorry! \n\nThe date of birth inserted is not valid, please insert it again.");
		theForm.nascitagiorno.focus();
		return (false);
	}
	
	if ((theForm.email.value == "") || (theForm.email.value.length < 5) || (theForm.email.value.indexOf("@") == -1))
	{
		alert("Sorry! \n\nThe e-mail inserted is not valid, please insert it again.");
		theForm.email.focus();
		return (false);
	}
	
	if (theForm.via.value == "")
	{
		alert("Sorry! \n\nThe address inserted is not valid, please insert it again.");
		theForm.via.focus();
		return (false);
	}
	
	if (theForm.cap.value == "")
	{
		alert("Sorry! \n\nThe post code inserted is not valid, please insert it again.");
		theForm.cap.focus();
		return (false);
	}
	
	if (theForm.citta.value == "")
	{
		alert("Sorry! \n\nThe city inserted is not valid, please insert it again.");
		theForm.citta.focus();
		return (false);
	}
	
	if (theForm.provincia.value == "")
	{
		alert("Sorry! \n\nThe province inserted is not valid, please insert it again.");
		theForm.provincia.focus();
		return (false);
	}
	
	if (theForm.stato.value == "")
	{
		alert("Sorry! \n\nThe country inserted is not valid, please insert it again.");
		theForm.stato.focus();
		return (false);
	}
	
	if (theForm.telefono.value == "")
	{
		alert("Sorry! \n\nThe telephone inserted is not valid, please insert it again.");
		theForm.telefono.focus();
		return (false);
	}
	
	
	if (theForm.titolostudiodenominazione.value == "")
	{
		alert("Sorry! \n\nThe name of diploma inserted is not valid, please insert it again.");
		theForm.titolostudiodenominazione.focus();
		return (false);
	}
	
	if (theForm.titolostudioistituto.value == "")
	{
		alert("Sorry! \n\nThe name of the school inserted is not valid, please insert it again.");
		theForm.titolostudioistituto.focus();
		return (false);
	}
	
	if (theForm.titolostudioanno.value == "")
	{
		alert("Sorry! \n\nThe graduation year inserted is not valid, please insert it again.");
		theForm.titolostudioanno.focus();
		return (false);
	}
	
	if (theForm.titolostudiocitta.value == "")
	{
		alert("Sorry! \n\nThe county of the diploma inserted is not valid, please insert it again.");
		theForm.titolostudiocitta.focus();
		return (false);
	}
	
	if (theForm.titolostudioprovincia.value == "")
	{
		alert("Sorry! \n\nThe province of the diploma inserted is not valid, please insert it again.");
		theForm.titolostudioprovincia.focus();
		return (false);
	}
	
	if (theForm.titolostudiostato.value == "")
	{
		alert("Sorry! \n\nThe country of the diploma inserted is not valid, please insert it again.");
		theForm.titolostudiostato.focus();
		return (false);
	}
	
	theForm.emailmittente.value = theForm.email.value;
	theForm.nomemittente.value = theForm.nome.value;
	theForm.cognomemittente.value = theForm.cognome.value;
	theForm.indirizzo.value = "chiara.nicolai@fondazionecampus.it,marco.terranova@fondazionecampus.it,info@matteovarisco.com";
	theForm.subject.value = "Modulo Preiscrizione Triennale Campus Lucca Inglese";
	
	// Se ha passato tutti i controlli allora convalida la form
	return (true);
}
// fine controllaFormPreiscrizioneLB


// Questa funzione riporta true se la form riempita dall'utente è valida
function controllaFormPreiscrizioneLS (theForm)
{
	if (theForm.nome.value == "")
	{
		alert("Sorry! \n\nThe name inserted is not valid, please insert it again.");
		theForm.nome.focus();
		return (false);
	}
	
	if (theForm.cognome.value == "")
	{
		alert("Sorry! \n\nThe surname inserted is not valid, please insert it again.");
		theForm.cognome.focus();
		return (false);
	}
	
	if (theForm.cittadinanza.value == "")
	{
		alert("Sorry! \n\nThe nationality inserted is not valid, please insert it again.");
		theForm.cittadinanza.focus();
		return (false);
	}
	
	if (theForm.luogodinascita.value == "")
	{
		alert("Sorry! \n\nThe place of birth inserted is not valid, please insert it again.");
		theForm.luogodinascita.focus();
		return (false);
	}
	
	if ((theForm.nascitagiorno.value == "") || (theForm.nascitamese.value == "") || (theForm.nascitaanno.value == ""))
	{
		alert("Sorry! \n\nThe date of birth inserted is not valid, please insert it again");
		theForm.nascitagiorno.focus();
		return (false);
	}
	
	if ((theForm.email.value == "") || (theForm.email.value.length < 5) || (theForm.email.value.indexOf("@") == -1))
	{
		alert("Sorry! \n\nThe e-mail inserted is not valid, please insert it again.");
		theForm.email.focus();
		return (false);
	}
	
	
	if (theForm.via.value == "")
	{
		alert("Sorry! \n\nThe address inserted is not valid, please insert it again.");
		theForm.via.focus();
		return (false);
	}
	
	if (theForm.cap.value == "")
	{
		alert("Sorry! \n\nThe post code inserted is not valid, please insert it again.");
		theForm.cap.focus();
		return (false);
	}
	
	if (theForm.citta.value == "")
	{
		alert("Sorry! \n\nThe city inserted is not valid, please insert it again.");
		theForm.citta.focus();
		return (false);
	}
	
	if (theForm.provincia.value == "")
	{
		alert("Sorry! \n\nThe province inserted is not valid, please insert it again.");
		theForm.provincia.focus();
		return (false);
	}
	
	if (theForm.stato.value == "")
	{
		alert("Sorry! \n\nThe country inserted is not valid, please insert it again.");
		theForm.stato.focus();
		return (false);
	}
	
	if (theForm.telefono.value == "")
	{
		alert("Sorry! \n\nThe telephone inserted is not valid, please insert it again.");
		theForm.telefono.focus();
		return (false);
	}
	
	
	if (theForm.corsodilaurea.value == "")
	{
		alert("Sorry! \n\nThe name of bachelor inserted is not valid, please insert it again.");
		theForm.corsodilaurea.focus();
		return (false);
	}
	
	if (theForm.annoaccademico.value == "")
	{
		alert("Sorry! \n\nThe graduation year inserted is not valid, please insert it again.");
		theForm.annoaccademico.focus();
		return (false);
	}
	
	if (theForm.universita.value == "")
	{
		alert("Sorry! \n\nThe county of the university inserted is not valid, please insert it again.");
		theForm.universita.focus();
		return (false);
	}
	
	if (theForm.universitastato.value == "")
	{
		alert("Sorry! \n\nThe country of the diploma inserted is not valid, please insert it again.");
		theForm.universitastato.focus();
		return (false);
	}
	
	theForm.emailmittente.value = theForm.email.value;
	theForm.nomemittente.value = theForm.nome.value;
	theForm.cognomemittente.value = theForm.cognome.value;
	theForm.indirizzo.value = "chiara.nicolai@fondazionecampus.it,marco.terranova@fondazionecampus.it,info@matteovarisco.com";
	theForm.subject.value = "Modulo Preiscrizione Specialistica Campus Lucca Inglese";
	
	// Se ha passato tutti i controlli allora convalida la form
	return (true);
}
// fine controllaFormPreiscrizioneLS


// Variabili globali per tenere traccia delle foto caricate
var gCurrentPhotoIndex = 0;
var kMaxPhotos = 20;

var gPhotos = new Array(kMaxPhotos);
gPhotos[0] = "seminario_veduta";
gPhotos[1] = "parco_seminario";
gPhotos[2] = "campo_basket";
gPhotos[3] = "aula_studenti_professore";
gPhotos[4] = "studenti_aula_2";
gPhotos[5] = "studenti_aula";
gPhotos[6] = "studenti";
gPhotos[7] = "studentesse_libro";
gPhotos[8] = "aula_computer_alto";
gPhotos[9] = "studenti_al_computer";
gPhotos[10] = "aula_con_separatori";
gPhotos[11] = "camera_con_vista";
gPhotos[12] = "camera_finestra_aperta";
gPhotos[13] = "ragazzi_e_chitarra";
gPhotos[14] = "biblioteca";
gPhotos[15] = "biblioteca_tavolo";
gPhotos[16] = "caffetteria_campus_1";
gPhotos[17] = "caffetteria_campus_2";
gPhotos[18] = "taglio_torta_campus";
gPhotos[19] = "torta_campus";


// Funzione per il caricamento di una foto
function loadPhoto (thePhotoName)
{
	var myImage = new Image(320,240);
	myImage.src = "Foto/" + thePhotoName + ".jpg";
	
	document.images["foto"].src = myImage.src;
	
	if (thePhotoName == "seminario_veduta")							{	gCurrentPhotoIndex = 0;	}
	else if (thePhotoName == "parco_seminario")						{	gCurrentPhotoIndex = 1;	}
	else if (thePhotoName == "campo_basket")						{	gCurrentPhotoIndex = 2;	}
	else if (thePhotoName == "aula_studenti_professore")			{	gCurrentPhotoIndex = 3;	}
	else if (thePhotoName == "studenti_aula_2")						{	gCurrentPhotoIndex = 4;	}
	else if (thePhotoName == "studenti_aula")						{	gCurrentPhotoIndex = 5;	}
	else if (thePhotoName == "studenti")							{	gCurrentPhotoIndex = 6;	}
	else if (thePhotoName == "studentesse_libro")					{	gCurrentPhotoIndex = 7;	}
	else if (thePhotoName == "aula_computer_alto")					{	gCurrentPhotoIndex = 8;	}
	else if (thePhotoName == "studenti_al_computer")				{	gCurrentPhotoIndex = 9;	}
	else if (thePhotoName == "aula_con_separatori")					{	gCurrentPhotoIndex = 10;	}
	else if (thePhotoName == "camera_con_vista")					{	gCurrentPhotoIndex = 11;	}
	else if (thePhotoName == "camera_finestra_aperta")				{	gCurrentPhotoIndex = 12;	}
	else if (thePhotoName == "ragazzi_e_chitarra")					{	gCurrentPhotoIndex = 13;	}
	else if (thePhotoName == "biblioteca")							{	gCurrentPhotoIndex = 14;	}
	else if (thePhotoName == "biblioteca_tavolo")					{	gCurrentPhotoIndex = 15;	}
	else if (thePhotoName == "caffetteria_campus_1")				{	gCurrentPhotoIndex = 16;	}
	else if (thePhotoName == "caffetteria_campus_2")				{	gCurrentPhotoIndex = 17;	}
	else if (thePhotoName == "taglio_torta_campus")					{	gCurrentPhotoIndex = 18;	}
	else if (thePhotoName == "torta_campus")						{	gCurrentPhotoIndex = 19;	}
	
}
// fine loadPhoto


// Questa funzione carica la foto precedente a quella corrente
function previousPhoto ()
{
	// Decrementa il contatore delle foto
	if (gCurrentPhotoIndex > 0)
	{
		gCurrentPhotoIndex = (gCurrentPhotoIndex - 1);
	}
	else
	{
		gCurrentPhotoIndex = (kMaxPhotos - 1);
	}
	
	// Prende il nome della foto
	var myPhotoName = gPhotos[gCurrentPhotoIndex];
	
	// Richiama la routine che carica la foto
	loadPhoto(myPhotoName);
}
// fine previousPhoto


// Questa funzione carica la foto successiva a quella corrente
function nextPhoto ()
{
	// Decrementa il contatore delle foto
	if (gCurrentPhotoIndex < (kMaxPhotos - 1))
	{
		gCurrentPhotoIndex = (gCurrentPhotoIndex + 1);
	}
	else
	{
		gCurrentPhotoIndex = 0;
	}
	
	// Prende il nome della foto
	var myPhotoName = gPhotos[gCurrentPhotoIndex];
	
	// Richiama la routine che carica la foto
	loadPhoto(myPhotoName);
}
// fine nextPhoto


// Questa funzione apre una finestra popup con un banner
function popupPiantinaForesteria ()
{
	myPage = "popuppiantinaforesteria.htm";
	
	myWind = window.open(myPage, "Foresteria", "toolbar=no,directories=no,menubar=no,scrollbars=no,width=820,height=500");
}
// fine popupPiantinaForesteria


// ¥¥¥


//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
