$(function() {
	
	$("ul.sf-menu").superfish(); 
    setInterval( "slideSwitch()", 5000 );
	
	$('.table_box a').bind('mouseenter',function(){
		var tipNo 	= $(this).attr('rel'),
			yPos 	= $(this).parent().offset().top,
			xPos 	= $(this).parent().offset().left,
			newX	= xPos + 210,
			newY	= yPos - 1;
		
		$('#'+tipNo+'').show();
		$('#'+tipNo+'').css({
			top	: newY,
			left: newX				
		});
	});
	
	$('.table_box a').bind('mouseleave',function(){
		var tipNo 	= $(this).attr('rel');
		$('#'+tipNo+'').hide();
	});
	
	$('#select_languages').bind('click',function(){
		$('#languages_container').show();
		return false;
	});
	
	$("body").bind("mouseup",function(){
		$('#languages_container').hide();
		return false;
	});
	
	var contentCount 	 = $('#announcement_content_container div').length,	
	    newHeight		 = contentCount * 130,
	    announcementYpos = 0;
	
	$.timer(6000,function(timer){
		if(announcementYpos == -newHeight)
		{	
			announcementYpos = 0;	
		}
		else{			
			$('#announcement_content_container').animate({top:''+announcementYpos+'px'},500);
			announcementYpos = announcementYpos - 130;
		}
	});
	
});


function slideSwitch() {
    var $active = $('#slideshow a.active');

    if ( $active.length == 0 ) $active = $('#slideshow a:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow a:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

