	
/*
	Functions - ends
*/

$(document).ready(function(){

//	Property details gallery
	$("#gallery-list img").click(function() 
	{	
		
		$("#gallery-main-image").attr("src", 'img/'+$(this).attr("name")+'/470/289');
		
	});
	

//	Properties pagination
	$("#pagination a").live("click", function(e)
	{
		e.preventDefault();
		
		//	Go Top page
			$("html, body").animate( { scrollTop: 150 }, 'slow' );
		
		//	Loader
			$("#reload-property-list").fadeIn('slow').html('<div class="loader"></div>');
		
		$.post(this.href, function()
		{
			//	Pagination	
				$("#reload-pagination").load("_php/_go/go.php?f=reload-pagination #pagination", function()
				{
					//	Listings	
						$("#reload-property-list").load("_php/_go/go.php?f=reload-propertyListings .property-list", function()
						{
							//	Bling
								$("#reload-property-list").effect("highlight", {}, 500);
							
							//	Sidebar map
								$("#reload-sidebar-map").fadeOut().load("_php/_go/go.php?f=reload-right_side_map").fadeIn();
						});
				});
		});
		
	});

//	Submit property search form
	$("#search_form").live("submit", function(e)
	{ 			
		e.preventDefault();
		
		$.post('_php/_go/go.php?f=search-properties', $("#search_form").serialize(), function() 
		{
			//	Checkng in which page we are
				if($(".property-list").length)
				{
					//	Loader
						$("#reload-property-list").fadeIn('slow').html('<div class="loader"></div>');
			
					//	Listings	
						$("#reload-property-list").load("_php/_go/go.php?f=reload-propertyListings .property-list", function()
						{
							//	Bling
								$("#reload-property-list").effect("highlight", {}, 500);
								
							//	Sidebar map
								$("#reload-sidebar-map").fadeOut().load("_php/_go/go.php?f=reload-right_side_map").fadeIn();
						});
					
					//	Pagination	
						$("#reload-pagination").load("_php/_go/go.php?f=reload-pagination #pagination");
				}
				else
				{
					//	Redirecting
					window.location = "properties-to-rent"
				}
		});	
		
	});	
		
});	
