function loadswf(swf, w, h){
	document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
	document.write("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\"");
   	document.write("width=\""+w+"\" height=\""+h+"\">");
    document.write("<param name='movie' value='"+swf+"' />\n");
    document.write("<param name='quality' value='high' /><param name='wmode' value='transparent' />\n");
    document.write("<embed src=\""+swf+"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\"></embed>");
    document.write("</object>\n");
}


var indirizzoEmail;

function checkEmailAddress(field) {

     var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.biz)|(\..{2,2}))$)\b/gi);
     
     if (goodEmail){
        indirizzoEmail = true
     } 
     else {
        alert('Inserire un indirizzo email valido');
        field.focus();
        field.select();
        indirizzoEmail = false;
        }
  	return indirizzoEmail;
}

function showCalendario(nomediv){
	if(nomediv!=''){
		document.getElementById('table_default').style.display = "none";
		// Qui impostare tutti i div come none
		document.getElementById('table_castiglione').style.display = "none";
		document.getElementById('table_corciano').style.display = "none";
		document.getElementById('table_magione').style.display = "none";
		document.getElementById('table_panicale').style.display = "none";
		document.getElementById('table_paciano').style.display = "none";
		document.getElementById('table_pieve').style.display = "none";
		document.getElementById('table_passignano').style.display = "none";
		document.getElementById('table_piegaro').style.display = "none";
		document.getElementById('table_tuoro').style.display = "none";
		
		
		document.getElementById('table_' + nomediv).style.display = "block";
	}
}

function downloadTariffe(){
	thisForm = document.form_tariffe;
	if(thisForm.comune.selectedIndex==0){
		alert("Selezionare un comune");
		return
	}
	if(thisForm.modulo.selectedIndex==0){
		alert("Selezionare un modulo");
		return
	}
	
	thisForm.action = 'pdf/' + thisForm.comune.options[thisForm.comune.selectedIndex].value + '_' + thisForm.modulo.options[thisForm.modulo.selectedIndex].value + '.pdf';
	thisForm.target = '_blank';
	thisForm.submit();
}

function popupPanicale(){
	
		if(document.documentElement){
			posx = document.documentElement.clientWidth;
			posy = document.documentElement.scrollTop;
		}
		else if(document.body){
			posx = document.body.clientWidth;
			posy = document.body.scrollTop;
		}
		else if(window){
			posx = window.innerWidth;
			posy = window.pageYOffset;
		}
		document.getElementById('cartina_zoom').style.top = (posy+1) + 'px';
		document.getElementById('cartina_zoom').style.left = ((posx-1210)/2) + 'px';
		document.getElementById('cartina_zoom').style.display = 'block';
	
}

function popupMagione(){
	
		if(document.documentElement){
			posx = document.documentElement.clientWidth;
			posy = document.documentElement.scrollTop;
		}
		else if(document.body){
			posx = document.body.clientWidth;
			posy = document.body.scrollTop;
		}
		else if(window){
			posx = window.innerWidth;
			posy = window.pageYOffset;
		}
		document.getElementById('magione_zoom').style.top = (posy+1) + 'px';
		document.getElementById('magione_zoom').style.left = ((posx-1000)/2) + 'px';
		document.getElementById('magione_zoom').style.display = 'block';
	
}

function cartinaMagioneClose(){
	
	document.getElementById('magione_zoom').style.display = 'none';
	document.getElementById('magione_zoom').style.top = 0 + 'px';
	document.getElementById('magione_zoom').style.left = 0 + 'px';
}

function cartinaClose(){
	
	document.getElementById('cartina_zoom').style.display = 'none';
	document.getElementById('cartina_zoom').style.top = 0 + 'px';
	document.getElementById('cartina_zoom').style.left = 0 + 'px';
}

