// JavaScript Document

// ------------------------------------------------------------------------------------ validazione data

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');

function LZ(x){return(x<0||x>9?"":"0")+x}

function isDate(val,format){var date=getDateFromFormat(val,format);if(date==0){return false;}return true;}

function compareDates(date1,dateformat1,date2,dateformat2){var d1=getDateFromFormat(date1,dateformat1);var d2=getDateFromFormat(date2,dateformat2);if(d1==0 || d2==0){return -1;}else if(d1 > d2){return 1;}return 0;}

function formatDate(date,format){format=format+"";var result="";var i_format=0;var c="";var token="";var y=date.getYear()+"";var M=date.getMonth()+1;var d=date.getDate();var E=date.getDay();var H=date.getHours();var m=date.getMinutes();var s=date.getSeconds();var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;var value=new Object();if(y.length < 4){y=""+(y-0+1900);}value["y"]=""+y;value["yyyy"]=y;value["yy"]=y.substring(2,4);value["M"]=M;value["MM"]=LZ(M);value["MMM"]=MONTH_NAMES[M-1];value["NNN"]=MONTH_NAMES[M+11];value["d"]=d;value["dd"]=LZ(d);value["E"]=DAY_NAMES[E+7];value["EE"]=DAY_NAMES[E];value["H"]=H;value["HH"]=LZ(H);if(H==0){value["h"]=12;}else if(H>12){value["h"]=H-12;}else{value["h"]=H;}value["hh"]=LZ(value["h"]);if(H>11){value["K"]=H-12;}else{value["K"]=H;}value["k"]=H+1;value["KK"]=LZ(value["K"]);value["kk"]=LZ(value["k"]);if(H > 11){value["a"]="PM";}else{value["a"]="AM";}value["m"]=m;value["mm"]=LZ(m);value["s"]=s;value["ss"]=LZ(s);while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(value[token] != null){result=result + value[token];}else{result=result + token;}}return result;}

function _isInteger(val){var digits="1234567890";for(var i=0;i < val.length;i++){if(digits.indexOf(val.charAt(i))==-1){return false;}}return true;}

function _getInt(str,i,minlength,maxlength){for(var x=maxlength;x>=minlength;x--){var token=str.substring(i,i+x);if(token.length < minlength){return null;}if(_isInteger(token)){return token;}}return null;}

function getDateFromFormat(val,format){val=val+"";format=format+"";var i_val=0;var i_format=0;var c="";var token="";var token2="";var x,y;var now=new Date();var year=now.getYear();var month=now.getMonth()+1;var date=1;var hh=now.getHours();var mm=now.getMinutes();var ss=now.getSeconds();var ampm="";while(i_format < format.length){c=format.charAt(i_format);token="";while((format.charAt(i_format)==c) &&(i_format < format.length)){token += format.charAt(i_format++);}if(token=="yyyy" || token=="yy" || token=="y"){if(token=="yyyy"){x=4;y=4;}if(token=="yy"){x=2;y=2;}if(token=="y"){x=2;y=4;}year=_getInt(val,i_val,x,y);if(year==null){return 0;}i_val += year.length;if(year.length==2){if(year > 70){year=1900+(year-0);}else{year=2000+(year-0);}}}else if(token=="MMM"||token=="NNN"){month=0;for(var i=0;i<MONTH_NAMES.length;i++){var month_name=MONTH_NAMES[i];if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){if(token=="MMM"||(token=="NNN"&&i>11)){month=i+1;if(month>12){month -= 12;}i_val += month_name.length;break;}}}if((month < 1)||(month>12)){return 0;}}else if(token=="EE"||token=="E"){for(var i=0;i<DAY_NAMES.length;i++){var day_name=DAY_NAMES[i];if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){i_val += day_name.length;break;}}}else if(token=="MM"||token=="M"){month=_getInt(val,i_val,token.length,2);if(month==null||(month<1)||(month>12)){return 0;}i_val+=month.length;}else if(token=="dd"||token=="d"){date=_getInt(val,i_val,token.length,2);if(date==null||(date<1)||(date>31)){return 0;}i_val+=date.length;}else if(token=="hh"||token=="h"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>12)){return 0;}i_val+=hh.length;}else if(token=="HH"||token=="H"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>23)){return 0;}i_val+=hh.length;}else if(token=="KK"||token=="K"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<0)||(hh>11)){return 0;}i_val+=hh.length;}else if(token=="kk"||token=="k"){hh=_getInt(val,i_val,token.length,2);if(hh==null||(hh<1)||(hh>24)){return 0;}i_val+=hh.length;hh--;}else if(token=="mm"||token=="m"){mm=_getInt(val,i_val,token.length,2);if(mm==null||(mm<0)||(mm>59)){return 0;}i_val+=mm.length;}else if(token=="ss"||token=="s"){ss=_getInt(val,i_val,token.length,2);if(ss==null||(ss<0)||(ss>59)){return 0;}i_val+=ss.length;}else if(token=="a"){if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}else{return 0;}i_val+=2;}else{if(val.substring(i_val,i_val+token.length)!=token){return 0;}else{i_val+=token.length;}}}if(i_val != val.length){return 0;}if(month==2){if( ((year%4==0)&&(year%100 != 0) ) ||(year%400==0) ){if(date > 29){return 0;}}else{if(date > 28){return 0;}}}if((month==4)||(month==6)||(month==9)||(month==11)){if(date > 30){return 0;}}if(hh<12 && ampm=="PM"){hh=hh-0+12;}else if(hh>11 && ampm=="AM"){hh-=12;}var newdate=new Date(year,month-1,date,hh,mm,ss);return newdate.getTime();}

