$(document).ready(function(){

	doResize();
	
	setInterval(doResize, 1000);

	function doResize() {
		$('#flash-gallery').height(($(window).height())-200);
		//var pageHeight = $('#content .page').height()+20;
		//$('#content').height(pageHeight);
		var windowHeight = $(window).height()-200;
		var contentHeight = $('#content').height();
		if(windowHeight>contentHeight) {
			if(windowHeight>1000) { windowHeight = 1000; }
			$('#smoke').height(windowHeight);
			if(windowHeight<500) { homeFlashHeight = 500; } else { homeFlashHeight = windowHeight; }
			$('#home-flash').height(homeFlashHeight);
		} else {
			if(contentHeight>1000) { contentHeight = 1000; }
			$('#smoke').height(contentHeight);
			if(contentHeight<500) { homeFlashHeight = 500; } else { homeFlashHeight = contentHeight; }
			$('#home-flash').height(homeFlashHeight);
		}
		//$('.siteby').text('windowHeight: '+windowHeight+' | contentHeight: '+contentHeight+' | pageHeight: '+pageHeight);
	};
	
	var resizeTimer = null;
	$(window).bind('resize', function() {
		if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(doResize, 50);
	});
	
	$('#tags-allowed').hide();
	
	$('.formatting a.toggle').click( function() {
		$('#tags-allowed').slideToggle();
		return false;
	});
	
	if($('label.contactmailtoggle input').attr('checked')) {
		$('fieldset.contactmail').show();
	} else {
		$('fieldset.contactmail').hide();
	}
	
	$('label.contactmailtoggle input').click( function() {
		if($(this).attr('checked')) {
			$('fieldset.contactmail').fadeIn();
		} else {
			$('fieldset.contactmail').fadeOut();
		}
	} );
	
	function sfHover() {
		var sfEls = document.getElementById("menu").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" hover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" hover\\b"), "");
			}
		}
	}
	
	sfHover();
	
});