// JavaScript Document

var WB = {
	
	init : function()
	{
		$$('a.page').each( function(page)
		{
			new Tip(page,
			{
				ajax: 
				{
					url: '/includes/ajax/getPage.php',
					options:
					{
						method: 'get',
						parameters: { slug:page.id },
						onComplete: function(transport)
						{
							//alert(transport.responseText);
						}
					}
				  	},
					style: 'orange',
					stem: 'topRight',
					hook: { tip: 'topRight', target:'bottomMiddle', mouse: false },
					offset: { x: 0, y: 5 }
				});
		});
		
		$$('a.album').each( function(album)
		{
			album.onclick = function()
			{
				new Ajax.Request('/includes/ajax/getAlbum.php',
				{
				method:'get',
					parameters: { albumtype: this.rel },
					onSuccess: function(transport)
					{
						var response = transport.responseText || "no response text";
						//alert(response);
						$('thumbs').update(response);
						WB.assignThumbAction();
						
					},
					onFailure: function()
					{ 
						//alert('Something went wrong...')
					}
				});
				return false;
			}
		});
	},
	
	assignThumbAction : function()
	{
		$$('a.link').each( function(thumb)
		{
			thumb.onclick = function()
			{
				$('medium_image').update('<a rel="lightbox" href="/upload/large/'+this.id+'" target="zoom"><img src="/upload/med/'+this.id+'" /><p>Click to enlarge</p></a>');
				Lightbox.prototype.updateImageList();
				return false;
			}
		});
	}
}

Event.observe( window, 'load', WB.init );