function parseDate(val){var preferEuro=(arguments.length==2)?arguments[1]:false;generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');var d=null;for(var i=0;i<checkList.length;i++){var l=window[checkList[i]];for(var j=0;j<l.length;j++){d=getDateFromFormat(val,l[j]);if(d!=0){return new Date(d);}}}return null;}



function aggiungi_itin(){

	var s=document.getElementById("tipo_itin");

    s.options[s.options.length] = new Option(document.getElementById("nuovo_init").value,document.getElementById("nuovo_init").value);

    s.selectedIndex=s.options.length-1;

}



function nascondi_20km(){

if (document.getElementById("tutto").checked)

document.getElementById("km20").style.visibility='hidden';

else

document.getElementById("km20").style.visibility='visible';

}



function nuovo_tipo(){

document.getElementById("nuovo_it").style.visibility='visible';

}



function invia_newsletter(){

document.getElementById("newsletter").action="admin_newsletter.php";

document.getElementById("newsletter").target="_self";

document.getElementById("newsletter").Invia.value="Invia";

document.getElementById("newsletter").submit();

}



function anteprima_newsletter(){

document.getElementById("newsletter").action="anteprima_newsletter.php";

document.getElementById("newsletter").target="_blank";

document.getElementById("newsletter").submit();

document.getElementById("newsletter").action="admin_newsletter.php";

document.getElementById("newsletter").target="_self";

document.getElementById("newsletter").submit();

}





function elimina_camera()
{

	if (window.confirm(top.lingua[0])){
		location.replace("elimina_camera.php");

}





}

function cerca_news(pag,id_div){



id_div_errore=id_div;

loadXMLDoc('ajax_news.php?pag='+pag);



}



function news(id,div){

	id_div_errore=div;
	loadXMLDoc('dett_news.php?id='+id);
	document.getElementById(id_div_errore).focus();

}



function grafico(data1,id_camera,nc,ns,id_div)
{

	id_div_errore=id_div;
	var data2
	var d = new Date()
	d.setTime(getDateFromFormat(data1.value,"dd/MM/y")+5*86400*1000)
	var m=parseInt(d.getMonth())+1;
	var g=parseInt(d.getDate());

	if (m<10){
		m='0'+m;
	}

	if (g<10){
		g='0'+g;
	}

	data2=d.getFullYear()+'-'+m+'-'+g;
	loadXMLDoc('ajax_grafico.php?id='+id_camera+'&ns='+ns+'&datainizio='+data2+'&nc='+nc+'&num=30');

}

function elimina_tar(data,id_cam)
{
	if (window.confirm(top.lingua[1])){
		id_div_errore="tariffael_"+id_cam;
		loadXMLDoc('elimina_tar.php?id_cam='+id_cam+'&data='+data);
	}
}

function visual_albero(){

if (document.getElementById('albero').style.display=='none'){

document.getElementById('albero').style.display='block';

document.getElementById('radice').innerHTML="- Guida incoming";

}

else

{

document.getElementById('albero').style.display='none';

document.getElementById('radice').innerHTML="+ Guida incoming"

}

}

function visual_albero2(){

if (document.getElementById('albero_avanzato').style.display=='none'){

document.getElementById('albero_avanzato').style.display='block';

document.getElementById('radice_avanzato').innerHTML="- Guida Avanzata";

}

else

{

document.getElementById('albero_avanzato').style.display='none';

document.getElementById('radice_avanzato').innerHTML="+ Guida avanzata"

}

}



function aggiornaTD()
{

	document.getElementById('num_cam_').innerHTML=top.lingua[2]+' <b>'+document.getElementById('id_cam').value+'<b>';

}



function cerca_da_it()
{
	document.getElementById('premi').click();
}

function itinerario(id,id_div,interno)
{
	id_div_errore=id_div;
	id_div_errore=id_div;
	if (!(interno == 'si')){
		var interno = 'no';
	}
	loadXMLDoc('ajax/dett_itinerario.php?id='+id+'&interno='+interno);
	document.getElementById(id_div).focus();
}

function cerca_itin(n_pag,id_div,selec,interno)
{

	var loc="";
	var sel_loc=document.getElementById('sel_loc1');
	if (sel_loc != null){
		var loc=sel_loc.options[sel_loc.selectedIndex].value;
	} else {
		sel_loc=document.getElementById('h_loc');
		if (sel_loc != null){
			var loc = sel_loc.value;
		}
	}

	var sel_=document.getElementById('tipo_it');
	var tipo=sel_.options[sel_.selectedIndex].value;
	var search=document.getElementById('cerca').value;
	var tutto="no";
	
	var prov="";
	if ((document.getElementById('prov')!=null)){
		if (document.getElementById('prov').type!="hidden"){
			var sel_prov=document.getElementById('prov');
			prov=sel_prov.options[sel_prov.selectedIndex].value;
		}
	}
	if (document.getElementById('tutto')!=null)
		if (document.getElementById('tutto').checked)
			tutto="ok";
	id_div_errore=id_div;
	if (!(interno == 'si')){
		var interno = 'no';
	}

	/*
	tolto il 9/01/2008 per far andare gli itinerari distanti 20 Km dalla struttura, in desc_struttura.php

	if (prov == ''){
		loc = '';
	}
	*/

//	alert('ajax_itin.php?loc='+loc+'&tipo='+tipo+'&search='+search+'&pag='+n_pag+'&selec='+selec+'&tutto='+tutto+'&prov='+prov+'&interno='+interno);

	// per far andare le lingue con motore_itin_natale.php

	var cittadino = new Array('cidadão', 'city', 'Stadt', 'ciudadano', '市');
	for (i = 0; i < cittadino.length; i++) {
		if (cittadino[i] == tipo) {
			tipo = 'cittadino';
		}
	}

	var arte = new Array('historical-artistic');
	for (i = 0; i < arte.length; i++) {
		if (arte[i] == tipo) {
			tipo = 'storico-artistico';
		}
	}

	var natura = new Array('naturalistic', 'naturalistisch');
	for (i = 0; i < natura.length; i++) {
		if (natura[i] == tipo) {
			tipo = 'naturalistico';
		}
	}

	var  eventi = new Array('folkloristico');
	for (i = 0; i < eventi.length; i++) {
		if (eventi[i] == tipo) {
			tipo = 'folkloristico';
		}
	}
	loadXMLDoc('ajax_itin.php?loc='+loc+'&tipo='+tipo+'&search='+search+'&pag='+n_pag+'&selec='+selec+'&tutto='+tutto+'&prov='+prov+'&interno='+interno);
}



function succ(num,ord){

	fine_url = document.location.pathname.substr(document.location.pathname.length-7, 7);
	url = document.location.pathname.split("/");

	

	if (
		(fine_url == 'smi.php') || (fine_url == 'spa.php') || (url[1] == 'vetrina_gargano.php') || 
		(url[1] == 'vetrina_salento.php') || (url[1] == 'vetrina_mare.php') || (url[1] == 'vetrina_montagna.php') || 
		(url[1] == 'vetrina_offerte.php') || (url[2] == 'vetrina_gargano.php') || (url[2] == 'vetrina_salento.php') || 
		(url[2] == 'vetrina_mare.php') || (url[2] == 'vetrina_montagna.php') || (url[2] == 'vetrina_offerte.php')
	){
		document.location.href=document.location.pathname+"?num="+num;
		return true;
	}

//	alert(substr(document.location.href,document.location.href.length-10,5));


	if (document.getElementById('da') == null)
		var data1 = '';
	else 
		var data1=document.getElementById("da").value;

	if (document.getElementById('a') == null)
		var data2 = '';
	else 
		var data2=document.getElementById("a").value;

	if (document.getElementById('num_posti') != null){	
		if (!_isInteger(document.getElementById('num_posti').value)){
			document.getElementById('num_posti').value="";
		}

		if (document.getElementById('num_posti').value=="" && (data1!="")){
			document.getElementById('num_posti').value=1;
		}
	}

	if ((data1 != '') && (data2 != '')){

		if ((compareDates(data1,"dd/MM/y",data2,"dd/MM/y")==1)||(!_isInteger(data2))||(data1.value==data2)){
			var d = new Date()
			d.setTime(getDateFromFormat(data1.value,"dd/MM/y")+86400*1000)
			var m=parseInt(d.getMonth())+1;
			var g=parseInt(d.getDate());
			if (m<10){
				m='0'+m;
			}
			if (g<10){
				g='0'+g;
			}
			data2.value=g+'/'+m+'/'+d.getFullYear();
			/*
			if (data1!=""){
				document.getElementById('num_posti').value=1;
			}
			*/
		}
	}

	if ((data1!="")||document.getElementById('num_posti').value!=""){

		hid_loc('sel_loc1','h_loc');
		if (ord == ""){
			ord = "distanza";
		}
		document.getElementById('motore_di_ricerca').action="risultaticamera.php?ordine="+ord+"&num="+num;
		document.getElementById('motore_di_ricerca').submit();

	} else {

		hid_loc('sel_loc1','h_loc');
		document.getElementById('motore_di_ricerca').action="risultatistruttura.php?ordine="+ord+"&num="+num;
		document.getElementById('motore_di_ricerca').submit();
	}

}





function assegna_data(s,d){

if (d.value=="")

{

d.value=s.value;

}

}



function confronta1(data1,data2){

	/*
	if (top.numero_risultati == 0)
	{
		alert(top.lingua[21]);
		return false;
	}
	*/

	if	(document.getElementById('prov').value == ''){
		alert(top.lingua[17]);
		return false;
	}

	if (!_isInteger(document.getElementById('num_posti').value)){
		document.getElementById('num_posti').value="";
	}

	if ((document.getElementById('num_posti').value=="") && (data1.value!="")){
		document.getElementById('num_posti').value=1;
	}

	if ( (document.getElementById('num_posti').value!="") && (data1.value=="") ){
		today = new Date()
		var m=parseInt(today.getMonth())+1;
		var g=parseInt(today.getDate());
		if (m<10){
			m='0'+m;
		}
		if (g<10){
			g='0'+g;
		}
		data1.value=g+'/'+m+'/'+today.getFullYear();
		data2.disabled=false
		var d = new Date()
		d.setTime(getDateFromFormat(data1.value,"dd/MM/y")+86400*1000)
		var m=parseInt(d.getMonth())+1;
		var g=parseInt(d.getDate());
		if (m<10){
			m='0'+m;
		}
		if (g<10){
			g='0'+g;
		}
		if (data1.value!=""){
			data2.value=g+'/'+m+'/'+d.getFullYear();
		}
	}

	if ( (compareDates(data1.value,"dd/MM/y",data2.value,"dd/MM/y")==1)||(data2.value=="")||(data1.value==data2.value)){
		var d = new Date()
		d.setTime(getDateFromFormat(data1.value,"dd/MM/y")+86400*1000)
		var m=parseInt(d.getMonth())+1;
		var g=parseInt(d.getDate());
		if (m<10){
			m='0'+m;
		}
		if (g<10){
			g='0'+g;
		}
		if (data1.value!=""){
			data2.value=g+'/'+m+'/'+d.getFullYear();
			document.getElementById('num_posti').value=1;
		}
	}

	if ((data1.value!="")||document.getElementById('num_posti').value!=""){
		hid_loc('sel_loc1','h_loc');
		document.getElementById('motore_di_ricerca').action="risultaticamera.php";
		document.getElementById('motore_di_ricerca').submit();
	} else {	
		hid_loc('sel_loc1','h_loc');
		document.getElementById('motore_di_ricerca').action="risultatistruttura.php";
		document.getElementById('motore_di_ricerca').submit();
	}

}



function ordina(ord)

{





var data1=document.getElementById("da");

var data2=document.getElementById("a");

if (!_isInteger(document.getElementById('num_posti').value))

{

document.getElementById('num_posti').value="";

}

if (document.getElementById('num_posti').value=="" && (data1.value!=""))

{

document.getElementById('num_posti').value=1;

}

 if ( (compareDates(data1.value,"dd/MM/y",data2.value,"dd/MM/y")==1)||(data2.value=="")||(data1.value==data2.value))

  {

var d = new Date()

d.setTime(getDateFromFormat(data1.value,"dd/MM/y")+86400*1000)

var m=parseInt(d.getMonth())+1;

var g=parseInt(d.getDate());

if (m<10)

{

m='0'+m;

}



if (g<10)

{

g='0'+g;

}



      if (data1.value!="")

      {

          document.getElementById('num_posti').value=1;

           data2.value=g+'/'+m+'/'+d.getFullYear();



      }

  }

  if ((data1.value!="")||document.getElementById('num_posti').value!="")

  {

      hid_loc('sel_loc1','h_loc');

      document.getElementById('motore_di_ricerca').action="risultaticamera.php?ordine="+ord.value+"&num="+0;

      document.getElementById('motore_di_ricerca').submit();

  }

  else

  {



      hid_loc('sel_loc1','h_loc');

      document.getElementById('motore_di_ricerca').action="risultatistruttura.php?ordine="+ord.value+"&num="+0;

      document.getElementById('motore_di_ricerca').submit();



  }





}



function confronta(data1,data2,errore)
{
	
	if (compareDates(data1.value,"dd/MM/y",data2.value,"dd/MM/y")==1){
		document.getElementById(errore).innerHTML=top.lingua[3];
		return false;
	}
	return true;

}



function verif_date(input,errore)
{

	var regex = new RegExp("[/-]");
	var date = input.split(regex);
	var nbJours = new Array('',31,28,31,30,31,30,31,31,30,31,30,31);
	var result = true;

	if ( date['2']%4 == 0 && date['2']%100 > 0 || date['2']%400 == 0 )
		nbJours['2'] = 29;

	if( isNaN(date['2']) ){
		if (document.getElementById(errore)) 
			document.getElementById(errore).innerHTML=top.lingua[4];
		result=false;
	}

	if ( isNaN(date['1']) || date['1'] > 12 || date['1'] < 1 ){
		if (document.getElementById(errore)) 
			document.getElementById(errore).innerHTML=top.lingua[4];
		result=false;
	}

	if ( isNaN(date['0']) || date['0'] > nbJours[Math.round(date['1'])] || date['0'] < 1 ){
		if (document.getElementById(errore)) 
			document.getElementById(errore).innerHTML=top.lingua[4];
		result=false;
	}	

	if (result){
		var d=new Date();
		var m=parseInt(d.getMonth())+1;
		var g=parseInt(d.getDate());

		if (m<10){
			m='0'+m;
		}

		if (g<10){
			g='0'+g;
		}

		var g=g+'/'+m+'/'+d.getFullYear();

		if (compareDates(g,"dd/MM/y",input,"dd/MM/y")==1){
			document.getElementById(errore).innerHTML=top.lingua[5];
			result=false;
		}
	}

	return result;

}



//--------------------------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------ajax------------



function loadXMLDoc(url){

	var ie_bast;
	if (url.indexOf('?')==-1)
		ie_bast=url+'?';
	else
		ie_bast=url+'&';
	ie_bast=ie_bast+"rand="+escape(Math.random());

	// codice per Mozilla, etc.
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
		xmlhttp.onreadystatechange=xmlhttpChange;
		xmlhttp.open('GET',ie_bast,true);
		if (top.tipo_lingua == "jp"){ 
			xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=UTF-8;");
		} else { 
			xmlhttp.setRequestHeader("Content-Type", "text/xml; iso-8859-1;");
		} 
		xmlhttp.send(null);
	}

	// codice per  IExplore

	else if (window.ActiveXObject){

		xmlhttp=new ActiveXObject('Msxml2.XMLHTTP');
		if (xmlhttp){
			xmlhttp.onreadystatechange=xmlhttpChange;
			xmlhttp.open('GET',ie_bast,true);
			if (top.tipo_lingua == "jp"){ 
				xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=UTF-8;");
			} else { 
				xmlhttp.setRequestHeader("Content-Type", "text/xml; iso-8859-1;");
			} 
			xmlhttp.send();
		}
	}
}



