
function prepareGallery()
{
	$("#imageOptions a").click(function()
        {
        var imageSource = $(this).children("img").attr("src");
       	
		if($(this).children("img").attr("title"))
		{
			var imageTitle =  $(this).children("img").attr("title");
		}else{
			var imageTitle = "";
		}
		
	   	$("#loader").fadeIn(400);
        $("#loader").addClass("loading");
        $("h3").remove();
		
		imageSource = imageSource.replace(/.jpg/, "large.jpg"); 
		//alert( imageSource );
		
		$("h5").remove();
          showImage(imageSource, imageTitle);
          return false;
        });
		
}

function mainmenu()
{
$(" #nav ul ").css({display: "none"}); // Opera Fix
$(" #nav li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).fadeIn(100);
		},function(){
		$(this).find('ul:first').css({visibility: "hidden"});
		});
}



function showImage(src, title)
{
	$("#loader img").fadeOut(400).remove();
	var largeImage = new Image();
	
	$(largeImage).load(function()
    {
    //$(this).fadeOut(400);
    $("#loader").append(this).removeClass("loading");
    
	// add the content of the title property
	if (title) 
	{
		console.log( title );
		$("#loader").append("<h5>" + title + "</h5>");
	}
                 
    $(this).fadeIn(400);              
    });    
	$(largeImage).attr("src", src);                                                                               
}


$(document).ready(function()
 {
						
	// navigation
	mainmenu();
	
	//make gallery
	prepareGallery();
	
	$("#loader").click(function()
    {
    	$(this).fadeOut(400);
    });


	
});



