/*
 * jQuery EasIng v1.1.2 - http://gsgd.co.uk/sandbox/jquery.easIng.php
 *
 * Uses the built In easIng capabilities added In jQuery 1.1
 * to offer multiple easIng options
 *
 * Copyright (c) 2007 George Smith
 * Licensed under the MIT License:
 *   http://www.opensource.org/licenses/mit-license.php
 */
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;
	}
});

/**
 * @author Alexander Farkas
 * v. 1.02
 */
(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(){
		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+")"}, 1400, "easeOutExpo")
			})
		}
		slideFX('.mnu_start', '-265px', '0px', '0', '0px');
		slideFX('.mnu_artikel', '-265px', '-46px', '0', '-46px');
		slideFX('.mnu_projekte', '-265px', '-99px', '0', '-99px');
		slideFX('.mnu_extras', '-265px', '-152px', '0', '-152px');
		slideFX('.mnu_kontakt', '-265px', '-205px', '0', '-205px');

		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);
			})
			
			$('.projectlink, .extralink')
			.css( {backgroundPosition: "-10px -146px"} )
			.mouseover(function(){
				$(this).stop().animate({backgroundPosition:"(-10px 0)"}, 120);
				$(this).children('img').stop().animate({opacity:0.5}, 140);
			})
			.mouseout(function(){
				$(this).stop().animate({backgroundPosition:"(-10px -146px)"}, 10);
				$(this).children('img').stop().animate({opacity:1}, 600);
			})
		}

		try {
			$(".projectlink").fancybox({ 'zoomSpeedIn': 400, 'zoomSpeedOut': 200, 'frameWidth': 550, 'frameHeight': 350, 'overlayShow': true, overlayOpacity: 0.8, 'hideOnContentClick': true }); 
		} catch(e) {}

		try {
			$.jtabber({
				mainLinkTag: "#tabs_projekte a",
				activeLinkClass: "tabactive",
				hiddenContentClass: "tabbed",
				showDefaultTab: 1,
				showErrors: false,
				effect: 'fade',
				effectSpeed: 'medium'
			})
			$.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>");
			slideFX('#projekte_1', '0px', '0px', '0px', '-40px');
			slideFX('#projekte_2', '-95px', '0px', '-95px', '-40px');
			slideFX('#projekte_3', '-206px', '0px', '-206px', '-40px');
			slideFX('#projekte_4', '-275px', '0px', '-275px', '-40px');
			slideFX('#projekte_5', '-417px', '0px', '-417px', '-40px');
			slideFX('#extras_1', '0px', '0px', '0px', '-40px');
			slideFX('#extras_2', '-93px', '0px', '-93px', '-40px');
			slideFX('#extras_3', '-197px', '0px', '-197px', '-40px');
			slideFX('#extras_4', '-299px', '0px', '-299px', '-40px');
			slideFX('#extras_5', '-399px', '0px', '-399px', '-40px');
		} catch(e) {}
	});
});