function xmlhttpChange()
{

	// if xmlhttp shows \"loaded\"

	if (xmlhttp.readyState==4){



		// if \"OK\"

		if (id_div_errore=='click_ban'){
			return;
		}

		if (id_div_errore=='ad'){

			id_div_errore="drop_area_2";
			var str11='drop_area.php?ajax=si';
			loadXMLDoc(str11);
			return;
		}

		if (id_div_errore.indexOf('tariffael')==0){

			var id=id_div_errore.substr(id_div_errore.lastIndexOf('_')+1)
			visualizza_off(id);
			return;
		}

		if (xmlhttp.status==200){

			// ...il vostro codice...
			var R = document.getElementById(id_div_errore);
			R.innerHTML = xmlhttp.responseText;
			if (id_div_errore=="dettagli_news"){
				cerca_news(0,'ris_news')
			}

			if (id_div_errore=="dettagli_itin"){

				if (document.getElementById("id_itinerario").value=="si"){
					ricaricaProv2("BA");
					document.getElementById("id_itinerario").value="no";
				}
			}

			if (id_div_errore=="ajax_alert"){
				if (document.getElementById(id_div_errore).innerHTML.indexOf('Impossibile')==-1){
					document.getElementById("add_tariffa").disabled=false;
					document.getElementById("img_add_tariffa").style.display='block';
					document.getElementById("upload").style.display='block';
				}			
			}

			if (id_div_errore.indexOf('error_off_')!=-1){
				var id=id_div_errore.substr(id_div_errore.lastIndexOf('_')+1)
				visual_form(id);
				visualizza_off(id);
			}

			if (id_div_errore=="seleziona_loc"){
				if (document.getElementById('sel_loc1')!=null){
					var ii;
					for (ii=0;ii<document.getElementById('sel_loc1').options.length;ii++){

						if (document.getElementById('sel_loc1').options[ii].value==document.getElementById('h_loc').value){
							document.getElementById('sel_loc1').options[ii].selected=true;
						}
					}
					numeroRisultati();
				}
			}

			if (id_div_errore=="seleziona_loc_strut"){
				var ii;
				for (ii=0;ii<document.getElementById('sel_loc1').options.length;ii++){

					if (document.getElementById('sel_loc1').options[ii].value==document.getElementById('h_loc').value){
						document.getElementById('sel_loc1').options[ii].selected=true;
					}
				}
			}

			if (id_div_errore=="sottocategoria_mod"){
				var ii;
				for (ii=0;ii<document.getElementById('sottocat').options.length;ii++){

					if (document.getElementById('sottocat').options[ii].value==document.getElementById('sotto_c').value){

						document.getElementById('sottocat').options[ii].selected=true;
					}
				}
			}

			if (id_div_errore=='drop_area_2'){
				posiziona();
				if (document.getElementById('nome_str_'+caga_num[4])!=null)
					str4='setta_grafico.php?padre=4&id='+caga_num[4]+'&ns='+document.getElementById('nome_str_'+caga_num[4]).value+'&datainizio='+document.getElementById('data_inizio_'+caga_num[4]).value+'&nc='+document.getElementById('nome_cam_'+caga_num[4]).value;

				if (document.getElementById('nome_str_'+caga_num[3])!=null)
					str3='setta_grafico.php?padre=3&id='+caga_num[3]+'&ns='+document.getElementById('nome_str_'+caga_num[3]).value+'&datainizio='+document.getElementById('data_inizio_'+caga_num[3]).value+'&num='+document.getElementById('num_gg_'+caga_num[3]).value+'&nc='+document.getElementById('nome_cam_'+caga_num[3]).value;

				if (document.getElementById('nome_str_'+caga_num[2])!=null)
					str2='setta_grafico.php?padre=2&id='+caga_num[2]+'&ns='+document.getElementById('nome_str_'+caga_num[2]).value+'&datainizio='+document.getElementById('data_inizio_'+caga_num[2]).value+'&num='+document.getElementById('num_gg_'+caga_num[2]).value+'&nc='+document.getElementById('nome_cam_'+caga_num[2]).value;

				if (document.getElementById('nome_str_'+caga_num[1])!=null)
					str1='setta_grafico.php?padre=1&id='+caga_num[1]+'&ns='+document.getElementById('nome_str_'+caga_num[1]).value+'&datainizio='+document.getElementById('data_inizio_'+caga_num[1]).value+'&nc='+document.getElementById('nome_cam_'+caga_num[1]).value;
			}

			if (id_div_errore=="drop_area1"||id_div_errore=="drop_area2"||id_div_errore=="drop_area3"||id_div_errore=="drop_area4"){
				i=id_div_errore.substr(id_div_errore.lastIndexOf('ea')+2);
				document.getElementById('div_drag'+caga_num[i]).style.position='relative';
				document.getElementById('div_drag'+caga_num[i]).style.left='0px';
				document.getElementById('div_drag'+caga_num[i]).style.top='0px';
				var j=parseInt(i)+1;
				c(j);
			}

			if (id_div_errore=="log_div" && document.getElementById(id_div_errore).innerHTML!=top.lingua[20])
				self.location.replace("servizi.php"); 

			if (id_div_errore=="log_div0" && document.getElementById(id_div_errore).innerHTML!=top.lingua[6])
				document.getElementById('renew_user').innerHTML=document.getElementById('username_ut').value;

			if (id_div_errore=="log_div2" && document.getElementById(id_div_errore).innerHTML==top.lingua[7])
				self.location.replace("index.php");

			if (id_div_errore=="info_strutt_div_pass" && document.getElementById(id_div_errore).innerHTML!=top.lingua[6])
				document.getElementById('renew_user').innerHTML=document.getElementById('username').value;

			if (id_div_errore=="ris_ricerca"){
				if (document.getElementById('tipo_it').style.position=='absolute'){

					document.getElementById('tipo_it').style.top=position2('casa_select','t')+'px';
					document.getElementById('tipo_it').style.left=position2('casa_select','l')+200+'px';
				}
			}
		} 
		else
		{
			alert(top.lingua[8]+ xmlhttp.status)
		}

	}

}



