/**
 * @author Christophe
 */
// JavaScript Document
var $j = jQuery.noConflict();

var current = null;

var timeOut    = 500;
var closeTimer = 0;
var	menuItem = 0;

function menu_open() {
	cancel_timer();
	menu_close();
	
	menuItem = $j(this).find('ul').css('visibility', 'visible');
}

function menu_close() {
	if(menuItem)
		menuItem.css('visibility', 'hidden');
}

function timer() {
	closeTimer = window.setTimeout(menu_close,timeOut);
}

function cancel_timer() {
	if(closeTimer) {
		window.clearTimeout(closeTimer);
		closeTimer = null;
	}
}

$j(document).ready(function($){

	$j("#featured").tabs().tabs("rotate", 5000, false).removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all');
	$j("#spotlight").tabs().tabs("rotate", 10000, false).removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all');

	$('#button.nyheter').hover(function() { $(this).attr('src', 'button_nyheter_active.png'); }, function() { $(this).attr('src', 'button_nyheter.png');} );
	$('#button.nyheter').click(function() { $(this).unbind('mouseenter mouseleave'); var oldClass = $('img[src$="_on.png"]').attr('class'); $('img[src$="_on.png"]').attr('src', 'button_' + oldClass + '.png'); $(this).attr('src', 'button_nyheter_on.png'); $('#button.' + oldClass).hover(function() { $(this).attr('src', 'button_' + oldClass + '_active.png'); }, function() { $(this).attr('src', 'button_' + oldClass + '.png');} ); $('#sub_nyheter').removeClass('sub_hidden').siblings().addClass('sub_hidden');});

	$('#button.community').hover(function() { $(this).attr('src', 'button_community_active.png'); }, function() { $(this).attr('src', 'button_community.png');});
	$('#button.community').click(function() { $(this).unbind('mouseenter mouseleave'); var oldClass = $('img[src$="_on.png"]').attr('class'); $('img[src$="_on.png"]').attr('src', 'button_' + oldClass + '.png'); $(this).attr('src', 'button_community_on.png'); $('#button.' + oldClass).hover(function() { $(this).attr('src', 'button_' + oldClass + '_active.png'); }, function() { $(this).attr('src', 'button_' + oldClass + '.png');} ); $('#sub_community').removeClass('sub_hidden').siblings().addClass('sub_hidden');});

	$('#button.media').hover(function() { $(this).attr('src', 'button_media_active.png'); }, function() { $(this).attr('src', 'button_media.png');});
	$('#button.media').click(function() { $(this).unbind('mouseenter mouseleave'); var oldClass = $('img[src$="_on.png"]').attr('class'); $('img[src$="_on.png"]').attr('src', 'button_' + oldClass + '.png'); $(this).attr('src', 'button_media_on.png'); $('#button.' + oldClass).hover(function() { $(this).attr('src', 'button_' + oldClass + '_active.png'); }, function() { $(this).attr('src', 'button_' + oldClass + '.png');} ); $('#sub_media').removeClass('sub_hidden').siblings().addClass('sub_hidden');});

	$('#button.cuper').hover(function() { $(this).attr('src', 'button_cuper_active.png'); }, function() { $(this).attr('src', 'button_cuper.png');});
	$('#button.cuper').click(function() { $(this).unbind('mouseenter mouseleave'); var oldClass = $('img[src$="_on.png"]').attr('class'); $('img[src$="_on.png"]').attr('src', 'button_' + oldClass + '.png'); $(this).attr('src', 'button_cuper_on.png'); $('#button.' + oldClass).hover(function() { $(this).attr('src', 'button_' + oldClass + '_active.png'); }, function() { $(this).attr('src', 'button_' + oldClass + '.png');} ); $('#sub_cuper').removeClass('sub_hidden').siblings().addClass('sub_hidden');});

	$('#button.live').hover(function() { $(this).attr('src', 'button_live_active.png'); }, function() { $(this).attr('src', 'button_live.png');});
	$('#button.live').click(function() { $(this).unbind('mouseenter mouseleave'); var oldClass = $('img[src$="_on.png"]').attr('class'); $('img[src$="_on.png"]').attr('src', 'button_' + oldClass + '.png'); $(this).attr('src', 'button_live_on.png'); $('#button.' + oldClass).hover(function() { $(this).attr('src', 'button_' + oldClass + '_active.png'); }, function() { $(this).attr('src', 'button_' + oldClass + '.png');} );});

});
