function VerificaDatePreventivo(lingua,form,contatore){
	var error = '';
	data_arrivo=new Date()
	data_partenza=new Date()
	today = new Date()
	today=Date.parse(today);

	switch(lingua){
		case'it':
			data_arrivo_data_odierna="La data di arrivo non puo' essere inferiore dalla data odierna";
			data_partenza_data_arrivo="La data di partenza non puo' essere inferiore dalla data di arrivo";
			inserire_data_arrivo = "Inserire la data di arrivo";
			inserire_data_partenza = "Inserire la data di partenza";
		break;
		case'en':
			data_arrivo_data_odierna="The arrival date cannot today be inferior from the date";
			data_partenza_data_arrivo="The departure date cannot be inferior from the arrival date";
			inserire_data_arrivo = "Insert the arrival date";
			inserire_data_partenza = "Insert the departure date";
		break;
		case'fr':
			data_arrivo_data_odierna="La date d'arrivée ne peut pas aujourd'hui être inférieure de la date";
			data_partenza_data_arrivo="La date de départ ne peut pas être inférieure de la date d'arrivée";
			inserire_data_arrivo = "Insérer la date d'arrivée";
			inserire_data_partenza = "Insérer la date de départ";
		break;
		case'de':
			data_arrivo_data_odierna="Das Ankunft Datum kann nicht vom Datum minderwertig heute sein";
			data_partenza_data_arrivo="Das Abfahrtdatum kann nicht vom Ankunft Datum minderwertig sein";
			inserire_data_arrivo = "Geben Sie das Ankunft Datum";
			inserire_data_partenza = "Geben Sie das Abfahrtdatum";
		break;
	}

	giorno_arrivo=eval("document."+form+"_"+contatore+".gg_arrivo.selectedIndex")+1;
	mese_arrivo=eval("document."+form+"_"+contatore+".mm_arrivo.selectedIndex")+1;
	anno_arrivo=eval("document."+form+"_"+contatore+".aa_arrivo.selectedIndex")+1;
	giorno_partenza=eval("document."+form+"_"+contatore+".gg_partenza.selectedIndex")+1;
	giorno_mese=eval("document."+form+"_"+contatore+".mm_partenza.selectedIndex")+1;
	anno_partenza=eval("document."+form+"_"+contatore+".aa_partenza.selectedIndex")+1;

	/*Date della prenotazione*/
	if( (giorno_arrivo>0) || (mese_arrivo>0) || (anno_arrivo>0) || (giorno_partenza>0) || (giorno_mese>0) || (anno_partenza>0) ) {
		//data di arrivo
		gg_arrivo=new String()
		gg_arrivo=eval("document."+form+"_"+contatore+".gg_arrivo.options[document."+form+"_"+contatore+".gg_arrivo.selectedIndex].value;");
		//gg_arrivo=document.dati.gg_arrivo.options[document.dati.gg_arrivo.selectedIndex].value;
		mm_arrivo=new String()
		mm_arrivo=eval("document."+form+"_"+contatore+".mm_arrivo.options[document."+form+"_"+contatore+".mm_arrivo.selectedIndex].value;");
		//mm_arrivo=document.dati.mm_arrivo.options[document.dati.mm_arrivo.selectedIndex].value;
		aa_arrivo=new String()
		aa_arrivo=eval("document."+form+"_"+contatore+".aa_arrivo.options[document."+form+"_"+contatore+".aa_arrivo.selectedIndex].value;");
		//aa_arrivo=document.dati.aa_arrivo.options[document.dati.aa_arrivo.selectedIndex].value;
		data_arrivo=new Date( mm_arrivo + "/" + gg_arrivo + "/" + aa_arrivo );
		data_arrivo=Date.parse(data_arrivo);

		//data di partenza
		gg_partenza=new String()
		gg_partenza=eval("document."+form+"_"+contatore+".gg_partenza.options[document."+form+"_"+contatore+".gg_partenza.selectedIndex].value;");
		//gg_partenza=document.dati.gg_partenza.options[document.dati.gg_partenza.selectedIndex].value;
		mm_partenza=new String()
		mm_partenza=eval("document."+form+"_"+contatore+".mm_partenza.options[document."+form+"_"+contatore+".mm_partenza.selectedIndex].value;");
		//mm_partenza=document.dati.al_mm.options[document.dati.mm_partenza.selectedIndex].value;
		aa_partenza=new String()
		aa_partenza=eval("document."+form+"_"+contatore+".aa_partenza.options[document."+form+"_"+contatore+".aa_partenza.selectedIndex].value;");
		//aa_partenza=document.dati.aa_partenza.options[document.dati.aa_partenza.selectedIndex].value;
		data_partenza=new Date( mm_partenza + "/" + gg_partenza + "/" + aa_partenza );
		data_partenza=Date.parse(data_partenza);

		if (data_arrivo <= today) {
			alert(data_arrivo_data_odierna);
			eval("document."+form+"_"+contatore+".gg_arrivo.focus()");
			return false;
		}
		if (data_partenza < data_arrivo) {
			alert(data_partenza_data_arrivo);
			eval("document."+form+"_"+contatore+".gg_partenza.focus()");
			return false;
		}
	}
	if( (giorno_arrivo==0) || (mese_arrivo==0) || (anno_arrivo==0) ) {
		alert(inserire_data_arrivo);
		eval("document."+form+"_"+contatore+".gg_arrivo.focus()");
		return false;
	}
	
	if( (giorno_partenza==0) || (giorno_mese==0) || (anno_partenza==0) ) {
		alert(inserire_data_partenza);
		eval("document."+form+"_"+contatore+".gg_partenza.focus()");
		return false;
	}


	if (error == ''){
		eval("document."+form+"_"+contatore+".submit()");
		return true;
	}else{
		alert(error);
		return false;
	}
}

