function ChooseCategory() {

	var width = 600;
	var height = (216/952*width)*4/2 + 20;
	
	var str = '<div style="position:absolute;top:-1000px;left:50%;width:0px;height:0px;z-index:2000;" class="WindowCentered">';

	str = str + '<div style="width:'+width+'px; height:600px; margin-left:-'+width/2+'px; margin-top:-'+height+'px"> <h2>Selectionner le Forum</h2>';
	
	str = str + '<span style="cursor:  pointer;">';
	str = str + '<img src="http://www.ts-x.eu/images/banner.jpg?img=10&txt=CS:S RolePlay And Fun" width="'+width+'" onclick="window.location = \'http://www.ts-x.eu/forum/index.php?force_forum=31\'"/><br />';
	str = str + '<img src="http://www.ts-x.eu/images/banner.jpg?img=8&txt=League Of Legend" width="'+width+'" onclick="window.location = \'http://www.ts-x.eu/forum/index.php?force_forum=88\'" /><br />';
        str = str + '<img src="http://www.ts-x.eu/images/banner.jpg?img=11&txt=MineCraft" width="'+width+'" onclick="window.location = \'http://www.ts-x.eu/forum/index.php?force_forum=69\'" /><br />';
        str = str + '<img src="http://www.ts-x.eu/images/banner.jpg?img=7&txt=Team Fortress 2" width="'+width+'" onclick="window.location = \'http://www.ts-x.eu/forum/index.php?force_forum=83\'" /><br />';
	
	str = str + '</span></div>';

	str = str + '</div><div style="position:fixed;top:0px;left:0px;width:100%;height:100%;background-color:#000000;" id="errorbox_bg"></div>';

	$("body").append(str);
	$("#errorbox_bg").animate({ opacity: 0.8}, 0);

	WindowCentered();	
}

$(document).ready(function() {
	
	$(".ChooseCategory").children().append("&nbsp;&nbsp;&nbsp;<img src='http://www.ts-x.eu/images/icons/down-arrow.png' border='0'/>");

	$(".ChooseCategory").children().hover(
		function () {
			ChooseCategory_init(this);
		}, 
		function () {
			ChooseCategory_stop(this);
		}
	);

	init_taskbar();
});

$(window).resize(function() {
	if( $("#CategoryBar").exists() ) {

	        var offset = $(".ChooseCategory").children().offset();
	        var top = offset.top + 50;
	        var left = offset.left + 30;

	        $("#CategoryBar").animate({ top: ""+top+"px", left: ""+left+"px"}, {queue: false, duration: 0});
	}
});

function ChooseCategory_init(that) {

	if( $("#CategoryBar").exists() ) {
		return false;
	}

	var txt = '';

        txt = txt + '<li><a style="margin-top:2px;" href="http://www.ts-x.eu/forum/index.php?force_forum=0">Toutes Cat&eacute;gories</a></li>';
	txt = txt + '<li><img class="left" src="http://www.ts-x.eu/images/icons/section/2.png" style="margin-top:5px;"/><a style="margin-top:2px;" href="http://www.ts-x.eu/forum/index.php?force_forum=31">RolePlay&FUN</a></li>';
        txt = txt + '<li><img class="left" src="http://www.ts-x.eu/images/icons/section/3.png" style="margin-top:5px;"/><a style="margin-top:2px;" href="http://www.ts-x.eu/forum/index.php?force_forum=88">League Of Legend</a></li>';
	txt = txt + '<li><img class="left" src="http://www.ts-x.eu/images/icons/section/7.png" style="margin-top:5px;"/><a style="margin-top:2px;" href="http://www.ts-x.eu/forum/index.php?force_forum=69">MineCraft</a></li>';
	txt = txt + '<li><img class="left" src="http://www.ts-x.eu/images/icons/section/4.png" style="margin-top:5px;"/><a style="margin-top:2px;" href="http://www.ts-x.eu/forum/index.php?force_forum=83">Team Fortress 2</a></li>';

	$('body').append('<ul id="CategoryBar">'+txt+'</ul>');

	var offset = $(that).offset();
	var top = offset.top + 50;
	var left = offset.left + 30;

	$("#CategoryBar").animate({ top: ""+top+"px", left: ""+left+"px"}, {queue: false, duration: 0});
	$("#CategoryBar").show("slide", { direction: "up" }, 500);
}
function ChooseCategory_stop(that) {
	if( ! $("#CategoryBar").exists() ) {
                return false;
        }

	setTimeout( function() {
		$("#CategoryBar").hide("slide", { direction: "up" }, 500);
		$("#CategoryBar").fadeOut(500, function() { $("#CategoryBar").remove(); } );
	}, 4500);
}

function init_taskbar() {
	if( getCookie("expand0") != 1 )
		return;

	var txt = '';

	txt = txt + '<div id="TaskBarContener">';
        txt = txt + '	<div id="TaskBarBorder"></div>';
        txt = txt + '	<div id="TaskBar"><img src="/images/ajax-loader.gif" /> Chargement en cours...</div>';
        txt = txt + '</div>';

	$('body').append(''+txt+'');

	$("#TaskBarContener").hover(
		function() {
			if (timeout) {
				clearTimeout(timeout);
				timeout = null;
			}
			$(this).animate({ right: -20 }, 'fast');
		},
		function() {
			var menuBar = $(this);
			timeout = setTimeout(function() {
				timeout = null;
				menuBar.animate({ right: -170 }, 'slow');
			}, 1000);
		}
	);

	setTimeout( function() { update_taskbar(); }, 1);
}
function update_taskbar() {
        $.ajax({
                type: "GET",
                url: "http://www.ts-x.eu/panel.php?page=taskbar",
                cache: false,
                success: function(result) {
                        $('#TaskBar').html(result);
                }
        });

	setTimeout( function() { update_taskbar(); }, 5000);
}

var timeout = null;