function position2(id,p){

                var ctl=document.getElementById(id);

				var aTag = document.getElementById(id);

                var leftpos=0;

                var toppos=0;

				do {

					aTag = aTag.offsetParent;

                    leftpos	+= aTag.offsetLeft;

					toppos += aTag.offsetTop;

				} while((aTag.tagName!="BODY")&&(aTag.tagName!="HTML"));





                if (p=="l")

                {

                    return leftpos+ctl.offsetLeft;

                }

                else

                    return toppos+ctl.offsetTop;





                 }



function do_load(url){

if (window.confirm('Confermare l\'eliminazione?')) loadXMLDoc(url);

}

//------------------------------------------------------------------------------------------------------------------------------------------------

function cancellaErrore(id_div_errore){

if (document.getElementById(id_div_errore)) document.getElementById(id_div_errore).innerHTML="";

}



function checkEmailAddress(field,errore)
{
	var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
	if (goodEmail){
		return true;
	} else {
		document.getElementById(errore).innerHTML=top.lingua[9];
		field.focus();
		field.select();
		return false;
	}
}

function IsDouble(field,errore)
//  check for valid numeric strings
{

	var strValidChars = "0123456789.";
	var strChar;
	var blnResult = true;
	var strString = field.value
	if (strString.length == 0) {
		if (document.getElementById(errore)) document.getElementById(errore).innerHTML=top.lingua[10];
		return false;
	}

	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++){
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1){
			blnResult = false;
		}
	}

	if (!blnResult){
		if (document.getElementById(errore)) 
			document.getElementById(errore).innerHTML=top.lingua[11];
		field.focus()
		field.select()
	}
	return blnResult;
}



function IsNumeric(field,errore)

   //  check for valid numeric strings

   {

   var strValidChars = "0123456789";

   var strChar;

   var blnResult = true;

   var strString = field.value

   if (strString.length == 0) {

     if (document.getElementById(errore)) document.getElementById(errore).innerHTML=top.lingua[10];

      return false;

      }



   //  test strString consists of valid characters listed above

   for (i = 0; i < strString.length && blnResult == true; i++)

      {

      strChar = strString.charAt(i);

      if (strValidChars.indexOf(strChar) == -1)

         {

         blnResult = false;

         }

      }

  if (!blnResult)

  {

     if (document.getElementById(errore)) document.getElementById(errore).innerHTML=top.lingua[11];

    field.focus()

    field.select()

  }

 return blnResult;

  }