function VerificaPreventivo(lingua,form,contatore){
	var error = '';

	switch(lingua){
		case'it':
			inserire_nome = 'Inserire il nome';
			indirizzo_email = "Specificare l'indirizzo email";
			indirizzo_email_sbagliato = "L'indirizzo email non e' stato digitato correttamente";
			autorizzo = "Autorizzare al trattamento dei dati";
		break;
		case'en':
			inserire_nome = 'Insert name';
			indirizzo_email = 'Specify email address';
			indirizzo_email_sbagliato = 'The Email address is not correct';
			autorizzo = "To authorize to the treatment of the data";
		break;
		case'fr':
			inserire_nome = 'Insérer le nom';
			indirizzo_email = "Spécifier l'adresse email";
			indirizzo_email_sbagliato = "Le email address n'est pas correct";
			autorizzo = "Pour autoriser au traitement des données";
		break;
		case'de':
			inserire_nome = 'Geben Sie Ihren Namen an';
			indirizzo_email = "Geben Sie Ihre Email-Addresse an";
			indirizzo_email_sbagliato = "Die Email-Addresse ist nicht korrekt";
			autorizzo = "Zur Verarbeitung der Daten autorisieren";
		break;
	}

	if(eval("document."+form+"_"+contatore+".nome.value")==""){
		alert(inserire_nome);
		eval("document."+form+"_"+contatore+".nome.focus()");
		return false;
	}
	if(eval("document."+form+"_"+contatore+".email.value")==""){
		alert(indirizzo_email);
		eval("document."+form+"_"+contatore+".email.focus()");
		return false;
	}
	if(!checkMail(eval("document."+form+"_"+contatore+".email.value"))){
		alert(indirizzo_email_sbagliato);
		eval("document."+form+"_"+contatore+".email.focus()");
		return false;
	}
	if(eval("document."+form+"_"+contatore+".privacy.checked")==false){
		alert(autorizzo);
		eval("document."+form+"_"+contatore+".privacy.focus()");
		return false;
	}

	if (error == ''){
		eval("document."+form+"_"+contatore+".submit()");
		return true;
	}else{
		alert(error);
		return false;
	}
}


