var tipo ="";

function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object



// creazione menu progetti
function menu2(){
if (http.readyState == 4) {
if (http.responseText.indexOf('invalid') == -1) {
resultsM = http.responseText.split("::");
} 
document.getElementById('menuP1').innerHTML = resultsM[0];
document.getElementById('menuP2').innerHTML = resultsM[1];
isWorking = false;
menuBreve1();
}
}

var isWorking = false;
function menu1() {
if (!isWorking && http) {
var url = "leggiMenuPrgt.php";
http.open("GET", url, true);
http.onreadystatechange = menu2;
isWorking = true;
http.send(null);
}
}


// creazione menu progetti Brevi
function menuBreve2(){
if (http.readyState == 4) {
if (http.responseText.indexOf('invalid') == -1) {
resultsB = http.responseText;
}
txtMB="<center><img src='imgBase/mappa_mondo.gif' width='154' height='86' border='0'><br><br>";
txtMB+="<select onChange='mostraProgBreve1()' class='form' id='prgtB'>";
txtMB+="<option value='scegli un paese'>scegli un paese</option>";
txtMB+=resultsB;
txtMB+="</select><br></center>";
document.getElementById("progettiBrevi").innerHTML = txtMB;
isWorking = false;
}
}

var isWorking = false;
function menuBreve1() {
if (!isWorking && http) {
var url = "leggiMenuPrgtBreve.php";
http.open("GET", url, true);
http.onreadystatechange = menuBreve2;
isWorking = true;
http.send(null);
}
}


// creazione pagina progetti
function progetto2(){
if (http.readyState == 4) {
if (http.responseText.indexOf('invalid') == -1) {

txtPrgt = http.responseText;
/* window.alert(results[0]); */
} 
document.getElementById('centrale').innerHTML = txtPrgt;

isWorking = false;
}
}

var isWorking = false;
function progetto1(nId) {
numID = nId;
if (!isWorking && http) {
var url = "leggiProgetto.php?id=" + numID;
/* window.alert(url_cerca); */
http.open("GET", url, true);
http.onreadystatechange = progetto2;
isWorking = true;
http.send(null);
}
}

// mostra progetto breve
function mostraProgBreve2(){
if (http.readyState == 4) {
if (http.responseText.indexOf('invalid') == -1) {
resultsPB = http.responseText;
resultsPB += "<br><a href='javascript:menuBreve1()'>&laquo; indietro</a>";
} 

document.getElementById('progettiBrevi').innerHTML = resultsPB;
isWorking = false;
}
}
var idP=0;
var isWorking = false;
function mostraProgBreve1() {
if (!isWorking && http) {
idP = document.getElementById('prgtB').options[document.getElementById('prgtB').selectedIndex].value;
var url = "leggiPrgtBreve.php?nazione=" + idP;
/* window.alert(url); */
http.open("GET", url, true);
http.onreadystatechange = mostraProgBreve2;
isWorking = true;
http.send(null);
}
}
function leggiPagina(x) {
}


// creazione pagine
function leggiPagina2(){
if (http.readyState == 4) {
if (http.responseText.indexOf('invalid') == -1) {
txtTipo=tipo.replace(/_/g," ");
results = "<p class='titoloPagina'>" + txtTipo + "</p>" + http.responseText;
} 
document.getElementById('centrale').innerHTML = results;
isWorking = false;
}
}

var isWorking = false;
function leggiPagina1(x) {
tipo = x;
if (!isWorking && http) {
var url = "leggiPagine.php?tipo=" + tipo;
/* window.alert(url); */
http.open("GET", url, true);
http.onreadystatechange = leggiPagina2;
isWorking = true;
http.send(null);
}
}



// creazione menuAnni
function menuAnno2(){
if (http.readyState == 4) {
if (http.responseText.indexOf('invalid') == -1) {
txt = http.responseText;
}
document.getElementById('pannAnni').style.display = "block";
document.getElementById('pannAnni').innerHTML = txt;
isWorking = false;
}
}

var isWorking = false;
function menuAnno1(anno) {
numAnno = anno;
if (!isWorking && http) {
var url = "leggiMenuAnni.php?anno=" + numAnno;
http.open("GET", url, true);
http.onreadystatechange = menuAnno2;
isWorking = true;
http.send(null);
}
}


// iscrizione newsletter
function news_si2(){
if (http.readyState == 4) {
if (http.responseText.indexOf('invalid') == -1) {
}
document.getElementById('avvisoForm').style.display = "block";
document.getElementById('avvisoForm').innerHTML = http.responseText;
isWorking = false;
}
}

var isWorking = false;
function news_si1() {
var chck = emailCheck(document.getElementById('indirizzo').value);
if(chck){
var mail = document.getElementById('indirizzo').value;
if (!isWorking && http) {
var url = "inserisci_iscritto.php?mail=" + mail;
http.open("GET", url, true);
http.onreadystatechange = news_si2;
isWorking = true;
http.send(null);
}
}
}


// iscrizione newsletter
function news_no2(){
if (http.readyState == 4) {
if (http.responseText.indexOf('invalid') == -1) {
}
document.getElementById('avvisoForm').style.display = "block";
document.getElementById('avvisoForm').innerHTML = http.responseText;
isWorking = false;
}
}

var isWorking = false;
function news_no1() {
var chck = emailCheck(document.getElementById('indirizzo').value);
if(chck){
var mail = document.getElementById('indirizzo').value;
if (!isWorking && http) {
var url = "elimina_iscritto.php?mail=" + mail;
http.open("GET", url, true);
http.onreadystatechange = news_no2;
isWorking = true;
http.send(null);
}
}
}








var Today=new Date();
var ThisDay=Today.getDay();
var ThisDate=Today.getDate();
var ThisMonth=Today.getMonth()+1;
var ThisYear=Today.getFullYear();
function DayTxt (DayNumber) {
var Day=new Array();
Day[0]="domenica";
Day[1]="luned&igrave;";
Day[2]="marted&igrave;";
Day[3]="mercoled&igrave;";
Day[4]="gioved&igrave;";
Day[5]="venerd&igrave;";
Day[6]="sabato";
return Day[DayNumber];
}
function MonthTxt (MonthNumber) {
var Month=new Array();
Month[1]="gennaio";
Month[2]="febbraio";
Month[3]="marzo";
Month[4]="aprile";
Month[5]="maggio";
Month[6]="giugno";
Month[7]="luglio";
Month[8]="agosto";
Month[9]="settembre";
Month[10]="ottobre";
Month[11]="novembre";
Month[12]="dicembre";
return Month[MonthNumber];
}
var MonthName=MonthTxt(ThisMonth);
var d = new Date();
var h = d.getHours();
var datadioggi=ThisDate+" "+MonthName+" "+ThisYear;

// scroll menu
var suGiu1=0;
var suGiu2=0;

$(document).ready(
function ()
{
$('#linkA1').click(
function() {
if(suGiu1==0){
$('#linkB1').slideDown(900);
document.getElementById("trng1").src='imgBase/f_giu.gif';
suGiu1=1;
}
else {
$('#linkB1').slideUp(900);
document.getElementById("trng1").src='imgBase/f_su.gif';
suGiu1=0;
}
}
);


$('#linkA2').click(
function() {
if(suGiu2==0){
$('#linkB2').slideDown(900);
document.getElementById("trng2").src='imgBase/f_giu.gif';
suGiu2=1;
}
else {
$('#linkB2').slideUp(900);
document.getElementById('pannAnni').style.display="none";
document.getElementById("trng2").src='imgBase/f_su.gif';
suGiu2=0;
}
}
)
}
);