function createObject() {
    var tipo_richiesta;

    var browserUtente = navigator.userAgent.toUpperCase();
    if(typeof(XMLHttpRequest) === "function" || typeof(XMLHttpRequest) === "object")
    tipo_richiesta = new XMLHttpRequest();

    else if(
    window.ActiveXObject &&
    browserUtente.indexOf("MSIE 4") < 0
    ) {
if(browserUtente.indexOf("MSIE 5") < 0)
   tipo_richiesta = new ActiveXObject("Msxml2.XMLHTTP");


else
   tipo_richiesta = new ActiveXObject("Microsoft.XMLHTTP");

 }
 return tipo_richiesta;
} 
var http = createObject();

function handleResponse(dest) {

if(http.readyState < 4) {
document.getElementById(dest).innerHTML = "Attendere..."; // "status"
}
if(http.readyState == 4) {
if(http.status == 200) {
document.getElementById(dest).innerHTML = http.responseText; // "status"
} else {
document.getElementById(dest).innerHTML = http.status;
handleErrFullPage(strResponse); // "status"
}
}
}

function sendGet(valore, dest) {
    http.open('GET', valore, true);
    http.onreadystatechange = function() { handleResponse(dest); }; 
    http.send(null);
}



         
         function loadimg()
         {

         sendGet('RicercaProv?regione=' + document.ricerca.regione.value + '&r=' + Math.random(),'DIVprov');
         
         setTimeout('caricaimg()',1000);
         
         }
         
         function caricaimg(){
         sendGet('RicercaImg?regione'+ document.ricerca.regione.value + '&r=' + Math.random(),'foto');
         } 
         
         function loadimg2()
         {
         sendGet('RicercaLoc?provincia=' + document.ricerca.provincia.value + '&r=' + Math.random(),'DIVloc');
         setTimeout('caricaimg2()',1000);
         
         }
         function caricaimg2()
         {
         sendGet('RicercaImg2?provincia=' + document.ricerca.provincia.value + '&r=' + Math.random(),'foto');
         } 


    function LoadDest(){
        
        sendGet('RicercaDest?destinazione=' + document.ricerca.destinazione.value + '&r=' + Math.random(),'DIVdestinazione');
        
        setTimeout('loadreg()',1000);

        


}


function loadreg(){

    sendGet('RicercaReg?regione=' + document.ricerca.regione.value + '&r=' + Math.random(),'DIVregione');

}     


function cambiaImgGallery(name){

document.images.gallery.src='images/gallery/'+name;

}

function cambiaImgDaVedere(name){

document.images.vedere.src='images/davedere/'+name;

}

function isemail(stringa) {
	if (! stringa) return false;
	stringa = stringa.toString();
	//risp = stringa.match(/^[\w\._]+\@[\w\.]{2,}\.[a-z]{2,4}$/i);
	//risp = risp && ! stringa.match(/\@.*\.{2,}/);
	
	risp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
	if (risp.test(stringa))
      return true;
	else
      return false;
   
}
function testmail(dove) {
	if (isemail(''+dove.value)) {
		
                return true;
	} else {
		
		return false;
	}
}
function change_site() {

var site = document.sel.select.selectedIndex;

var valore=document.sel.select.options[site].value;
       
window.location.href = valore ;
}


function getkey(e)
{
if (window.event)
   return window.event.keyCode;
else if (e)
   return e.which;
else
   return null;
}



function caratteriok(e, goods)
{
var key, keychar;
key = getkey(e);
if (key == null) return true;

// get character
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
goods = goods.toLowerCase();

// check goodkeys
if (goods.indexOf(keychar) != -1)
	return true;

// control keys
if ( key==null || key==0 || key==8 || key==9 
    || key==13 || key==27 )
   return true;

// else return false
return false;
}

