jQuery(document).ready(function($) {
	$('a[rel*=facebox]').facebox();
})
$(document).ready(function() {
	$('html').pngFix( );
});

$(document).ready(function() {
	/* // // // // // // // // // // // //	*/	
	/* GLOBAL NAVIGATION					*/
	/* // // // // // // // // // // // //	*/	
	$("#navcontainer li ul").css({display:"none"});
	$("#navcontainer li#currentItem ul").css({display:"block"});
	$("#navcontainer li.ancestorItem ul").css({display:"block"});
		
	/* // // // // // // // // // // // //	*/	
	/* VIDEOPOPUP WEGEN DOWLOAD DEAKTVIERT	*/
	/* // // // // // // // // // // // //	*/
	
		$('a.ScreenCast').each(function () {
			var movie = $(this).attr('rel');
			$(this).css({cursor: "pointer"});
			$(this).click(function () { 
				jQuery.facebox('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="720" height="500" codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"><param name="src" value="'+movie+'"><param name="autoplay" value="false"><embed src="'+movie+'" width="720" height="500" pluginspage="http://www.apple.com/quicktime/download/" autoplay="true"></object>');
			});
		});
	
	/* // // // // // // // // // // // //	*/	
	/* BLOG									*/
	/* // // // // // // // // // // // //	*/
	$(".blog-entry").addClass("PostInfoPopup");
	$(".blog-entry").prepend('<div class="blog_sign"></div>');
	$(".blog-entry").prepend('<div class="popup open"></div>');

	//$(".blog-entry").fadeTo(1, 0.5);
	//$("p.blog-entry-tags").fadeTo(1, 0.5);
	
	$(".popup").css({ 
				position: "absolute",
				left:"50%", top:"50%",
				marginLeft:"-50px", marginTop: "-50px",  
				opacity: "0",
				height: "100px",
				width: "100px" 
				});

	/* :: :: :: :: :: :: :: :: :: :: :: ::	*/	
	/* Blog-Entry Hover						*/
	/*
	$(".blog-entry").hover(
		function () {
			$(this).fadeTo("fast", 1);
		}, 
		function () {
			$(this).fadeTo("fast", 0.7);
		}
		);
	*/
	/* :: :: :: :: :: :: :: :: :: :: :: ::	*/	
	/* Open Post H1 Slide / fade			*/
	$("h1.blog-entry-title a").addClass("trigger");
	$(".blog-read-more a").addClass("trigger");

	/* // // // // // // // // // // // //	*/	
	/* SIDEBAR								*/
	/* // // // // // // // // // // // //	*/	
/*	$("#sidebar:empty").remove();	
	$("#sidebarContainer").css({opacity: "0.7", height:"100%", backgroundPosition: '+50px 0px'});
	$("#sidebar").css({paddingLeft: "50px"});
		
	$("#sidebar").hover(
		  function () {
			
			$(this).animate({
				paddingLeft: "0px"
				}, 100 );
			
			$("#sidebarContainer").animate({
				opacity: 1,
				backgroundPosition: '0px 0px'
				}, 100 ); 	 
			}, 
		  function () {
			$(this).animate({
				paddingLeft: "50px"
				}, 100 );
			$("#sidebarContainer").animate({
				opacity: 0.4,
				backgroundPosition: '+50px 0px'
				}, 100 );			
		  }
		);

	/* // // // // // // // // // // // //	*/	
	/* DOCK NAV &SLIDEMOVE					*/
	/* // // // // // // // // // // // //	*/
	$("#navcontainer ul li ul a").addClass("docky");
	$("#navcontainer ul ul ul a").removeClass("docky");	
	
	$("#navcontainer a.docky").clone().appendTo("#dock");
	if ($("form#warenkorb").length) {
		$('#dock').prepend('<a class="docky" id="checkout" href="javascript: onClick=warenkorb.submit();">Checkout</a>');
	};
	$("#navcontainer ul a").removeClass("docky");	
	$("#dock:empty").remove();
	
	$("#HeaderSlideshow").prependTo('#pageHeader');

    /* // // // // // // // // // // // //	*/	
	/* FAQ					*/
	/* // // // // // // // // // // // //	*/
	$('#faq-header ul li').each(function () {
		var faqHeader	= $(this).attr('id');
		var faqContent	= faqHeader.substr(0,faqHeader.length-4);
		//$("body").prepend(faqContent);
		$("a", this).removeAttr("href");
		$("a", this).css({cursor: "pointer"});
		$("a", this).click(function () { 
			jQuery.facebox($("li#" + faqContent));
		});
	});
		$("#faq-header ul li").hover(
		function () {
			$(this).fadeTo("fast", 0.5);
		}, 
		function () {
			$(this).fadeTo("fast", 1);
	});	
});

