function autoFill(id, v){
  if($(id).val()=="" || $(id).val()==v){
    $(id).css({ color: "#b2adad" }).attr({ value: v });
  }
	$(id).focus(function(){
		if($(this).val()==v){
			$(this).val("").css({ color: "#333" });
		}
	}).blur(function(){
		if($(this).val()==""){
			$(this).css({ color: "#b2adad" }).val(v);
		}
	});
}

function openPopup(file,input) {
  window.open(file, input, 'width=350,height=400,resizable=1');
}

function openWin(file,input, width, height) {
  if ( width == null )
	width = 740;
  if ( height == null )
	height = 550;
  prop = 'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes';
  window.open(file, input, prop);
}

function openGMap(lat, lng, name, description) { 
  url = '/maps/?lat=' + lat + '&lng=' + lng + '&name=' + name + '&description=' + description;
	window.open(encodeURI(url), 'map', 'width=520,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,dependent=yes,resizable=yes,scrollbars=yes');
}

function openMapWindow(url) { 
	window.open(url, 'map', 'width=520,height=400,top=170,left=162,toolbar=no,location=no,directories=no,status=no,menubar=no,dependent=yes,resizable=no,status=no,scrollbars=yes');
}

function openMap(hotelId, domain, cid)
{ 
  url = 'http://' + domain + '/hotel/maps/' + hotelId + '?cid=135219';
  window.open(url, 'map', 'width=700,height=400,top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,dependent=yes,resizable=yes,status=no,scrollbars=no');
}

function openVTour(hotelId, domain, cid)
{ 
  url = 'http://' + domain + '/hotel/tours/' + hotelId + '?cid=135219';
  window.open(url, 'map', 'width=800,height=560,top=170,left=162,toolbar=no,location=no,directories=no,status=no,menubar=no,dependent=yes,resizable=yes,status=no,scrollbars=yes');
}

function openPhoto( hotelId )
{
  url = '/res/property.php?req=photos&hotelId=' + hotelId;
  window.open( url, 'thor', 'top=5,left=75,width=609,height=560,resizable=1,scrollbars=yes' );
}
/*
function openCalendar(dayField, day, monthField, month, yearField, year, format, formName)
{
  if ( formName == null )
	formName = 'formSearch';
  file = '/scripts/calendar.php?formName=' + formName + '&format=' + format;
  if ( dayField != null )
	file += '&dayField=' + dayField + '&day=' + day;
  if ( monthField != null )
	file += '&monthField=' + monthField + '&month=' + month;
  if ( yearField != null )
	file += '&yearField=' + yearField + '&year=' + year;
  window.open( file, "dates", 'width=220,height=220,resizable=1');
}
*/
function setCSC(city, state, country)
{
	form = document.forms.formSearch;
  var destField = form.destination;
  var cityField = form.city;
  var countrySelect = form.country;
  var stateSelect = form.state;
	if (destField != null) {
  	destField.value = city + ", " + state + ", " + country;
  }
  else {
  	cityField.value = city;
  	countrySelect.value = country;
  	if (state == null || state == "") {
  		stateSelect.value = "";
  		stateSelect.disabled = true;
  	}
  	else {
  		stateSelect.disabled = false;
  		stateSelect.value = state;
  	}
  }
} 

function UpdateState(form)
{
  if ( form == null )
	form = document.forms.formSearch;
  var countrySelect = form.country;
  var stateSelect = form.state;
  var country = countrySelect.options[countrySelect.selectedIndex].value;
  if (country == "US" || country == "CA" || country == "AU")
  { stateSelect.disabled = false; }
  else { stateSelect.value = ""; stateSelect.disabled = true; }
} 

function converter(file, input)
{
  currencyWindow=window.open(file,input,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=640,height=215,top=100,left=100");
  currencyWindow.focus();
}

function showhide(id){
	if (document.getElementById){
		obj = document.getElementById(id);
		if (obj.style.display == "none"){
			obj.style.display = "";
		} else {
		obj.style.display = "none";
		}
	}
}

function toggle(showHideDiv, switchImgTag) {
  var ele = document.getElementById(showHideDiv);
  var imageEle = document.getElementById(switchImgTag);
  if(ele.style.display == "none") {
    ele.style.display = "block";
    imageEle.innerHTML = '<img src="/images/icn_minus.gif" class="icn" alt="">';
  }
  else {
    ele.style.display = "none";
    imageEle.innerHTML = '<img src="/images/icn_plus.gif" class="icn" alt="">';
  }
}