$(document).ready(function() {
	noa_navHandler();
	noa_randomWordsHandler();
});

function noa_changeBgColor(obj, color, duration) {
	jQuery(obj).stop().animate({backgroundColor: color}, {queue: false, duration: duration});
} 

function noa_navHandler() {
	navMainItem = $("#nav-main ul li a");
	navMainItem.hover(function() { noa_changeBgColor(this, '#5c8ec0', 250) },
					  function() { if ($(this).hasClass('current') == false) { noa_changeBgColor(this, '#436d97', 250) } });

	blueHome = $("#header .nav-meta .blue-home");
	blueHome.hover(
			function() { noa_changeBgColor(this, '#5c8ec0', 250) },
			function() { noa_changeBgColor(this, '#436d97', 250) });
	
	blueHome.click(function() { window.location.href= '/'; });
}

function noa_randomWordsHandler() {
	randomWordsContainer = $("#header .emotion .home");
	$(randomWordsContainer).html('');
	
	words = new Array("konkret.", 
					  "kompetent.", 
					  "effizient.", 
					  "flexibel.",
					  "fair.",
					  "aufmerksam.",
					  "clever.",
					  "hartnäckig.",
					  "sensibel.",
					  "diskret.",
					  "einfühlsam.",
					  "präsent.",
					  "innovativ.",
					  "anders.",
					  "direkt.",
					  "schnell.",
					  "ehrgeizig.",
					  "erfolgreich.",
					  "exzellent.",
					  "ausgezeichnet.",
					  "operativ.",
					  "leidenschaftlich.");
	words.sort(function() {return 0.5 - Math.random()});
	
	for (i = 0; i < words.length; i++) {
		randomWordsContainer.append('<h3 class="word-' + i + '" style="display: none;">' + words[i] + '</h3>');
		if (i == 2) break;
	}
	randomWordsContainer.append('<h3 class="noa word-3" style="display: none;">noa.</h3>');
	
	$(".word-0", randomWordsContainer).fadeIn(1500, function() { $(".word-1", randomWordsContainer).fadeIn(1500, 
													function() { $('.word-2', randomWordsContainer).fadeIn(1500, 
													function() { $('.word-3', randomWordsContainer).fadeIn(1500); setTimeout("noa_randomWordsHandler()", 5000); } ); } ); } );
}

function noa_referenceBoxHandler(lang) {
	referenceBox = $("#body .content .reference-box");
	$(referenceBox).css('opacity', '0');
	referenceBox.hover(
						function() { $(this).animate({ opacity: 0.5 }, 350); },
						function() {  $(this).animate({ opacity: 0.0 }, 350); });
	if (lang == 'de') referenceBox.click(function() { location.href = '/referenzprojekte'; });
}