function ctrlform(){
 
 var lg=document.scrivi.language.value;
 //Qui imposto il form da controllare!
if(lg=="it")
frase="Sono stati riscontrati i seguenti problemi:\n\n";

 if(lg=="en")
frase="There are any problems in this page:\n\n";
 if(lg=="td")
frase="Sono stati riscontrati i seguenti problemi dk:\n\n";
  if(document.scrivi.nome.value == "")
{
    if(lg=="it")
    a = "Il campo Nome e' obbligatorio\n\n";
    else
        if(lg=="en")
         a = "The field name is required\n\n";
  }
else{
    a = "";
  }
 
  if(document.scrivi.cognome.value == "")
   {
    if(lg=="it")
    b = "Il campo Cognome e' obbligatorio\n\n";
    else
        if(lg=="en")
         b = "The field Surname is required\n\n";
  }
else{
    b = "";
  }

if(document.scrivi.citta.value == "")
{
    if(lg=="it")
    f = "Il campo Città e' obbligatorio\n\n";
    else
        if(lg=="en")
         f = "The field City is required\n\n";
  }
else{
    f = "";
  }
if(document.scrivi.stato.value == "")
{
    if(lg=="it")
    g = "Il campo Stato e' obbligatorio\n\n";
    else
        if(lg=="en")
         g = "The field Country is required\n\n";
  }
else{
    g = "";
  }

if(testmail(document.scrivi.email)==false){

    if(lg=="it")
    c = "L'e-mail inserita non è corretta\n\n";
    else
        if(lg=="en")
         c = "The e-mail isn't correct\n\n";
  }
else{
   c= "";
  }

if(testmail(document.scrivi.email2)==false){

    if(lg=="it")
    d = "L'e-mail di conferma inserita non è corretta\n\n";
    else
        if(lg=="en")
         d = "The re-type e-mail isn't correct\n\n";
  }
else{
   d= "";
  }
if((document.scrivi.email.value)!=(document.scrivi.email2.value)){
if(lg=="it")
    e = "Le e-email non coincidono\n\n";
    else
        if(lg=="en")
         e = "The e-mail aren't equals\n\n";
  }
else{
   e= "";
  }
  
  if(document.scrivi.dataArrivo.value == "")
{
    if(lg=="it")
    h = "Il campo Data arrivo e' obbligatorio\n\n";
    else
        if(lg=="en")
         h = "The field Arrival date is required\n\n";
  }
else{
    h = "";
  }
  
    if(document.scrivi.dataPartenza.value == "")
{
    if(lg=="it")
    i = "Il campo Data partenza e' obbligatorio\n\n";
    else
        if(lg=="en")
         i = "The field Departure date is required\n\n";
  }
else{
    i = "";
  }
  
      if(document.scrivi.adulti.value == "")
{
    if(lg=="it")
    l = "Il campo Adulti e' obbligatorio\n\n";
    else
        if(lg=="en")
         l = "The field Adults is required\n\n";
  }
else{
    l = "";
  }
  
 
  
    if(document.scrivi.bambini.value != "" && document.scrivi.bambini.value != "0")
{
	if(document.scrivi.etabambini.value == ""){
    	if(lg=="it")
    		n = "Il campo Età bambini e' obbligatorio\n\n";
    	else
        	if(lg=="en")
        		n = "The field Children age is required\n\n";
    }else{
    	n = "";
    }
  }
else{
    n = "";
  }

  //Se si verificano le condizioni di NON validazione invio un alert
  if(document.scrivi.nome.value == "" || document.scrivi.cognome.value == "" || document.scrivi.citta.value == "" || document.scrivi.stato.value == "" || c!= "" || d!= "" || e!= "" || h!= "" || i!= "" || l!= "" ||  n!="")
{
  {alert(frase+ a + b + c + d + e + f + g + h + i + l + n);
  
  //E qui blocco lo script per impedire che l'action del form sia eseguito!
  return false;}


  }
return true;
}

function goback(){
history.back();
}


function ctrlform2(){
var lg=document.BancaSella.language.value;

 if(lg=="it")
frase="Sono stati riscontrati i seguenti problemi:\n\n";

 if(lg=="en")
frase="There are any problems in this page:\n\n";
 if(lg=="td")
frase="Sono stati riscontrati i seguenti problemi dk:\n\n";
 //Qui imposto il form da controllare!

  if(document.BancaSella.amount.value == "")
{
    if(lg=="it")
    a = "Il campo Importo e' obbligatorio\n\nSi ricorda che il formato corretto è del tipo 'nn.nn' \n\n ";
    else
        {
        if(lg=="en")
        a="The field Amount is obligatory\n\nWe remember that the correct format is similar to  'nn.nn' \n\n ";
        else
        a="The field  amount is obligatory dk\n\n";
  }
}
else{
    a = "";
  }
 
  if(document.BancaSella.transactionID.value == "")
{
    if(lg=="it")
    b = "Il campo Causale e' obbligatorio\n\n";
    else
        {if(lg=="en")
        b="The field Motive is obligatory\n\n";
        else
         b="The field Motive is obligatory dk\n\n";
  }
}
else{
    b= "";
  }

  if(document.BancaSella.login.value == "")
{
    if(lg=="it")
    c = "Il campo Nome e' obbligatorio\n\n";
    else
        {
        if(lg=="en")
        c="The field name is obligatory\n\n";
        else
         c="The field name is obligatory dk\n\n";
  }
}
else{
    c = "";
  }


if(testmail(document.BancaSella.email)==false)
{
     if(lg=="it")
   i = "Il formato e-mail inserito non è corretto\n\n";
    else
        {if(lg=="en")
        i = "The format of e-mail isn't correct\n\n";
        else
        i = "Il formato e-mail inserito non è corretto dk\n\n";
  }
}
else{
    i = "";
  }

   

  //Se si verificano le condizioni di NON validazione invio un alert
  if(document.BancaSella.amount.value == "" || document.BancaSella.transactionID.value == "" || document.BancaSella.login.value == ""  || i!= "")
{

  {alert(frase + a + b + c + i );
  
  //E qui blocco lo script per impedire che l'action del form sia eseguito!
  return false;}


  }
else
return true;
}

function controlla()
{
var lg=document.scrivi.language.value;
if(lg=="it")
{attenzione="Non hai inserito nessun commento!";}
if(lg=="en")
{attenzione="The field of text is required to insert a comment!";}
if(lg=="td")
{attenzione="bo bob bobob!";}

if(document.scrivi.commento.value== "")
{
alert(attenzione);
return false;
}
else
return true;
}

