
function ClearText(txtInput) {
  if (txtInput.value == txtInput.defaultValue) {
    txtInput.value = "";
  }
}


function controlla(){

 if(document.modulo.form_chiave.value=="cerca nel sito"){
 alert("ATTENZIONE ! inserire il testo per la ricerca");
return false;
}
else{

		if(document.modulo.form_chiave.value==""){
			alert("ATTENZIONE ! inserire il testo per la ricerca");
			 document.modulo.form_chiave.focus();
			return false;
		}
		else{
			
           return true;
		}
}
}   
	
function controllaIns(){



		if(document.modulo2.annuncio.value==""){
			alert("ATTENZIONE ! inserire l'annuncio");
			 document.modulo2.annuncio.focus();
			return false;
			}
		else{
			if(document.modulo2.categoria.value=="categoria"){
			alert("ATTENZIONE ! scegliere la categoria");
			 document.modulo2.categoria.focus();
			return false;
		}
		else{
           return true;
		}

}    
}  


var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<b>Puoi inserire ancora <span id="'+theform.toString()+'">'+thelimit+'</span> caratteri</b>'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
}
}



var bookmarkurl="http://www.infoviterbo.it"
var bookmarktitle="InfoViterbo.it"
function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

function controllaIns(){
		if(document.riservato.user.value==""){
			alert("ATTENZIONE ! inserire Username");
			 document.riservato.user.focus();
			return false;
			}
		else{
			if(document.riservato.pass.value==""){
			alert("ATTENZIONE ! Inserire Password");
			 document.riservato.pass.focus();
			return false;
		}
		else{
           return true;
		}

}    
}  


adTime=10;  // seconds ad reminder is shown
chanceAd=1; // ad will be shown 1 in X times (put 1 for everytime)

var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"
adCount=0;
function initAd(){
	if(!ns && !ie && !w3) return;
	if(ie)		adDiv=eval('document.all.sponsorAdDiv.style');
	else if(ns)	adDiv=eval('document.layers["sponsorAdDiv"]');
	else if(w3)	adDiv=eval('document.getElementById("sponsorAdDiv").style');
	randAd=Math.ceil(Math.random()*chanceAd);
        if (ie||w3)
        adDiv.visibility="visible";
        else
        adDiv.visibility ="show";
	if(randAd==1) showAd();
}
function showAd(){
if(adCount<adTime*10){adCount+=1;
	if (ie){documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
	documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;}	
	else if (ns){documentWidth=window.innerWidth/2+window.pageXOffset-20;
	documentHeight=window.innerHeight/2+window.pageYOffset-20;} 
	else if (w3){documentWidth=self.innerWidth/2+window.pageXOffset-20;
	documentHeight=self.innerHeight/2+window.pageYOffset-20;} 
	adDiv.left=documentWidth-200+calunit;adDiv.top =documentHeight-200+calunit;
	setTimeout("showAd()",100);}else closeAd();
}
function closeAd(){
if (ie||w3)
adDiv.display="none";
else
adDiv.visibility ="hide";
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

onload=initAd;