/* Javascript File */
jQuery.noConflict();

// Nombre de joueurs en ligne Global count
var UAJEUX_countGlobal = 0;

jQuery(document).ready(function() {

	// Affecte une classe au menu sélectionné
	if (jQuery('[id^=simu]').size() > 0) {
		jQuery(this).find("#cjo-menu li.drop").each(function() {
			if (jQuery(this).is('.violet'))	{
				jQuery(this).addClass('selected');
			}
		});
	}
	else if (jQuery('[id^=gambling]').size() > 0) {
		jQuery(this).find("#cjo-menu li.drop").each(function() {
			if (jQuery(this).is('.vert')) {
				jQuery(this).addClass('selected');
			}
		});
	}
	else if (jQuery('[id^=promo_event]').size() > 0) {
		jQuery(this).find("#cjo-menu li.drop").each(function() {
			if (jQuery(this).is('.jaune2'))	{
				jQuery(this).addClass('selected');
			}
		});
	}
	else if (jQuery('[id^=promo_console]').size() > 0) {
		jQuery(this).find("#cjo-menu li.drop").each(function() {
			if (jQuery(this).is('.bleu2')) {
				jQuery(this).addClass('selected');
			}
		});
	}
	else if (jQuery('[id^=promo]').size() > 0) {
		jQuery(this).find("#cjo-menu li.drop").each(function() {
			if (jQuery(this).is('.jaune')) {
				jQuery(this).addClass('selected');
			}
		});
	}

	// Ajuste la div du menu pour la bannière
	jQuery(this).find("#cjo-menu [class^=dropdown]").each(function() {
		divWidth = divHeight = maxHeight = 0;
		jQuery(this).find(".col_1").each(function() {
			divWidth += jQuery(this).width();
			divHeight = jQuery(this).height();
			maxHeight = (divHeight > maxHeight) ? divHeight : maxHeight;
			jQuery(this).css({'height':maxHeight});
		});
		if ( jQuery(this).find(".banner img") ) {
			banWidth = jQuery(this).find(".banner img").width();
			banHeight = jQuery(this).find(".banner img").height();

			banMargin = (divWidth - banWidth) / 2;
			divPadding = banHeight;
			
			jQuery(this).find(".banner").css({'left':banMargin});
			jQuery(this).find("[class^=dropdown]").css({'padding-bottom':divPadding});
		}
	});	

	var config = {    
		 sensitivity: 10, // number = sensitivity threshold (must be 1 or higher)
		 interval: 5, // number = milliseconds for onMouseOver polling interval
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
		 timeout: 50, // number = milliseconds delay before onMouseOut
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)
	};

	jQuery("#cjo-menu [class^=dropdown]").css({'opacity':'0'});
	jQuery("#cjo-menu ul > li").hoverIntent(config);
});

/* Effet rollover du menu */
function megaHoverOver() {
	jQuery(this).find("[class^=dropdown]").stop().fadeTo('fast', 1).show();
}

function megaHoverOut() { 
	jQuery(this).find("[class^=dropdown]").stop().fadeTo('fast', 0, function() {
		jQuery(this).hide(); 
	});
}
