

var dynamicsC = {
name: "conseil",
targets: { "dashboard":"gc", "selvisuel":"sc" }
};

var dynamics = {
"conseil" :  { "innerdashboard":"gc", "selvisuel":"sc" },
"télécoms" :  { "innerdashboard":"gt", "selvisuel":"st" },
"expertises" : { "innerdashboard":"mexpertises"},
"mobiles" : { "innerdashboard":"mmobiles"},
"en ligne" : { "innerdashboard":"menligne"},
"mixtes" : { "innerdashboard":"mmixtes"},
"Selenium Group" : { "innerdashboard":"mselenium"},
"positionnons" : { "innerdashboard":"mposition"},
"veille" : { "innerdashboard":"mveille"},
"prospective" : { "innerdashboard":"mprosp"},
"haut-débit mobile" : { "innerdashboard":"mhdm"},
"objets communicants" : { "innerdashboard":"moc"},
"univers persistants" : { "innerdashboard":"muv"},
"référencement" : { "innerdashboard":"mref"},
"développement durable" : { "innerdashboard":"mdd"},
"recherche" : { "innerdashboard":"mrech"},
"sciences cognitives" : { "innerdashboard":"msc"},
"formations" : { "innerdashboard":"mform"},
"organisation colloques" : { "innerdashboard":"morga"},
"last" : { "innerdashboard":"mlast"}
}

var menus = {
"menuapproche"  : { "name":"notre approche","zone":["vcard"]},
"menuactivites" : { "name":"activités","zone":["expertises"]},
"menublogs"     : { "name":"blogs / actualités","zone":["kesako","blogs"]},
"menurefs"      : { "name":"références","zone":["references"]},
"menucontacts"  : { "name":"contacts","zone":["contacts","correspond","pied"]}
}

