var fologs={},VPG = VPG || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale': {} };
var toolTipSettings={positions:['bottom'],
  spikeLength:0,
  strokeStyle:"#D8CBBE",
  fill:"#F1EFEA",
  shadow:true,
  shadowOffsetX:2,
  shadowColor:'#777777',
  shadowBlur:5,
  offsetParent:'body',
  cssStyles:{
    fontFamily: 'Helvetica,Arial',
    fontSize:11,
    color:'#7A7472'
  },
  hoverIntentOpts:{
    interval:100,
    timout:150
  }
};

function getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ';', len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}

function initLogMessage(m){
    fologs[m]=new Date().getTime();
}

function addLogMessage(m){
    try{
      if(fologs[m]) console.debug(m+" ("+(new Date().getTime()-fologs[m])+")");
      else  console.debug(m);
    }catch(e){ }
    delete fologs[m];
}

//Lance un taggage de page EA
function addEACollector(o){
  if(typeof EA_collector=="function"){
    if(typeof o!="object") o=['path',o];
    EA_collector(o);
  }else{
    setTimeout(function(){
      addEACollector(o);
    },500);
  }
}
function addEAButton(s){
   if(typeof EA_button=="function") EA_button(s);
   else{
     setTimeout(function(){
       addEAButton(s);
     },500);
   }
}
function addEAEvent(s){
  if(typeof EA_event=="function") EA_event(s);
  else{
    setTimeout(function(){
      addEAEvent(s);
    },500);
  }
}

$(function(){
  //Gestion des erreurs ajax
  $('body').ajaxError(function(e, jqxhr, settings, exception){
    if(jqxhr.status==401) location.href=VPG.settings.basePath;
  });
  
  //Menu header
  if(VPG.settings.vp_theme==3){
    var f=function(o){
      if($(o).is(':visible')){
        $(o).addClass('menu-user-visible');
        EA_button('v3-Menu-Header');
      } else $(o).removeClass('menu-user-visible');
    }
    $('#menu-arrow').click(function() {
        $('#menu-user').toggle(400,function(){f(this);});
    })
    $(document).click(function(){
       if($('#menu-user').is('.menu-user-visible')) $('#menu-user').hide(400,function(){f(this);});
    });
  }
});


