$(function(){

	
	$("[rel=lightbox]").lightBox({
		imageLoading:images.loading,
		imageBtnPrev:images.prev,
		imageBtnNext:images.next,
		imageBtnClose:images.close,
		imageBlank:images.blank,
		txtImage: '',
		txtOf: ''
	});
	
	$(".partner img").hover(function(){
		$(this).attr('src',$(this).attr('src').replace('.gif','_on.gif'));
	},function(){
		$(this).attr('src',$(this).attr('src').replace('_on.gif','.gif'));
	})
	
	
	$("[rel=portfolio]").mouseover(function(){
		
		$("[rel=portfolio]").removeClass('on');
		
		$(".portfolio .zoom").fadeOut(function(){
			$(this).remove();
		});
		
		$('<img class="zoom"/>')
			.hide()
			.load(function(){
				$(this).fadeIn();
			})
			.attr('src',$(this).attr('href'))
			.prependTo('.portfolio .img');
		
		$(this).addClass('on');
		return false;
	}).click(function(){
		return false;
	});
	
	$(".portfolio .img")
		.mouseenter(function(){$(".overlay",this).stop(true,true).fadeIn('fast');})
		.mouseleave(function(){$(".overlay",this).stop(true,true).fadeOut('fast');});
	
	$(".gnext").click(function(){
		var o = $(".portfolio .images .on");
		(o.next().length ? o.next() : $(".portfolio .images a:first"))
			.mouseover();
	});
	$(".gprev").click(function(){
		var o = $(".portfolio .images .on");
		(o.prev().length ? o.prev() : $(".portfolio .images a:last"))
			.mouseover();
	})
	
	function play()
	{
		if(!fades[fadeIdx])
			fadeIdx = 0;
		
		$("<img />")
			.hide()
			.load(function(){
				var size = {
					w: $(this).width(),
					h: $(this).height()
				};
				
				$(this).siblings()
					.fadeOut(1200,function(){
						$(this).remove();
					});
				
				$(this)
					.css({
						width: 1000,
						top: ((310-size.h)*0.5)+'px',
						left: '0px'
					})
					.fadeIn(1200,function(){
						$(this)
							.animate({
								width: size.w
							}, 10000/*)
							.animate({
								top: ((310-size.h)*0.6)+'px',
								left: '-100px'
							}, 10000*/,function(){
								if(fades.length>1)
									window.setTimeout(play,2000);
							})
					})
			})
			.prependTo(".header")
			.attr('src',fades[fadeIdx++]);
	}
	
	var fadeIdx = 0;
	var fades = [];
	$('.header a').each(function(){
		fades.push($(this).attr('href'));
	}).remove();
	play(fades);
	
	function toEnable()
	{
		tot = window.setTimeout(function(){
			$("#clone").remove();
			},2000)
	}

	function toDisable()
	{
		window.clearTimeout(tot);
	}

	tot = null;
	$(".navi > li > a")
		.mouseenter(function(){
			toDisable();
			$("#clone").remove();
			$(this)
				.next(".second")
				.clone()
					.hide()
					.attr("id","clone")
					.css("position","absolute")
					.css("top",$(this).offset().top+$(this).outerHeight())
					.css("left",$(this).offset().left)
					.appendTo("body")
					.mouseover(toDisable)
					.mouseout(toEnable)
					.show()
		})
		.mouseout(toEnable)
		
	$("a.[rel=flashvideo]").click(function(){
		var height = $(".page").height();
		if($("body").height() > height)
			height = $("body").height();
		$(".player").height(height);
		$(".player,#player,#close").show();
		
		$("#player").flash({  
			swf: playerpath,
			width:565,
			height:337,
			flashvars: {
				file: $(this).attr('href'),
				autostart:"true"
				},
			params:{
					wmode: 			'opaque',
					allowfullscreen: 'true',
					allowscriptaccess: 'always'
				}
		});	
		
		$("*").scrollTop(0);
		
		return false;
	});
	
	$("#close,.player").click(function(){
		$("#player").html("");
		$(".player,#player,#close").hide();
	});
});

function getScrollY(){
	var scrOfY = 0;
	if(typeof(window.pageYOffset) == 'number'){
		/* Für Netscape */
		scrOfY = window.pageYOffset;
	}else if(document.body && document.body.scrollTop){
		/* Für DOM */
		scrOfY = document.body.scrollTop;
	}else if(document.documentElement && document.documentElement.scrollTop){
		/* Für IE6 */
		scrOfY = document.documentElement.scrollTop;
	}
	return scrOfY;
}

