		function VediDescrizione(Descr)
		{
			//document.getElementById("divSPDett").innerText = document.getElementById("divSPDescr").innerText;
			if(Descr == '')
				Descr = 'Non è inserita alcuna descrizione al momento.';
			document.getElementById("divSPDett").innerText = Descr;
			document.getElementById("divSPDett").style.display='none';
		}
		function Vedi()
		{
			document.getElementById("divSPDett").style.display='';
		}
		function ChiudiProdotto()
		{
			for(var i = 1; i <= eval(document.all('txtNumProdotto').value); i++)
			{
				document.all('divProdotto' + i).style.display='none';
				document.all('imgProdotto' + i).src='images/MenuChiuso.gif';
			}
		}
		
		function ApriChiudiProdotto(Prodotto,Num)
		{
			if(document.all('divProdotto' + Prodotto).style.display=='')
			{
				document.all('divProdotto' + Prodotto).style.display='none';
				document.all('imgProdotto' + Prodotto).src='images/MenuChiuso.gif';
			}
			else
			{
				document.all('divProdotto' + Prodotto).style.display='';
				document.all('imgProdotto' + Prodotto).src='images/MenuAperto.gif';
				for (var i=1; i < Num; i++) 
				{
				if(i.toString().length == 1)
					i = '0' + i;
					if (i != Prodotto) 
					{
						document.all('divProdotto' + i).style.display='none';
						document.all('imgProdotto' + i).src='images/MenuChiuso.gif';			
					}
				}
			}
		}
		function VisualizzaProdotto(NomeProdotto)
		{
			document.all('divProdotto').style.display='';
			document.all('divSottoProdotto').style.display='none';
			document.all('lblNomeProdotto').innerText=NomeProdotto;
			document.all('btAggiungiSottoProdotto').style.display=(NomeProdotto=='')?'none':'';
			document.getElementById("divSPDett").style.display='none';
		}
		
		function VisualizzaSottoProdotto(Id,NomeProdotto,Immagine)
		{
			document.all('divSottoProdotto').style.display='';
			document.all('divProdotto').style.display='none';
			document.all('lblNomeSottoProdotto').innerText=NomeProdotto;
			document.all('imgSottoProdotto').src = Immagine;
			document.all('btSPDescrizione').accesskey = Id;
			document.getElementById("divSPDett").style.display='none';
			PrelievoDescrizione(Id);
			//document.all('lblSPDescr').innerText = Descrizione;
			//alert(document.getElementById("imgSottoProdotto").outerHTML);
			//document.getElementById("imgSottoProdotto").onclick = window.open(Immagine,NomeProdotto);
		}
		
		function fConferma()
		{
			alert('Il tipo pratica è stato salvato');
		}
		function PrelievoDescrizione(Id){
			var datiRichiesta=Id;
			var nomePagina= ProtocolEHost()+AppPath()+"/default.aspx";
			var requestFrm='<form id="Form2" target="_self" method="post" action="'+nomePagina+'">'+
			'<textarea id="areaDati" name="areaDati">'+datiRichiesta+
			'</textarea><INPUT TYPE="SUBMIT" VALUE="OK"></form>'
			
			//alert(requestFrm)
			window.frames("FrameForRequest").document.body.innerHTML=requestFrm;
			try {
				var cdoc=window.frames("FrameForRequest").document
				var frm=cdoc.forms[0];
				//alert(requestFrm)
				frm.submit();
			}catch (e) {
				alert("Eccezione Nel submit della form di richiesta:"+e);
		}

		}
		function AppPath() {
			return document.location.pathname.substr(0,document.location.pathname.indexOf("/",1));
			}
		function ProtocolEHost() {
			return window.location.protocol+"//"+window.location.hostname
			}
		function Focus()
		{
		if(document.formData.txtUserId!=null)
			document.formData.txtUserId.focus();
				 else
			alert("non trovo la textbox!")
}
function RiempiCitta(city) {
    //alert(city);
    if (document.getElementById('ctl00_Main_Registrazione_txtCitta') != null)
        cityname = "ctl00_Main_Registrazione_txtCitta";
    else
        cityname = "ctl00_txtCitta";
    document.all(cityname).value = city.options(city.selectedIndex).text;
}
function ControllaCampi() {
    alert(document.getElementsByName('txtUserId').item[1]);
    if (document.getElementsByName('txtUserId').value == "") {
        alert("E' necessario inserire l'ID Utente!");
        document.getElementsByName('txtUserId').focus();
        return false;
    }
    if (document.getElementsByName('txtPassword').value == "") {
        alert("E' necessario inserire la Password!");
        document.getElementsByName('txtPassword').focus();
        return false;
    }
    document.body.style.cursor = 'wait';
    return true;
}

