$(document).ready(function() {
	
	$(".gallery a").fancybox();


    $('.stamp').click(function() {
        var this_src = $(this).children('img').attr('src');
        $('#stamp').attr('src',this_src);
    });



//----------

	//LINKS
	$('a').each(function() {
		if ($(this).attr('rel') == '_blank') {
			$(this).attr('target','_blank');
		}
	});
	//LINKS

//----------

	//TEXT SIZE
	$('.text-resize li a').click(function() {
		$.cookie('text-size',null);
		$.cookie(
			'text-size', 
			$(this).attr('class'), {
				expires: 7, 
				path: '/'
			}
		);
		resize_text($(this).attr('rel'));
		return false;
	});
	resize_on_load();
	//TEXT SIZE


//----------


//FUNCTIONS
	
	//Changing the text size of the whole page
	function resize_text(size) {
		if (size == 'small') {
			$('#content, #footer').css('font-size','0.9em');
			$('.text-resize li a').removeClass('active');
			$('.text-resize li a[rel="small"]').addClass('active');
		} else if (size == 'med') {
			$('#content, #footer').css('font-size','1em');
			$('.text-resize li a').removeClass('active');
			$('.text-resize li a[rel="med"]').addClass('active');
		} else if (size == 'large') {
			$('#content, #footer').css('font-size','1.1em');
			$('.text-resize li a').removeClass('active');
			$('.text-resize li a[rel="large"]').addClass('active');
		}
	}
	
	function resize_on_load() {
		var cookie = $.cookie('text-size');
		
		if (typeof(cookie) != "undefined") {
			resize_text(cookie);
		}
	}
	
	$(function()
		{
			// Call stylesheet init so that all stylesheet changing functions 
			// will work.
			$.stylesheetInit();
			
			// This code loops through the stylesheets when you click the link with 
			// an ID of "toggler" below.
			$('#toggler').bind(
				'click',
				function(e)
				{
					$.stylesheetToggle();
					return false;
				}
			);
			
			// When one of the styleswitch links is clicked then switch the stylesheet to
			// the one matching the value of that links rel attribute.
			$('.styleswitch').bind(
				'click',
				function(e)
				{
					$.stylesheetSwitch(this.getAttribute('rel'));
					return false;
				}
			);
		}
	);
	
	

//FUNCTIONS

});
