Cufon.replace("p.slogan", {fontFamily: "DIN Regular"});

var slideshows;
function slide() {

	slideshows.each(function() {

		active = $("img:visible", this);
		active.fadeOut(2000);
		active = active.parent().next().find("img");
		if(!active.size())
			active = $(this).find("img:first");
		active.fadeIn(2000);

	});

	setTimeout("slide();", 12000);

}

$(function() {

	if($("#splashscreen").size()) {

		$("#container").hide();
		$("#splashscreen").show().find("a").click(function() {

			$("#container").show();
			$("#splashscreen").fadeOut(1000);

			slideshows = $(".slide").each(function() {
				$("img:not(:first)", this).hide();
			});
			setTimeout("slide();", 4000);

			return false;

		});

	}
	else {

		slideshows = $(".slide").each(function() {
			$("img:not(:first)", this).hide();
		});
		setTimeout("slide();", 4000);

	}

});

$(function() {

	/*
	$("#slideLarge img").load(function() {

		if($(this).width() / 386 > $(this).height() / 362) {

			$(this).width( $(this).width() / ($(this).height() / 362) );
			$(this).height(362);

			$(this).css("margin-left", -($(this).width() - 386) / 2);

		} else {

			$(this).height( $(this).height() / ($(this).width() / 386) );
			$(this).width(386);

			$(this).css("margin-top", -($(this).height() - 362) / 2);

		}

	});

	$("#slideshow img").load(function() {

		if($(this).width() / 87 > $(this).height() / 75) {

			$(this).width( $(this).width() / ($(this).height() / 75) );
			$(this).height(75);

			$(this).css("margin-left", -($(this).width() - 87) / 2);

		} else {

			$(this).height( $(this).height() / ($(this).width() / 87) );
			$(this).width(87);

			$(this).css("margin-top", -($(this).height() - 75) / 2);

		}

	})
	*/
   $("#slideshow img").click(function() {

		$("#slideLarge img").attr("src", $(this).attr("src").replace('_thumb', '')).each(function() {

			if($(this).width() / 386 > $(this).height() / 362) {

				$(this).width( $(this).width() / ($(this).height() / 362) );
				$(this).height(362);

				$(this).css("margin-left", -($(this).width() - 386) / 2);

			} else {

				$(this).height( $(this).height() / ($(this).width() / 386) );
				$(this).width(386);

				$(this).css("margin-top", -($(this).height() - 362) / 2);

			}

		});

	});

	if($.browser.msie) {

		//$("#slideLarge img, #slideshow img").load();

	}

	$("#slideshow").jcarousel();

	var navTimeout;
	$("#nav").hover(function() {

		$(this).next().css("margin-bottom", -2-$(this).next().height());

		clearTimeout(navTimeout);
		$(this).next().show();

	}, function() {

		el = $(this);
		navTimeout = setTimeout(function() { $(el).next().hide(); }, 250);

	});

	$("#sub").hover(function() {

		clearTimeout(navTimeout);

	}, function() {

		navTimeout = setTimeout(function() { $(el).next().hide(); }, 250);

	});

});
