// MAIN-NAV
$(document).ready(function() {
	$('.fade').append('<span class="hover"></span>').each(function () {
	  var $span = $('> span.hover', this).css('opacity', 0);
	  $(this).hover(function () {
	    $span.stop().fadeTo(200, 1);
	  }, function () {
	    $span.stop().fadeTo(200, 0);
	  });
	});
});

// GLOBAL
$(document).ready(function() {

	// TOOLTIP
	$('a[rel=tooltip]').mouseover(function(e) {
		var tip = $(this).attr('title');	
		$(this).attr('title','');
		$(this).append('<div id="tooltip" class="tipBody">' + tip + '</div>');		
		$('#tooltip').fadeIn("slow");
	}).mousemove(function(e) {
		$('#tooltip').css('top', e.pageY - 0);
		$('#tooltip').css('left', e.pageX + 20 );
	}).mouseout(function() {
		$(this).attr('title',$('.tipBody').html());
		$(this).children('div#tooltip').remove();
	});

	// HOVER-LINK: CONTENT
	$('#content a:not(ul a)').hover(function(){
	    $(this).animate({ color: "#56CBBA" }, "fast");
	}, function() {
	    $(this).animate({ color: "#48A89B" }, "fast");
	});
	
	$('#footer a').hover(function(){
	    $(this).animate({ color: "#56CBBA" }, "fast");
	}, function() {
	    $(this).animate({ color: "#48A89B" }, "fast");
	});

	// FLICKR+FANCYBOX: FOOTER
	$('span.flickr').append('<ul id="flickr" class="flickr-thumbs"></ul>');
	$('ul#flickr').jflickrfeed({
		limit: 8,
		qstrings: {
			id: '33265594@N06'
		},
		itemTemplate: '<li>'+
						'<a href="{{image}}" title="{{title}}">' +
							'<img src="{{image_s}}" alt="{{title}}" width="55" height="55" />' +
						'</a>' +
					  '</li>'
	}, function(data) {
		$('#flickr a').fancybox(),
		$('.flickr-thumbs li:nth-child(5n+4)').addClass('last'),
		$('.flickr-thumbs li:nth-child(1n+5)').addClass('bottom'),
		$('.flickr-thumbs li:nth-child(2n+8)').addClass('last'),
		
		// ANIMATE ON HOVER
		$('ul#flickr a img').hover(function(){
			$(this).stop().animate({ opacity: 1 }, "fast");
		}, function() {
			$(this).stop().animate({ opacity: 0.7 }, "fast");
		});
	});

});

// START
$(document).ready(function() {

	// NIVO-SLIDER: START
	$('#content-head-slider').nivoSlider({
		effect: 'fade',
		animSpeed: 500,
		pauseTime: 4000,
		directionNav: false,
	});

});

// UEBER MICH
$(document).ready(function() {

	// DIAGRAMM SKILLS & PROGRAMMS
	$('ul.skills li, ul.programms li').hover(function(){
	    $(this).animate({ backgroundColor: "#56CBBA" }, 120);
	}, function() {
	    $(this).animate({ backgroundColor: "#48A89B" }, 120);
	});
	
	// HOVER: ARBEITSPROBEN
	$('.worksample').hover(function(){
	    $(".worksample-description", this).stop().fadeTo("fast", 0.95);
	}, function() {
	    $(".worksample-description", this).stop().fadeTo("fast", 0);
	});

});

// PORTFOLIO
$(document).ready(function() {
	
	// ANIMATED-SCROLL
	$('span.top').click(function(){
		$('html, body').animate({ scrollTop: 0 }, "slow");
		return false;
	});
	
	// FANCYBOX: PORTFOLIO
	$("a[rel=the-lorean]").fancybox();
	$("a[rel=visitenkarte]").fancybox();
	$("a[rel=baugenossenschaft]").fancybox();
	$("a[rel=graphic]").fancybox();
	$("a[rel=hof-on-focus]").fancybox();
	$("a[rel=shoot]").fancybox();
	$("a[rel=typozzle]").fancybox();
	$("a[rel=vekton]").fancybox();
	$("a[rel=was-passiert]").fancybox();
	$("a[rel=whattheclub]").fancybox();
	
	// ANIMATE ON HOVER
	$('.project-images img').hover(function(){
		$(this).stop().animate({ opacity: 1 }, "fast");
	}, function() {
		$(this).stop().animate({ opacity: 0.7 }, "fast");
	});
	
	$('ul.description li a').hover(function(){
	    $(this).animate({ color: "#56CBBA" }, 120);
	}, function() {
	    $(this).animate({ color: "#48A89B" }, 120);
	});

});


// KONTAKT
$(document).ready(function() {

	// VALIDATION: CONTACT-FORM
	$("#contactform").validate();

	// CLEAR/SET-FORM: CONTACT-FORM
	/*
	function clearName () {
		if (document.contactform.name.value = "Dein Name") {
			document.contactform.name.value = "";
		}
	}
	
	function setName () {
		if (document.contactform.name.value = " ") {
			document.contactform.name.value = "Dein Name";
		}
	}
	
	function clearEMail () {
		if (document.contactform.email.value = "Deine@E-Mail.com") {
			document.contactform.email.value = "";
		}
	}
	
	function setEMail () {
		if (document.contactform.email.value = " ") {
			document.contactform.email.value = "Deine@E-Mail.com";
		}
	}
	
	function clearSubject () {
		if (document.contactform.subject.value = "Ich m&ouml;chte...") {
			document.contactform.subject.value = "";
		}
	}
	
	function setSubject () {
		if (document.contactform.subject.value = " ") {
			document.contactform.subject.value = "Ich m&ouml;chte...";
		}
	}
	*/

});