$(document).ready(function(){
	if($('map')){drawMap();}
	if($('#booking_num_guests')){
		showOrHideGuestDetails($('#booking_num_guests').val());
			
		$('#booking_num_guests').change(function(){ 
			showOrHideGuestDetails($(this).val()); 
		});
	}
	if($('#hidden_fields'))addInput();
});

showOrHideGuestDetails = function (numGuests) {
	$('#guests_fieldset').children('div').each(function(i){  (i < numGuests) ? $(this).show() : $(this).hide();  });
}
			
		

addPrintPageEvent = function(){
	$('#print_page_link').click(function(){if(window.print())window.print();});
};

drawMap = function(){
    var obj_map = document.getElementById("map");
 
	 if (GBrowserIsCompatible() && obj_map) { 
	 	var map = new GMap2(obj_map); 
	 	map.disableDragging(); 
	 	map.disableDoubleClickZoom(); 
	 	var ourLatLng = new GLatLng(map_lat, map_lng);
    	map.setCenter(ourLatLng, 8);
	 	map.addOverlay(new GMarker(ourLatLng));
	}
};

addInput = function(){

	if($('#hidden_fields').length > 0){
	var form_id = $('#hidden_fields').parent()[0].id;

	var form_id_arr = form_id.split('_');
	var prefix = form_id_arr[0];
	if(typeof screenSize == 'object'){
	$('#hidden_fields').append('<input type="hidden" name="'+prefix+'_screenresolution" value="' + screenSize.x + 'x' + screenSize.y + '">');

	}

}
};

function getScreenSize() {
	var x=0;
	var y=0;
	var coords = new Object();
	x=screen.width ? screen.width : screen.availWidth;
	y=screen.height ? screen.height : screen.availHeight;
	coords.x=x;
	coords.y=y;
	return(coords);
}
screenSize = getScreenSize();







  



