var current_image = "image1";

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

$(document).ready(function(){

	$("#alternateViewsLinks a#image1").addClass("selected");
	
	var bookmark = get_bookmark();
	
	if (bookmark) {
		showImage(bookmark);
		current_image = bookmark;
	}
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	$("a.magnify").click(function () { 
	
		nw = window.open(this,'large',"status=no,scrollbars=yes,location=no");
		nw.focus();
		return false;
	});
	
	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	$('.scrollpane').jScrollPane({showArrows:true,scrollbarWidth:23,scrollbarMargin:0});

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	
	$('#alternateViewsLinks a').click(function () { 
		showImage($(this).attr('id'));
		return false;
	});

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    
	var timeout1;
	
	$("ul.links > li.invitations").hover(
	  function () {
		clearTimeout(timeout1);
		$(this).find("a").addClass('hover');
		$(this).find("ul").fadeIn();
	  }, 
	  function () {
		$(this).find("a").removeClass('hover');
	 	timeout1 = setTimeout(function() {
	  		$("ul.links li ul").fadeOut();
	  	}, 300);
	  }
	);

    $('#invitations_link').bind('click', function(event){ event.preventDefault(); });
    $('#invitations_link').bind('mouseover', function(event){ $(event.target).css('cursor','default'); });
  
});
   
    
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

function showImage(image) {
	if (image != current_image) {
		$('#mainContent .images img.'+image).show();
		$('#mainContent .images img.'+current_image).hide();
		$('#alternateViewsLinks a#'+image).addClass("selected");
		$('#alternateViewsLinks a#'+current_image).removeClass("selected");
		current_image = image;
	}
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
	
function get_bookmark() {
	
	if (window.location.hash != '')
		return window.location.hash.substr(1).split('/');
	else
		return null;
}



