
$(document).ready(


	function() {
		$("#logo_left img").hover(
			function(){
				$("#logo_left img").stop().fadeTo("slow", 1.0); 
			},
			function(){
				$("#logo_left img").stop().fadeTo("slow", 0.1); 
			}
		);
		
		$("#galerieNav img").hover(
			function(){
				this.src="pics/bullet-black.gif";
			},
			function(){
				if(this.className != 'active')
					this.src="pics/bullet-gray.gif"; 
			}
		);
		
		$("#galerieImage").load(
			function() {
				$("#galerieImage").fadeIn(500);
			}
		);
	
		if(typeof article_id != "undefined"){
		
			$('#logo_left img').css(
				{
						opacity: '1.0'
				}
			);
		
			setTimeout(function() {
				imageRotate();
				setTimeout(function()
					{
						$("#logo_left img").fadeTo(2000, 0.1);
					},
					1000
				);
			},
			4000
		);
		
		} else {
			imageRotate();
		}
		
		// Overview der Bilder anzeigen mit Sliceposition
		$('#overview').before('<div id="navOverView">').cycle(
			{ 
				speedIn: 1500,
				speedOut: 1, 
				timeout: 4500, 
				type: 'sequence',
				//startingSlide: + startSlide, // 0-basiert
				pager:  '#navOverView'
			}
		);
		
		animateDragContent();
	}
);

function imageRotate(){
	$('#image_rotate img').each(
		function(i){
			$(this).css(
				{
					display: 'block'
				}
			)
		}			
	);
	
	$('#image_rotate').innerfade(
		{
				speed: 1500,
				speedOut: 1, 
				timeout: 4500,
				type: 'sequence' 
		}
	);
}

function isImagesLoaded(el){
	var loaded = true;
	$(el).each(
		function (i) {
			if(!this.complete)
				loaded=false;
		}
	);
	return loaded;
}

function animateDragContent(){

	var duration = 300;

	if(!isImagesLoaded('#dragContent img'))
	{
		setTimeout(
			function() {
				animateDragContent();
			},
			100
		);
		
	} else {
	
		$('#dragContent img').each(
			function (index, domElement) {

				if(index==0) $(domElement).fadeIn(duration);
				else {
					setTimeout(
						function() {
							$(domElement).fadeIn(duration);
						},
						(duration*index)
					);
				}
			}
		);
		//$('#dragWrapper').hide();
		//$('#dragContent img').show();
		//$('#dragWrapper').show('slow');
	}
}
var muchTime = 3500;
$(
	function() {
		$('#picFade').css(
			{
				display: 'none'
			}
		);
		setTimeout(
			function() {
				$('#firstPic').hide(1,
					function(){
						$('#picFade').css(
							{display: 'block'}						
						);
						
						$('#picFade img:first').fadeIn(1500);
						
						$('#picFade').before('<ul id="navFade">').cycle(
							{ 
								speedIn: 1500,
								speedOut: 1, 
								timeout: 8000, 
								type: 'sequence',
								pager:  '#navFade',
								before: function(idx, slide)
								{
									var top		= '' + slide.style.top + '';
									top			= top.replace("px","");
									top			= top-20 + 'px';
									var left	= '' + slide.style.left + '';
									var zahl	= idx + 1;
									
									$('#navFade').css(
										{'top' : top}
									);
									
									$('#navFade').css(
										{'left' : left}
									);
									
									return '<li><a href="#">'+ zahl +'</a></li>'; 
								}
							}
						);
					}
				);
			}, 
			+ muchTime
		);
	}
);

var windowStore = null;
function toggleWindow(w,h) 
{
	if(windowStore.max) {
		window.resizeTo(windowStore.width, windowStore.height);
		window.moveTo(windowStore.x, windowStore.y);
		windowStore.max = false;
		document.getElementById('resizeImg').src='./pics/resize-full.gif';
	} else {
		window.resizeTo(screen.availWidth, screen.availHeight);
		window.moveTo(0, 0);
		windowStore.max = true;
		document.getElementById('resizeImg').src='./pics/resize-back.gif';
	}
}

window.onresize = (
	function()
	{
		
		var width  = (document.all) ? document.documentElement.clientWidth : window.outerWidth;
		var height = (document.all) ? document.documentElement.clientHeight : window.outerHeight;
		
		if(width != screen.availWidth && height != screen.availHeight){
			windowStore.width  = width;
			windowStore.height = height;
			document.getElementById('resizeImg').src='./pics/resize-full.gif';
		}
	}
);

function init(){

	windowStore = {
		width: (document.all) ? document.documentElement.clientWidth : window.outerWidth,
		height: (document.all) ? document.documentElement.clientHeight : window.outerHeight,
		x: (document.all) ? window.screenLeft : window.screenX,
		y: (document.all) ? window.screenTop : window.screenY,
		max: false
	};
}

