   
    $(document).ready(function () {
    	
        var PresentationDiv = $('#PresentationId');
        var RulesDiv = $('#RulesId');
        var ConditionDiv = $('#ConditionId');
        
        var PresDisp = "none";
        var RulesDisp = "none";
        var ConditionDisp = "none";
        /**
        * 	Fonction qui prépare les attributs à poster:
        */
        function createQuery(event)
		{
			var aParams = new Array();
			var sParam = encodeURIComponent('_SQ')+'='+encodeURIComponent('Y');
				aParams.push(sParam);

		    $("form").each(function() {

					var form = this;
					if(form.name=='Valid')
					{
						  $(":input",form).each(function(){
							 	  if(this.name=="Event")
							 	  	sParam = encodeURIComponent('Event')+'='+encodeURIComponent(event);
							 	  else
							 	  	  sParam = encodeURIComponent(this.name)+"="+encodeURIComponent(this.value);
							 	  
							 	  aParams.push(sParam);
						   });
					}
	
			});
		    return aParams.join('&');
		}
		
		
        $('#PresentationLink').click(function () {
            // cache the 'this' instance as we need access to it within a setTimeout, where 'this' is set to 'window'
			$("#RulesOuter").slideUp("slow");
   			$("#ConditionOuter").slideUp("slow");
            $('#PresentationOuter').slideToggle(); 
           
            /*
            	var t = this; 
            	var event = "showPresentation" ; 
            	/*var query = createQuery(event);
            	$.post("index.php",
            			{
					       message: "message",       name: "Data",      action: "postmsg",       time: timestamp
			     		},      	function(xml) 	{
							   	addMessages(xml);
								}
					); 
            	
            	if (this.timer) clearTimeout(this.timer);
                
                // fire an ajax request in 1/5 of a second
                this.timer = setTimeout(function () {
                    $.ajax({
                        beforeSend : function (j) {
                        	//alert('before send');
	                    },
	                    type: 'POST',
                        url: 'index.php',
                        data: query+'division=Presentation' ,
                        // dataType: 'json',
                        type: 'post',
                        success: function (j) {
     						//var inner = doTreatResponse(j);
                        	$('#PresentationInner').html(j);
	                     }
	                }); 
                }, 100);
                
           function doTreatResponse(j)
           {
            	//$('#PresentationInner').html("<input type=Text class='standardField />");
            	return j;
           }
             */
         });
        
         
         $('#RulesLink').click(
	         	function () {
		         	$("#PresentationOuter").slideUp("slow");
		   			$("#ConditionOuter").slideUp("slow");
		            $("#RulesOuter").slideToggle(); 
	         	
	            }
            );
          
           $('#ConditionLink').click(function () {
           	
           		$("#PresentationOuter").slideUp("slow");
   				$("#RulesOuter").slideUp("slow");
            	$('#ConditionOuter').slideToggle(); 
           

            });
            
            
     });//**  $(document).ready
    
     function SwitchMenuSelection(MenuId, li)
     {
 		
 		var active = $(li).attr('active');
 		if(active == 'Y')
 			return;
 			
 		var lang = $(li).attr('headKey');
 		var SwitchMenuhead = $("#SwitchMenuhead_"+MenuId);
     	var MenuContentDiv = $("#SwitchMenuContent_"+MenuId);
     	//** Désactivation:
	    $('li[@id*=MenuHead_]', SwitchMenuhead).filter("[active='Y']").each(
								
				function()
				{
					$(this).removeClass('SwitchMenuheaderActive');
	                $(this).addClass('SwitchMenuheader');
	                $('a',this).get(0).className = 'SwitchMenuheader';
	                this.setAttribute('active','N') ;
	                
	                var ContentToHide  = "MenuContent_"+MenuId+"_"+ $(this).attr('headKey');
					$('#'+ContentToHide).hide(); 
				}
		 );
		 
		 //** Activation:
		// var  selectedHeadId = "MenuHead_"+MenuId+"_"+lang;
		 $(li).removeClass('SwitchMenuheader');
	     $(li).addClass('SwitchMenuheaderActive');
	     $(li).attr('active', 'Y');  
	     $('a',li).get(0).className = 'SwitchMenuheaderActive';
	     
	     var ContentToShow = "MenuContent_"+MenuId+"_"+lang;
	     $('#'+ContentToShow).show(); 
     }
  
   	 function openDiv(index)
     {
     	$('div[@id^=Outer]').each(
			function()
			{
				if(this.id != 'Outer_'+index){
					$(this).slideUp("slow");
				}
			}
		);
		$('div[@id^=InOuter]').each(
			function()
			{
				if(this.id != 'InOuter_'+index){
					$(this).slideUp("slow");
				}
			}
		);
        
        $('#Outer_'+index).slideToggle(); 
     }

     function openDivIn(index)
     {
     	$('div[@id^=InOuter]').each(
			function()
			{
				if(this.id != 'InOuter_'+index){
					$(this).slideUp("slow");
				}
				
			}
		);
        $('#InOuter_'+index).slideToggle();
        changeIcon("Img_"+index);
     }
     
     function openDivInDataBse(index)
     {
     	$('div[@id^=DuplcateFounInDataBaseOuter]').each(
			function()
			{
				if(this.id != 'DuplcateFounInDataBaseOuter_'+index){
					$(this).slideUp("slow");
				}
				
			}
		);
        $('#DuplcateFounInDataBaseOuter_'+index).slideToggle();
        changeIcon("Img_"+index);
     }