function zoomPhoto(image){
	switch(image){
		case "borghetto":
			numfoto = 1;
		break;
		case "castelrigone":
			numfoto = 2;
		break;
		case "castiglionedellago":
			numfoto = 6;
		break;
		case "cittadellapieve":
			numfoto = 4;
		break;
		case "corciano":
			numfoto = 3;
		break;
		case "gioiella":
			numfoto = 2;
		break;
		case "magione":
			numfoto = 6;
		break;
		case "moiano":
			numfoto = 2;
		break;
		case "montedellago":
			numfoto = 3;
		break;
		case "paciano":
			numfoto = 4;
		break;
		case "panicale":
			numfoto = 5;
		break;
		case "passignano":
			numfoto = 3;
		break;
		case "piegaro":
			numfoto = 5;
		break;
		case "pobandino":
			numfoto = 1;
		break;
		case "pozzuolo":
			numfoto = 3;
		break;
		case "sanfeliciano":
			numfoto = 4;
		break;
		case "sanmariano":
			numfoto = 2;
		break;
		case "sansavino":
			numfoto = 5;
		break;
		case "santarcangelo":
			numfoto = 4;
		break;
		case "solomeo":
			numfoto = 2;
		break;
		case "tavernelle":
			numfoto = 4;
		break;
		case "torricella":
			numfoto = 2;
		break;
		case "tuoro":
			numfoto = 2;
		break;
		case "vernazzano":
			numfoto = 1;
		break;
		case "villastrada":
			numfoto = 2;
		break;
	}
	contfoto = 1;
	citta = image;
	document.getElementById('pulback').style.display = 'none';
	document["zoom_image"].src = "images/spacer.gif";
	document["zoom_image"].src = "areogallery/" + image + "_zoom_1.jpg";
	document.forms[0].numfoto.value = 'foto ' + contfoto + ' di ' + numfoto;
	if(contfoto<numfoto) 
		document.getElementById('pulforward').style.display = 'block';
	
	checkLoad();
}

function zoomClose(){
	
	document.getElementById('photo_zoom').style.display = 'none';
	document["zoom_image"].src = "images/spacer.gif";
	document.getElementById('photo_zoom').style.top = 0 + 'px';
	document.getElementById('photo_zoom').style.left = 0 + 'px';
	contfoto = 1;
}

function checkLoad(){
	if (document["zoom_image"].complete){
		if(document.documentElement){
			posx = document.documentElement.clientWidth;
			posy = document.documentElement.scrollTop;
		}
		else if(document.body){
			posx = document.body.clientWidth;
			posy = document.body.scrollTop;
		}
		else if(window){
			posx = window.innerWidth;
			posy = window.pageYOffset;
		}
		document.getElementById('photo_zoom').style.top = (posy+1) + 'px';
		document.getElementById('photo_zoom').style.left = ((posx-640)/2) + 'px';
		document.getElementById('photo_zoom').style.display = 'block';
	}
	else{
		timerID = setTimeout("checkLoad()",10);
	}
}

function zoomBack(){
	contfoto--;
	if(contfoto==1) 
		document.getElementById('pulback').style.display = 'none';
	
	if(contfoto<numfoto) 
		document.getElementById('pulforward').style.display = 'block';
	else
		document.getElementById('pulforward').style.display = 'none';
	
	document["zoom_image"].src = "images/spacer.gif";
	document["zoom_image"].src = "areogallery/" + citta + "_zoom_"+ contfoto +".jpg";
	document.forms[0].numfoto.value = 'foto ' + contfoto + ' di ' + numfoto;
	
}

function zoomForward(){
	contfoto++;
	if(contfoto<numfoto) 
		document.getElementById('pulforward').style.display = 'block';
	else
		document.getElementById('pulforward').style.display = 'none';
	document.getElementById('pulback').style.display = 'block';
	document["zoom_image"].src = "images/spacer.gif";
	document["zoom_image"].src = "areogallery/" + citta + "_zoom_"+ contfoto +".jpg";
	
	document.forms[0].numfoto.value = 'foto ' + contfoto + ' di ' + numfoto;
	
}
