/*
    jQuery(document).ready(function(){ 
        jQuery(document).pngFix(); 
        
    //alert("PNG fix attivo");


    jQuery(".newsletter").click(function () {
      jQuery("#formnewsletter").fadeIn(1000, function () {
        jQuery("formnewsletter").fadeIn(20);
      });
	return false;
    }); 

   jQuery(".chiudi").click(function () {
      //alert("chiudi form")
      jQuery("#formnewsletter").fadeOut(1000, function () {
        jQuery("formnewsletter").fadeOut(20);
      });
	return false;
    }); 
    }); 
 //
 */
 function checkOK() {
	var myURL = this.location.href;
	//alert("myURL ="+myURL);
	var myPos = myURL.lastIndexOf("?");
	myParam = myURL.substring(myPos+1, myURL.length);
	//alert("myParam ="+myParam);
//window.document.menuagenzie.SetVariable("dest", myParam);
//alert("myParam = "+myParam);
if(myParam == "OK") {
top.close();
}
}
//

 	function invio() { 
  		conferma = (confirm("Vi ringraziamo per la vostra attenzione.\nPremere OK per inviare la vostra richiesta"))        
        
       if (conferma == true)	{
       document.Info.submit();
       //history.go(-1);
       }
  }

	function testinvio() { 
		
		testnome();
		testcognome();
		testemail();
		check_newsletter();
		check_checkbox();
		if(error == false) {
		invio();
		} 
	}
	
		
	function testnome()	{
		if (document.Info.nome.value == "") 
		{Nom = prompt("Prego, digitare il proprio nome!","");
		document.Info.nome.value = Nom;
		testnome();
		}
	}

	function testcognome()	{
		if (document.Info.cognome.value == "") 
		{Cog = prompt("Prego, digitare il proprio cognome!","");
		document.Info.cognome.value = Cog;
		testcognome();
		}
	}
	
	function testemail()	{
		if (document.Info.e_mail.value == "" || document.Info.e_mail.value.indexOf('@', 0) == -1) 
		{Em = prompt("Indirizzo e-mail non valido!\nPrego digitare il corretto indirizzo e-mail",""); 
		document.Info.e_mail.value = Em;
		testemail();
		}
	}

	function testrichiesta()	{
		if (document.Info.Chiede.value == "") 
		{Rich = prompt("Prego, specificare la richiesta!","");
		document.Info.Chiede.value = Rich;
		testrichiesta();
		}
	}
	
	function cancella() {
	//var nom = document.getElementById('nome').value;
	//alert("nome = "+nom);
	document.getElementById('nome').value = "";
	document.getElementById('cognome').value = "";
	document.getElementById('e_mail').value = "";
	document.getElementById('tel').value = "";
	}

function 
check_checkbox() {
	if(document.Info.elements.privacy.checked) {
		//alert("Privacy OK");
		error = false;
	} else {
		//error = true;
		conferma = (confirm("Clicca qui per dichiarare di aver preso visione della nota e di aver dato il proprio consenso al trattamento dei dati."));
		       if (conferma == true)	{
		       error = true;
		       document.Info.elements.privacy.checked = true;
      invio();
	}
	}
}

function check_newsletter() {
	if(document.Info.elements.checknewsletter.checked) {
	document.Info.elements.newsletter.value = 'si';
	} else {
	document.Info.elements.newsletter.value = 'no';
	}
	//alert(document.Info.elements.newsletter.value);
}



/////////// FORM NEWSLETTER   ///////////

 	function invioNews() { 
  		conferma = (confirm("Vi ringraziamo per la vostra attenzione.\nPremere OK per inviare la vostra richiesta"))        
        
       if (conferma == true)	{
       document.Newsletter.submit();
       }
  }
  
  
	function testinvioNews() { 
		
		testnomeNews();
		testcognomeNews();
		testemailNews();
		// testrichiesta();
		check_checkboxNews();
		if(errorNews == false) {
		invioNews();
		} 
	}
	
		
	function testnomeNews()	{
		if (document.Newsletter.nome.value == "") 
		{Nom = prompt("Prego, digitare il proprio nome!","");
		document.Newsletter.nome.value = Nom;
		testnomeNews();
		}
	}

	function testcognomeNews()	{
		if (document.Newsletter.cognome.value == "") 
		{Cog = prompt("Prego, digitare il proprio cognome!","");
		document.Newsletter.cognome.value = Cog;
		testcognomeNews();
		}
	}
	
	function testemailNews()	{
		if (document.Newsletter.e_mail.value == "" || document.Newsletter.e_mail.value.indexOf('@', 0) == -1) 
		{Em = prompt("Indirizzo e-mail non valido!\nPrego digitare il corretto indirizzo e-mail",""); 
		document.Newsletter.e_mail.value = Em;
		testemailNews();
		}
	}

	
	function cancella() {
	//var nom = document.getElementById('nome').value;
	//alert("nome = "+nom);
	document.getElementById('nome').value = "";
	document.getElementById('cognome').value = "";
	document.getElementById('e_mail').value = "";
	document.getElementById('tel').value = "";
	}

