$.preloadImages("/img/background_dark.jpg", "/img/background_light_short.jpg", "/img/background2_dark.jpg", "/img/background2_light_short.jpg");

$(function() {
	$("ul.sf-menu").supersubs({ 
		minWidth: 12,
		maxWidth: 16,
		extraWidth: 1
	}).superfish();
	
	if (typeof byrWaterType != "undefined"){
		setBgByWaterType(byrWaterType);
	}
	
	$("#container img, #header div").pngfix();
	
	/*
	$("#container").hide();
	
	var preloadCnt = 0;
	var preloadImages = ["/img/background_dark.jpg", "/img/background_light_short.jpg"];
	
	$.each(preloadImages, function (e) {
		$("<img>")
			.attr("src", this)
			.bind('load', function() {
				preloadCnt++;
				
				if (preloadCnt == preloadImages.length) {
					$("#container").show();
					$("#container img, #header div").pngfix();
				}
			});
	});
	*/
});

function setBgByWaterType(water_type) {
	if ( water_type == 'fresh' || water_type == 'salt') {
		$("body").attr("class", "bg" + water_type);
		return true;
	} else {
		$("body").removeAttr("class");
		return false;
	}
}