$(window).load(function(){
	if (navigator.userAgent.indexOf('iPhone') != -1) {
		setTimeout(hideURLbar, 300);       
	}
})
$(document).ready(function(){
//	$('a.phatBox').lightBox();
	// search field nicer (more style in the future)
	$("#topSearch label:first").hide()
	var searchText = $("#topSearch label:first").text();
	$("#topSearch input:first").val(searchText);
	$("#topSearch input:first").focus(function(){
		if($(this).val() == searchText){
			$(this).val("")
		}
	});
	$("#topSearch input:first").blur(function(){
		if(jQuery.trim($(this).val()) == ""){
			$(this).val(searchText)
		}
	});
	$(".photoAlbumsPhotos img").mouseover(function(){
		$(this).css({
			margin:"4px",
			width:"79px",
			height:"79px"
		})	
	})
	$(".photoAlbumsPhotos img").mouseout(function(){
		$(this).css({
			margin:"6px",
			width:"75px",
			height:"75px"
		})	
	})
	$(".photoAlbumPhotos img, .flickr-photos img").mouseover(function(){
		$(this).css("margin","4px")	
		$(this).css("width","79px")	
		$(this).css("height","79px")	
	})
	$(".photoAlbumPhotos img, .flickr-photos img").mouseout(function(){
		$(this).css("margin","6px")	
		$(this).css("width","75px")	
		$(this).css("height","75px")	
	})
 	$("#sidebar").append('<img src="/image/button.close.gif" alt="close" class="sidebarCloser">');

	$(".nav li:first a:eq(1),.sidebarCloser").click(function(){
		$("#sidebar").slideToggle(400)
		if ($(".nav li:first img").attr("src").search("expand")!=-1){
			$(".nav li:first img").attr("src","/image/arrow.contract.png");
		} else {
			$(".nav li:first img").attr("src","/image/arrow.expand.png");	
		}
		return false;
	})

//phatBox	
/*	var imageWidth;
	var imageHeight;

	var x = $(window).height() - 50;
	var y = $(window).width() - 50;
		
	var imgPreLoader = new Image();
	imgPreLoader.src = "/image/snurra.gif"
	var imgLoader = new Image();
	imgLoader.onload = function(){    
		imgLoader.onload = null;
		var imageWidth = imgLoader.width;
		var imageHeight = imgLoader.height;
		if (imageWidth > x) {
			imageHeight = imageHeight * (x / imageWidth); 
			imageWidth = x;
			if (imageHeight > y) { 
				imageWidth = imageWidth * (y / imageHeight); 
				imageHeight = y;
			}
		} else if (imageHeight > y) { 
			imageWidth = imageWidth * (y / imageHeight); 
			imageHeight = y; 
			if (imageWidth > x) { 
				imageHeight = imageHeight * (x / imageWidth); 
				imageWidth = x;
			}
		}
		$(".phatPic").width(imageWidth + "px");
		$(".phatPic").height(imageHeight + "px");
		$(".phatPic").attr("src",imgLoader.src);
		$(".phatPic").fadeIn(200)
		$(".phatCloser").fadeIn(400)
		$(".phatDiv").css({
			
			left:((y/2)-((imageWidth)/2) + 25)+"px",
			top:((x/2)-((imageHeight)/2) + 25)+"px"
		});
		
		
	}
	
	
	
	
 	$("body:first").append('<div class="phatBg"></div><div class="phatDiv"><img src="'+imgPreLoader.src+'" class="phatPic" alt="loading"><img src="/image/button.close.gif" alt="close" class="phatCloser"></div>');
	$(".phatDiv").css({
		left:((y/2)-((500)/2))+"px",
		top:((x/2)-((160)/2))+"px"
	});

	$(".phatBox").click(function(){
		var theText = $(this).attr("title");
		var theTitle = $("img:first",this).attr("alt");
		imgLoader.src = $(this).attr("href");
		$(".phatDiv,.phatBg").fadeIn(100)

		
		return false;
	});
	$(".phatBg,.phatCloser").click(function(){
		$(".phatDiv,.phatBg").fadeOut()
	});
	*/
});
function hideURLbar() {
        window.scrollTo(0, 1);
}


jQuery.fn.fadeToggle = function(speed, easing, callback) {
  return this.animate({opacity: 'toggle'}, speed, easing, callback); 
};
