/*
 * 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('.Home', '-265px', '0px', '0px', '0px');
		slideFX('.mail_support', '-265px', '-37px', '0px', '-37px');
		slideFX('.chat_support', '-265px', '-71px', '0px', '-71px');
		slideFX('.phone_support', '-265px', '-106px', '0px', '-106px');
		slideFX('.news', '-265px', '-141px', '-0px', '-141px');
		slideFX('.about_us', '-265px', '-176px', '0px', '-176px');
		slideFX('.why_us', '-265px', '-211px', '0px', '-211px');
		slideFX('.Our_Clients', '-265px', '-246px', '0px', '-246px');
		slideFX('.Site_Map', '-265px', '-282px', '0px', '-282px');
		slideFX('.Privacy_Policy', '-265px', '-317px', '-0px', '-317px');
		slideFX('.FAQ', '-265px', '-352px', '0px', '-352px');
		slideFX('.Contact_Us', '-265px', '-387px', '-0px', '-387px');
		

		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);
				})	
		}

		function crossfadeFX(itemName) {
			$(itemName)
				.css( {backgroundPosition:"0 0"} )
				.prepend("<div class=\"hoverimage\"></div>")
				.append("<div class=\"hoverarea\"></div>");
			$(itemName + " .hoverimage").css( {opacity:0} )
			$(itemName + " .hoverarea")
				.mouseover(function(){
					$(this).parent().find("div.hoverimage").stop().animate({opacity:1}, 250);
				})
				.mouseout(function(){
					$(this).parent().find("div.hoverimage").stop().animate({opacity:0}, 850);
				})
		}
		crossfadeFX('.webdesigntools #rankcheck');
		crossfadeFX('#rssmenu .rssfeedbig');

		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"} )} );
				})

			$.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');
			$(".projectlink").fancybox({ 'zoomSpeedIn': 400, 'zoomSpeedOut': 200, 'frameWidth': 550, 'frameHeight': 350, 'overlayShow': true, overlayOpacity: 0.8, 'hideOnContentClick': true }); 
		} catch(e) {}
	});
});