function Is_void (field,errore)

   //  check for valid numeric strings

   {

   var blnResult = true;

   var strString = field.value;

   if (strString.length == 0) {

     if (document.getElementById(errore)) document.getElementById(errore).innerHTML=top.lingua[10];

      return false;

      }



 return blnResult;

  }



// per il form delle camere (registrazione)------------------------------------------------------------------------------------------------



function abilita_but(){

document.getElementById('sub').disabled=false;

}



function ricaricaProv(idd,localita)
{

//	visualizza_num_stelle();

	var sel=document.getElementById(idd);
	var prov=sel.options[sel.selectedIndex].value;
	id_div_errore="seleziona_loc";

	if (prov != ''){
		if(navigator.appName == 'Microsoft Internet Explorer'){
			document.getElementById('seleziona_loc_testo').style.display = 'inline';
			document.getElementById('seleziona_loc_testo').innerHTML = document.getElementById('seleziona_loc_testo_nascosto').innerHTML;
			document.getElementById('seleziona_loc').style.display = 'inline';
		} else {
			document.getElementById('seleziona_loc_testo').style.display = 'table-cell';
			document.getElementById('seleziona_loc').style.display = 'table-cell';
		}
		if (localita == null)
		{	
			loadXMLDoc('comuni_sel.php?prov='+prov+'&lingua='+top.tipo_lingua);
		} else {
			loadXMLDoc('comuni_sel.php?prov='+prov+'&lingua='+top.tipo_lingua+'&localita='+localita);
		}
	} else {
		document.getElementById('seleziona_loc_testo').style.display = 'none';
		document.getElementById('seleziona_loc').style.display = 'none';
		numeroRisultati();
	}
	
}

function ricaricaProv1(id,localita)

{



var sel=document.getElementById(id);

var prov=sel.options[sel.selectedIndex].value;

id_div_errore="seleziona_loc_strut";

if (localita == null)
		{	
			loadXMLDoc('comuni_sel.php?prov='+prov+'&lingua='+top.tipo_lingua);
		} else {
			loadXMLDoc('comuni_sel.php?prov='+prov+'&lingua='+top.tipo_lingua+'&localita='+localita);
		}

}



function hid_loc(ids,idd)
{

	var sel=document.getElementById(ids);
	if (sel != null){
		if (sel.selectedIndex == -1)
		{
			document.getElementById(idd).value = '';
		} else {
			document.getElementById(idd).value=sel.options[sel.selectedIndex].value;
		}
	} else {
		document.getElementById(idd).value = '';
	}
}







function validate_form3()
{

	vediCodice();

	var nome=document.getElementById("id_itin").value;
	var subm=true;
	document.getElementById('sub').disabled=true;
	
	if (nome=="") {
		document.getElementById("id_itin_notify").innerHTML="Campo assente!";
		subm=false;
	}


	if (document.getElementById('nuova_sot_cat')){
		if (document.getElementById('nuova_sot_cat').value==''){
			var sel=document.getElementById('sottocat');
			document.getElementById('sotto_c').value=sel.options[sel.selectedIndex].value;
		} else {
			document.getElementById('sotto_c').value=document.getElementById('nuova_sot_cat').value;
		}
	}


	if (subm){
		document.getElementById("itiner_reg_form").submit();
	} else ;


}






function validate_form4(){
vediCodice();
var nome=document.getElementById("id_itin").value;
var subm=true;
document.getElementById('sub').disabled=true;

if (subm){

document.getElementById("itiner_reg_form_uk").submit();
}else ;

}





function validate_form5(){
vediCodice();
var nome=document.getElementById("id_itin").value;
var subm=true;
document.getElementById('sub').disabled=true;

if (subm){

document.getElementById("itiner_reg_form_de").submit();
}else ;

}

function val_num(){
	if (!IsNumeric(document.getElementById("num"),'num_notify')) {
		alert('Inserisci un valore numerico!');
	}
}



function val_prezzo(){

if (!IsNumeric(document.getElementById("prezzo"),'prezzo_notify')) {

}

}





function val_posti(){

	if (!IsNumeric(document.getElementById("posti"),'posti_notify')) {
		alert('Inserisci un valore numerico!');
	}

}



function val_id_cam(){

var field=document.getElementById("id_cam").value;

if (field=="") {

document.getElementById("id_cam_notify").innerHTML="Campo assente!";

}

}



// per il form dell'utente (registrazione)------------------------------------------------------------------------------------------------

function valida_offerta(id)

{

var loc;

document.getElementById("data_off_"+id).onchange();

document.getElementById("prezzo_off_"+id).onchange();

if ((document.getElementById('errore_data_off'+id).innerHTML=="")&&(document.getElementById('errore_prezzo_off'+id).innerHTML==""))

id_div_errore="error_off_"+id;

loc="salva_offerta.php?id_cam="+id+"&data="+document.getElementById("data_off_"+id).value+"&prezzo="+document.getElementById("prezzo_off_"+id).value;

loadXMLDoc(loc);

}



function validate_form(){

var subm=true;

var nome=document.getElementById("nome_ut").value;

var cognome=document.getElementById("cognome_ut").value;

var mail=document.getElementById("mail_ut").value;

var user=document.getElementById("username_ut").value;

var tel=document.getElementById("tel_ut").value;

var pwd=document.getElementById("pass_ut").value;

var c_pwd=document.getElementById("conf_pass_ut").value;



if (cognome=="") {

document.getElementById("cognome_notify").innerHTML=top.lingua[10];

subm=false;

}

if (nome=="") {

document.getElementById("nome_notify").innerHTML=top.lingua[10];

subm=false;



}

if (pwd=="") {

document.getElementById("pwd_notify1").innerHTML=top.lingua[10];

subm=false;



}

if (c_pwd=="") {

document.getElementById("pwd_notify2").innerHTML=top.lingua[10];

subm=false;



}

if (pwd!=c_pwd) {

document.getElementById("pwd_notify2").innerHTML=top.lingua[12];

subm=false;



}

if (user=="") {

document.getElementById("username_notify2").innerHTML=top.lingua[10];

subm=false;



}



if (!IsNumeric(document.getElementById("tel_ut"),'tel_notify')) {

subm=false;



}



var goodEmail = mail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

if (!goodEmail){

document.getElementById("mail_notify").innerHTML=top.lingua[9];

subm=false;



}



if (subm){

document.getElementById("reg_form").submit();

}



}



function val_user(){

var field=document.getElementById("username_ut").value;

if (field=="") {

document.getElementById("username_notify2").innerHTML=top.lingua[10];

}

}



function val_nome(){

var field=document.getElementById("nome_ut").value;

if (field=="") {

document.getElementById("nome_notify").innerHTML=top.lingua[10];

}

}





function val_cognome(){

var field=document.getElementById("cognome_ut").value;

if (field=="") {

document.getElementById("cognome_notify").innerHTML=top.lingua[10];

}

}



function val_mail(){

var field=document.getElementById("mail_ut").value;

var goodEmail = field.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

if (!goodEmail){

document.getElementById("mail_notify").innerHTML=top.lingua[9];

}

}



function val_tel(){

if (!IsNumeric(document.getElementById("tel_ut"),'tel_notify')) {

}

}



