


//-----------------------------------------------------------------------------------
//
//  Script
//	by Felix Baltruschat - http://www.wortbildton.de
//	01/23/08
//
//  v. 0.25
//
//	For more information on this script, visit:
//	http://www.wortbildton.de
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//
//
// -----------------------------------------------------------------------------------
if(jQuery) (function($){
		$(document).ready(function(){
			var curLink = null;
			var curEle = null;
			var lastLink = null;
			var hideTimeout = null;
			$("div#hoverNavi ul").css('display', 'none');
			$("div.navi a").mouseout(function(){
					if(hideTimeout == null){
						var fElement = $(this);
						hideTimeout = window.setTimeout(function(){
							var elementName = toNiceLink(fElement.attr("title").toLowerCase());
								if($('.'+elementName+'_sub').length > 0 && elementName){
									$('#hoverNavi').css('display', 'none');
									$('.'+elementName+'_sub').css('display', 'none');
									curEle.attr("href",lastLink);
								}
						},100);
					}
				$(curEle).css('color','#004237');
			}).mouseover(function(){
				var elementName = toNiceLink($(this).attr("title").toLowerCase());
				if($('.'+elementName+'_sub').length > 0 && elementName){
				
					if(hideTimeout != null){
						$('.'+curLink+'_sub').css('display', 'none');
						$(curEle).css('color','#004237');
						clearTimeout(hideTimeout);
						hideTimeout = null;
					}
					
					curLink = elementName;
					curEle = $(this);
					$(curEle).css('color','#7d3f0b');
					if($('.'+elementName+'_sub').length > 0){
						lastLink = $(this).attr("href");
						$(this).attr("href",'#');
						$('#hoverNavi').css('display', 'block');
						$("."+elementName+"_sub").css('display', 'block');
						$("#hoverNavi").mouseover(function(){
								if(hideTimeout != null){
									clearTimeout(hideTimeout);
									hideTimeout = null;
								}
								$('#hoverNavi').css('display', 'block');
								$('.'+curLink+'_sub').css('display', 'block');
								$(curEle).css('color','#7d3f0b');
						}).mouseout(function(){
									if(hideTimeout == null){
										hideTimeout = window.setTimeout(function(){
											curEle.attr('href',lastLink);
											$('#hoverNavi').css('display', 'none');
											$('.'+curLink+'_sub').css('display', 'none');
											$(curEle).css('color','#004237');																			 
										},500);
									}
						});
					}
				}
			});
			
			$('#hoverNavi').css('left', (($(window).width()/2)-354)+68);
			$(window).bind("resize", function(){ 
				$('#hoverNavi').css('left', (($(window).width()/2)-354)+68);
			});
			
		});
		
		function toNiceLink(string){
			var l = string.split(' ');
			var out = '';
			for(var i=0;i<l.length;i++){
				if(i == (l.length-1)){
						out += l[i];
				}else{
					out += l[i]+'-';
				}
			}
			 out=out.replace(/&-/g, "");
			 out=out.replace(/\u00fc/g, "ue");
			 out=out.replace(/\u00f6/g, "oe");
			 out=out.replace(/\u00e4/g, "ae");
			 out=out.replace(/\u00df/g, "ss");
			return out;
		}
		

})(jQuery);