/* // // // // // // // // // // // //	*/	
/* DOCK									*/
/* // // // // // // // // // // // //	*/
$(function () {
	$('.docky').each(function () {
		var str			= $(this).text();
		var imgpath		= str.replace(" ",'');
		var MeineDomain = 'http://myownapp.com/moapp2.0/';

		$(this).wrap('<div class="smallBubble"></div>').css({position: "absolute"});
		$(".smallBubble").css({
			position: "relative", 	
			height:"66px",
			width: "66px",
			display: "block"
		});
	
		var breiteBubble	= $(this).width()+20;
		var breiteBubble	= breiteBubble/2;
		var breiteBubble	= 33-breiteBubble;
		
		$(this).html('<img class="reflect rheight33 ropacity66" src="'+ MeineDomain + 'dockicons/' + imgpath +'.png" alt="'+ str +'"/>'); 
		$(this).parent().addClass(str);
		$(this).parent().prepend('<div class="popup"><span class="txt">'+ str +'</span><span class="pfeil"></span></div>');
		
		/*CSS*/
		
		$("#dock .popup").css({
			position: "absolute",
			/*background:'url(images/dock_bub_l.png) no-repeat left top',*/
			paddingLeft: "10px",
			color:"#fff",
			marginTop: "-40px",			
			height: "22px" 
			});

		$(this).siblings().css("marginLeft", breiteBubble);
			
		$("#dock .popup span.txt").css({
			/*background:'url(images/dock_bub_r.png) no-repeat right top',*/
			paddingRight: "10px",
			paddingTop: "3px",
			height: "19px",
			overflow: "hidden",	
			whiteSpace: "nowrap",
			display: "block"
			});	

		$("#dock .popup span.pfeil").css({
			/*background:'url(images/dock_bub_p.png) no-repeat center top',*/
			paddingRight: "10px",
			height: "10px",
			marginLeft: "-10px",
			display: "block"
			});						
	});
});

	
/* // // // // // // // // // // // //	*/	
/* POST INFO BUBBLE						*/
/* // // // // // // // // // // // //	*/	
$(function () {
	  $('.PostInfoPopup').each(function () {
	    // options
	    var time = 350;
	    var hideDelay = 350;

	    var hideDelayTimer = null;

	    // tracker
	    var beingShown = false;
	    var shown = false;

	    var trigger = $('.trigger', this);
	    var popup = $('.popup', this).css('opacity', 0);

	    $(trigger, popup).mouseover(function () {
	      if (hideDelayTimer) clearTimeout(hideDelayTimer);
	      if (beingShown || shown) {
	        return;
	      } else {
	        beingShown = true;
			/*RESET POPUP*/
   	        popup.css({
				left:"50%", top:"50%",
				marginLeft:"-50px", marginTop: "-50px",  
				display: 'block' 
				})

	        .animate({
				left:"50%", top:"50%",
				marginLeft:"-50px", marginTop: "-50px", 
				opacity: 1
	        }, time, 'swing', function() {
	          beingShown = false;
	          shown = true;
	        });
	      }
	    }).mouseout(function () {
	      if (hideDelayTimer) clearTimeout(hideDelayTimer);
	      hideDelayTimer = setTimeout(function () {
	        hideDelayTimer = null;
	        popup.animate({
	          //marginTop: "-50%",
	          opacity: 0
	        }, time, 'swing', function () {
	          shown = false;
	          popup.css('display', 'none');
	        });
	      }, hideDelay);
	    });
	  });
	});	
	