function val_pwd(){

var pwd=document.getElementById("pass_ut").value;

var c_pwd=document.getElementById("conf_pass_ut").value;

if (pwd=="") {

document.getElementById("pwd_notify1").innerHTML=top.lingua[10];

}

if (c_pwd=="") {

document.getElementById("pwd_notify2").innerHTML=top.lingua[10];

}

if (pwd!=c_pwd) {

document.getElementById("pwd_notify2").innerHTML=top.lingua[12];

}

}



//--------------------------------------------------------------------------------------------------------------



function add_tarif(){

document.getElementById("add_tariffa").disabled=true;
document.getElementById("img_add_tariffa").style.display='none';

var new_tr=document.createElement("tr");

var new_td=document.createElement("td");

var new_tab=document.createElement("table"); var t_body = document.createElement("tbody");

var new_tr1=document.createElement("tr");var new_td1=document.createElement("td");var new_td2=document.createElement("td");

var new_tr2=document.createElement("tr");var new_td3=document.createElement("td");var new_td4=document.createElement("td");

var new_tr3=document.createElement("tr");var new_td5=document.createElement("td");var new_td6=document.createElement("td");

var new_tr4=document.createElement("tr");var new_td7=document.createElement("td");var new_td8=document.createElement("td");

var new_td9=document.createElement("td");var new_td10=document.createElement("td");var new_td11=document.createElement("td");var new_td12=document.createElement("td");

new_td10.setAttribute('id','errore_di'+id);



new_td11.setAttribute('id','errore_df'+id);



new_td12.setAttribute('id','errore_n'+id);



new_td9.setAttribute('id','errore_p'+id);



var new_div_e=document.createElement("div");

new_div_e.setAttribute('id','conf_tariffa_'+id);



var new_but=document.createElement("input");

var new_but1=document.createElement("input");

new_but.setAttribute('type',"button");

new_but1.setAttribute('type',"button");



new_tr.setAttribute('id',"tab_row_"+id);



var new_block=document.createElement("div");

new_block.setAttribute("id",id);



var new_tit=document.createElement("div");

new_tit.setAttribute("id","tariffa_"+id);

new_text=document.createTextNode("tariffa ");

new_tit.appendChild(new_text);



var new_input_text1= document.createElement("input");

new_input_text1.setAttribute('type','text');

new_input_text1.setAttribute('id',id+'text1');

new_input_text1.setAttribute('size','10');

new_input_text1.setAttribute('maxlength','10');

new_input_text1.setAttribute('readOnly','true');

new_input_text1.setAttribute('name',id);

new_input_text1.onclick=function (){popUpCalendar(this, this,'dd/mm/yyyy');cancellaErrore(new_td10.id);riab_save_but(this.name);}

new_input_text1.onchange=function (){verif_date(this.value,new_td10.id);}



new_text1=document.createTextNode("  data inizio   ");



new_td1.appendChild(new_text1);

new_td2.appendChild(new_input_text1);

new_tr1.appendChild(new_td1);

new_tr1.appendChild(new_td2);



var new_input_text2= document.createElement("input");

new_input_text2.setAttribute('type','text');

new_input_text2.setAttribute('id',id+'text2');

new_input_text2.setAttribute('size','10');

new_input_text2.setAttribute('maxlength','10');

new_input_text2.setAttribute('readOnly','true');

new_input_text2.setAttribute('name',id);

new_input_text2.onclick=function (){popUpCalendar(this, this,'dd/mm/yyyy');cancellaErrore(new_td11.id);riab_save_but(this.name);}

new_input_text2.onchange=function (){verif_date(this.value,new_td11.id);}



new_text2=document.createTextNode("  data fine     ");



new_td3.appendChild(new_text2);

new_td4.appendChild(new_input_text2);

new_tr2.appendChild(new_td3);

new_tr2.appendChild(new_td4);



var new_input_text3= document.createElement("input");

new_input_text3.setAttribute('type','text');

new_input_text3.setAttribute('id',id+'text3');

new_input_text3.setAttribute('size','10');

new_input_text3.setAttribute('maxlength','10');

new_input_text3.setAttribute('name',id);

new_text3=document.createTextNode("   prezzo giornaliero     ");

new_input_text3.onchange=function (){IsDouble(this,new_td9.id);}

new_input_text3.onkeyup=function (){riab_save_but(this.name);}

new_input_text3.onclick=function (){cancellaErrore(new_td9.id);riab_save_but(this.name);}

new_input_text3.onfocus=function (){cancellaErrore(new_td9.id);riab_save_but(this.name);}



new_td5.appendChild(new_text3);

new_td6.appendChild(new_input_text3);

new_tr3.appendChild(new_td5);

new_tr3.appendChild(new_td6);



var new_input_text4= document.createElement("input");

new_input_text4.setAttribute('type','text');

new_input_text4.setAttribute('id',id+'text4');

new_input_text4.setAttribute('size','20');

//new_input_text4.setAttribute('maxlength','6');

new_input_text4.setAttribute('name',id);

new_text4=document.createTextNode("   nome tariffa     ");

new_input_text4.onchange=function (){Is_void(this,new_td12.id);}

new_input_text4.onkeyup=function (){riab_save_but(this.name);}

new_input_text4.onclick=function (){cancellaErrore(new_td12.id);riab_save_but(this.name);}

new_input_text4.onfocus=function (){cancellaErrore(new_td12.id);riab_save_but(this.name);}



new_td7.appendChild(new_text4);

new_td8.appendChild(new_input_text4);

new_tr4.appendChild(new_td7);

new_tr4.appendChild(new_td8);



new_tr3.appendChild(new_td9);

new_tr1.appendChild(new_td10);

new_tr2.appendChild(new_td11);

new_tr4.appendChild(new_td12);



//new_but.setAttribute("id","cancel_"+id);

//new_but.setAttribute("name",id);

new_but.setAttribute("value","- elimina -");

my_style=new_but.style;

my_style.position="relative";

my_style.color="red";

my_style.left='83px';

new_but.setAttribute("style",my_style);

new_but.onclick=function (){rem_tarif(this.name);}



var new_image=document.createElement("img");
new_image.setAttribute("id","cancel_"+id);
new_image.setAttribute("name",id);
new_image.setAttribute('src',"images_ita/bottone_cancella.gif");
new_image.onclick=function (){rem_tarif(this.name);}

var new_image2=document.createElement("img");
new_image2.setAttribute("id","salva_"+id);
new_image2.setAttribute("name",id);
new_image2.setAttribute('src',"images_ita/bottone_salva.gif");
new_image2.onclick=function (){save_tarif(this.name);}

//new_tit.appendChild(new_but);

new_tit.appendChild(new_image);
new_tit.appendChild(new_image2);






new_but1.setAttribute("id","salva_"+id);

//new_but1.setAttribute("name",id);

new_but1.setAttribute("value","- salva -");

my_style=new_but1.style;

my_style.position="relative";

my_style.color="red";

my_style.left='82px';

new_but1.setAttribute("style",my_style);

new_but1.onclick=function (){save_tarif(this.name);}

//new_tit.appendChild(new_but1);



t_body.appendChild(new_tr4);

t_body.appendChild(new_tr1);

t_body.appendChild(new_tr2);

t_body.appendChild(new_tr3);



new_tab.appendChild(t_body);



new_block.appendChild(new_tit);

new_block.appendChild(new_tab);



new_td.appendChild(new_block);

new_tr.appendChild(new_td);

new_block.appendChild(new_div_e);



document.getElementById('tr_tariffe').getElementsByTagName('tbody')[0].appendChild(new_tr);



document.getElementById(id).style.border="1px black solid";

document.getElementById(id).style.width="330px";

//document.getElementById(id).style.height="150px";





//document.getElementById("tariffa_"+id).style.backgroundColor="#6185b5";

document.getElementById("tariffa_"+id).style.width="310px";

document.getElementById("tariffa_"+id).style.height="25px";

document.getElementById("tariffa_"+id).style.paddingLeft="20px";

document.getElementById("tariffa_"+id).style.color="#6185b5";



document.getElementById('errore_di'+id).style.color='#ff0000';

document.getElementById('errore_di'+id).style.fontSize='8pt';

document.getElementById('errore_df'+id).style.color='#ff0000';

document.getElementById('errore_df'+id).style.fontSize='8pt';

document.getElementById("errore_n"+id).style.color='#ff0000';

document.getElementById('errore_n'+id).style.fontSize='8pt';

document.getElementById("errore_p"+id).style.color='#ff0000';

document.getElementById('errore_p'+id).style.fontSize='8pt';





id++;

}



