function verify(form) { 	
	  for (i=0; i<form.elements.length; i++ ) { 
		if ((form.elements[i].type=="text" || form.elements[i].type=="password" || form.elements[i].type=="radio") &&	form.elements[i].value == "") { 
		  if(form.elements[i].focus) form.elements[i].focus();
		  alert("Campo richiesto vuoto: " + form.elements[i].name);
		  return false;		
		} else  if (form.elements[i].type=="password" && form.elements[i].name == "CODICEOP"){
			if(form.elements[i].value != "MWSP"){
				alert("Il codice inserito non e' valido.");
				 return false;
			}
		} else  if (form.elements[i].type=="text" && form.elements[i].name == "EMAIL"){
			var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
			if (!espressione.test(form.elements[i].value)){
				if(form.elements[i].focus) form.elements[i].focus();
				alert("L'email non sembra corretta");
				return false;				
			}
		} else  if (form.elements[i].type=="select-one"){		
			if(document.elements[i].selectedIndex==-1){
				if(form.elements[i].focus) form.elements[i].focus();
				alert("Campo richiesto vuoto");
				return false;
			}
		}
	  }
	  return true;
}
function getWindowHeight() { 
    var p = [window.innerHeight ? window.innerHeight : null, document.body ? document.body.clientHeight : null, document.documentElement ? document.documentElement.clientHeight : null];
    for (var i = 0; i < p.length; i++) {
        if (p[i] > 0) return p[i];
    }
    return 0;
}

function getWindowWidth() { 
    var p = [window.innerWidth ? window.innerWidth : null, document.documentElement ? document.documentElement.clientWidth : null, document.body ? document.body.clientWidth : null];
    for (var i = 0; i < p.length; i++) {
        if (p[i] > 0) return p[i];
    }
    return 0;
}

function showVideo(id){    
    var f_width = getWindowWidth();
    var f_height = getWindowHeight();
    var h = '<div id="video'+id+'" class="videoBack">';
    h += '<div id="video'+id+'C" class="videoC" style=" position:relative;margin-top:20px;margin-left:'+parseInt(f_width/2 - 320)+'px">';
	h += '<div id="closevideo" style="height:50px; width:50px; position:absolute; z-index:99;margin-left:640px;cursor:pointer;background:url(../img/X_close.png) no-repeat" onclick="hideVideo('+id+');"><img src="../img/trasp.gif" width="50" height="50" onclick="hideVideo('+id+');" alt="chiudi" /></div>';
    h += '<div style="height:560px; width:640px;padding-top:50px;">';
    h += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="640" height="520" id="player'+id+'" align="middle">';
    h += '<param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';
    h += '<param name="movie" value="../swf/player'+id+'.swf" />';
    h += '<embed src="../swf/player'+id+'.swf" quality="high" bgcolor="#ffffff" width="640" height="520" name="player'+id+'" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
    h += '</object>';
    h += '</div>';
    h += '</div>';
    h += '</div>';
    
	var div = document.getElementById("videocarrier");
	if(div == null){
    	div = document.createElement("DIV");
    	document.body.appendChild(div);
		div.id = "videocarrier";		
	}
    div.innerHTML = h;

    div.style["height"] = f_height + "px";

	if(typeof(pngfix) != typeof(undefined)){
		pngfix();
	}
}