function 
check_checkboxNews() {
	if(document.Newsletter.elements.privacy.checked) {
		//alert("Privacy OK");
		errorNews = false;
	} else {
		//error = true;
		conferma = (confirm("Clicca qui per dichiarare di aver preso visione della nota e di aver dato il proprio consenso al trattamento dei dati."));
		       if (conferma == true)	{
		       errorNews = true;
		       document.Newsletter.elements.privacy.checked = true;
      invio();
	}
	}
}

///////////////////////////////////////////

//
function popupWindow2(url2) {
  window.open(url2,'privacy','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=500,height=400,screenX=150,screenY=150,top=150,left=150')
}

//////////////////////////////////////////////

//
function popupNews() {
  window.open('newsletter.htm','newsletter','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=610,height=500,screenX=150,screenY=150,top=150,left=150')
}

//////////////////////////////////////////////

function set_cartella(arg) {
path = "pdf/"+arg+"/";
}

//
function carica_offerta(arg) {

eval('xmlDoc=loadXMLDoc("xml/'+arg+'");');

var ll = xmlDoc.getElementsByTagName("offerta").length;
var out = "";

var ll = xmlDoc.getElementsByTagName("offerta").length;
var out = "";
out += '<div id="risultati">';
out += '<table width="800" border="0" cellspacing="0" cellpadding="0">';
// titolo tabella
out += '<tr height="5">';
out += '<td colspan="3" bgcolor="#ceefbb" width="800" height="5">&nbsp;</td>';
out += '</tr>';
// prima riga tabella
out += '<tr height="20">';
out += '<td bgcolor="#ceefbb" class="tabella_alto_sx" align="right" valign="top" width="490" height="20">&nbsp;</td>';
out += '<td bgcolor="#ceefbb" width="10" height="20">&nbsp;</td>';
out += '<td bgcolor="#ceefbb" class="tabella_alto_dx" width="200" height="20">&nbsp;</td>';
out += '</tr>';
document.write(out);
var out1 = "";
for(n=0; n<ll; n++) {
offerta = xmlDoc.getElementsByTagName("offerta")[n].childNodes[0].data;
offerta = offerta.replace("#","<br>")
offerta = offerta.replace("","&agrave;")
offerta = offerta.replace("","&egrave;")
offerta = offerta.replace("","&igrave;")
offerta = offerta.replace("","&ograve;")
offerta = offerta.replace("","&ugrave;")
offerta = offerta.replace("","&rsquo;")
pdf = xmlDoc.getElementsByTagName("pdf")[n].childNodes[0].data;
//
if(pdf != "---") {
out1 += '<tr>';
out1 += '<td class="tabella_cella_sx" align="right" valign="top" width="490" height="18">'+offerta+'</td>';
out1 += '<td class="tabella_cella_centro" bgcolor="#ceefbb" width="10" height="18">&nbsp;</td>';
out1 += '<td id="cella_pdf'+n+'" class="tabella_cella_dx" width="200" height="18"><img src="immagini/pdf.gif" alt="" height="16" width="20" align="left" border="0"><a href="'+path+pdf+'" target="_blank" onmouseover="cella_on('+n+')" onmouseout="cella_off('+n+')">stampa/scarica pdf</a></td>';
out1 += '</tr>';
} else {
out1 += '<tr height="200">';
out1 += '<td colspan="3" align="center" valign="middle" bgcolor="#ceefbb" width="800" height="200">Non sono presenti offerte.</td>';
out1 += '</tr>';
}
}
document.write(out1);
// ultima riga tabella
var out2 = "";
out2 += '<tr>';
out2 += '<td bgcolor="#ceefbb" class="tabella_basso_sx" align="right" valign="top" width="490" height="20">&nbsp;</td>';
out2 += '<td bgcolor="#ceefbb" width="10" height="20">&nbsp</td>';
out2 += '<td bgcolor="#ceefbb" class="tabella_basso_dx" width="200" height="20">&nbsp</td>';
out2 += '</tr>';
out2 += '</table>';
            //
out2 += '</div>';
//
document.write(out2);
}