function rem_tarif(id){

id_div_errore="ajax_alert";

loadXMLDoc("conf_reg_elimina.php?id="+id);

var id_r="tab_row_"+id;

document.getElementById('tbody_tar').removeChild(document.getElementById(id_r));

alert('Tariffa eliminata correttamente');


}

//--------------------------------------------------------validaz tariffe



function valida_tarif(id){//this.name

var bool=true;

var d1=document.getElementById(id+'text1');

var d2=document.getElementById(id+'text2');

var n=document.getElementById(id+'text4');

var p=document.getElementById(id+'text3');

var but=document.getElementById('salva_'+id);



if (!Is_void(d1,'errore_di'+id )|| !verif_date(d1.value,'errore_di'+id)) bool=false;

if (!Is_void(d2,'errore_df'+id )|| !verif_date(d2.value,'errore_df'+id)) bool=false;

if ( !Is_void(n,'errore_n'+id)) bool=false;

if ( !Is_void(p,'errore_p'+id) || !IsDouble(p,'errore_p'+id)) bool=false;

if (!confronta(d1,d2,'errore_df'+id)) bool=false;



if (bool==true) {

but.disabled=true;

document.getElementById('errore_di'+id).innerHTML='';

document.getElementById('errore_df'+id).innerHTML='';

document.getElementById('errore_n'+id).innerHTML='';

document.getElementById('errore_p'+id).innerHTML='';

}

return bool;

}



function save_tarif(id){

if (valida_tarif(id)){



document.getElementById("add_tariffa").disabled=false;
document.getElementById("img_add_tariffa").style.display='block';

var d1=document.getElementById(id+'text1').value;

var d2=document.getElementById(id+'text2').value;

var n=document.getElementById(id+'text4').value;

var p=document.getElementById(id+'text3').value;

var loc='conf_reg_tariffa.php?id='+id+'&nome='+n+'&data_inizio='+d1+'&data_fine='+d2+'&prezzo='+p;

id_div_errore='conf_tariffa_'+id;

loadXMLDoc(loc);



}

//else ...

}



//--------------------------------------------------------



function riab_save_but(id){

if (document.getElementById('salva_'+id)){

var but=document.getElementById('salva_'+id);

but.disabled=false;

}

}



function concat_value(){

var tipo=document.getElementById("tipo_cam").value;

var posti=document.getElementById("posti").value;

var nome=document.getElementById("id_cam").value;

var desc=document.getElementById("desc").value;

var num=document.getElementById("num").value;

var loc='conf_reg_camera.php?tipo_cam='+tipo+'&posti='+posti+'&nome='+nome+'&desc='+desc+'&num='+num;

return loc;



}

function visualizza_div(id,chiamante)
{
	if	(document.getElementById('prov').value == ''){
		alert(top.lingua[17]);
	} else {
		if (document.getElementById(chiamante).innerHTML==top.lingua[15]){
			document.getElementById(id).style.display='block';
			document.getElementById(chiamante).innerHTML=top.lingua[16];
		} else {
			document.getElementById(id).style.display='none';
			document.getElementById(chiamante).innerHTML=top.lingua[15];
		}
	}	
	if (document.getElementById("drop_area_2")!=null)
		posiziona();
	
}


function tool_tip1(id,colore){

document.getElementById(id).style.backgroundColor=colore;

}

function visualizza_off(id){

id_div_errore='off_'+id;

loadXMLDoc('visualizza_offerte.php?id_cam='+id);

}


function visualizza_div2(id,chiamante){
if (document.getElementById(chiamante).innerHTML=='Visualizza commenti')
{
document.getElementById(id).style.display='block';
document.getElementById(chiamante).innerHTML='Nascondi commenti';
}
else
{
document.getElementById(id).style.display='none';
document.getElementById(chiamante).innerHTML='Visualizza commenti';
}

if (document.getElementById("drop_area_2")!=null)
posiziona()
}


function nascondi(id){

id_div_errore='off_'+id;

loadXMLDoc('ritornano.php?id_cam='+id);

}



function visual_form(id){

if (document.getElementById('link_'+id).innerHTML!='Nascondi')

{

    document.getElementById('form_offerta_'+id).style.display='block';

    document.getElementById('link_'+id).innerHTML='Nascondi';

    document.getElementById('error_off_'+id).innerHTML='';

}

else

{

    document.getElementById('prezzo_off_'+id).value="";

    document.getElementById('data_off_'+id).value="";

    document.getElementById('form_offerta_'+id).style.display='none';

    document.getElementById('link_'+id).innerHTML='Inserisci offerta';

}



}

//---------------------------------------------------------------------------------------------funzione info



function echo_info(){

 document.getElementById('info_div').innerHTML=top.lingua[13];



}



function delete_info() {

 document.getElementById('info_div').innerHTML="Info";



}

//------------------------------------------------------------------------

function del_mess(){

 document.getElementById('inser_itin').innerHTML="";

}



function numeroRisultati()
{
	
	var loc;
	var sel=document.getElementById('prov');
	var prov=sel.options[sel.selectedIndex].value;

	if (document.getElementById('cont')==null)   //usato quando nn serve contare numeri
		return;

	//provincia
	loc="?prov="+prov;

	//dettagli ricerca avanzata
	var i=0;
	var j=0;
	for (i=0;i<=document.getElementById('cont').value;i++){
		if (document.getElementById('det_'+i).checked==true){
//			loc=loc+"&det_"+j+"="+document.getElementById('det_'+i).value;
			loc=loc+"&det_"+j+"="+i;
			j++;
		}
	}
	loc=loc+"&num_det="+j;

	//numero posti
	if (document.getElementById('num_posti').value!= null){
		loc=loc+"&num_posti="+document.getElementById('num_posti').value
	}
	if (document.getElementById('da').value!= null){
		loc=loc+"&data_da="+document.getElementById('da').value
	}
	if (document.getElementById('a').value!= null){
		loc=loc+"&data_a="+document.getElementById('a').value
	}
	//filtri tipo struttura e numero stelle e nome struttura
	if (document.getElementById('filtro_tipo_struttura').value!= null){
		loc=loc+"&filtro_tipo_struttura="+document.getElementById('filtro_tipo_struttura').value
	}
	if (document.getElementById('filtro_num_stelle').value!= null){
		loc=loc+"&filtro_num_stelle="+document.getElementById('filtro_num_stelle').value
	}
	if (document.getElementById('filtro_nome_struttura').value!= null){
		loc=loc+"&filtro_nome_struttura="+document.getElementById('filtro_nome_struttura').value
	}

	fine_url = document.location.pathname.substr(document.location.pathname.length-8, 8);

	if (fine_url == 'mera.php'){
		loc="nulla";
//		loc="ajax/numero_camere.php"+loc;
//		id_div_errore="num_risultati";
//		loadXMLDoc(loc);
	} else {
		loc="ajax/numero_strutture.php"+loc;
		id_div_errore="num_risultati";
		loadXMLDoc(loc);
	}

}


