

jQuery(function($){

	//$("#content .container p:first").remove();
	
	
	/*if(!$.browser.webkit){
	
	$("img").not("#home, nav>img, #load").each(function(){
		$(this).attr('original', $(this).attr('src'));
		$(this).attr('src','http://eggger.com/files/gimgs/spaceball.gif');
	});
	
	};*/
	
	
	//----------- BILD VERGRÖSSERN BEI FIRST LOAD --------------------------------

/*	function supersex() {
		var imageAR = $("img").width()/$("img").height();
		var windowwidth = $(window).width();
		var windowheight = $(window).height();

		var windowAR = windowwidth/windowheight;
		if(windowAR > imageAR){
			$("img").width(windowwidth);
			$("img").height($("img").width()/imageAR);
		} else {
			$("img").height(windowheight);
			$("img").width($("img").height()*imageAR);
		}
	}
	
	supersex();*/
	
	document.onkeydown = function(evt) {
    evt = evt || window.event;
    var keyCode = evt.keyCode;
    if (keyCode >= 37 && keyCode <= 40) {
        return false;
    }
};
	
	$("iframe").clone().appendTo("#content>.container");
	$("p>iframe").remove();
	$("#beschreibungstext").prev("p").remove();

	if (document.URL.indexOf('film') != -1){
		$("#arr-l, #splashname, #secureimage").remove();
		$("#content>.container>p").wrap("<div id='beschreibungstext'/>")
		$("#menu").css({'z-index':'5'});
		
		if ($.browser.mozilla) {
				$("iframe").css({'position':'absolute', 'left':'50%', 'top': '50%', 'z-index':'5000', 'margin-left':($("iframe").width()/2)*(-1), 'margin-top':($("iframe").height()/2)*(-1)}).addClass('video');
		} 
			else if ($.browser.msie) {
			
			$("iframe").css({'position':'absolute', 'left':'50%', 'top': '50%', 'z-index':'5000', 'margin-left':($("iframe").width()/2)*(-1), 'margin-top':($("iframe").height()/2)*(-1)}).addClass('video');
		
		}
		
		
		else {
				$("iframe").css({'position':'absolute', 'left':'50%', 'top': '50%', 'z-index':'5000', 'margin-left':($("iframe").width()/2)*(-1), 'margin-top':($("iframe").height()/2)*(-1)}).addClass('video');
		}
		
		$("body").prepend("<div id='filmoverlay' style='position:fixed; z-index:6000; width:100%; height:100%; display:block; background:black; opacity:0.5;'></div>");
		$("#arr-r").css('z-index','8000');
		$("#arr-r, #filmoverlay").click(function(){
			$("#arr-r, #filmoverlay, #beschreibungstext").fadeOut(200);
		});
		
	}





	//----------- BILD VERGRÖSSERN BEI RESIZE WINDOW --------------------------------






	
	function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
        $('<img/>')[0].src = this;
    });
	};

	preload([
    	'http://www.nickkapros.com/files/gimgs/arr-l-over.png',
    	'http://www.nickkapros.com/files/gimgs/arr-r-over.png'
    ]);
	
	/*$("#arr-r").hover(function(){
		$(this).attr('src', 'http://www.nickkapros.com/files/gimgs/arr-r-over.png');
	}, function(){
		$(this).attr('src', 'http://www.nickkapros.com/files/gimgs/arr-r.png');
	});

	$("#arr-l").hover(function(){
		$(this).attr('src', 'http://www.nickkapros.com/files/gimgs/arr-l-over.png');
	}, function(){
		$(this).attr('src', 'http://www.nickkapros.com/files/gimgs/arr-l.png');
	});*/
	
		
		
		
	$("#overlay").delay(500	).fadeOut(500);	
	
	$("#img-container>span:empty").css({'background':'none'}).children().hide();
	
	//$(".section-title, .section-title+li").css({'float':'left'});
	
	//$("#menu").width($(window).width()-220);
	
	$(".overlay").each(function(){
		$(this).css({'width':$(this).next().width()});
	});	
	
	//$("ul").after("<br/>");
	
	$("#img-list").children(":first-child").addClass("focus");

	
	
	$("#img-container>span:first").addClass("shit");
	$(".shit").nextAll().hide();
	
	$(".focus").css({'opacity':'0.5'});
	$(".focus").next().nextAll().animate({opacity:'0'},0);
	$(".focus").next().animate({opacity:'0.5'},0);
	
	
	$("#img-container>span").each(function(){
		$(this).append("<span class='counter'></span>");	
	})
	
	var alle = $("#img-list").children().length-1;
	var sichtbar = 1;
	var gesamt = "( " + sichtbar + "/" + alle + " )";
	
	$(".counter").text(gesamt);
	
	
	$("#arr-l").css({'opacity':'0'})
	
	$(".shit").children('span').not('.counter').fadeOut(0);
	$("#arr-l").css({'cursor':'default'});
	$(".counter").css({'opacity':'1'});
	
	$("#arr-r").click(function(){
		$("#arr-l").css({'cursor':'pointer'});
		$(".shit").children().fadeIn(0);
	
		if ($(".focus").is(":first-child") && $(".focus").css('opacity') == 1){
				
				$(".focus").next().addClass("focus").prev().removeClass("focus");
				$(".focus").animate({opacity:'1'},250);		
				$(".focus").next().animate({'opacity':'0.5'},250);
				$(".focus").prev().animate({'opacity':'1'},250);
		}


		if ($(".focus").is(":first-child")){
			$("#arr-l").animate({opacity:'1'}, 100);
			$("#beschreibungstext").fadeOut();
			
			$(".focus").animate({opacity:'1'},250);		

			$(this).css({'cursor':'pointer'});
			

		}
		
		
		
		else if (!$(".focus").is(":last-child") && !$(".focus").is(":first-child")){

		$(".shit").fadeOut();
		$(".shit").next().addClass("shit").prev().removeClass("shit");
		$(".shit").fadeIn();

		
	    $(function() { 
        	$sum = 0; 
            $('.focus').prevAll().not(":first-child").each(function() 
            { 
            	$sum += $(this).width(); 
            }); 
        }); 
				
		var slidepx = (-1)*$sum-($(".focus").width()-(($(window).width()-$(".focus").width()))/2);
		
		$("#img-list").animate({left:slidepx});
		
			$(".focus").next().addClass("focus").prev().removeClass("focus");
			$(".focus").animate({opacity:'0.5'},250);		
			$(".focus").next().animate({'opacity':'0.5'},250);
			$(".focus").prev().animate({'opacity':'1'},250);
			$(".focus").prev().prev().animate({'opacity':'0.5'},250);

		$(this).css({'cursor':'pointer'});
				
		var sichtbar = $("#img-list>.focus").index();
		var gesamt = "( " + sichtbar + "/" + alle + " )";
		$(".counter").text(gesamt);

		$("#img-container>span").css({'bottom':'25px'});
		$(".counter").css({'padding-left':'6px'});
		
		if ($.browser.webkit) {
			$(".counter").css({'padding-right':'10px', 'padding-left':'0'});
			$("#img-container>span").css({'padding-right':'0'});

		}
		
		} else {
			$("#img-list").animate({left:'0'},500);
			$("#img-list").children().removeClass("focus");
			$("#img-list").children(":first-child").addClass("focus").animate({'opacity':'0.5'},450);;
			
			$(".shit").animate({opacity:'0'}, 100);
			$(".shit").prevAll("span").fadeOut();
			$("#img-container>span").removeClass("shit");
			$("#img-container>span:first").addClass("shit").fadeIn();
			
			$("#beschreibungstext").fadeIn();

			
			var sichtbar = 1;
			var gesamt = "( " + sichtbar + "/" + alle + " )";
			$(".counter").text(gesamt);
			$("#arr-l").animate({opacity:'0'}, 100);
			$("#arr-l").css({'cursor':'default'});
			
		}
	});

		
		


		$("#arr-l").click(function(){
		
		
		if ($(".focus").is(":first-child")) {
			$(".focus").animate({opacity:'0.5'},250);		
			$("#beschreibungstext").fadeIn();
			$(".shit").fadeIn();
			$("#arr-l").animate({opacity:'0'}, 100);
			$(".shit").children().fadeOut(100);
			$(".shit").children('.counter').fadeIn(0);
			$("#arr-l").css({'cursor':'default'});
		}
		
		
		
		
		
		if ($(".focus").is(":nth-child(3)")) {
			$("#arr-l").animate({opacity:'1'}, 100);


			$("#img-list").animate({left:'0'},300);
			
			$("#img-list>img:first-child").addClass("focus").siblings().removeClass("focus");
			
			$(".focus").animate({opacity:'1'},250);
			$(".focus").next().animate({opacity:'0.5'},250);
			$(this).css({'cursor':'pointer'})
			
			$(".shit").fadeOut();
			$(".shit").prev().addClass("shit").next().removeClass("shit");
			$(".shit").fadeIn();
			
			var sichtbar = 1;
			var gesamt = "( " + sichtbar + "/" + alle + " )";
			$(".counter").text(gesamt);
		}
	
				
		if (!$(".focus").is(":first-child") && !$(".focus").is(":nth-child(3)")){
		$("#arr-l").animate({opacity:'1'}, 100);
		
		$(".shit").fadeOut();
		$(".shit").prev().addClass("shit").next().removeClass("shit");
		$(".shit").fadeIn();

	    $(function() { 
        	$sum2 = 0; 
            $('.focus').prevAll().each(function() 
            { 
            	$sum2 += $(this).width(); 
            }); 
        }); 
			
		var slidepx2 = (-1)*$sum2+(($(".focus").width()*2)+(($(window).width()-$(".focus").width()))/2);
		
		$("#img-list").animate({left:slidepx2});
		
		
		
		
		$(".focus").prev().addClass("focus").next().removeClass("focus");
		$(".focus").animate({opacity:'0.5'},250);
		$(".focus").prev().animate({opacity:'1'},250);
		$(".focus").next().animate({opacity:'0.5'},250);
		$(this).css({'cursor':'pointer'})
		
		var sichtbar = $("#img-list>.focus").index()+1;
		var gesamt = "( " + sichtbar + "/" + alle + " )";
		$(".counter").text(gesamt);
		
		} 
		
	});




	//-------------- IF DOCUMENT URL = STARTSEITE ---------------
	
	
	if ((document.URL == "nickkapros.com") || (document.URL == "nickkapros.com/") || (document.URL == "www.nickkapros.com") || (document.URL == "www.nickkapros.com/") || (document.URL == "http://nickkapros.com") || (document.URL == "http://nickkapros.com/") || (document.URL == "http://www.nickkapros.com") || (document.URL == "http://www.nickkapros.com/")){
			
		$("#img-list").css({'left':'0'});
		//$("img").css({'opacity':'1'});
		
		function supersex() {
		
		$("#beschreibungstext").addClass("beschreibungstext").removeAttr('id');
		$(".beschreibungstext").css({'margin-top':(-1)*($(".beschreibungstext").height()/2)});	
		$("#splashname").css({'margin-top':(-1)*($("#splashname").height()/2)});	
		
		var imageAR = $("#img-list>img").width()/$("#img-list>img").height();
		var windowwidth = $(window).width();
		var windowheight = $(window).height();

		var windowAR = windowwidth/windowheight;
		if(windowAR > imageAR){
			$("#img-list>img").width(windowwidth);
			$("#img-list>img").height($("#img-list>img").width()/imageAR);
		} else {
			$("#img-list>img").height(windowheight);
			$("#img-list>img").width($("#img-list>img").height()*imageAR);
		}
	}
	
	supersex();
	$(window).resize(function(){
		supersex();
		//$("#menu").width($(window).width()-220);
	});
	
	$("#arr-r, #arr-l, .shit").hide();
	
	$("#beschreibungstext").addClass("beschreibungstext").removeAttr('id');
	
	$(".beschreibungstext").css({'margin-top':(-1)*($(".beschreibungstext").height()/2)});	
	
	$("#splashname").css({'margin-top':(-1)*($("#splashname").height()/2)});	
	
	$("strong:nth-child(3)").addClass("addresses");
	
	$(".addresses").html($(".addresses").html().replace(/mail@nickkapros.com/,"<a href='mailto:mail@nickkapros.com'>mail@nickkapros.com</a>"));
	
	$(".beschreibungstext").prev().remove();


	}


	$("#menu>.container>ul:first").before("<ul><li class='section-title' id='aboutbutton' style='padding-right:15px;'><a href='http://www.nickkapros.com'>About</a></li></ul>");
	
	$("#menu").css({'opacity':'0'});


	
	//----------- INFOBOX --------------------------------
	
	
	/*$("#infobox-trigger").hover(function(){
		$("article, #titlebox, header, #infobox-trigger, #projectlist").animate({bottom:'+=200px'},300);
	}, function(){
	});*/

	
	
	//$("#menu").css({'bottom':(-1)*$("#menu").height()-10});
	
	
	
	/*
	$('#about').click(function(){
	
		if ($(this).hasClass("aktivv")){
			$(this).removeClass("aktivv");
			$("#menu").animate({bottom:'-80', opacity:'0'},300);
			$("#menu").removeClass("opened");
		} else {
			$(this).addClass("aktivv");
			$("#menu").animate({bottom:'-80', opacity:'0'},300);
			$("#menu").removeClass("opened");
		}
		
	});*/
	
	

	
	
	
	
	//
	
	$("#menu2").mouseenter(function(){
		$("#menu").addClass("opened");
		$("#about").removeClass("aktivv");
		}).mouseleave(function(){
			$("#menu").animate({bottom:'-80', opacity:'0'},300);
			//$("#menu").hide();
			$("#about").removeClass("aktivv");
			setTimeout(function(){
			$("#menu").removeClass("opened")},500);
	});
	
	$("#menu").children().find("a").css({'cursor':'default'});
	
	
	$("#name").toggle(function(){
			$("#menu").animate({opacity:'1'},200);
			$("#menu").css({'z-index':'6000000'});
			$("#menu").children().find("a").css({'cursor':'pointer'});
							//$(".focus").prev().css({'opacity':'0.5'});

			if ((document.URL == "nickkapros.com") || (document.URL == "nickkapros.com/") || (document.URL == "www.nickkapros.com") || (document.URL == "www.nickkapros.com/") || (document.URL == "http://nickkapros.com") || (document.URL == "http://nickkapros.com/") || (document.URL == "http://www.nickkapros.com") || (document.URL == "http://www.nickkapros.com/")){
				$("#splashname").animate({opacity:'0'},200);
				$(".beschreibungstext").animate({opacity:'0'},200);
				$(".focus").css({'opacity':'1'});
			}
		}, function(){
			$("#menu").animate({opacity:'0'},200);
			$("#menu").css({'z-index':'3000'});
			$("#menu").children().find("a").css({'cursor':'default'});
							//$(".focus").prev().css({'opacity':'1'});

			if ((document.URL == "nickkapros.com") || (document.URL == "nickkapros.com/") || (document.URL == "www.nickkapros.com") || (document.URL == "www.nickkapros.com/") || (document.URL == "http://nickkapros.com") || (document.URL == "http://nickkapros.com/") || (document.URL == "http://www.nickkapros.com") || (document.URL == "http://www.nickkapros.com/")){
				$("#splashname").animate({opacity:'1'},200);
				$(".beschreibungstext").animate({opacity:'1'},200);
				$(".focus").css({'opacity':'0.5'});
			}
	});


	


	//$("#menu>.container").children("ul:first").remove();
	

	if ($.browser.webkit) {
	
		$("strong").css({'padding':'3px 15px 4px 15px'});
		$(".section-title").css({'padding':'6px 15px 3px 15px', 'margin-bottom':'3px'});
		
		$("li:not('.section-title')").css({'padding': '3px 20px 4px 20px', 'margin-bottom':'3px'});
		$("#name").css({'padding':'3px 15px 0 15px'});
		$("#img-container>span").css({'padding':'4px 0 3px 15px'});
		$(".counter").css({'padding':'4px 10px 3px 8px'});
	}
	
	if ($.browser.msie) {
		$("#content>.container p").css({'margin-left':'-320px'});
		$("#img-container>span").css({'padding':'4px 0 3px 10px'});
		$(".counter").css({'padding':'4px 10px 3px 8px'});
	}


	
	
	//$('#aboutcontainer').load('http://nickkapros.com/index.php?/about/about/ #content>.container>p');
	
	
	

	

	//$("#splashname").css({'top':($(window).height()/2)-($("#splashname").height()/2)});

	if ((document.URL != "nickkapros.com") && (document.URL != "nickkapros.com/") && (document.URL != "www.nickkapros.com") && (document.URL != "www.nickkapros.com/") && (document.URL != "http://nickkapros.com") && (document.URL != "http://nickkapros.com/") && (document.URL != "http://www.nickkapros.com") && (document.URL != "http://www.nickkapros.com/")){
		$("#splashname, .beschreibungstext").css({'opacity':'0'});
		$("#beschreibungstext").css({'left':'370'});
	};
	
	
	$(".section-title").after("<img class='sperre' style='float:left; width:1px; height:33px;' src='http://www.nickkapros.com/files/gimgs/sperre.gif' />");
	$("ul:not(':nth-child(3)')>.section-title+.sperre").height(20);


	$("li:not('.section-title, .active')").hover(function(){
			$(this).css('background','white');
			$(this).children('a').css('color', 'black');
		}, function(){
			$(this).css('background','black');
			$(this).children('a').css('color', 'white');
		});
			
			
		$(".active>a").css('color','black');
		$(".active").css('background','white');
		
		
		$("li:#aboutbutton").hover(function(){
			$(this).css('background','white');
			$(this).children('a').css('color', 'black');
		}, function(){
			$(this).css('background','black');
			$(this).children('a').css('color', 'white');
		});


	
		$(".shit").css({'padding-left':'5px'});




});







