var effectMultiplier = 15;
$.fn.wait = function(time, type) {
	time = time || 1000;
	type = type || "fx";
	return this.queue(type, function() {
		var self = this;
		setTimeout(function() {
			$(self).dequeue();
		}, time);
	});
};

function headerRotate() {
	
		$('.header-image').children('img:first').animate({top: '0'}, 150 * effectMultiplier, function(){
			$(this).fadeOut(200 * effectMultiplier, function(){
				//$(this).next().animate({width: '945px', height: '309px', left: '0'}, 1000 * effectMultiplier);
				$(this).next().wait(5000).fadeOut(200 * effectMultiplier, function() {
						$(this).next().animate({left: '0'}, 300 * effectMultiplier);
					})
				});
		});
}

$(document).ready(function(){
	headerRotate();
	
	$("form #email").val("email@provider.com");
	
	$("form #email").click(function(){
		$(this).val("");
		$(".hiddenform").slideDown();
	});
	
    $(".teaser").mouseenter(function() {
        $(this).children().children(".readmore").fadeIn("fast");
    });
    $(".teaser").mouseleave(function() {
        $(this).children().children(".readmore").fadeOut("slow");
    });
	$(".mini-calendar ul li").mouseenter(function() {
		$(this).children("a").addClass("hover-class");		
	});
	$(".mini-calendar ul li").mouseleave(function() {
		$(this).children("a").removeClass("hover-class");
	});
	
	$(".mainmenu li.parent").mouseover(function() {
		if ($(this).children(".dropdown-menu").length > 0) {
			$(this).children(".dropdown-menu").show();
		}
	});
	
	$(".mainmenu li.parent").mouseleave(function() {
		$(this).children(".dropdown-menu").hide();
	});
	
	$(".submenu li a").mouseover(function() {
		var name = $(this).parent().attr("name");
		var submenu = $(".subsubmenu ul[name=" + name + "]");
		$(this).parent().parent().children("li").children("a").removeClass("hover");
		if (!$(this).hasClass("selected")) {
			$(this).addClass("hover");
		}
		if ($(submenu).length > 0) {
			$(".subsubmenu ul:visible[name!="+name+"]").slideUp();
			$(submenu).slideDown();
		}
	});
	
	$(".banners ul li").fadeTo("slow", 0.33);
	$(".banners ul li").mouseover(function(){ $(this).fadeTo("fast", 1); });
	$(".banners ul li").mouseleave(function(){ $(this).fadeTo("slow", 0.33); });

	$("#footer .whitespace").fadeTo("slow", 0.33);
	$("#footer .whitespace").mouseover(function(){ $(this).fadeTo("fast", 1); });
	$("#footer .whitespace").mouseleave(function(){ $(this).fadeTo("fast", 0.33); });
	
	$(".scroller").jCarouselLite({
		btnNext: ".scrollarrow-right",
		btnPrev: ".scrollarrow-left",
		circular: false,
		visible: 4
    });
});