function showPopup() { 
    var f_width = getWindowWidth();
    var f_height = getWindowHeight();
    
    var h = '<div id="video999" class="videoBack">';
    h += '<div id=popesagerati" class="videoC" style=" position:relative;margin-top:50px;margin-left:'+parseInt(f_width/2 - 320)+'px">';
    h += '<div id="closevideo" style="height:50px; width:50px; position:absolute; z-index:99;margin-left:640px;cursor:pointer;background:url(../img/X_close.png) no-repeat" onclick="hideVideo(999);"><img src="../img/trasp.gif" width="50" height="50" onclick="hideVideo(999);" alt="chiudi" /></div>';
	h += '<div id="col" class="arial_14_gre_m"  style="width:600px;padding:20px;">';
    h += '<h2><span class="Stile2">Schema ad uso dei consumatori &quot;esagerati&quot;</span></h2>';
    h += '<ol>';
    h += '<li><span class="Stile1"><strong><em>Consumi  allineati con la media nazionale</em></strong> (fino a 80 kWh/mese per kW di potenza):<br />';
    h += '<span class="bold Stile3">11 &euro; per kW</span></span><span class="Stile1"> di potenza del  contatore, tutto compreso (a parte imposte e Iva);<br />';
    h += '<br />';
    h += '</span></li>';
    h += '<li class="Stile1"><strong><em>Consumi superiori alla media nazionale</em></strong> (fra 80 kWh/mese e 100 kWh/mese per kW di potenza): <span class="bold Stile3">15 &euro; per kW</span> di potenza del contatore, tutto compreso (a parte  imposte e Iva);<br />';
    h += '<br />';
    h += '</li>';
    h += '<li><span class="Stile1"><strong><em>Consumi MOLTO superiori alla media nazionale</em></strong> (oltre 133%): <span class="bold Stile3">scatta  il “tetto per l&rsquo;efficienza”</span></span>';
    h += '<ol class="Stile1">';
    h += '<li>18 &euro; per kW di potenza del contatore</li>';
    h += '<li>0,018 &euro;/kWh per i consumi che superano  i 100 kWh/mese<br />';
    h += '<br />';
    h += '</li>';
    h += '</ol>';
    h += '<span class="Stile1"><em><span class="bold Stile3">Perch&eacute;?</span><br />';
    h += '</em>L&rsquo;energia &egrave; una risorsa utile e preziosa e Sorgenia  non vuole incentivarne un uso sconsiderato grazie a un prezzo che non cambia in  base ai consumi. <br />';
    h += 'Per questo abbiamo deciso di definire un &quot;tetto&quot; oltre il quale una famiglia  sta davvero sprecando l&rsquo;energia, a danno dell&rsquo;ambiente e di tutti gli altri  consumatori: oltre questo tetto, il prezzo della bolletta non &egrave; pi&ugrave; <em>flat</em>, ma ognuno paga quanto consuma (anzi, quanto spreca...)</span>';
    h += '<p></li></ol>';
    h += '</div>';
    h += '</div>';
    h += '</div>';
	
	var div = document.getElementById("videocarrier");
	if(div == null){
    	div = document.createElement("DIV");
    	document.body.appendChild(div);
		div.id = "videocarrier";		
	}
    div.innerHTML = h;

    div.style["height"] = f_height + "px";

	if(typeof(pngfix) != typeof(undefined)){
		pngfix();
	}
}

function hideVideo(id){
	var div = document.getElementById("video"+id);
	document.getElementById("video"+id).innerHTML="";
	div.parentNode.removeChild(div);
}

function setValue1(val, label){
	var hiddenFA = document.getElementById('hiddenFA');
	hiddenFA.value = val;
	var selectShow = document.getElementById('selectShow1');
	selectShow.value = label;
	var div = document.getElementById('faMenu');
	div.style["display"] = "none"
}
function setValue2(val, label){
	var hiddenSA = document.getElementById('hiddenSA');
	hiddenSA.value = val;
	var selectShow = document.getElementById('selectShow2');
	selectShow.value = label;
	var div = document.getElementById('saMenu');
	div.style["display"] = "none"
}
function shoowMenu1(who){
	var div = document.getElementById(who);
	div.style["display"] = "block";
	div.style["left"] = document.getElementById('selectShow1').offsetLeft + "px";
	div.style["top"] = "68px";
}
function shoowMenu2(who){
	var div = document.getElementById(who);
	div.style["display"] = "block";
	div.style["left"] = document.getElementById('selectShow2').offsetLeft + "px";
	div.style["top"] = "12px";
}
function hideMenu(who){
	var div = document.getElementById(who);
	div.style["display"] = "none";
}
