var lim=100; 
function count(a){ 
	var dif = lim - a.value.length;
	while(dif < 0){ 
	 	a.value=a.value.replace(/.$/,'')
	 	dif = lim-a.value.length; 
	} 
	document.getElementById('counter').firstChild.data=dif; 
} 

function swap_image (image_url) {

	var main = document.getElementById("placeholder");
	
	main.src = image_url;
	
}

function submit_form (frm) {
    document.frm.submit();
}

function confirmSubmit(msg) {
	var agree=confirm("Are you sure you want to " + msg + "?");
	if (agree)
		return true ;
	else
		return false ;
}

function showElement(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	} else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		} else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function hideElement(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	} else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		} else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function checkBid () {
		if (document.getElementById('bid_amount').value > 0) {
			showElement('confirm_bid');
		} else {
			alert('Please enter a quote amount');
		}
}

function enterKey(btn)
{
	if (event.keyCode == 13)
	{
		event.cancelBubble = true;
		event.returnValue = false;
		document.getElementById(btn).click();
	}
}

function set_beds() {
	var bedrooms = document.getElementById('no_of_bedrooms').value;
	
	for (var i=1; i<=10;i++) {
		document.getElementById('beds_' + i).style.display = 'none';
		if (i <= bedrooms) {
			document.getElementById('beds_' + i).style.display = 'block';		
		}
	}
}

function matchDates() {
	if (document.getElementById('startdate').value != '') {
			document.getElementById('enddate').value = document.getElementById('startdate').value;
	}
}

/*function loadmap(address) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		var geocoder = new GClientGeocoder();

		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					return false;
				} else {
					map.setCenter(point, 13);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					map.addControl(new GLargeMapControl());
					//marker.openInfoWindowHtml(address);
				}
			}
		);

		//map.setCenter(new GLatLng(37.4419, -122.1419), 13);
	}
}*/

function loadmap(point) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.setCenter(point, 5);
		var marker = new GMarker(point);
		map.addOverlay(marker);
		map.addControl(new GLargeMapControl());
	}
}

function get_location(response) {
				if (response.Placemark != null) {
					place = response.Placemark[0];
					point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
					var property_details = document.getElementById('property_details');
					var newdiv = document.createElement('div');
					newdiv.setAttribute("class", "box top_margin");
     			newdiv.innerHTML = newdiv.innerHTML + '<h2>area<span class="brown">map</span></h2><br />'; 
					newdiv.innerHTML = newdiv.innerHTML + '<div id="map" style="width: 458px; height: 500px"></div>'; 
					property_details.appendChild(newdiv);
					loadmap(point);
				}
      }
