function controlla()
{
	var data_arrivo;
	var data_attuale;	
	
	if(document.fastSearch_f.FirstSelectDay)
		document.getElementById('data_arrivo').value=document.fastSearch_f.FirstSelectDay.value+"/"+document.fastSearch_f.FirstSelectMonth.value+"/"+document.fastSearch_f.FirstSelectYear.value;
	
	data_arrivo=document.getElementById('data_arrivo').value;
	
     var now = new Date();
     var nowYear = now.getYear();
     var nowMonth = now.getMonth();
     var nowDay   = now.getDate();
     
     data_attuale=nowDay+"/"+((nowMonth*1)+1)+"/"+nowYear;
	
	if(document.getElementById('data_arrivo').value=="")
	{
		alert("Selezionare la data di arrivo!");
		return false
	}
	else
	{
	     //alert(data_arrivo+" - "+data_attuale);
	     compareD=cmpDate(data_arrivo,data_attuale);
	     if(compareD==false)
	     {
	          alert("la data di arrivo non puo' essere precende alla data attuale");
	          return false;
	     }
	     else
	     {
	          document.fastSearch_f.submit();
	     }
	}
}

function openwin(URL){
     //alert('ciao');
     window.open(URL,"chat","width=580 height=550");
}
function visualizza(nome)
{
if(!document.all){
	window.captureEvents(Event.MOUSEMOVE)
 window.onmousemove=Move
	}else{
  posx=((window.event.clientX+document.body.scrollLeft)+10)+ ' px';
  posy=((window.event.clientY+document.body.scrollTop)-100)+ ' px';

/*
  document.getElementById(nome).style.visibility='visible';
  document.getElementById(nome).style.top=posy;
  document.getElementById(nome).style.left=posx;
*/
  //f=eval("document.layers."+nome);
  //f=document.layers[nome];
  f=document.getElementById(nome);
  f.style.visibility="visible";
  f.style.top=posy;
  f.style.left=posx;
	}
}

function nascondi(nome){
	document.getElementById(nome).style.visibility="hidden";
}
function Move(e) {
	//alert('entrato'+e.pageX);
 document.getElementById('img_zona1').left=e.pageX
 document.getElementById('img_zona1').top=e.pageY
}

function visualizza_fs(){
	document.getElementById('table_fastsearch').style.display='';
	document.getElementById('table_fastsearch1').style.display='';
	document.getElementById('table_fastsearch2').style.display='';
	document.getElementById('table_fastsearch3').style.display='';			
	document.getElementById('table_advancedsearch').style.display='none';
	document.getElementById('ric_veloce').className='search_on';
	document.getElementById('ric_avanzata').className='search_off';
	if(document.getElementById('table_fast'))
	     document.getElementById('table_fast').style.display='none';
	colora('avanzata');
}

function visualizza_as(){
	//calDate.style.display ='none';
	document.getElementById('table_fastsearch').style.display='none';
	document.getElementById('table_fastsearch1').style.display='none';
	document.getElementById('table_fastsearch2').style.display='none';	
	document.getElementById('table_fastsearch3').style.display='none';	
	document.getElementById('table_advancedsearch').style.display='';
	document.getElementById('ric_veloce').className='search_off';
	document.getElementById('ric_avanzata').className='search_on';
	colora('veloce');
}

function colora_testo_avanzata(){
	var campo=document.getElementById('ric_avanzata');
	campo.style.color=(campo.style.color=='#000000'?'#FF9900':'#000000');
}
function colora_testo_veloce(){
	var campo=document.getElementById('ric_veloce');
	campo.style.color=(campo.style.color=='#000000'?'#FF9900':'#000000');
}

var veloce;
var avanzata;

function colora(valore){
	if(valore=='avanzata'){
		avanzata=setInterval(colora_testo_avanzata,500);
		if(veloce) clearInterval(veloce);
	}else{
		veloce=setInterval(colora_testo_veloce,500);
		if(avanzata) clearInterval(avanzata);
	}
}

function change_color(){
	olc=document.getElementById("errore_ricerca");
	olc.className=(olc.className=="label_titolo_2"?"label_titolo_3":"label_titolo_2");
}

function change_color_load(){
	setInterval(change_color,200);
}

function change_color_ll(valore){
	//alert(valore);
	oll=document.getElementById(valore);
	//alert(document.getElementById(valore));
	//alert(document.getElementById(valore).className);
	oll.className=(oll.className=="label_titolo_2"?"label_titolo_3":"label_titolo_2");
}

function change_color_ll_load(valore){
	setInterval("change_color_ll(valore)",1000);
}

function pulisci(nr_form)
{
	//alert(numero_form);
	for(i=1;i<numero_form;i++)
	{
		if(i!=nr_form)
		{
			f=eval("document.getElementById('modulo"+i+"')");
			f.campo.value="";
			document.getElementById('modulo'+i).campo1.value="";
			document.getElementById('modulo'+i).campo2.value="";
		}
	}
}

function pulisci(nr_form)
{
	//alert(numero_form);
	for(i=1;i<numero_form;i++)
	{
		if(i!=nr_form)
		{
			f=eval("document.getElementById('modulo"+i+"')");
			f.campo.value="";
			document.getElementById('modulo'+i).campo1.value="";
			document.getElementById('modulo'+i).campo2.value="";
		}
	}
}

