$(document).ready(function(){

	resizeEverything();
	
	function resizeEverything() {

		$('#back').animate({
	   		height: $(window).height()-30 + "px",
	   		width: $(window).width()-20 + "px"
	   }, 500);
	   
	   $('#container').css('width', $(window).width() + "px"); 
	   $('#flashcontent').css('width', $(window).width() + "px"); 
	   $('#flashcontent').css('height', $(window).height()-190 + "px"); 
	   
	   /*
	   $('#flashcontent').animate({
	   		width: $(window).width() + "px"
	   }, 500);
		*/
		var availableHeight = $(window).height()-140;
		if(availableHeight > 10) {
			$('#flashcontent p').css("padding-top", $(window).height()/2 + "px");
			//$('#flashcontent').css("margin-top", availableHeight/30 + "px");
		}
		
	};
	
	var resizeTimer = null;
	$(window).bind('resize', function() {
	   if (resizeTimer) clearTimeout(resizeTimer);
	   resizeTimer = setTimeout(resizeEverything, 100);
	});
	
	var originalSizes = new Array();
	var minWidth = $(window).width()-80;
	
    $('span.email').each(function()
    {
        var obfAddress = $(this).text();
        var realAddress = obfAddress.replace(/\[at\]/g, '@').replace(/\[dot\]/g, '.');
        var emailLink = document.createElement('a');
        $(emailLink).attr(
        {
            'href': 'mailto:' + realAddress,
            'title': 'Email ' + realAddress,
            'class': 'email'
        }).text(realAddress);
        $(this).replaceWith(emailLink);
    });
    
	$('#container').bind("mouseenter", function(event){
	  $('#flashcontent').focus();
	});
	$(window).bind("click", function(event){
	  $('#flashcontent').focus();
	});

});

function setCategory(str) {
	
	$('#flashcontent').focus();
	//console.log(str);
	var timer = 300;
	
	$('#category #underline').addClass('underline');
	
	if($('#category .text').html() != str) {
		$('#category .text').animate({ opacity: 0 }, timer);
        $('#category .text').queue(function () {
        	$('#category .text').html(str);
        	$(this).dequeue();
        });
        $('#category .text').animate({ opacity: 1}, timer );
    	$('#category .text').queue(function () {
			$(this).dequeue();
    	});
	}
}