/* // // // // // // // // // // // //	*/	
/* POST INFO BUBBLE						*/
/* // // // // // // // // // // // //	*/	

$(function () {
	  $('.smallBubble').each(function () {
		var trigger = $('.docky', this);
	    var popup = $('.popup', this).css('opacity', 0);

	    $([trigger.get(0), popup.get(0)]).mouseover(function () {
   	        popup.css({ display: "block", opacity: "1" })
	    }).mouseout(function () {
			popup.css({ display: "none", opacity: "0" })
	    });
	  });
	});	
	
	/* // // // // // // // // // // // //	*/	
	/* Slideshow Desktop			*/
	/* // // // // // // // // // // // //	*/
	$(document).ready(function() {
		$('#HeaderSlideshow IMG').css({display: "none"});
		$('#HeaderSlideshow IMG.active').css({display: "block"});
		$('#HeaderSlideshow IMG:first').addClass("lastimageSlide");
	});	
	function slideSwitch() {
	    var $active = $('#HeaderSlideshow IMG.active');
		if ( $active.length == 0 ) $active = $('#HeaderSlideshow IMG:first');
		var $next =  $active.next().length ? $active.next():$('#HeaderSlideshow IMG:first');

			if ($next.is(".lastimageSlide")){ 
				$next.css({display:"block"});
				$active.fadeOut(3000);
	            $active.removeClass('active last-active');				
			} else {
			$next.addClass('active').fadeIn(3000,function() {
				$active.addClass('last-active').hide();
	            $active.removeClass('active last-active');			
	        });
			}


	}
	$(function() {
	    setInterval( "slideSwitch()", 3500 );
	});
/* // // // // // // // // // // // //	*/	
/* BUBBLE 		 						*/
/* // // // // // // // // // // // //	*/
$(function () {
	  $('.bubbleSmallInfo').each(function () {
	    // options
	    var distance = 50;
	    var time = 250;
	    var hideDelay = 100;

	    var hideDelayTimer = null;

	    // tracker
	    var beingShown = false;
	    var shown = false;

	    var trigger = $('.trigger', this);
	    var popup = $('.popuper', this).css('opacity', 0);

	    // set the mouseover and mouseout on both element
	    $([trigger.get(0), popup.get(0)]).mouseover(function () {
	      // stops the hide event if we move from the trigger to the popup element
	      if (hideDelayTimer) clearTimeout(hideDelayTimer);

	      // don't trigger the animation again if we're being shown, or already visible
	      if (beingShown || shown) {
	        return;
	      } else {
	        beingShown = true;

	        // reset position of popup box
	        popup.css({
	          top: 0,
	          left: 0,
	          display: 'block' // brings the popup back in to view
	        })

	        // (we're using chaining on the popup) now animate it's opacity and position
	        .animate({
	          left: '-=' + distance + 'px',
	          opacity: 1
	        }, time, 'swing', function() {
	          // once the animation is complete, set the tracker variables
	          beingShown = false;
	          shown = true;
	        });
	      }
	    }).mouseout(function () {
	      // reset the timer if we get fired again - avoids double animations
	      if (hideDelayTimer) clearTimeout(hideDelayTimer);

	      // store the timer so that it can be cleared in the mouseover if required
	      hideDelayTimer = setTimeout(function () {
	        hideDelayTimer = null;
	        popup.animate({
	          left: '-=' + distance + 'px',
	          opacity: 0
	        }, time, 'swing', function () {
	          // once the animate is complete, set the tracker variables
	          shown = false;
	          // hide the popup entirely after the effect (opacity alone doesn't do the job)
	          popup.css('display', 'none');
	        });
	      }, hideDelay);
	    });
	  });
	});	