function controlla_nrpers(nr_form,nr_max,errore_caratteri,errore_numero)
{
if ((document.all['modulo'+nr_form].campo1.value!="")||(document.all['modulo'+nr_form].campo2.value!=""))
  {
    if((isNaN(document.all['modulo'+nr_form].campo.value)==true)||(isNaN(document.all['modulo'+nr_form].campo1.value)==true)||(isNaN(document.all['modulo'+nr_form].campo2.value)==true))
      {
	      //errore_caratteri="<?=$errore_caratteri[$ml];?>";
	      alert(errore_caratteri);
	      return false;
      }
      else
      {
         if (((document.all['modulo'+nr_form].campo1.value)*1)+((document.all['modulo'+nr_form].campo2.value)*1)!=nr_max)
         {
	         //errore_numero="<?=$errore_numero[$ml];?>";
	         alert(errore_numero);
	         return false;
         }
         else
         {
         	return true;
         }
      } 
  }
  else
  {
	  //errore_numero='<?=$errore_numero[$ml];?>';
	  //errore_numero="ciao &nbsp;";
	  alert(errore_numero);
	  return false;
  }
}

function visualizza(nome,flag)
{
  if (flag==true)
  {
    posx=event.clientX+document.body.scrollLeft + ' px';
    //posy=event.clientY+document.body.scrollTop + ' px';
    //alert(event.clientY+" "+event.clientX);10 + 
    posy=((event.clientY+document.body.scrollTop)-30)+ ' px';
    //posx=((event.clientX+document.body.scrollLeft)+100)+ ' px';
  }
  else posy="-1000 px"
  document.frames[nome].style.top=posy;
  document.frames[nome].style.left=posx;
}

function change_color_chat(){
	olc=document.getElementById("loading");
	olc.className=(olc.className=="titolo_pag_h2"?"titolo_pag_h0":"titolo_pag_h2");
}

function change_color_chat_load(){
	alert("ciao");
	setInterval(change_color_chat,200);
}

function cmpDate(_v1,_v2) { 
	data1=new String(_v1); 
	data2=new String(_v2); 
	data1=_v1.substring(_v1.indexOf("/")+1, _v1.lastIndexOf("/"))+"/"+_v1.substring(0,_v1.indexOf("/"))+"/"+_v1.substring(_v1.lastIndexOf("/")+1,_v1.length); 
	data2=_v2.substring(_v2.indexOf("/")+1, _v2.lastIndexOf("/"))+"/"+_v2.substring(0,_v2.indexOf("/"))+"/"+_v2.substring(_v2.lastIndexOf("/")+1,_v2.length); 
	var _d1 = new Date(data1) 
	var _d2 = new Date(data2) 
 var _delta = 0; 
 var _a1 = _d1; 
 var _a2 = _d2; 
 _delta = _a1.getTime() - _a2.getTime(); 
 _delta /= (1000 * 60 * 60 * 24); 
 if(_delta<0) return false;
 //alert(_delta); 
 //return _delta; 
}

function controlla_data_sp2()
{
	var errore=0;
	if(document.getElementById('data_arrivo').value=="")
	{
		alert("Selezionare la data di arrivo!");
		return false;
	}
	else
	{
		if (document.getElementById('data_arrivo').value.charAt(0)!="")
		{
			if (isNaN(document.getElementById('data_arrivo').value.charAt(0))==true)
			{
				//alert("Scrivere una data di arrivo valida!");
				errore++;
			}
		}
		if (document.getElementById('data_arrivo').value.charAt(1)!="")
		{
			if (isNaN(document.getElementById('data_arrivo').value.charAt(1))==true)
			{
				//alert("Scrivere una data di arrivo valida!");
				errore++;
			}
		}
		if (document.getElementById('data_arrivo').value.charAt(2)!="")
		{
			if (document.getElementById('data_arrivo').value.charAt(2)!="/")
			{
				//alert("Scrivere una data di arrivo valida!");
				errore++;
			}
		}
		if (document.getElementById('data_arrivo').value.charAt(3)!="")
		{
			if (isNaN(document.getElementById('data_arrivo').value.charAt(3))==true)
			{
				//alert("Scrivere una data di arrivo valida!");
				errore++;
			}
		}
		if (document.getElementById('data_arrivo').value.charAt(4)!="")
		{
			if (isNaN(document.getElementById('data_arrivo').value.charAt(4))==true)
			{
				//alert("Scrivere una data di arrivo valida!");
				errore++;
			}
		}		
		if (document.getElementById('data_arrivo').value.charAt(5)!="")
		{
			if (document.getElementById('data_arrivo').value.charAt(5)!="/")
			{
				//alert("Scrivere una data di arrivo valida!");
				errore++;
			}
		}
		for(i=6;i<10;i++)
		if (document.getElementById('data_arrivo').value.charAt(i)!="")
		{
			if (document.getElementById('data_arrivo').value.charAt(i)!="/")
			{
				//alert("Scrivere una data di arrivo valida!");
				errore++;
			}
		}
		if(errore>0) alert("Scrivere una data di arrivo valida!");
	}
}


function aggFavoriti(lingua,descrizione)
{
	var urlSito=""
	if(lingua=="I" || lingua=="") urlSito="http://www.napolisweethome.it";
	else urlSito="http://www.napolisweethome.com";
	alert(descrizione);
	window.external.AddFavorite(urlSito,descrizione);
}

function impHP(lingua)
{
	var urlSito=""
	if(lingua=="I" || lingua=="") urlSito="http://www.napolisweethome.it";
	else urlSito="http://www.napolisweethome.com";
	document.body.style.behavior='url(#default#homepage)';document.body.setHomePage(urlSito);
}

function controllo(errore)
{
if (document.scrivici.messaggio.value=="" || document.scrivici.email.value=="")
	{
		//alert(errore);
		return false;
	}
}