/* text resizing */
var cookieOptions = { expires: 7, path: '/' };
$(document).ready(function(){
    var fontSizes = ['1em','1.2em','1.6em','1.8em'];
	var footerFontSizes = ['1em','1.2em','1.4em','1.6em'];
    var currentSizeIndex = 0;

	if($.cookie('fontsize')) {
		currentSizeIndex = $.cookie('fontsize');
		$('#container').css('font-size', fontSizes[currentSizeIndex]);
		$('#footer').css('font-size', footerFontSizes[currentSizeIndex]);
	}

	$('li#text-large > a').click(function(e){ 
	    e.preventDefault();
        if (currentSizeIndex < fontSizes.length-1) {
            currentSizeIndex++;
        }
    	$('#container').css('font-size', fontSizes[currentSizeIndex]);
		$('#footer').css('font-size', footerFontSizes[currentSizeIndex]);

		$.cookie('fontsize', currentSizeIndex, cookieOptions);
		return false;
	});

	$('li#text-small > a').click(function(e){
	    e.preventDefault();
        if (currentSizeIndex > 0) {
    	    currentSizeIndex--;
        }
    	$('#container').css('font-size', fontSizes[currentSizeIndex]);
		$('#footer').css('font-size', footerFontSizes[currentSizeIndex]);

		$.cookie('fontsize', currentSizeIndex, cookieOptions);
		return false;
	});

	$('li#print a').click(function(){window.print();});
	
	if($('div#edit').length > 0) {
		var speed = 500;
		var toggleState;
		var hideTop = "-145px";
		var hideLeft = "-133px";
		
		if($.cookie('toggleState'))
		{	
			toggleState = $.cookie('toggleState');
			if(toggleState == 'shown') {
				$('div#edit').css("top","0px").css("left","0px");
				$('a#editToggle').addClass('hide').removeClass('show');	
			} 
			if(toggleState == 'hidden') {
				$('div#edit').css("top",hideTop).css("left",hideLeft);
				$('a#editToggle').addClass('show').removeClass('hide');		
			}
		}

		$('a#editToggle').click(function(){
			if($('div#edit').css('top')=='0px')
			{
				toggleState = 'hidden';
				$('div#edit').animate({top: hideTop, left:hideLeft}, speed, function(){$('a#editToggle').addClass('show').removeClass('hide');});	
			} 
			else
			{
				toggleState = 'shown';
				$('div#edit').animate({top: "0px", left:"0px"}, speed, function(){$('a#editToggle').addClass('hide').removeClass('show');});	
			}
			$.cookie('toggleState', toggleState, cookieOptions);
		});
	}

});
