$(document).ready(function(){	
	$('#nav li').hover(function(){
		$(this)
			.children('ul').each(function(){
				if (! $(this).parents('li').hasClass('current')){
					$(this).css({left:'0'})
				}
			})
			.end()	
			.addClass('hover');
	}, function(){
		$(this)
			.children('ul').each(function(){
				if (! $(this).parents('li').hasClass('current')){
					$(this).css({left:'-999em'})
				}
			})
			.end()	
			.removeClass('hover');
	});
	
	var wrapWidth = function() {
		var w = $('body').width();
		return w > 1275 ? 1150 : w - 125;
	}();	
	
	$('#wrap').width(wrapWidth + 5);
	
	$('li.current').parents('li').addClass('current');
	
	$('#splash').flash({
	    src: '/swf/Home.swf',
	    width: wrapWidth,
	    height: Math.ceil(wrapWidth * 0.521739),
		wmode: 'transparent'
	});
	
	$('#about').flash({
	    src: '/swf/About.swf',
	    width: wrapWidth,
	    height: Math.ceil(wrapWidth * 0.6217391),
		wmode: 'transparent'
	});
	
	$('#gallery').each(function(){
		var m = location.href.match(/\/(\d+)/g);
		if (m) {
			var flashParams = '/swf/Gallery.swf?u=/api/galleries' + m[0];
			if (typeof(m[1]) !== 'undefined') {
				flashParams = flashParams + "&q=" + m[1].slice(1);
			}
		}
		
		$(this).flash({
			src: flashParams,
			width: wrapWidth,
		    height: Math.ceil(wrapWidth * 0.8521739) +20,
			wmode: 'transparent'
		});
	});
});