function apri(arg) {
if(arg != "http://www.umbriaitaliaincoming.com/") {
document.location.href = arg;
} else {
window.open(arg, '_blank');
}
}


//create the Cross-browser XMLHttpRequest object
function getFile(pURL,pFunc) {
    if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
        xmlhttp=new XMLHttpRequest();
        eval('xmlhttp.onreadystatechange='+pFunc+';');
        xmlhttp.open("GET", pURL, true); // leave true for Gecko
        xmlhttp.send(null);
    } else if (window.ActiveXObject) { //IE 
        xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
        if (xmlhttp) {
            eval('xmlhttp.onreadystatechange='+pFunc+';');
            xmlhttp.open('GET', pURL, false);
            xmlhttp.send();
        }
    }

}


function makeList() {
    if (xmlhttp.readyState==4) { 
        if (xmlhttp.status==200) { 
            var tmpArr=xmlhttp.responseText.split('\n');
            var out='<select name="states" size="1">';
            var tmp;
            var val;
            var txt;
            for (var idx=0;idx<tmpArr.length;idx++) {
                tmp=tmpArr[idx].split(',');
                val = tmp[0].replace('"','');
                val = val.replace('"','');
                txt = tmp[1].replace('"','');
                txt = txt.replace('"','');
                out += '<option value="'+val+'">'+txt+'</option>';
            }
            out += '</select>';
            document.getElementById('theExample').innerHTML=out;
        }
    }

}





function cella_on(arg) {
document.getElementById('cella_pdf'+arg).className = 'tabella_cella_dx_over';
}
function cella_off(arg) {
document.getElementById('cella_pdf'+arg).className = 'tabella_cella_dx';
}

function makeTable() {
    if (xmlhttp.readyState==4) { 
        if (xmlhttp.status==200) { 
            var tmpArr=xmlhttp.responseText.split('\n');
            var out='<table width="800" border="0" cellspacing="0" cellpadding="0">';
            // titolo tabella
            // out += '<tr height="56">';
			//out += '<td colspan="3" width="600" height="56"><img src="immagini/titolo_capodanno.jpg" alt="" height="56" width="600" border="0"></td>';
			// out += '</tr>';
			out += '<tr height="5">';
			out += '<td colspan="3" bgcolor="#ceefbb" width="800" height="5">&nbsp;</td>';
			out += '</tr>';
			
			// prima riga tabella
            out += '<tr height="20">';
			out += '<td bgcolor="#ceefbb" class="tabella_alto_sx" align="right" valign="top" width="490" height="20">&nbsp;</td>';
			out += '<td bgcolor="#ceefbb" width="10" height="20">&nbsp;</td>';
			out += '<td bgcolor="#ceefbb" class="tabella_alto_dx" width="200" height="20">&nbsp;</td>';
			out += '</tr>';
			//
            var tmp;
            var val;
            var txt;
            for (var idx=0;idx<tmpArr.length;idx++) {
                tmp=tmpArr[idx].split(',');
                val = tmp[0].replace('"','');
                val = val.replace('"','');
                txt = tmp[1].replace('"','');
                txt = txt.replace('"','');
                //
            if(val != " ") {
                out += '<tr>';
				out += '<td class="tabella_cella_sx" align="right" valign="top" width="490" height="18">'+val+'</td>';
				out += '<td class="tabella_cella_centro" bgcolor="#ceefbb" width="10" height="18">&nbsp;</td>';
				out += '<td id="cella_pdf'+idx+'" class="tabella_cella_dx" width="200" height="18"><img src="immagini/pdf.gif" alt="" height="16" width="20" align="left" border="0"><a href="'+path+txt+'" target="_blank" onmouseover="cella_on('+idx+')" onmouseout="cella_off('+idx+')">stampa/scarica pdf</a></td>';
				out += '</tr>';
				} else {
				out += '<tr height="200">';
			out += '<td colspan="3" align="center" valign="middle" bgcolor="#ceefbb" width="800" height="200">Non sono presenti offerte.</td>';
			out += '</tr>';
				}
            }
            // ultima riga tabella
            out += '<tr>';
			out += '<td bgcolor="#ceefbb" class="tabella_basso_sx" align="right" valign="top" width="490" height="20">&nbsp;</td>';
			out += '<td bgcolor="#ceefbb" width="10" height="20">&nbsp</td>';
			out += '<td bgcolor="#ceefbb" class="tabella_basso_dx" width="200" height="20">&nbsp</td>';
			out += '</tr>';
			out += '</table>';
            //
            document.getElementById('risultati').innerHTML=out;
        }
    }

}

