function id(h){return document.getElementById(h);}

function ResizeMe(me,c,a){var cw,ch,mh,mw;id(me).style.opacity="0";
mh=id(me).height;mw=id(me).width; 

if(c=="w"){cw=hws().width;ch=hws().height;}else{cw=id(me).parentNode.clientWidth;ch=id(me).parentNode.clientHeight;}
if(Math.abs(cw-mw)>Math.abs(ch-mh)){mh=(mh*cw)/mw;mw=cw;}else{mw=(mw*ch)/mh;mh=ch;}

if(a=="y"){while(mh<ch||mw<cw){if(Math.abs(cw-mw)>Math.abs(ch-mh)){mh=(mh*cw)/mw;mw=cw;}else{mw=(mw*ch)/mh;mh=ch;}}}else{
id(me).parentNode.style.backgroundColor="#000";id(me).style.display="block";
id(me).style.margin=Math.abs(ch-mh)/2+"px auto";}
id(me).height=mh;id(me).width=mw;
id(me).style.opacity="1";


}
function hws(){var s=new Image();if(typeof(window.innerWidth)=='number'){s.width=window.innerWidth;s.height=window.innerHeight;}
else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){s.width=document.documentElement.clientWidth;s.height=document.documentElement.clientHeight;}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){s.width=document.body.clientWidth;s.height=document.body.clientHeight;}return s;}



function createxmlhttp2(){var xmlhttp=null;try{xmlhttp=new XMLHttpRequest();}catch(e){try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlhttp;}
function ajaxget(pag,dati,myaction){var myreq=createxmlhttp2();var myhandy=function()
{if(myreq.readyState==4&&myreq.status==200){myaction(myreq.responseText);}}
myreq.onreadystatechange=myhandy;myreq.open("GET",pag+"?"+dati);myreq.send(null);}
function ajaxpost(pagina,dati,myaction){var myreqp=createxmlhttp2();var myhandyp=function()
{if(myreqp.readyState==4&&myreqp.status==200){myaction(myreqp.responseText);}}
myreqp.onreadystatechange=myhandyp;myreqp.open("POST",pagina,true);myreqp.setRequestHeader("Content-type","application/x-www-form-urlencoded");myreqp.setRequestHeader("Content-length",dati.length);myreqp.setRequestHeader("Connection","close");myreqp.send(dati);}
function inpdate(nome,nuovadata){if(nuovadata!=""){var arrdate=nuovadata.split('-');}var sel;var giorni;var mesi;var anni;var giorni="<select name=\"giorni_"+nome+"\" class="+nome+">";for(var i=1;i<=31;i++){if(arrdate['0']==i){sel="SELECTED";}else{sel="";}giorni+="<option value=\""+i+"\" "+sel+">"+i+"</option>";}giorni+="</select>";var mesi="<select name=\"mesi_"+nome+"\" class="+nome+">";for(var i=1;i<=12;i++){if(arrdate['1']==i){sel="SELECTED";}else{sel="";}mesi+="<option value=\""+i+"\" "+sel+">"+i+"</option>";}mesi+="</select>";var anni="<select name=\"anni_"+nome+"\" class="+nome+">";for(var i=1990;i<=2020;i++){if(arrdate['2']==i){sel="SELECTED";}else{sel="";}anni+="<option value=\""+i+"\" "+sel+">"+i+"</option>";}anni+="</select>";var style="<style>."+nome+"{width:60px;text-align:center}</style>";document.write(style);document.write(giorni+"-"+mesi+"-"+anni);}

function stampares(testo){id('sottosez').innerHTML=testo;}

function popbox(cont){
		
	id('pop').innerHTML ="<span onclick =\"chiudipop()\" class=chiudi_pop>X</span><br>"+id(cont).innerHTML;
	id('pop').style.display='block';
	id('fade').style.display='block';	
	
}

function chiudipop(){
	id('pop').innerHTML ="";
	id('pop').style.display='none';
	id('fade').style.display='none';	
}



function popgalbox(cont){
		
	id('boxgal').innerHTML ="<span onclick =\"chiudigalbox()\" class=chiudi_pop_gal>X</span>"+cont;
	id('boxgal').style.display='block';
	id('fade').style.display='block';	
	
}

function chiudigalbox(){
	id('boxgal').innerHTML ="";
	id('boxgal').style.display='none';
	id('fade').style.display='none';	
}

function popnews(cont){id('bnews').innerHTML="<span onclick =\"chiudinews()\" class=chiudi_pop_news>X</span>"+id(cont).innerHTML;id('bnews').style.display='block';Cufon.refresh();id('fade').style.display='block';}
function chiudinews(){	id('bnews').innerHTML ="";	id('bnews').style.display='none';	id('fade').style.display='none';	}



function ctrl_vuoti(myform, mess){var errori=0;var myf=document.forms[myform];for(var intLoop = 0; intLoop<myf.elements.length; intLoop++){if(myf.elements[intLoop].value==""){errori++;}}if(errori>0){alert(mess);return false;}}






function  hs(x, h){if(id(x).style.opacity==1){id(x).style.opacity=0;id(h).innerHTML="[ + ]";}else{id(x).style.opacity=1;id(h).innerHTML="[ - ]";}}

			function mostramodulo(mydiv){var prova = document.getElementById(mydiv);if (prova.style.display == "none"){prova.style.display = "block";}else{prova.style.display = "none";}}
			
			

function controlla_lingua(l){if(id('titolo_'+l).value!="" && id('corpo_'+l).value!=""){id('full_'+l).value ="1";id('checkme_'+l).innerHTML="<img src='img/ok_lng.png' alt='ok' />";} else {id('full_'+l).value ="";}}
function submitform(myform, messx){document.forms[myform].elements['azione'].value=messx;document.forms[myform].submit();}

function StripTags(strMod){
    if(arguments.length<3) strMod=strMod.replace(/<\/?(?!\!)[^>]*>/gi, '');
    else{
        var IsAllowed=arguments[1];
        var Specified=eval("["+arguments[2]+"]");
        if(IsAllowed){
            var strRegExp='</?(?!(' + Specified.join('|') + '))\b[^>]*>';
            strMod=strMod.replace(new RegExp(strRegExp, 'gi'), '');
        }else{
            var strRegExp='</?(' + Specified.join('|') + ')\b[^>]*>';
            strMod=strMod.replace(new RegExp(strRegExp, 'gi'), '');
        }
    }
    return strMod;
}
function StripCommentSGML(strMod){
    //Thanks to: http://www.faqts.com/knowledge_base/view.phtml/aid/21761
    strMod=strMod.replace(/<!(?:--[sS]*?--s*)?>s*/g,''); //double dashes escaped cuz of SGML comment
    return strMod;
}
			
			
