$(document).ready(function(event){
/*		$("#SearchButton").click(function(event){
		SearchPhotos($("#Query").val(), "");
		$("#photoDiv").show(0);
		return false;
		});*/
	
	$("#photoDiv img").live("click", function(){
		URL = $(this).attr("src");
		URL = URL.replace(/thumbnail=/, "preview=");
		URL = URL.replace(/&aspect&width=112/, "");
		//alert(URL);
		$("#photoPreview").slideUp("fast").html("<a href='"+URL+"'><img src='" + URL + "' border='0' /></a>").slideDown("slow");
		$("#photoCaption").html($(this).attr("title"));
		//window.location = URL;
		return false;
	});

	$("#pagingDiv a").live("click", function(){
		URL = $(this).attr("href");
		Host = "www.blm.gov";
		URI = URL.replace(/http:\/\/www.blm.gov/,"");
		//alert(URI);
		$("#photoDiv").html("");
		SearchPhotos($("#QueryPhotos").val(), escape(URI));
		$("#photoPreview").html("");
		$("#photoCaption").html("");
		return false;
	});

	SearchPhotos('yaquina', "");
	$("#photoDiv").show(0);		
});


/*****************************************************
**  SearchPhotos
****************
**
*****************************************************/
function SearchPhotos(SearchResults, URI)
{
	URL = "/or/includes/providers/provider_blmphotos.php?search=" + SearchResults
	if (URI != '') { URL = URL + "&uri=" + URI; }
	URL = URL + "&callback=?"
	$.getJSON(URL,
		function(data){
			if (data.numberItems > 0)
				{
					ContentResults = "";
					PagingLinks = "";
					
					$.each(data.images, function(i,itemca){
						ContentResults = ContentResults + itemca.src;
					});						
					
					$.each(data.pagingHtml, function(i,itemlk){
						PagingLinks = PagingLinks + "&nbsp;" + itemlk.link + "&nbsp;";
					}); 
					//PagingLinks = data.pagingHtml;
				}
			else {
				ContentResults = "Sorry, no results found"; 
				PagingLinks = ""; }
			$("#photoDiv").html(ContentResults);
			$("#pagingDiv").html(PagingLinks);
		});
}