
$(function(){
	/* Search */
	if($('input.search_field').size() > 0){
		$('input.search_field').each(function(){
			if($(this).attr('title')) $(this).watermark($(this).attr('title'));
		});
	}
	
	/* bigTargets */
	$(".subsite li a").bigTarget({hoverClass: 'over', clickZone : 'li:eq(0)'});
	$(".logo h3 a").bigTarget({hoverClass: 'over', clickZone : 'div:eq(0)'});
	
	/* EqualHeights */
	if ($("#thumbs ul li").size() > 0) $("#thumbs ul li").equalHeights();
	
	/* Cufon*/
	var sidebar_height = $(".sidebar", "#main").height();
	var content_height = $("#content").height();
	if (sidebar_height > content_height) $("#content").height(sidebar_height+'px');

	if($.browser.msie && parseFloat($.browser.version) <= 7){
		$('.transbox').css('bottom', '-3px');
		$('#nav a.root').css({'padding': '2px 12px'});
		$('#nav .sub').css({'top': '27px'});
		$('#nav li .sub ul').css({'width': '210px'});
	}else{	
		$('.transbox').css('opacity', 0.8);
	}

	$('#nvb-form').validate({meta: "validate"});

	// Cufon
	Cufon.set('fontFamily', 'Lucida Sans').replace('ul#nav a.root', { hover: true });
	Cufon.set('fontFamily', 'Lucida Sans').replace('h1,div.ambiance h2 span, div#thumbs h2, #searchbox h6, div.sidebar h5, .transbox h2, #content h2');
	Cufon.now();
})

$(document).ready(function () {
	// MENU
	var i = 0;
	function megaHoverOver(){
		$(this).find('a.root').addClass('selected'); 
		$(this).find(".sub").stop().css('filter', 'none').fadeTo('fast', 1).show();
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
	}					
							
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().css('filter', 'none').fadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	  $(this).find('a.root').removeClass('selected'); 
	  Cufon.refresh();
	}
	
	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 50, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 100, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

	// $("div#navigation ul li .sub").css({'top':'0'});
	$("div#navigation ul li").hoverIntent(config);
	
	$("ul#nav li a").each(function(index) {
		if($(this).attr('href') == '#') {
			$(this).css({'cursor': 'default'});
			$(this).attr('href', 'javascript:;') ;
		}							   
	});
	
	$('a.root', 'ul#nav div.sub').each(function(index) {
		var parent_w = $(this).parent().outerWidth() - 30;			
		$(this).css({width:parent_w+'px'});		
  	});

	// Adressbar width
	var parent_w = 0;
	$('li', 'div#footer div.bottom ul').each(function(index) {
		parent_w += $(this).outerWidth()+8;			
  	});	
	$('div#footer div.bottom ul').css({'width' : parent_w+'px'});
});	
