function formSubmit(formName) {
	$(formName).submit();
}
function submitBoxSearch()
{
	var x;
	var y;
	
	x = document.getElementById('destinazione');
	y = document.getElementById('search_type');
	
	if(y.value=="comune")
	{
		if( x.value == "" || x.value == "inserisci una destinazione" || x.value == 'insert your destination' || x.value == 'insérez une destination'  )
		{
			alert("E' necessario inserire una destinazione.");
			return false;
		}
		
		var check = document.getElementById('solo_disponibili');
		if (check.checked)
		{
			x = document.getElementById('check_in');
			if (x.value == "")
			{
				alert("E' necessario inserire una data di check in.");
				return false;
			}
			
			x = document.getElementById('check_out');
			if (x.value == "")
			{
				alert("E' necessario inserire una data di check out.");
				return false;
			}
		}
	} else {
		y = Form.getInputs('ricercaAvanzata','radio','prov_id').find(function(radio) { return radio.checked; });
		if(y == undefined)
		{
			alert("E' necessario scegliere una provincia.");
			return false;
		}
	}
	return true;
}

function cleanDestinazione(obj)
{
	if( obj.value == 'inserisci una destinazione' || obj.value == 'insert your destination' || obj.value == 'insérez une destination' )
	{
		obj.value = '';
	}  
}

function showHide(x)
{
	var obj = document.getElementById(x);
	if( obj.className == "show" )
	{
		obj.className = "hide";
	}
	else
	{
		obj.className = "show";
	}
}

function showHideTr(x)
{
	var obj = document.getElementById(x);
	if( obj.className == "showTr" )
	{
		obj.className = "hide";
	}
	else
	{
		obj.className = "showTr";
	}
}


function showmap(x)
{
	var obj       = document.getElementById('mapContainer');
	var iframeObj = document.getElementById('mapIframe');
	if( obj.className == "show" )
	{
		obj.className = "hide";
		iframeObj.src = '';
	}
	else
	{
		obj.className = "show";
		iframeObj.src = 'maps/map_struttura.php';
	}
}

function prSubmit()
{
	alert("ATTENZIONE: La prenotazione sara' abilitata a breve!");
	return false;
}
function showDiv(x)
{
	var obj = document.getElementById(x);
	obj.style.display = "block";
}
function hideDiv(x)
{
	var obj = document.getElementById(x);
	obj.style.display = "none";
}


function showPhoto(path, id,img_w)
{
	x = document.getElementById(id);
	if (img_w == '')
		x.innerHTML = '<img src="'+ path +'" alt="">';
	else
		x.innerHTML = '<img src="'+ path +'" alt="" width="' + img_w + 'px">';
}

function openDisclaimersWin()
{
  var url = 'disclaimers.php';
	window.open(url,"disclaimers","width=790,height=650,menubar=no,statusbar=no,resizable=yes,scrollbars=yes");
}

function openMailafriendWin(page)
{
  var url = 'popup_mailafriend.php?url='+page;
	window.open(url,"mailafriend","width=460,height=420,menubar=no,statusbar=no,resizable=yes,scrollbars=yes");
}


function toggle_ricerca_prov_dest(tipo_ricerca)
{
	x = document.getElementById('search_type');
	x.value = tipo_ricerca;
   if (tipo_ricerca == 'provincia' || tipo_ricerca == 'province')
   {
     $('span_comune').style.display = 'none';
     $('tr_destinazione').style.display = 'none';
     $('tr_check_in').style.display = 'none';
     $('tr_check_out').style.display = 'none';
     $('tr_solo_disponibili').style.display = 'none';
     $('tr_rad').style.display = 'none';
		 
     $('span_provincia').style.display = 'inline';
     $('tr_province_id').style.display = '';
		 
   } else {
    //comune
     $('span_comune').style.display = 'inline';
     $('tr_destinazione').style.display = '';
     $('tr_check_in').style.display = '';
     $('tr_check_out').style.display = '';
     $('tr_solo_disponibili').style.display = '';
     $('tr_rad').style.display = '';
		 
     $('span_provincia').style.display = 'none';
     $('tr_province_id').style.display = 'none';
   }

}


function show_more(div)
{
  img = div.replace(/(\w+_\d+)/, 'toggle_$1');

  if ($(div).style.display != 'block')
  {
    $(img).blur();
    $(img).src = $(img).src.replace(/plus/, 'minus');
    $(div).style.display = 'block';
  }
  else
  {
    $(img).blur();
    $(img).src = $(img).src.replace(/minus/, 'plus');
    $(div).style.display = 'none';
  }
  return false;
}