function Verificadati_completo(form){
	var error = '';
	data_arrivo=new Date()
	data_partenza=new Date()
	today = new Date()
	today=Date.parse(today);

	data_arrivo_data_odierna="La data di arrivo non puo' essere inferiore dalla data odierna";
	data_partenza_data_arrivo="La data di partenza non puo' essere inferiore dalla data di arrivo";
	inserire_data_arrivo = "Inserire la data di arrivo";
	inserire_data_partenza = "Inserire la data di partenza";
	inserire_nome = 'Inserire il nome';
	indirizzo_email = "Specificare l'indirizzo email";
	indirizzo_email_sbagliato = "L'indirizzo email non e' stato digitato correttamente";
	indirizzo_conferma_email = "Le due email che hai inserito devono essere uguali";
	autorizzo = "Autorizzare al trattamento dei dati";

	if(eval("document."+form+".nome.value")==""){
		alert(inserire_nome);
		eval("document."+form+".nome.focus()");
		return false;
	}
	if(eval("document."+form+".email.value")==""){
		alert(indirizzo_email);
		eval("document."+form+".email.focus()");
		return false;
	}
	if(!checkMail(eval("document."+form+".email.value"))){
		alert(indirizzo_email_sbagliato);
		eval("document."+form+".email.focus()");
		return false;
	}
	if(eval("document."+form+".email.value")!=eval("document."+form+".conferma_email.value")){
		alert(indirizzo_conferma_email);
		eval("document."+form+".conferma_email.focus()");
		return false;
	}

	giorno_arrivo=eval("document."+form+".gg_arrivo.selectedIndex")+1;
	mese_arrivo=eval("document."+form+".mm_arrivo.selectedIndex")+1;
	anno_arrivo=eval("document."+form+".aa_arrivo.selectedIndex")+1;
	giorno_partenza=eval("document."+form+".gg_partenza.selectedIndex")+1;
	giorno_mese=eval("document."+form+".mm_partenza.selectedIndex")+1;
	anno_partenza=eval("document."+form+".aa_partenza.selectedIndex")+1;

	/*Date della prenotazione*/
	if( (giorno_arrivo>0) || (mese_arrivo>0) || (anno_arrivo>0) || (giorno_partenza>0) || (giorno_mese>0) || (anno_partenza>0) ) {
		//data di arrivo
		gg_arrivo=new String()
		gg_arrivo=eval("document."+form+".gg_arrivo.options[document."+form+".gg_arrivo.selectedIndex].value;");
		//gg_arrivo=document.dati.gg_arrivo.options[document.dati.gg_arrivo.selectedIndex].value;
		mm_arrivo=new String()
		mm_arrivo=eval("document."+form+".mm_arrivo.options[document."+form+".mm_arrivo.selectedIndex].value;");
		//mm_arrivo=document.dati.mm_arrivo.options[document.dati.mm_arrivo.selectedIndex].value;
		aa_arrivo=new String()
		aa_arrivo=eval("document."+form+".aa_arrivo.options[document."+form+".aa_arrivo.selectedIndex].value;");
		//aa_arrivo=document.dati.aa_arrivo.options[document.dati.aa_arrivo.selectedIndex].value;
		data_arrivo=new Date( mm_arrivo + "/" + gg_arrivo + "/" + aa_arrivo );
		data_arrivo=Date.parse(data_arrivo);

		//data di partenza
		gg_partenza=new String()
		gg_partenza=eval("document."+form+".gg_partenza.options[document."+form+".gg_partenza.selectedIndex].value;");
		//gg_partenza=document.dati.gg_partenza.options[document.dati.gg_partenza.selectedIndex].value;
		mm_partenza=new String()
		mm_partenza=eval("document."+form+".mm_partenza.options[document."+form+".mm_partenza.selectedIndex].value;");
		//mm_partenza=document.dati.al_mm.options[document.dati.mm_partenza.selectedIndex].value;
		aa_partenza=new String()
		aa_partenza=eval("document."+form+".aa_partenza.options[document."+form+".aa_partenza.selectedIndex].value;");
		//aa_partenza=document.dati.aa_partenza.options[document.dati.aa_partenza.selectedIndex].value;
		data_partenza=new Date( mm_partenza + "/" + gg_partenza + "/" + aa_partenza );
		data_partenza=Date.parse(data_partenza);

		if (data_arrivo <= today) {
			alert(data_arrivo_data_odierna);
			eval("document."+form+".gg_arrivo.focus()");
			return false;
		}
		if (data_partenza < data_arrivo) {
			alert(data_partenza_data_arrivo);
			eval("document."+form+".gg_partenza.focus()");
			return false;
		}
	}
	if( (giorno_arrivo==0) || (mese_arrivo==0) || (anno_arrivo==0) ) {
		alert(inserire_data_arrivo);
		eval("document."+form+".gg_arrivo.focus()");
		return false;
	}
	
	if( (giorno_partenza==0) || (giorno_mese==0) || (anno_partenza==0) ) {
		alert(inserire_data_partenza);
		eval("document."+form+".gg_partenza.focus()");
		return false;
	}

	if(eval("document."+form+".privacy.checked")==false){
		alert(autorizzo);
		eval("document."+form+".privacy.focus()");
		return false;
	}

	if (error == ''){
//		eval("document."+form+".submit()");
		return true;
	}else{
//		alert(error);
		return false;
	}
}