function InitFocus() {
    document.formData.txtUserId.focus();
    if (window.parent.location.href != window.location.href) window.parent.location.href = window.location.href;
    return true;
}
var FinestraP
var apertaP = "N"
function ChiudiFinestraP() {
    if (apertaP == "S") {
        FinestraP.close();
    }
}
function ControllaEmail(email) {
    if (email == null)
        email = document.all('txtEmail');
    if (email.value.length == 0) {
        alert("Occorre inserire l'indirizzo Email");
        email.focus();
        return false;
    }
    if (IsEmailValid(email.value) == false) {
        email.focus();
        return false;
    }
}

function IsEmailValid(Temp) {
    var EmailOk = true;
    var AtSym = Temp.indexOf('@')
    var Period = Temp.lastIndexOf('.')
    var Space = Temp.indexOf(' ')
    var Length = Temp.length - 1
    // Array is from 0 to length-1

    if ((AtSym < 1) || (Period <= AtSym + 1) || (Period == Length) || (Space != -1)) {
        alert("Inserire un indirizzo E-mail valido");
        EmailOk = false;
    }
    return EmailOk;
}
function Disabilita(bt) {
    if (window.giacliccato)
        return false;
    else {
        window.giacliccato = true;
        return true;
    }
}
function ApriOpera(img) {
    window.open(img.alt, 'titolo', 'menubar=no, resizable=yes, status=no, toolbar=no, location=no, scrollbars=yes, width=600, height=450,top=' + (screen.height - 121) / 2 + ', left=' + (screen.width - 261) / 2, true);
}
function ControllaDati() {
    if (document.getElementById('ctl00_Main_Registrazione_txtNome') != null)
        nome = document.getElementById('ctl00_Main_Registrazione_txtNome');
    else
        nome = document.getElementById('ctl00_txtNome');
    //alert(document.getElementById('_ctl0:cmbProvincia').value);

    if (document.getElementById('ctl00$Main$Registrazione$cmbProvincia') != null) {
        //selIndex = document.getElementById('_ctl0:cmbProvincia')selectedIndex;
        provincia = document.getElementById('ctl00$Main$Registrazione$cmbProvincia');
    }
    else {
        //selIndex = document.getElementById('ctl00$cmbProvincia')selectedIndex; 
        provincia = document.getElementById('ctl00$cmbProvincia');
    }

    if (document.getElementById('ctl00_Main_Registrazione_txtCap') != null)
        cap = document.getElementById('ctl00_Main_Registrazione_txtCap');
    else
        cap = document.getElementById('ctl00_txtCap');
    //alert(cap.value);

    if (document.getElementById('ctl00$Main$Registrazione$cmbCitta') != null)
        citta = document.getElementById('ctl00$Main$Registrazione$cmbCitta');
    else if (document.getElementById('ctl00$cmbCitta') != null)
        citta = document.getElementById('ctl00$cmbCitta');
    else if (document.getElementById('ctl00_Main_Registrazione_txtLocEstera') != null)
        citta = document.getElementById('ctl00_Main_Registrazione_txtLocEstera');
    else if (document.getElementById('ctl00_txtLocEstera') != null)
        citta = document.getElementById('ctl00_txtLocEstera');

    if (document.getElementById('ctl00_Main_Registrazione_txtIndirizzo') != null)
        indirizzo = document.getElementById('ctl00_Main_Registrazione_txtIndirizzo');
    else
        indirizzo = document.getElementById('ctl00_txtIndirizzo');

    if (document.getElementById('ctl00_Main_Registrazione_txtTelefono') != null)
        telefono = document.getElementById('ctl00_Main_Registrazione_txtTelefono');
    else
        telefono = document.getElementById('ctl00_txtTelefono');

    if (document.getElementById('ctl00_Main_Registrazione_txtData') != null)
        data = document.getElementById('ctl00_Main_Registrazione_txtData');
    else
        data = document.getElementById('ctl00_txtData');
    //alert(data.value);
    if (document.getElementById('ctl00_Main_Registrazione_txtEmail') != null)
        email = document.getElementById('ctl00_Main_Registrazione_txtEmail');
    else
        email = document.getElementById('ctl00_txtEmail');

    if (document.getElementById('ctl00_Main_Registrazione_txtUserId') != null)
        user = document.getElementById('ctl00_Main_Registrazione_txtUserId');
    else
        user = document.getElementById('ctl00_txtUserId');
    //alert(user.value.length);
    if (document.getElementById('ctl00_Main_Registrazione_txtPassword') != null)
        pwd1 = document.getElementById('ctl00_Main_Registrazione_txtPassword');
    else
        pwd1 = document.getElementById('ctl00_txtPassword');

    if (document.getElementById('ctl00_Main_Registrazione_txtPassword2') != null)
        pwd2 = document.getElementById('ctl00_Main_Registrazione_txtPassword2');
    else
        pwd2 = document.getElementById('ctl00_txtPassword2');
    //alert(pwd1.value.length);

    chk = document.getElementById('chkConsenso');

    //alert(pwd1.value+"-"+pwd2.value);
    if (nome.value.length == 0) {
        alert("Occorre inserire Nome e Cognome");
        nome.focus();
        return false;
    }
    if (provincia.value.length == 0) {
        alert("Occorre selezionare la Provincia");
        provincia.focus();
        return false;
    }
    if (cap.value.length == 0) {
        alert("Occorre inserire il CAP");
        cap.focus();
        return false;
    }
    if (cap.value.length != 0) {
        if ((!checknumber(cap.value)) || (cap.value.length < 5)) {
            alert("CAP inserito non valido!\nIl formato corretto prevede 5 cifre");
            cap.focus();
            return false;
        }
    }
    if (citta.value.length == 0) {
        alert("Occorre selezionare la Città o il Paese");
        citta.focus();
        return false;
    }
    if (indirizzo.value.length == 0) {
        alert("Occorre inserire l\'Indirizzo");
        indirizzo.focus();
        return false;
    }
    if (telefono.value.length == 0) {
        alert("Occorre inserire il N.ro di Telefono");
        telefono.focus();
        return false;
    }
    if (telefono.value.length != 0) {
        if (!checknumber(telefono.value)) {
            alert("Telefono inserito non valido!\nInserire soltanto le cifre");
            telefono.focus();
            return false;
        }
    }
    if (data.value.length == 0) {
        alert("Occorre inserire la Data di Nascita");
        data.focus();
        return false;
    }
    if (data.value.length != 0) {
        if (!checkeurodate(data.value)) {
            alert("Data o Formato Data non valido!\nIl formato ammesso è gg/mm/aaaa");
            data.focus();
            return false;
        }
    }
    if (email.value.length == 0) {
        alert("Occorre inserire l\'indirizzo email");
        email.focus();
        return false;
    }
    if (user.value.length == 0) {
        alert("Occorre inserire la UserName");
        user.focus();
        return false;
    }
    if (user.value.length < 4) {
        alert("La UserName deve contenere almeno 4 caratteri");
        user.focus();
        return false;
    }
    if (pwd1.value.length == 0) {
        alert("Occorre inserire la Password");
        pwd1.focus();
        return false;
    }
    if (pwd1.value.length < 6) {
        alert("La Password deve contenere almeno 6 caratteri");
        pwd1.focus();
        return false;
    }
    if ((pwd1.value.length != 0) && (pwd2.value.length == 0)) {
        alert("Occorre confermare la Password");
        pwd2.focus();
        return false;
    }
    if (!chk.checked) {
        alert("E' necessario dare il consenso per dati personali");
        chk.focus();
        return false;
    }
    if ((pwd1.value.length != 0) && (pwd2.value.length != 0)) {
        if (pwd1.value != pwd2.value) {
            alert("Le Password inserite non coincidono");
            pwd2.focus();
            return false;
        }
    }
}
function ControllaEmail(email) {
    if (email == null)
        email = document.all('txtEmail');
    if (email.value.length == 0) {
        alert("Occorre inserire l'indirizzo Email");
        email.focus();
        return false;
    }
    if (IsEmailValid(email.value) == false) {
        email.focus();
        return false;
    }
}

