jQuery.extend( jQuery.easing,
{
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	}
});

(function($) {
	$.extend($.fx.step,{
	    backgroundPosition: function(fx) {
            if (fx.state === 0 && typeof fx.end == "string") {
                var start = $.curCSS(fx.elem,"backgroundPosition");
                start = toArray(start);
                fx.start = [start[0],start[2]];
                var end = toArray(fx.end);
                fx.end = [end[0],end[2]];
                fx.unit = [end[1],end[3]];
			}
            var nowPosX = [];
            nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
            nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
            fx.elem.style.backgroundPosition = nowPosX[0]+" "+nowPosX[1];

           function toArray(strg){
               strg = strg.replace(/left|top/g,"0px");
               strg = strg.replace(/right|bottom/g,"100%");
               strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
               var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
               return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
           }
        }
	});
})(jQuery);

$(document).ready(function(){
	$(function(){
		$("#searchbox")
			.focus(function(){
				searchValue = $(this).attr("value");
				if (searchValue == "Suchbegriff") { $(this).attr({ value: "" }) };
			})
			.blur(function(){
				inputValue = $(this).attr("value");
				if ($.trim(inputValue) == "") { $(this).attr({ value: searchValue }) };
			})

		function slideFX(mnuName, xPos, yPos, xPosAni, yPosAni) {
			$(mnuName)
				.css({ backgroundPosition:xPos+" "+yPos })
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition:"("+xPosAni+" "+yPosAni+")"}, 500, "easeOutExpo");
				})
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition:"("+xPos+" "+yPos+")"}, 2500, "easeOutExpo");
				})
		}
		
		slideFX(".mnu_1", "-265px", "-302px", "-15px", "-302px");
		slideFX(".mnu_2", "-265px", "-345px", "-15px", "-345px");
		slideFX(".mnu_3", "-265px", "-386px", "-15px", "-386px");
		slideFX(".mnu_4", "-265px", "-427px", "-15px", "-427px");
		slideFX(".mnu_5", "-265px", "-468px", "-15px", "-468px");

		if ($.browser.msie) {
			$(".imagelink")
				.mouseover(function(){
					$(this).css({ opacity: 0.5, marginLeft: "-3px" });
				})
				.mouseout(function(){
					$(this).css({ opacity: 1 });
				})
			
			$(".projectlink, .extralink")
				.css({ backgroundPosition:"-10px -146px" })
				.mouseover(function(){
					$(this).stop().animate({ backgroundPosition:"(-10px 0)"}, 50);
					$(this).children("img").stop().animate({ opacity: 0.5 }, 20);
				})
				.mouseout(function(){
					$(this).stop().animate({ backgroundPosition:"(-10px -146px)"}, 10);
					$(this).children("img").stop().animate({ opacity: 1 }, 50);
				})
		} else {
			$(".imagelink")
				.mouseover(function(){
					$(this).stop().fadeTo(200, 0.5);
				})
				.mouseout(function(){
					$(this).stop().fadeTo(650, 1);
				})			
		}
		
		try {
			$("#showcased").attr({ href: window.location.href + "#showcased" })
			$("#showcased, .featuredbox")
				.mouseover(function(){
					$(".featuredbox").css({ display:"block" })
					$(".featuredbox").stop().animate({ opacity: 1 }, 240);
				})
				.mouseout(function(){
					$(".featuredbox").stop().animate({ opacity: 0 }, 300, function(){ $(".featuredbox").css({ display:"none" }) });
				})
			
			if (window.location.href.toString().substr(-7) == "/extras") {
				$.jtabber({
					mainLinkTag: "#tabs_extras a",
					activeLinkClass: "tabactive",
					hiddenContentClass: "tabbed",
					showDefaultTab: 1,
					showErrors: false,
					effect: "fade",
					effectSpeed: "medium"
				});
			}

			$("body").append("<style type=\"text/css\">div.tabbed { display:none; }</style>");
		} catch(e) {}

	});
});