/** Controlla la correttezza dell'indirizzo email.
	Forse si può sostituire con una funzione PHP per il controllo delle expr regolari, tipo eregi(). */
function checkMail(mail){
	var iAtPosition;
	var iDotPosition;

	iAtPosition = mail.indexOf("@");
	if (iAtPosition < 1 || iAtPosition == mail.length)
		return false;
	iDotPosition = mail.indexOf('.', iAtPosition);
	if (iDotPosition < 0)
		return false;
	return true;
}	// checkMail()

function VerificaNewsletter(lingua, nome_form){
	var error = '';

	//switch(lingua){
	//	case'it':
			inserire_nome = 'Inserire il nome';
			inserire_cognome = 'Inserire il cognome';
			indirizzo_email = "Specificare l'indirizzo email";
			indirizzo_email_sbagliato = "L'indirizzo email non è stato digitato correttamente";
			autorizzo = "Autorizzare al trattamento dei dati";
	/*	break;
		case'en':
			inserire_nome = 'Insert name';
			inserire_cognome = 'Insert last Name';
			indirizzo_email = 'Specify email address';
			indirizzo_email_sbagliato = 'The Email address is not correct';
			autorizzo = "To authorize to the treatment of the data";
		break;
		case'fr':
			inserire_nome = 'Insérer le nom';
			inserire_cognome = 'Insérer le nom';
			indirizzo_email = "Spécifier l'adresse email";
			indirizzo_email_sbagliato = "Le email address n'est pas correct";
			autorizzo = "Pour autoriser au traitement des données";
		break;
		case'de':
			inserire_nome = 'Geben Sie Ihren Namen an';
			inserire_cognome = 'Geben Sie Ihren Nachname an';
			indirizzo_email = "Geben Sie Ihre Email-Addresse an";
			indirizzo_email_sbagliato = "Die Email-Addresse ist nicht korrekt";
			autorizzo = "Zur Verarbeitung der Daten autorisieren";
		break;
	}*/

/*	if(document.form_newsletter.nome.value==""){
		alert(inserire_nome);
		document.form_newsletter.nome.focus();
		return false;
	}
	if(document.form_newsletter.cognome.value==""){
		alert(inserire_cognome);
		document.form_newsletter.cognome.focus();
		return false;
	}
*/
	if(eval("document."+form+".email_newsletter.value")==""){
		alert(indirizzo_email);
		eval("document."+form+".email_newsletter.focus()");
		return false;
	}
	if(!checkMail(eval("document."+form+".email_newsletter.value"))){
		alert(indirizzo_email_sbagliato);
		eval("document."+form+".email_newsletter.focus()");
		return false;
	}
	if(document.form_newsletter.privacy.checked==false){
		alert(autorizzo);
		document.form_newsletter.privacy.focus();
		return false;
	}

	if (error == ''){
		eval("document."+form+".submit()");
		return true;
	}else{
//		alert(error);
		return false;
	}
}

