// JavaScript Document


/////// Menu Click ///////////////////////////////////////////////


$().ready(function () {
	
	if(window.location.hash != "") projektdetail(window.location.hash.substring(1,(window.location.hash).length));
	
        $(".navihome").click(function () {
			$(".auftrag .hide").fadeOut(300);								 
        	$(".uni .hide").fadeOut(300);
			$(".frei .hide").fadeOut(300);
			
			var scrollDuration = ($('html').attr('scrollTop') > 100)? 700 : 0;  //scroll to top
			
			$('html').animate({scrollTop: 0}, scrollDuration, 'swing', function(){
				$('#detail').delay(50).slideUp(800)	
			});		  
        	return false;
        });					
					
        $(".naviauftrag").click(function () {
			$(".auftrag .hide").fadeOut(300);
        	$(".uni .hide").fadeIn(300);
			$(".frei .hide").fadeIn(300);
		  
			var scrollDuration = ($('html').attr('scrollTop') > 100)? 700 : 0;  //scroll to top
			
			$('html').animate({scrollTop: 0}, scrollDuration, 'swing', function(){
				$('#detail').delay(50).slideUp(800)	
			});
		  	return false;
        });
		

        $(".naviuni").click(function () {
        	$(".auftrag .hide").fadeIn(300);
			$(".uni .hide").fadeOut(300);
			$(".frei .hide").fadeIn(300);
			
			var scrollDuration = ($('html').attr('scrollTop') > 100)? 700 : 0;  //scroll to top
			
			$('html').animate({scrollTop: 0}, scrollDuration, 'swing', function(){
				$('#detail').delay(50).slideUp(800)	
			});		  
        	return false;
        });

        $(".navifrei").click(function () {
        	$(".auftrag .hide").fadeIn(300);
			$(".uni .hide").fadeIn(300);
			$(".frei .hide").fadeOut(300);
			
			var scrollDuration = ($('html').attr('scrollTop') > 100)? 700 : 0;  //scroll to top
			
			$('html').animate({scrollTop: 0}, scrollDuration, 'swing', function(){
				$('#detail').delay(50).slideUp(800)	
			});		  
        	return false;
        });
		
        $(".naviabout").click(function () {
        	$(".auftrag .hide").fadeOut(300);
			$(".uni .hide").fadeOut(300);
			$(".frei .hide").fadeOut(300);
			$("img", this).animate({
				backgroundColor:'#999999'
				},150 );	
			
			
			var contentFile = './projects/about/detail.html';
			
			var scrollDuration = ($('html').attr('scrollTop') > 100)? 700 : 0;
			
			//$("object").css("visibility", "hidden");
			
			$('html').animate({scrollTop: 0}, scrollDuration, 'swing', function(){
				$('#detail').delay(50).slideUp(800, function(){
					$('#detail').load(contentFile, function(){
						$('#detail').delay(200).slideDown(900, function(){
							//$("object").css("visibility", "visible");
							
						});
					});
				});		
			});		  
        	return false;
        });		
		
		
		$(".navigation").click(function () {
			$(this).addClass('selected');
			$(".navigation").not($(this)).removeClass('selected').children('img').animate({
				backgroundColor:'#FFF'
				}, 500 );
        });
		
/////// Menu MouseOver ///////////////////////////////////////////////	
		
		$('.navigation').hover(
		  function() {
			$(this)
			  .css('color','#bbb')
			  .animate({'color': '#fff'}, 300);
		  },
		  function() {
			$(this)
			  .animate({'color': '#bbb'}, 150);
		  }
		);
		
        
		
/////// MouseOver Projects ///////////////////////////////////////////////

		
		
		
		$('.projects').hover(
		  function() {
			$('.desc', this)
			  .css('borderBottomColor','#fff')
			  .animate({'borderBottomColor': '#333'}, 300);
		  },
		  function() {
			$('.desc', this)
			  .animate({'borderBottomColor': '#fff'}, 150);
		  }
		);
		

				
		
		
/////// Click Projects ///////////////////////////////////////////////		
		
		
		function projektdetail(projekturl){
			
			//alert(projekturl);
			
			$(".auftrag .hide").delay(250).fadeOut(200);								 
			$(".uni .hide").delay(250).fadeOut(200);
			$(".frei .hide").delay(250).fadeOut(200);
			
			var contentFile = "./projects/"+projekturl+ "/detail.html";
			//alert(contentFile);
			jQuery.url.attr("path") // returns '/information/about/index.html'
			
			// get the protocol
			jQuery.url.setUrl("http://www.uhsless.de/" + "path")


			
			var scrollDuration = ($('html').attr('scrollTop') > 50)? 900 : 0;
			
			//$("object").css("visibility", "hidden");
			/*
			$('html').animate({scrollTop: 0}, scrollDuration, 'swing', function(){
				$('#detail').delay(50).fadeOut(400, function(){
					$('#detail').load(contentFile, function(){
						$('#detail').delay(100).css("width", "1000px");
						$('#detail').delay(100).show(2400, function(){
							//$("object").css("visibility", "visible");
							
						});
					});
				});		
			});	*/
			
			$('html').animate({scrollTop: 0}, scrollDuration, 'swing', function(){
				$('#detail').delay(50).slideUp('slow', function(){
					$('#detail').load(contentFile, function(){
						$('#detail').delay(100).slideDown(1200);
					});										 
				});
			});
			
			
			
			window.location.hash = projekturl;
			return false;
		}
		
		$(".projects a").click(function(){
			
			projektdetail($(this).attr('href').substring(11,($(this).attr('href').length-1)));
			return false;
			/*$(".auftrag .hide").fadeOut(200);								 
			$(".uni .hide").fadeOut(200);
			$(".frei .hide").fadeOut(200);
			$(".detail .videohide").fadeOut(200);
			*/
			/*
			var paths = $(this).attr('href').split('/');
			var projectId = paths[paths.length - 2];
			var contentFile = "projects/"+ projectId + ".html";
			*/
			//alert($(this).attr('href'));
			//var contentFile = $(this).attr('href') + "detail.html";
			//alert($(this).attr('href').substring(11,($(this).attr('href').length-1)));
			
			//alert($(this).attr('href').length);
			//window.location.hash=$(this).attr('href');
			
			// get the path
			//jQuery.url.attr("path") // returns '/information/about/index.html'
			
			// get the protocol
			//jQuery.url.setUrl("http://www.uhsless.de/" + "path")


			
			//var scrollDuration = ($('html').attr('scrollTop') > 50)? 900 : 0;
			
			//$("object").css("visibility", "hidden");
			
			/*$('html').animate({scrollTop: 0}, scrollDuration, 'swing', function(){
				$('#detail').delay(50).hide(800, function(){
					$('#detail').load(contentFile, function(){
						$('#detail').delay(100).show(1200, function(){
							//$("object").css("visibility", "visible");
							
						});
					});
				});		
			});	
			
			return false;*/
			
			
			
		});



});
