$(document).ready(function()
{
	MaxComboDemoHeightLimit = 352;

	if ($('#combo-demo-menu li').length > (11 + 2))
	{
		$('#ul-content').mousemove(function(e) {
			var s_top = parseInt($('#ul-content').offset().top);
			var s_bottom = parseInt($('#ul-content').height() + s_top);
   		var mheight = $('#combo-demo-menu').height() - MaxComboDemoHeight;
			var top_value = Math.round(( (s_top - e.pageY) /100) * mheight / 2);
			if (top_value > 0) top_value = 0;
			if (top_value < -mheight) top_value = -mheight;
			$('#combo-demo-menu').css("top", (top_value));
		});
	}

  if ($('#combo-demo-menu').height() < MaxComboDemoHeightLimit)
		MaxComboDemoHeight = $('#combo-demo-menu').height();
	else
    MaxComboDemoHeight = MaxComboDemoHeightLimit;

	$('#ul-content').css('top', '0px');
	$('#ul-content').height('0px');

	$("#combo-demo").hover(
		function(){
		  $("#myQuicktime").css("visibility", "hidden");
		  $('#ul-content').stop().animate({
		  	height: MaxComboDemoHeight + 'px',
		    top: '-'+MaxComboDemoHeight+'px'
		  }, {queue:false, duration:500});
    },
		function(){
		  CloseComboDemo();
		}
  );

  $("a.combo-demo-a").click(
		function(){
		  $("a.combo-demo-a").removeClass("active");
			CloseComboDemo();
			var rel = $(this).attr("rel").split('|');
		  SetCurrentDemo(rel[0]);
		  $("#combo-demo-label").html($(this).html());
		  $(this).addClass("active");
    }
  );
});

function CloseComboDemo() {
	$("#myQuicktime").css("visibility", "visible");
  $("#ul-content").stop().animate({
    height: '0px',
    top: '0px'
  }, {queue:false, duration:250, complete:function(){
		
	}});
}

function UpdateComboDemoContent(type, val)
{
	$('#combo-demo-menu li').each(function(index) {
    var rel = ($("a", this).attr("rel") ? $("a", this).attr("rel").split('|') : null);
    
    if (rel != null)
    {
	    if (type == "auteur" && (rel[1] == val || val == '0')) $(this).show();
	    else if (type == "auteur") $(this).hide();

	    if (type == "secteur" && (rel[2] == val || val == '0')) $(this).show();
	    else if (type == "secteur") $(this).hide();
    }
  });
  
  if ($('#combo-demo-menu').height() < MaxComboDemoHeightLimit)
		MaxComboDemoHeight = $('#combo-demo-menu').height();
	else
    MaxComboDemoHeight = MaxComboDemoHeightLimit;
}
