invalid_email = new Array(' ', '!', '\"', '#', '$', '%', '&', '\'', '(', ')', '*', ',', ':', ';', '<', '=', '>', '?', '[', ']','\\', '`',  '{', '}', '|');

/*
function LinkToDIV(targetDIV, url) {
  var mioLV = new LoadVars();
  dest = document.getElementById(targetDIV);
  
  mioLV.onLoad = function(s)
  {
   if(s)
   {
	//alert(this.getText());
    document.getElementById(targetDIV).innerHTML =this.getText();
   }
   else // problemi durante il caricamento dati
   {
    alert('Problemi durante il caricamento di '+url);
   }
  }
  document.getElementById(targetDIV).innerHTML ='<img src="img/loading.gif">';
  mioLV.decodeData =false;
  mioLV.load(url);   
}
*/

function LinkToDIV(targetDIV, url, loading_img) {
	try {
  		 var mioLV = new LoadVars();
  		 dest = document.getElementById(targetDIV);
  
  		 if (!dest) return false;
		 
  		 //Cancella il vecchio contenuto
  		 while (dest.firstChild) dest.removeChild(dest.firstChild);
  		 if (loading_img==null) loading_img ="img/loading.gif";
         dest.innerHTML ='<img src="'+loading_img+'">';
  
  		 mioLV.onLoad = function(s)
  		   {
   			  if (s)
   			  {
   				//alert(this.getText());
    			//document.getElementById(targetDIV).innerHTML =this.getText();
    			var d=document.createElement("div");
    			d.innerHTML=this.getText();
    			//Cancella il vecchio contenuto
  		        while (dest.firstChild) dest.removeChild(dest.firstChild); 
    			dest.appendChild(d);
   			  }
   			  else // problemi durante il caricamento dati
   			  {
   				//alert('Problemi durante il caricamento di '+url);
            
   				//Cancella il vecchio contenuto
   				while (dest.firstChild) dest.removeChild(dest.firstChild); 
   				dest.appendChild(document.createTextNode('errore caricamento di '+url));
   			  }
           }  
        
         mioLV.decodeData =false;
         mioLV.load(url);
	}
	catch (l) {
		 while (dest.firstChild) dest.removeChild(dest.firstChild); 
		 dest.appendChild(document.createTextNode('errore richiesta di '+url));
	  } 
}


function LoadMosaic(url){
 parent.document.Mosaico.src = url;
}

function checkInvalidChars(value, invalidchars) {
	  l_value = value.toLowerCase();
	  for (var i=0; i<invalidchars.length; i++) {
	   if (l_value.indexOf(invalidchars[i])>-1) return true;
	  }
	  return false;
}

function checkData_Contatti() {
	 if (document.Mail) {
		  is_ok_Email = ((document.Mail.email_From.value!='') && !(checkInvalidChars(document.Mail.email_From.value, invalid_email)) && (document.Mail.email_From.value.indexOf('@')>-1));
		  is_ok_Oggetto = (document.Mail.email_subject.value!='');
		  is_ok_Testo = (document.Mail.email_text.value!='');
		  is_ok = is_ok_Email && is_ok_Oggetto && is_ok_Testo;
		  
		  if (is_ok_Email) document.getElementById("mittente").style.color = "#E6A60C"; else document.getElementById("mittente").style.color = "red";
		  if (is_ok_Oggetto) document.getElementById("oggetto").style.color = "#E6A60C"; else document.getElementById("oggetto").style.color = "red";
		  if (is_ok_Testo) document.getElementById("testo").style.color = "#E6A60C"; else document.getElementById("testo").style.color = "red";
		  
		  document.getElementById("imageField").disabled = (!is_ok);
		  if (is_ok) document.getElementById("imageField").src = "img/but/scrivimi.gif"; else document.getElementById("imageField").src = "img/but/scrivimi_bn.gif"; 
	 }
}	 
		 
		 
		 

