$(document).ready(function() {

		$('a.out').bind("click", openWindow);


	function megaHoverOver(){
		$(this).find(".sub").stop().fadeTo('fast', 1000).show();
	  $('.overLayer').show().css(cssObj);	
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 		
		if ( $(this).find(".row").length > 0 ) {
			var biggestRow = 0;	
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
		} else {			
			$(this).calcSubWidth();
			$(this).find(".sub").css({'width' : rowWidth});			
		}
	}	
	function megaHoverOut(){ 
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() {
		  $(this).hide();
	  });
	}
			var cssObj = {
      'height' : $(window).height()+'px'
    }
	function megaHoverUlOver(){

	  $('.overLayer').show().css(cssObj);	
	}	
	function megaHoverUlOut(){ 
   	$('.overLayer').hide(); 
	}
	
	var config = {    
		 sensitivity: 2, 
		 interval: 0,  
		 over: megaHoverOver,  
		 timeout: 100,
		 out: megaHoverOut 
	};
	var configUl = {    
		 sensitivity: 2, 
		 interval: 0,  
		 over: megaHoverUlOver,  
		 timeout: 100,
		 out: megaHoverUlOut 
	};

	$("ul#menu li").hoverIntent(config);
	$("ul#menu").hoverIntent(configUl);
	
        $("#menu li").has(".sub").addClass("hasSub");
        
        /*HP slideshow*/
        $(function() {        
            $('#news').cycle({
                fx:      'scrollHorz',
                speed:    800, 
                timeout:  5000,
                pause:    1,
                next:    '#next',
                cleartype:  true,
                cleartypeNoBg:  true
            });               
            $('#partners').cycle({
                fx:      'scrollHorz',
                speed:    800, 
                timeout:  4000,
                pause:    1,
                prev:    '#prev2',
                next:    '#next2',
                cleartype:  true,
                cleartypeNoBg:  true
            });                          
        });        


        $('#menu li.item').mouseenter(function() {
                $(this).find('a.itemLink').addClass('active');
                Cufon.replace($(this).find('a.itemLink'), {color: '#a6aa12'});
        }).mouseleave(function() {
                $(this).find('a.itemLink').removeClass('active');
                Cufon.replace($(this).find('a.itemLink'), {color: '#cccccc'});
        });
	
});

function openWindow() {
        window.open(this.href);
        return false;
}
