﻿function _init(){
    if(location.hash.length<2) location.hash="#"+showindex;
    $("#timelineContainer").css("visibility","hidden");
	$("#timelineMovable .caseTimeline .vignetteActu").click(function(e)
	{
		location.href=$("a",this).attr("href");
		return false;
	}).hover(
      function () {
        var im=$(this);
        if(im.attr("style2")==undefined){
            var oldStyle=im.attr("style");
            oldStyle=(oldStyle)?oldStyle:"";
            im.attr("style2",oldStyle);
        }
        im.css("background","#0a64a7 none no-repeat center center");
      }, 
      function () {
        var im=$(this);
        im.attr("style"," "+im.attr("style2"));
      }
    );    
	$(".sliderDetail a").click(function(e)
	{
	    if($("#evenement").css("display")=="none"){
            $(".minisite h2").html($("#rpTitre").html());
            $(".minisite .resume").html($("#rpResume").html());
	    }
	    else{
            $("#rpTitre").html($(".minisite h2").html());
            $("#rpResume").html($(".minisite .resume").html());
	    }					
		return false;
	});
    $("#flLeft, #flRight").hide().click(function(){return false});
}
$(document).ready(_init);
$(window).bind("load", function() {
    var p="/";
	$("#timelineContainer").css("visibility","visible").codaSlider({maxShow : 4});
	$(".vignetteActu").each(function(i){
	    if($(this).html()==""){
	        var self=this;
            /******/
            /* prepare un overlay pour les action ajax */
            /******/
            var loadingTimer,loadingFrame=1;
            function animateLoading() {
                if (!$(".oz_loading",self).is(':visible')){
                    clearInterval(loadingTimer);
                    $(".oz_overlay",self).hide();
                    return;
                }

                $(".oz_loading > div",self).css('top', (loadingFrame * -40) + 'px');

                loadingFrame = (loadingFrame + 1) % 12;
            };
            function showLoading() {
                $(".oz_overlay",self).show();
                clearInterval(loadingTimer);
                $(".oz_loading",self).show();
                loadingTimer = setInterval(animateLoading, 66);
            };
	        var html="<div id=\"ol"+i+"\" class=\"oz_overlay\"><!-- --></div>";
            html += '<div class="oz_loading"><div><!-- --></div></div>';
            $(html).prependTo($(self));
            $("#ol"+i).css('opacity', '0.8');
            showLoading();
            /*****/
            /* fin overlay */
            /*****/
	        $.ajax({
                type : 'GET',
                url  : p+'loadNews.aspx?id='+self.id.slice(1)+((l)?"&e=1":""),
                success: function(result) {
                    $(".oz_loading",self).show();
                    var tab=result.split("|||");
                    if(tab.length>0){       
	                 var i=0,html=[];
                     html[i++]="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
                     html[i++]="<tr><td class=\"img\" style=\"background-image:url(";
                     html[i++]=tab[0];
                     html[i++]=")\"><div class=\"date\">";
                     html[i++]=tab[1];
                     html[i++]="<br/>";
                     html[i++]=tab[2];
                     html[i++]="</div></td></tr>";
                     html[i++]="<tr><td class=\"accroche\"><a href=\"";
                     html[i++]=tab[3];
                     html[i++]="\">";
                     html[i++]=tab[4];
                     html[i++]="</a></td></tr></table>";
                     $(self).html(html.join(''));
                    }
                }
            });
	    }
	});
});