function SelHotel(form, name, i){
	var nome_div = document.getElementById(name);
	var nome_input = document.getElementById('num_hotel_selezionati').value;
	var classe="";

	if(nome_div.className=='item'){
		nome_div.className='item selected';
		nome_input++;
	}else if(nome_div.className=='item last'){
		nome_div.className='item selected last';
		nome_input++;
	}else{
	  if(((i%5)==0) && (i!=1)) classe=' last';
		nome_div.className='item'+classe;
		nome_input--;
	}
	document.getElementById('num_hotel_selezionati').value=nome_input;
}

//conta click nella scheda
function conta(url){ 
	var s = document.createElement('SCRIPT');
	s.type = 'text/javascript';
	s.src = url;
	window.document.body.appendChild (s);
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	//chars = chars || "\\s";
	//return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
	return str.replace(new RegExp("^[ ]+", "g"), "");
}

function rtrim(str, chars) {
	//chars = chars || "\\s";
	//return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	return str.replace(new RegExp("[ ]+$", "g"), "");
}

function TogliServizio(servizio, event){
	var nome_div = document.ricerca_hotel.ric_servizi.value;
//	alert("_"+nome_div+"_ - _"+trim(nome_div)+"_"+" - _"+servizio.toLowerCase()+"_");
	//nome_div=nome_div.substring(-1)
	var array=nome_div.split(",");
	var input="";

	for(var i in array){
	  array[i]=trim(array[i]);
	  if(array[i]!=''){
		if(array[i].toLowerCase()!=servizio.toLowerCase()) input+=array[i]+", ";
		//alert(input);
	  }
	}
	document.ricerca_hotel.ric_servizi.value=input;
//	return false;
}

function EliminaLuogo(filtro, event){
	var nome_div = document.ricerca_hotel.ric_luogo.value;
	nome_div=nome_div.toLowerCase();
	var array=nome_div.split(", ");
	var input="";

	for(var i in array){
	  if(array[i]!=''){
		if(array[i]!=filtro.toLowerCase()) input=array[i];
	  }
	}
	document.ricerca_hotel.ric_luogo.value=input;
//	return false;
}

function EliminaLuogoMultiplo(luogo, event){
	var nome_div = document.ricerca_hotel.ric_luogo.value;
	nome_div=nome_div.toLowerCase();
	var array=nome_div.split(", ");
	var input="";
	for(var i in array){
	  if(array[i]!=''){
		if(array[i]!=luogo){
			input+=array[i]+", ";
		}
	  }
	}
	document.ricerca_hotel.ric_luogo.value=input;
//	return false;
}

/*Apri lastsecond*/
function apri(){
	$('.box_lastsecond').slideToggle();
}


/**************************** per geomaps  - inizio ****************************************************************************/
function mostraDove_siamo(html, geomaps){
	google.setOnLoadCallback(initialize("map", html, geomaps));
}

// Call this function when the page has been loaded 
function initialize(div, html, geomaps) { 
	var map = new google.maps.Map2(document.getElementById(div));

	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());

	var array=geomaps.split(", ");
	var longi=parseFloat(array[0]);
	var latit=parseFloat(array[1]);

	point = new google.maps.LatLng(longi, latit);
	map.setCenter(point, 13);

	var marker = new GMarker(point);
	GEvent.addListener(marker, "click", function() {
	  marker.openInfoWindowHtml(html);
	});
	map.addOverlay(marker);
}

