$(document).ready(function(){
	$(".quickfinder-content-centercol").animate({
		"width": "0",
		"opacity": 0
	},0);
	$(".tx-quickfinder-indexed-search").css("top",0);
	/*
	$(".quickfinder-grabber.quickfinder-grabber-closed").live('mouseover',function(){
		$(this).parents(".quickfinder").stop(true,false).animate({
			"width" : 43
		},250);
	});
	*/
	$(".quickfinder-grabber.quickfinder-grabber-closed").live('mouseout',function(){
		$(this).parents(".quickfinder").stop(true,false).animate({
			"width" : 43
		},250);
	});
	$(".quickfinder-grabber.quickfinder-grabber-closed").live('click',function(){
		$(this).removeClass("quickfinder-grabber-closed").addClass("quickfinder-grabber-open").parents(".quickfinder").animate({
			"width" : 989
		},1500,"swing",function(){
			$(".tx-quickfinder-indexed-search",$(this)).animate({
				"top": -50
			}, 250);
		});
	});
	$(".quickfinder-grabber.quickfinder-grabber-open").live('click',function(){
		var container = $(this).next(".quickfinder-content-wrapper").children(".quickfinder-content");
		$(".tx-quickfinder-indexed-search",$(this).parent()).animate({
			"top": 0
		}, 250); 
		$(this).removeClass("quickfinder-grabber-open").addClass("quickfinder-grabber-closed").parents(".quickfinder").animate({
			"width" : 43
		},1500,'swing',function(){
			container.removeClass("expanded");
			container.animate({
				"width": "49.9%"
			},0);
			container.children(".quickfinder-content-leftcol,.quickfinder-content-rightcol").animate({
				"width": "49.9%"
			},0);
			container.children(".quickfinder-content-centercol").animate({
				"width": "0",
				"opacity": 0
			},0);
		});
	});
	$(".quickfinder-content-leftcol  .quickfinder-launcher-inner,.quickfinder-content-rightcol .quickfinder-launcher-inner").mouseover(function(){
		$(this).addClass('quickfinder-launcher-inner-hover');
	}).mouseout(function(){
		$(this).removeClass('quickfinder-launcher-inner-hover');
	});
	$(".quickfinder-content-leftcol  .quickfinder-launcher-inner,.quickfinder-content-rightcol .quickfinder-launcher-inner").click(function(){
		var launcher  = $(this).parent();
		if(launcher.hasClass("quickfinder-launcher-active") == false) {
			$(".quickfinder-content-centercol .quickfinder-hide-border-partly").fadeOut(500);
			var container = launcher.parents(".quickfinder-content");
			if (!container.hasClass("expanded")) {
				container.addClass("expanded").animate({
					"width": "100%"
				}, 1000);
				container.children(".quickfinder-content-leftcol,.quickfinder-content-rightcol").animate({
					"width": "25%"
				}, 1000);
				container.children(".quickfinder-content-centercol").animate({
					"width": "49.9%"
				},1000,'swing',function(){
					container.children(".quickfinder-content-centercol").animate({
						"opacity": 1
					},1000);
				});
			}
			$(".quickfinder-content-leftcol div,.quickfinder-content-rightcol .quickfinder-launcher").removeClass("quickfinder-launcher-active",250);
			$(".quickfinder-content-leftcol .quickfinder-launcher-inner,.quickfinder-content-rightcol .quickfinder-launcher-inner").removeClass("quickfinder-launcher-inner-active");
			launcher.addClass("quickfinder-launcher-active",250);
			launcher.children(".quickfinder-launcher-inner").addClass("quickfinder-launcher-inner-active",250);
			if ($(".quickfinder-content-centercol .quickfinder-content-active",container).length) {
				$(".quickfinder-content-centercol .quickfinder-content-active",container).removeClass("quickfinder-content-active").stop(true, true).fadeOut(500, 'swing', function(){
					container.children(".quickfinder-content-centercol").children(".quickfinder-content-centercol-contentwrap").children(".quickfinder-content-centercol-" + launcher.attr("rel")).addClass("quickfinder-content-active").stop(true, true).fadeIn(500);
				});
			}else{
				container.children(".quickfinder-content-centercol").children(".quickfinder-content-centercol-contentwrap").children(".quickfinder-content-centercol-" + launcher.attr("rel")).addClass("quickfinder-content-active").stop(true, true).fadeIn(500);
			}
			switch(launcher.attr("rel")){
				case "1":
					$(".quickfinder-content-centercol .quickfinder-hide-border-partly").css("top","2px").css("left","0").css("right","auto").css("bottom","auto").fadeIn(500);
					break;
				case "2":
					$(".quickfinder-content-centercol .quickfinder-hide-border-partly").css("top","auto").css("left","0").css("right","auto").css("bottom","2px").fadeIn(500);
					break;
				case "3":
					$(".quickfinder-content-centercol .quickfinder-hide-border-partly").css("top","2px").css("left","auto").css("right","0").css("bottom","auto").fadeIn(500);
					break;
				case "4":
					$(".quickfinder-content-centercol .quickfinder-hide-border-partly").css("top","auto").css("left","auto").css("right","0").css("bottom","2px").fadeIn(500);
					break;
			}
		}
	});
});