jQuery(function() {

  var tl; // TimeLine
    $("#main").height($("#header").height() + $("#troiscol").height());
    $("#innerdashboard").html($("#bienvenue").html());
    jQuery("span.more").hover(function(){$(this).addClass('more-hover');},function(){$(this).removeClass('more-hover');});
    jQuery("span.more").click(function () {
        var elt = $(this).text();
        $("#dashboard").removeClass('initial').addClass('void');
        $("#innerdashboard").html($("#"+dynamics[elt]["innerdashboard"]).html()).addClass("innerdiv");
    });
    jQuery("span.menu").each(function(){$(this).html(menus[$(this).attr("id")]["name"]);});
    jQuery("span.menu").hover(function(){$(this).addClass('menu-hover');},function(){$(this).removeClass('menu-hover');});
    jQuery("span.menu").click(function () {
        var elt = $(this).text();
        var id  = $(this).attr("id");
        for (var z in menus[id]["zone"])  {
//jQuery("#debug").html("debug: ["+menus[id]["zone"][z]+"]");
//          jQuery("#"+menus[id]["zone"][z]).addClass('menuhilit');
          jQuery("#"+menus[id]["zone"][z]).fadeOut("slow").fadeIn("slow");
        }
    });

var hcardopened=0;
    jQuery("#openhcard").click(function () {
     if (hcardopened) {
       jQuery("#hcard-hidden").hide(800);
       hcardopened=0;
     } else {
//       jQuery("#hcard-hidden").show(800,function(){jQuery('#vcard').scrollTo($("#openhcard"),800);});
       jQuery("#hcard-hidden").show(800);
       hcardopened=1;
     }
});

 jQuery("#elargref").click(function () {
//jQuery("#debug")
   if (jQuery("#references").height() < 200)
    {jQuery("#references").animate({height:200}, {duration: 1000,
     easing: "easyInQuad", complete: function() {tl.layout();}});
     jQuery("#elargref").html("références et activités à venir").css({"cursor":"text"});
    }

 });


    jQuery("span.kw").hover(function(){$(this).addClass('kw-hover');},function(){$(this).removeClass('kw-hover');});
    jQuery("span.kw").draggable({helper: 'clone'});
    jQuery(".drop").droppable({
      accept: "span.kw",
      activeClass: 'droppable-active',
      hoverClass:  'droppable-hover',
      drop: function(ev, ui) {
        var elt = $(ui.draggable.element).text();
//        if (elt == dynamicsC.name) {
//          $(this).append($("#"+dynamicsC.targets[$(this).attr("id")]).html());
        if (dynamics[elt]) {
          $("#dashboard").removeClass('initial').addClass('void');
          $(this).html($("#"+dynamics[elt][$(this).attr("id")]).html());
        } else {
//          $(this).html("<b"."r>Dropped: ["+$(ui.draggable.element).text()+"]");
        }
        $("#innerdashboard").addClass("innerdiv");
     }
    });

	$(".test3").hrzAccordion({containerClass     : "hrzContainer3",
			listItemClass      : "listItem3",					
			contentStartClass  : "contentStart3",
			contentEndClass    : "contentEnd3",
			contentWrapper     : "contentWrapper3",
			contentInnerWrapper: "contentInnerWrapper3",
			handleClass        : "handle3",
			handleClassOver    : "handleOver3",
			handleClassSelected: "handleSelected3",
			customHandleClass  : "custom"
							  });


    var urls = {
    sel  : '/js/jfeed/proxy.php?url=http://www.nereys.fr/sel/feed/atom',
    ier  : '/js/jfeed/proxy.php?url=http://www.lactuier.info/feed/',
    trek : '/js/jfeed/proxy.php?url=http://www.nereys.fr/trek/feed/rss2',
    twit : '/js/jfeed/proxy.php?url=http://twitter.com/statuses/user_timeline/11048002.rss'
    }
    var nfeeds = {
    sel  : 5,
    ier  : 5,
    trek : 5,
    twit : 1
    }
    var feeds = {
    'Sel Marin'           : 'sel',
    "L'actuier"           : 'ier',
    'Trek Telecom'        : 'trek',
    'Twitter / AymericPM' : 'twit'
    }

    for (var b in urls) {

    jQuery.getFeed({
//        url: urls[b],
        url: urls[b],
        success: function(feed) {
        var leblog = feeds[feed.title];
/*            jQuery('#'+leblog+'visuel').html('');
            jQuery('#'+leblog+'visuel').append('<h'+'2>'
            + '<a href="'
            + feed.link
            + '">'
            + feed.title 
            + '</a>'
            + '</h2>');*/
            if (feed.description.length < 80) {jQuery('#'+leblog+'desc').html(feed.description);}
            
            var html = '';
            
            jQuery('#'+leblog+'rss').html('');
            for(var i = 0; i < feed.items.length && i < nfeeds[feeds[feed.title]]; i++) {
            
                var item = feed.items[i];

                if (feeds[feed.title] != 'twit') {
                
                  html += '<h'+'3>'
                  + '<a href="'
                  + item.link
                  + '" ta'+'rget="blogs">'
                  + item.title
                  + '</a>'
                  + '</h3>';
                }

                html += '<d'+'iv class="updated">'
                + item.updated
                + '</div>';


                html += '<d'+'iv>'
                + item.description
                + '</div>';

              }
            
            jQuery('#'+leblog+'rss').append(html);
        }
    });
}

Timeline.Platform.clientLocale="en";

  var eventSource = new Timeline.DefaultEventSource();
  var bandInfos = [
    Timeline.createBandInfo({
        eventSource:    eventSource,
        width:          "65%", 
        intervalUnit:   Timeline.DateTime.MONTH, 
        intervalPixels: 100
    }),
    Timeline.createBandInfo({
        showEventText:  false,
        trackHeight:    0.5,
        trackGap:       0.2,
        eventSource:    eventSource,
        width:          "35%",
        intervalUnit:   Timeline.DateTime.YEAR, 
        intervalPixels: 200
    })
  ];
  bandInfos[1].syncWith = 0;
  bandInfos[1].highlight = true;
tl = Timeline.create(document.getElementById("references"), bandInfos);
  Timeline.loadXML("references.xml", function(xml, url) { eventSource.loadXML(xml, url); });

$(".timeline-container").css({"font-size":"8pt"});

});