function showAddress(address, html, geomaps, address_hotel) {
  var map = new google.maps.Map2(document.getElementById("map"));
  map.addControl(new GLargeMapControl());
  map.addControl(new GMapTypeControl());

  var array=geomaps.split(", ");
  var longi=parseFloat(array[0]);
  var latit=parseFloat(array[1]);

  point = new google.maps.LatLng(longi, latit);
  map.setCenter(point, 13);

  var marker = new GMarker(point);
  GEvent.addListener(marker, "click", function() {
	marker.openInfoWindowHtml(address_hotel);
  });
  map.addOverlay(marker);

  
  geocoder = new GClientGeocoder();
  if (geocoder) {
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) {
		  alert(address + " not found");
		} else {
		map.setCenter(point, 13);
		var marker2 = new GMarker(point);
		GEvent.addListener(marker2, "click", function() {
		  marker2.openInfoWindowHtml(address+html);
		});
		map.addOverlay(marker2);
		}
	  }
	);
  }
}
/**************************** per geomaps  - fine ****************************************************************************/

/**************************** init.js  - inizio ****************************************************************************/
function bn_init () {
	BnElencoClick();
	//BnListClick();
	BnEmptyClick();
	BnConfrontaInit();
}

function BnElencoClick(){
  var bnList = $('span.maniglia_hotel');
  if (bnList.length>0){
	for (var i=0; i<bnList.length; i++) {
	  var tmp = new BnInterface('pulsante');
	  var code = tmp.pulsante.getCode($(bnList[i]));
	  if ($("#bn_elenco img[alt='"+code+"']").length>0){
		tmp.pulsante.switchIco($(bnList[i]));
		$(bnList[i]).toggle(
		  function(e){tmp.pulsante.rem(e.target);},
		  function (e) {tmp.pulsante.add(e.target);}
		);
	  }else{
		$(bnList[i]).toggle(
		  function(e){tmp.pulsante.add(e.target);},
		  function (e) {tmp.pulsante.rem(e.target);}
		);
	  }
	}
  }
}

function BnEmptyClick() {
  $('a.svuotaBn').click(function() {
	var tmp = new BnInterface('empty');
	tmp.empty.empty();
  });
}

function BnConfrontaInit() {
  var bnConf = $('#blocknotes_confronta').find('.rem_bn');
  for (var i=0;i<bnConf.length;i++) {
	$(bnConf[i]).click(function(e){
	  var tmp = new BnInterface('confronto');
	  tmp.confronto.rem(e.target);
	});
  }
}

/**************************** init.js  - fine ******************************************************************************/