function visualizza_num_stelle()
{
	filtro = document.getElementById('filtro_tipo_struttura').value;
	if (filtro == 1){
		document.getElementById('filtro_num_stelle_select').style.display="block";
		document.getElementById('filtro_num_stelle_testo').style.display="block";
	} else {
		document.getElementById('filtro_num_stelle_select').style.display="none";
		document.getElementById('filtro_num_stelle_testo').style.display="none";
		document.getElementById('filtro_num_stelle').value = 0;
	}
}



//------------------------------------------------------------------------------itinerario modifica



function error_mod_itin(){
	document.getElementById('div_mod_itin').innerHTML=top.lingua[14];
}



//------------------------------------------------------------------------modifica user



function conf_mod_user(url){



var subm=true;

var nome=document.getElementById("nome_ut").value;

var cognome=document.getElementById("cognome_ut").value;

var mail=document.getElementById("mail_ut").value;

var user=document.getElementById("username_ut").value;

var tel=document.getElementById("tel_ut").value;





if (cognome=="") {

document.getElementById("cognome_notify").innerHTML=top.lingua[10];

subm=false;

}

if (nome=="") {

document.getElementById("nome_notify").innerHTML=top.lingua[10];

subm=false;



}





if (user=="") {

document.getElementById("username_notify2").innerHTML=top.lingua[10];

subm=false;



}



if (!IsNumeric(document.getElementById("tel_ut"),'tel_notify')) {

subm=false;



}



var goodEmail = mail.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);

if (!goodEmail){

document.getElementById("mail_notify").innerHTML=top.lingua[9];

subm=false;



}



if (subm){

loadXMLDoc(url);

}



}



function conf_pwd_user(url){

var subm=true;

var pwd=document.getElementById("pw2").value;

var c_pwd=document.getElementById("pw3").value;

id_div_errore='info_strutt_div_pass2';

if (pwd=="") {

document.getElementById("pwd_notify1").innerHTML=top.lingua[10];

subm=false;



}

if (c_pwd=="") {

document.getElementById("pwd_notify2").innerHTML=top.lingua[10];

subm=false;



}



if (pwd!=c_pwd) {

document.getElementById("pwd_notify2").innerHTML=top.lingua[12];

subm=false;



}

if (subm){

loadXMLDoc(url);



}





}



function conf_canc_user(url){

if (window.confirm('Confermare l\'eliminazione?')) loadXMLDoc(url);

}



// ----------------------------------------------------appartengona al form itinerari


function cercasottocategoria(id)
{

	var sel=document.getElementById('tipo_itin');
	var prov=sel.options[sel.selectedIndex].value;
	id_div_errore=id;
	loadXMLDoc('trova_sottocategoria.php?categoria='+prov);

}



function nuovo(){

var sel=document.getElementById('sottocat');

var prov=sel.options[sel.selectedIndex].value;

if (prov=='nuovo')

 document.getElementById('nuova_sot_cat').style.display='block';

 else

 spegni()

}



function spegni(){

 document.getElementById('nuova_sot_cat').style.display='none';

 document.getElementById('nuova_sot_cat').value='';

}

//-------------------------------------------------------------modifica info struttura



function conf_mod_strut(url){

subm=true;

id_div_errore="info_strutt_div_pass";

var v=document.getElementById('username').value;



if (v=="") {

subm=false;



document.getElementById("info_strutt_div_pass0").innerHTML=top.lingua[10];



}

if (subm){

loadXMLDoc(url);



}





}





function registra_mail(valore)
{
	id_div_errore="e_mail";
	if (checkEmailAddress(valore,"e_mail")){
		loadXMLDoc("prova.php?email="+valore.value);
	}
}





function duplica_href()
{
	if (document.getElementById('h1')!=null)
		document.getElementById('a1').style.visibility="visible";
	if (document.getElementById('h2')!=null)
		document.getElementById('a2').style.visibility="visible";
}



function mypopup(url_file)
{
	var  mywindow = window.open (url_file,"mywindow","location=1,status=1,scrollbars=1,resizable=yes, width=423,height=300");
	mywindow.moveTo(100,200);
} 

function mypopup_img(url_img,larghezza,altezza,itin)
{
	meno_estensione = url_img.substr(0,url_img.length-4);
	estensione = url_img.substr(url_img.length-4);
	larghezza = 500;
	altezza = 500;
	var mywindow = window.open ('player_img_new.php?nome='+meno_estensione+'&est='+estensione+'&itin='+itin,"mywindow","location=1,status=1,scrollbars=0,resizable=yes, width="+larghezza+",height="+altezza);
	mywindow.moveTo(50,50);
} 

function myplayer_img(url_img,larghezza,altezza,itin)
{
	meno_estensione = url_img.substr(0,url_img.length-4);
	estensione = url_img.substr(url_img.length-4);
	larghezza = parseInt(larghezza) + 30;
	altezza = parseInt(altezza) + 30;	
	window.resizeTo(larghezza,altezza+100);
	document.location.href = 'player_img_new.php?nome='+meno_estensione+'&est='+estensione+'&itin='+itin;
} 


function get_height(){



browsername=navigator.appName;

if (browsername.indexOf("Netscape")!=-1) {browsername="NS"}

else

{if (browsername.indexOf("Microsoft")!=-1) {browsername="MSIE";document.getElementById('tab').style.top='-3px';}

else {browsername="N/A"}};





}



function svuota(){
	document.getElementById('da').value="";
	document.getElementById('a').value="";
	document.getElementById('num_posti').value="";
	for (var i=0;i<=document.getElementById('cont').value;i++){
		document.getElementById('det_'+i).checked=false;
	}
	numeroRisultati();
}

function svuota_motore_itin(){
	document.getElementById('cerca').value="";
}


function itinerari_body_onload()
{
	ricaricaProv('prov');
	window.setTimeout("cerca_itin(0,'ris_ricerca',0)",500);
}

function scelta_div(nome_div, lingua, id_abb)
{
	document.getElementById('descrizione').style.display = 'none';
	document.getElementById('dettagli').style.display = 'none';
	if (id_abb != 4){
		document.getElementById('camere').style.display = 'none';
		document.getElementById('mappa_e_meteo').style.display = 'none';
		document.getElementById('itinerari').style.display = 'none';
	}

	document.getElementById(nome_div).style.display = 'block';

	document.getElementById('img_descrizione').src = 'images_'+lingua+'/div_descrizione.gif';
	document.getElementById('img_dettagli').src = 'images_'+lingua+'/div_dettagli.gif';
	if (id_abb != 4){
		document.getElementById('img_camere').src = 'images_'+lingua+'/div_camere.gif';
		document.getElementById('img_mappa_e_meteo').src = 'images_'+lingua+'/div_mappa_e_meteo.gif';
		document.getElementById('img_itinerari').src = 'images_'+lingua+'/div_itinerari.gif';
	}

	document.getElementById('img_'+nome_div).src = 'images_'+lingua+'/div_'+nome_div+'_b.gif';

}

function conta_click_banner_adv(num)
{
	id_div_errore="click_ban";
	loadXMLDoc("ajax/conta_banner_adv.php?id_b="+num);
}



