var makeAnim = true;

$(document).ready(function () {
	$("div.scrollable").scrollable();

	$("div#background img").animate({'opacity':1}, 1000, null, function(){
		$("div#panel").css({'visibility':'visible'});

		jQuery.each(jQuery.browser, function(i, val) {
		  if(!$.browser.msie)
			$("div#panel").animate({'opacity':1}, 1000, null);
		});

	});
	
    $("div#menu ul li").click(function(){
		$("div#background img").stop();
		$("div#panel").stop();

		$("div#menu ul li a").removeClass("active");
        $("a", this).addClass("active");
        var href = $("a", this).attr('href');
		$("div#panel").animate({'opacity':0}, 500, null, function(){
			$("div#background img").animate({'opacity':0}, 500, null, function(){
				window.location = href;
			});
		});
		return false;
    });
	
	gallery();

	$(".ajaxForm").submit(function () {
		ajaxPostUpdate (this.id, this.action + (this.action.indexOf("?") == -1 ? "?" : "&") + "ajax=true", "responseDiv", false);
		return false;
	});
});


function gallery() {
	$(".items img").click(function() {

		// calclulate large image's URL based on the thumbnail URL (flickr specific)
		var url = $(this).attr("alt");

		// get handle to element that wraps the image and make it semitransparent
		var wrap = $("#image_wrap").fadeTo("medium", 0, function() {

			// the large image from flickr
			var img = new Image();

			// call this function after it's loaded
			img.onload = function() {
				// change the image
				wrap.find("img").attr("src", url);

				// make wrapper fully visible
				wrap.fadeTo("medium", 1);

			};

			// begin loading the image from flickr
			img.src = url;
		});

	// when page loads simulate a "click" on the first image
	}).filter(":first").click();
}