function IsEmailValid(Temp) {
    var EmailOk = true;
    var AtSym = Temp.indexOf('@')
    var Period = Temp.lastIndexOf('.')
    var Space = Temp.indexOf(' ')
    var Length = Temp.length - 1
    // Array is from 0 to length-1

    if ((AtSym < 1) || (Period <= AtSym + 1) || (Period == Length) || (Space != -1)) {
        alert("Inserire un indirizzo E-mail valido");
        EmailOk = false;
    }
    return EmailOk;
}
function Focusizza() {
    if (document.getElementById('ctl00_Main_Registrazione_txtNome') != null)
        document.getElementById('ctl00_Main_Registrazione_txtNome').focus();
    else {
        if (document.getElementById('ctl00_Main_Login_txtUserId') != null)
            document.getElementById('ctl00_Main_Login_txtUserId').focus();
    }
    //alert(document.getElementById("cmbSezione").options(document.getElementById("cmbSezione").selectedIndex).text);
    //if (document.all("cmbSezione") != null)
    //{
    //    document.all("cmbSezione").focus();
    //    document.all("cmbSezione").onchange();
        
    //}
    //if (CurrentPage() == "default.aspx") 
    //{
    //    createPlayer();
    //}
}
function OnlyHome() {
    if (CurrentPage() == "default.aspx") 
    {
       SWFHome();
    }
}
function checkData(fieldData) {
    if (fieldData.value == '') {
        return true;
    }
    if (!checkeurodate(fieldData.value)) {
        alert("Data o Formato Data non valido!\nIl formato ammesso è gg/mm/aaaa");
        fieldData.focus();
        return false;
    }
    return true;
}
function ControllaLogin() {
    user = document.getElementById('ctl00_Main_Login_txtUserId');
    password = document.getElementById('ctl00_Main_Login_txtPassword');
    if (user.value.length == 0) {
        alert("Occorre inserire la UserName");
        user.focus();
        return false;
    }
    if (password.value.length == 0) {
        alert("Occorre inserire la Password");
        password.focus();
        return false;
    }
}
function CurrentPage() {
    return document.location.pathname.substr(document.location.pathname.indexOf("/", 1) + 1);
}
function createPlayer()
{
    var s1 = new SWFObject('video/player.swf', 'playlist', '470', '320', '9');
    s1.addParam('allowscriptaccess', 'always');
    s1.addParam('allowfullscreen', 'true');
    s1.addParam('wmode', 'transparent');
    s1.addVariable('width', '470');
    s1.addVariable('height', '320');
    s1.addVariable('displaywidth', '320');
    s1.addVariable('displayheight', '240');
    s1.addVariable('file', 'public/xml/homeplaylist.xml');
    s1.addVariable('overstretch', 'false');
    s1.addVariable('autostart', 'true');
    s1.addVariable('shuffle', 'false');
    s1.addVariable('repeat', 'list');
    s1.addVariable('thumbsinplaylist', 'true');
    s1.addVariable('backcolor', '#ffffff'); // face of buttons
    s1.addVariable('frontcolor', '#ffba00'); // button symbols & playlist text
    s1.addVariable('lightcolor', '#ffe900'); // highlighted playlist item
    s1.addVariable('screencolor', '#f98321'); // screen background color
    s1.addVariable('enablejs', 'true');
    s1.addVariable('javascriptid', 'playlist');
    s1.write('homespace');
}
function loadFile(swf, obj) {
    alert("quimov");
    thisMovie(swf).loadFile(obj);
};

function thisMovie(movieName) {
    if (navigator.appName.indexOf('Microsoft') != -1) {
        return window[movieName];
    }
    else {
        return document[movieName];
    }
};

function AggiornzaSezione(sez) {
    alert("quisez");
    alert(sez.options(sez.selectedIndex).text);
    loadFile({ file: sez.options(sez.selectedIndex).text + '_videoplaylist.xml' }); 
    return false;
}