/**************************** bocknotes.js  - inizio ***********************************************************************/
function BnInterface(tipo) {
  /*function Scheda(){
	this.getCode= function(targ) {
	   return $(targ).parent().parent().prev().attr("id");
	};

	this.switchIco= function(targ) { 
	  if ($(targ).attr('src')==undefined) var obj = $(targ).parents('div:first').find('img');
	  else obj = targ;
	  var tmp = $(obj).attr('src');
	  if (tmp.match('-meno\.jpg$')=='-meno.jpg' || tmp.match('-meno-on\.jpg$')=='-meno-on.jpg') {
		if (tmp.match('-meno-on\.jpg$')=='-meno-on.jpg') $(obj).attr('src','http://www.adrias-web.com/lavori/caterina/trovahotels/html/img/icona-blocknotes-piu-on.jpg');
		else $(obj).attr('src','http://www.adrias-web.com/lavori/caterina/trovahotels/html/img/icona-blocknotes-piu.jpg');
	  }else {
		if (tmp.match('-piu-on\.jpg$')=='-piu-on.jpg') $(obj).attr('src','http://www.adrias-web.com/lavori/caterina/trovahotels/html/img/icona-blocknotes-meno-on.jpg');
		else $(obj).attr('src','http://www.adrias-web.com/lavori/caterina/trovahotels/html/img/icona-blocknotes-meno.jpg');
	  }
	}

	this.getImg = function(targ) {
	  return $(targ).parent().parent().prev().find('img').attr('src');
	}

	this.add = function(targ) {
	  this.switchIco(targ);
	  code = this.getCode(targ);
	  if ($("#bn_elenco img[alt='"+code+"']").length==0){
		img = this.getImg(targ);
		$.post('http://www.adrias-web.com/lavori/caterina/trovahotels/blocknotes.php',{op:'add',hotel:code});
		var block = $('#bn_elenco div.blocknotes');
		var i = 0;
		while ($(block[i]).children('img.bn_img').length) i++;
		$(block[i]).append('<img class="bn_img" src="'+img+'" alt="'+code+'" />');
		this.sync(code);
	   } else return false
	 }

	 this.rem = function(targ) {
	  this.switchIco(targ);
	  code = this.getCode(targ);
	  if ($("#bn_elenco img[alt='"+code+"']").length>0){
		$.post('http://www.adrias-web.com/lavori/caterina/trovahotels/blocknotes.php',{op:'rem',hotel:code});
		$("#bn_elenco img[alt='"+code+"']").remove();
		this.sync(code);
	  } else return false;
	 }

	 this.sync = function (code) {
	   if ($('#corpo_testo #'+code).length>0) $('#corpo_testo #'+code+' .maniglia_hotel').trigger('click');
	 }
  };*/

  function Pulsante(){
	this.getCode = function (targ) {
	   return $(targ).parents("li[id]:first").attr("id");
	 }

	this.switchIco = function (targ) {
	  if ($(targ).find('label').length>0) targ = $(targ).find('label');
	  if($(targ).hasClass('cb_01')){
		//$(targ).removeClass('bn_add');
		$(targ).addClass('checked');
		//var number=$('#blocknotes_link span.hotelselezionati');
		
	  }else{
		$(targ).removeClass('checked');
		//$(targ).addClass('bn_add');
	  }
	}

	/*this.getImg = function (targ) {
	   return $(targ).parents("li[id]:first").find('img:first').attr('src');
	   return $(targ).prev().attr('src');
	}*/

	this.add = function(targ) {
	  this.switchIco(targ);
	  code = this.getCode(targ);
	  if ($("#bn_elenco img[alt='"+code+"']").length==0){
		//img = this.getImg(targ);//<-- ma server, qui non mi deve andarea ad aggiungere un immagine ma sono un contatore
		//$.post('http://www.adrias-web.com/lavori/caterina/riminiit/blocknotes.php',{op:'add',hotel:code});
		$.post('http://www.hotel.rimini.it/blocknotes.php',{op:'add',hotel:code});
		var block = $('#bn_elenco div.blocknotes');
		var i = 0;
		
		while ($(block[i]).children('img.bn_img').length) i++;
		$(block[i]).append('<img class="bn_img" alt="'+code+'" />');
		var number=$('#blocknotes_link span.hotelselezionati');
		i++;
		var id = $(number).attr("id");
		//alert(id)
		$(number).replaceWith('<span class="hotelselezionati" id="number_'+i+'">'+i+'</span>');
		
		if(id == "number_0") showdiv('popup', 'Ci ricordiamo<br>degli hotel che selezioni!<br>Contattali quando vuoi,<br>con una sola mail.');/*Div messaggio hotel aggiunto nel dashboard*/
		
		//this.sync(code);
	  } else return false;
	}

	this.rem = function(targ) {
	  this.switchIco(targ);
	  code = this.getCode(targ);
	  if ($("#bn_elenco img[alt='"+code+"']").length>0){
		//$.post('http://www.adrias-web.com/lavori/caterina/riminiit/blocknotes.php',{op:'rem',hotel:code});
		$.post('http://www.hotel.rimini.it/blocknotes.php',{op:'rem',hotel:code});
		$("#bn_elenco img[alt='"+code+"']").remove();

		var number=$('#blocknotes_link span.hotelselezionati');
		var id_number=$(number).attr('id');
		var array=id_number.split("_");
		var i=array[1]-1;
		$(number).replaceWith('<span class="hotelselezionati" id="number_'+i+'">'+i+'</span>');
		//this.sync(code);
	  } else return false;
	}
/*	this.sync = function (code) {
	  if ($('#hotelChange').find('div#'+code).length>0) $('#hotelChange').find('.addIco:first').trigger('click');
	}*/
  }

  function Empty(){
	this.empty = function(){
	  var hotels = $('#bn_elenco .blocknotes .bn_img');
	  //$.post('http://www.adrias-web.com/lavori/caterina/riminiit/blocknotes.php',{op:'empty'},function(){
	  $.post('http://www.hotel.rimini.it/blocknotes.php',{op:'empty'},function(){
		$.post('http://www.hotel.rimini.it/blocknotes.php',{op:'redraw'},function(data){
		//$.post('http://www.adrias-web.com/lavori/caterina/riminiit/blocknotes.php',{op:'redraw'},function(data){
		 $('#bn_elenco').empty().append(data);
		},'html');
	  });
	 var number=$('#blocknotes_link span.hotelselezionati');
	 $(number).replaceWith('<span class="hotelselezionati" id="number_0">0</span>');
	  this.sync(hotels);
	}

	this.sync = function (hotels){
	  hotels.each(function() {
		code = $(this).attr('alt');
		//if ($('#hotelChange').find('div#'+code).length>0) $('#hotelChange').find('.addIco:first').trigger('click');
		//if ($('#corpo_testo #'+code).length>0) $('#corpo_testo #'+code+' .maniglia_hotel').trigger('click');
		if ($("#blocknotes_confronta .mailHotel a[title='"+code+"']").length>0) $("#blocknotes_confronta .mailHotel a[title='"+code+"']").parents('.mailHotel:first').remove();
	  });
	}
  }

  function Confronto(){
	this.getCode = function(targ) {
	  return $(targ).attr("title");
	}
	this.rem = function(targ) {
	  code = this.getCode(targ);
	  $.post('http://www.hotel.rimini.it/blocknotes.php',{op:'rem',hotel:code});
	  //$.post('http://www.adrias-web.com/lavori/caterina/riminiit/blocknotes.php',{op:'rem',hotel:code});
	  $(targ).parents('li.mailHotel').remove();
	  $("#bn_elenco img[alt='"+code+"']").remove();

		var number=$('#blocknotes_link span.hotelselezionati');
		var id_number=$(number).attr('id');
		var array=id_number.split("_");
		var i=array[1]-1;
		$(number).replaceWith('<span class="hotelselezionati" id="number_'+i+'">'+i+'</span>');

	  return false;
	}
  }

  /*if (tipo=='scheda') this.scheda = new Scheda();
  else */if (tipo=='pulsante') this.pulsante = new Pulsante();
  else if (tipo=='empty') this.empty = new Empty();
 // else if (tipo=='info') this.info = new Info();
  else this.confronto = new Confronto();
}
/**************************** bocknotes.js  - fine *************************************************************************/


/******************************************************
				messaggi
******************************************************/
var stato = "";

showdiv = function(id, message){
	var div = document.getElementById(id);
		
		$(div).fadeIn('slow');
		if(stato != "on"){
			timer = setInterval("hidediv()", 5000);
			stato = "on";
		} 
		if(message != undefined) {
		  div.innerHTML = message;
		}	
}

hidediv = function(){
	$('.popup').fadeOut('slow');
	clearInterval(timer);
	stato = "";
}
/**/

