function setEditable(inputName, editable) {
	link = $(inputName + "_link");
	textInput = $(inputName);
	link.style.display = editable ? "none" : "block";
	//textInput.focus();
	//textInput.select();
	textInput.style.display = editable ? "inline" : "none";
	//textInput.select();
	if(!editable) {
		link.innerHTML = textInput.value;
	}
	textInput.focus();
	textInput.select();
}

function addFormChangeCheck(formName) {
	//elements = Form.getElements(formName);
	//form = $(formName);
	//for(i=0; i<elements.length; i++) {
	//	element = elements[i];
	//	element.onchange = new function() {
	//		form.changed = true;
	//	}
	//}
	//document.body.onunload = new function() {
	//	alert("goodbye");
	//}
}

function showAddress(name, address, map) {
	var geocoder = new GClientGeocoder();
  geocoder.getLatLng(
    address,
    function(point) {
      if (point) {
        map.setCenter(point, 13);
        var marker = new GMarker(point);
        map.addOverlay(marker);
				GEvent.addListener(marker, "click", function() {
					marker.openInfoWindowHtml("<b>" + name + "</b><br/>" + address);
				});
      }
    }
  );
}

function addPin(detail, address, map, geocoder) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (point) {
				var marker = new GMarker(point);
        map.addOverlay(marker);
				GEvent.addListener(marker, "click", function() {
					marker.openInfoWindowHtml(detail);
				});
			}
		}
	);
}

function focusFirst() {
  var bFound = false;
  for (f=0; f < document.forms.length; f++) {
    for(i=0; i < document.forms[f].length; i++) {
      if (document.forms[f][i].type != "hidden") {
        if (document.forms[f][i].disabled != true) {
            document.forms[f][i].focus();
            var bFound = true;
        }
      }
      if (bFound == true)
        break;
    }
    if (bFound == true)
      break;
  }
}

function openTerms() {
	window.open("/data/legal/TermsAndConditions.html", "TermsAndConditions", "width=450,height=500,scrollbars=yes");
}

function addBookmark() {
	var url= "http://www.airportcarsclub.com"; 
	var title = "Airports Cars Club"; 
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url, ""); 
	} else if(document.all) {
		window.external.AddFavorite(url, title);
	} else if(window.opera && window.print) {
		return true;
	}
}

function decimalLatLongToDMS(decimal) {
	var latAbs = Math.abs( Math.round(decimal * 1000000.));
	var lonAbs = Math.abs(Math.round(decimal * 1000000.));
	return Math.floor(latAbs / 1000000) + '-' + 
		Math.floor(((latAbs/1000000) - Math.floor(latAbs/1000000)) * 60)  + '-' + 
		(Math.floor(((((latAbs/1000000) - Math.floor(latAbs/1000000)) * 60) - Math.floor(((latAbs/1000000) - Math.floor(latAbs/1000000)) * 60)) * 100000) *60/100000);
}
