

function onFocusCheckEntry(which, cont) {
	if(which.value == cont) {
		which.value = "";
	}
}

function onBlurCheckEntry(which, cont) {
	if(which.value == '') {
		which.value = cont;
	}
}




jQuery.noConflict();
     
jQuery(document).ready(function($){
       
   
   $('#tabnavi ul').tabs({ fxFade: true, fxSpeed: 'fast' });        

   

    var colNum = parseInt($('div.bgcol').attr('class').replace('bgcol col', ''), 10);
	
	if (isNaN(colNum)) {
		colNum = 0;
	}
	
 	var pagecol = 'col' + colNum;


  

	navhighlight=$('li.mnavhighlight').length;
	
	if (navhighlight==0){
	 currentIndex = 10;      
	 tf= false; 
	}
	else{
	 currentIndex = $("#mainnav li").index( $('.mnavhighlight')[0] );       
	 tf= true; 
	}
	
                               
		
	var mainNav = $('#mainnav');
	
	mainNav.find('span').remove();
	mainNav.kwicks({
		max : 148,
		spacing: 3,		
		duration : 200,
		defaultKwick : currentIndex,
		sticky : tf, 
		isVertical : false
	}).bind('mouseleave', function(e) {
		mainNav.find('li:eq('+currentIndex+')').trigger('mouseover');
	});
	
	
	

	mainNav.find('li').mouseover(function() {
		$(this).siblings().css('background-position', '0px 0px').end().css('background-position', '-148px 0px ');
	}).mouseout(function() {
		$(this).css('background-position', '0px 0px');
	});

	mainNav.find('li:eq('+currentIndex+')').trigger('mouseover').css({'position' : 'absolute', 'top' : '8px'}); 








    $('#thirdlevel li.first').hover(function() {
      $(this).addClass('lifirsthover');
      }, function() {
      $(this).removeClass('lifirsthover');
    });

    $('#thirdlevel li:not(.first)').hover(function() {
      $(this).addClass('lihover');
      }, function() {
      $(this).removeClass('lihover');
    });




    $('.col4 .acco .item').hover(function() {
      $(this).addClass('itemhover');
      }, function() {
      $(this).removeClass('itemhover');
    });




 function checkBrowserName(name){  
    var agent = navigator.userAgent.toLowerCase();  
    if (agent.indexOf(name.toLowerCase())>-1) {  
     return true;  
    }  
    return false;  
  }  



var isgalery = $(".maincol").find(".tabcontent");
  if(isgalery.length != 0){

   var imgurl=$(".maincol .boxhead").css("background-image");
   
    if(checkBrowserName('MSIE')){  
     var newurl= imgurl.substr(imgurl.lastIndexOf("(")+2,imgurl.length).replace(/"\)/,"");
    } 
    else {
      var newurl= imgurl.substr(imgurl.lastIndexOf("(")+2,imgurl.length).replace(/"\)/,"");
    }
   
   
   var finalurl = newurl.replace(/maincol.*gif/,"");

   $(".maincol .boxhead").css("background-image", "url("+finalurl+"maincol_tbhead_"+pagecol+"_gal.gif)" );  
   
   
   }  

 



 var galerybox = '<div class="gbox"></div>';
 var lupesrc =   '/images/icon_lupe.gif';
 var galerytxt = '<div class="gtxt"><img src="'+lupesrc+'" width="25" height="21" alt="Lupe" /></div>';

$('.galerie a').hover(function () {
      $(this).prepend($(galerybox));
      $(this).append($(galerytxt));
    },
      function () {
        $(this).find("div.gbox").remove();
        $(this).find("div.gtxt").remove();
    });





	setupAccordion(jQuery);


}); 



function setupAccordion($) {
	
	var context = $('#acconavi');
	var contentItems = context.find('ul.mlist');
	var speed = 500;
	var currentClass = 'current';
	
	// Quick fix gegen Flackern in FF3.5/XP
	var setContainerHeight = true;
	
	contentItems.hide().css({
		overflow : 'hidden',
		float : 'none',
		position : 'relative'
	});
	
	if (setContainerHeight) {
		var maxHeight = 0;
		contentItems.each(function(i, el) {
			var h = $(el).height();
			maxHeight = Math.max(h, maxHeight);
		});
		//console.log("maxHeight = ", maxHeight);
		var container = context.parents("div.maincol:eq(0)");
		//console.log(container);
		if (maxHeight > 0) {
			container.height(container.height() + maxHeight);
		}
	}
	
	
	
	
        
    context.find("a.accohead").click(function(e){
    	
    	var $this = $(this);
        var currentLink = context.find('a.' + currentClass);
		
		if (currentLink.size() > 0) {
			currentLink.removeClass(currentClass).next().slideUp(speed, function() {
				if (!$this.hasClass(currentClass)) {
					$this.addClass(currentClass).next().slideDown(speed);
				}
			});
			
		} else {
			$this.addClass(currentClass).next().slideDown(speed);
		}
		
		return false;
    });
	
     
	
	var currenthref= context.find("a").filter(
		function() {
			return this.href == location.href;
		}
	);
	
     
	//currenthref.parents('li.accobox').children("a.accohead").addClass("current").next(".mlist").slideDown("slow");
	//console.log("currenthref = ", currenthref);
	
	currenthref.parents('li.accobox').find('a.accohead:eq(0)').trigger('click');
	currenthref.parents('div.item').addClass('teaserhover');
	
	
	var teaserhgl = context.find(".teaserhover");
	
	if (teaserhgl.length == 0) {
		currenthref.parents('div.item').addClass('teaserhover');
	}

}




