
var isVisible = new Array();
var itemActif = "";
function lancerRecherche() {
        lancerResultat();
}
function lancerResultat() {
    var r = "" + jQuery("#ch_recherche").val();

    if (r.length > 2) {
        jQuery.post("_ajax/recup_recherche.aspx", {
            r: r
        }, function(d) {

        jQuery("#div_result").html(d);
        Cufon.replace('div.changetext');
            if (!jQuery("#div_result").is(":visible")) {
                jQuery("#div_result").fadeIn("slow");
            }

        });
    }
    else {
        jQuery("#div_result").fadeOut(300, function() {
            jQuery("#div_result").html("");
        });
        
        
    }
}

var onglet_active = "gris";
function askFormulaire(div,partie,animation)
 {
    if ( partie=="10") 
    {
     isVisible["0"] = true;
 
    }
    else
    {
        isVisible[partie]=true;
       
    }
    
    
     
     if (div == "princ") {

       
         div = "#contenu_" + onglet_active;

     }
    
    
     var p = $(div).position();
    
     /*if (partie < 9) {
        var left = p.left + 110 + 40 * partie;
     }
     else {
         var left = p.left + 110 + 40;
     }
     var top = p.top + 50;*/
     var top = p.top;
     if (div == ".box") {
         top = top + 10;
         left = left + 10
     }
     
     var left = p.left;
    
     $("#request_daily").css("top", top + "px");
     $("#request_daily").css("left", left + "px");
     var delay = 500;
     if ( animation )
     {
        delay = 1000;
     }

     if ($("#if_result").length > 0) {

         $("#request_daily").show(delay);
     }
     else {
         jQuery.post("_ajax/ajax_iframe.aspx", {
             part: partie
         }, function(d) {

             jQuery("#request_daily").html(d);
             $(".iresult").width($(div).width());
             if (div == ".box") {
                 $(".iresult").height(570);
             }
             $("#request_daily").show(1000);

         });
     }

 }
 function fermeFrame() {
     isVisible[itemActif] = false;

     $("#request_daily").hide(1000);
    
 }
 function changeLogo(part) {
     $("#img_logo").attr("src", "xox/images/logo_" + part + ".png");
     onglet_active = part;
 }

 function init() {


     var ong = $("#input_onglet").val();
     var op ="1";
     if ( ong =="spotter") 
     {
        op="7";
     }

     $(".test3").hrzAccordion({


         containerClass: "container3",
         listItemClass: "listItem3",
         contentWrapper: "contentWrapper3",
         contentInnerWrapper: "contentInnerWrapper3",
         handlePositionArray: "left,left,left,left,left,left,left,left,left",
         handleClass: "handle3",
         handleClassOver: "handleOver3",
         handleClassSelected: "handleSelected3",
         openOnLoad: op,
         eventAction: function(i) {
            
   
                $("#request_daily").hide();
             if (i == 0) {

             }
             else {
                 $(".slideshow").hide();
                 $(".report_gauche").hide();
                 $("#div_info").hide();
             }
             switch ("" + i) {
                 case "0":
                     $(".text_masque").hide();
                     chargerContenu("#bloc_princ");
                     changeLogo("gris");
                     $(".slideshow").show();
                     $(".report_gauche").show();
                     $("#div_info").show();
                    
                     break;
                 case "1":
                     $(".text_masque").hide();
                     $("#text_daily").delay(2000).show();
                     changeLogo("daily");
                     

                     break;
                 case "2":
                     $(".text_masque").hide();
                     $("#text_weekly").delay(2000).show();
                     changeLogo("weekly");
                    
                     break;
                 case "3":
                     $(".text_masque").hide();
                     $("#text_fresh").delay(2000).show();
                     changeLogo("fresh");
                     break;
                 case "4":
                     $(".text_masque").hide();
                     $("#text_cool").delay(2000).show();
                     changeLogo("cool");
                     break;
                 case "5":
                     $(".text_masque").hide();
                     $("#text_witlist").delay(2000).show();
                     changeLogo("witlist");
                     break;
                 case "6":
                     $(".text_masque").hide();
                     $("#text_witspotter").delay(2000).show();
                     changeLogo("witspotter");
                     break;
                 case "7":
                     $(".text_masque").hide();
                     $("#text_witometer").delay(2000).show();
                     changeLogo("witometer");
                     break;
                 case "8":
                     $(".text_masque").hide();
                     $("#text_sessions").delay(2000).show();
                     changeLogo("sessions");
                     break;
             }
         }
         ,completeAction: function(i) {
            itemActif = i;
         
            switch ("" + i) {
                 case "0":
                  if ( isVisible["0"])
                      askFormulaire("#contenu_gris",0,false);
                 break;
                 case "1":
                  if ( isVisible["1"])
                  {
                  
                     askFormulaire("#contenu_daily",1,false);
                      }
                 break;
                  case "2":
                  if ( isVisible["2"])
                      askFormulaire("#contenu_weekly",2,false);
                 break;
                  case "3":
                  if ( isVisible["3"])
                      askFormulaire("#contenu_fresh",3,false);
                 break;
                  case "4":
                  if ( isVisible["4"])
                      askFormulaire("#contenu_cool",4,false);
                 break;
                  case "5":
                  if ( isVisible["5"])
                      askFormulaire("#contenu_witlist",5,false);
                 break;
                  case "6":
                  if ( isVisible["6"])
                      askFormulaire("#contenu_witspotter",6,false);
                 break;
                  case "7":
                  if ( isVisible["7"])
                      askFormulaire("#contenu_witometer",7,false);
                 break;
                 case "8":
                  if ( isVisible["8"])
                      askFormulaire("#contenu_sessions",8,false);
                 break;
                 }
          }
     });
     $('.scroll_news').vTicker({
         speed: 500,
         pause: 10000,
         showItems: 2,
         animation: 'fade',
         mousePause: false,
         height: 110,
         direction: 'up'
     });
     $('.slideshow').cycle({
         fx: 'fade' 
     });

     var t = "";
     $("#ch_recherche").keyup(function() {

         clearTimeout(t);
         t = setTimeout("lancerRecherche()", 200);



     });

     $("#ch_recherche").focus(function() {
         if ($("#ch_recherche").val() == "Type your search ...") {
             $("#ch_recherche").css("color", "#000");
             $("#ch_recherche").val("");
         }
     });

     $("#ch_recherche").blur(function() {
         if ($("#ch_recherche").val() == "") {
             $("#ch_recherche").css("color", "#CCC");
             $("#ch_recherche").val("Type your search ...");
         }
     });




    

     $('#twitter').twitterMentions(['', ''], {
         avatar: true,
         maximum: 20,
         ulClass: 'twitter-mentions',
         odd: true,
         oddClass: 'odd'
     });

     $(".img_l").mouseover(function() {

         $(this).stop().fadeTo('fast', 0.5);

     });
     $(".img_l").mouseout(function() {

         $(this).stop().fadeTo('fast', 1);

     });

    /* $(".img_big").fancybox({
         'titleShow': false,
         'padding': 0,
         'transitionIn': 'none',
         'transitionOut': 'none',
         'type': 'image',
         'changeFade': 0
     });*/
        



 }
 function chargerContenu(fnc_page) {
     $(".bloc_bas").hide();
     $(fnc_page).show();

 }

 $(document).ready(function() {






     (function($) {
         $.fn.fullBg = function() {
             var bgImg = $(this);

             function resizeImg() {

                 var imgwidth = bgImg.width();
                 var imgheight = bgImg.height();

                 var winwidth = $(window).width();
                 var winheight = $(window).height();

                 var widthratio = winwidth / imgwidth;
                 var heightratio = winheight / imgheight;

                 var widthdiff = heightratio * imgwidth;
                 var heightdiff = widthratio * imgheight;
                 var margin = winheight - 850;
                 if (margin > 0) {
                     $("#container").css({ marginTop: margin + 'px' });
                 }

                 if (heightdiff > winheight) {

                     bgImg.css({
                         width: winwidth + 'px',
                         height: heightdiff + 'px'
                     });
                 } else {
                     bgImg.css({
                         width: widthdiff + 'px',
                         height: winheight + 'px'
                     });
                 }
             }
             resizeImg();
             $(window).resize(function() {
                 resizeImg();
             });
         };
     })(jQuery)
     //$('#bg').cycle({ timeout: 0, speed: 600 });
     $("#backimg1").fullBg();



     init();
    Cufon.replace('div.changetext');

 });
var article_prec = "0";


function infoHover() {
    jQuery(".lien_spotter").mouseenter(function () {

        var el2 = this;
        var el_id = $(el2).attr("id");
        var p_id = el_id.split("_")[2];
        tooltip.show("", 400);
        if (article_prec != p_id) {
            jQuery.post("_ajax/ajax_recup_image_spotter.aspx", {
                p_id: p_id,
                async: false
            }, function (d) {
                article_prec = p_id;
                $("#tt").html(d);

            }
                );
        }






    });
    jQuery(".lien_spotter").mouseout(function () {
        var el2 = this;

        tooltip.hide();

    });

}



 function scrollTopRight() {

     infoHover();
    
    
     $('.slideshow_0').cycle({
         fx: 'fade',
         timeout: 4000
     });
     $('.slideshow_3').cycle({
         fx: 'fade',
         timeout: 7000
     });
     $('.slideshow_6').cycle({
         fx: 'fade',
         timeout: 4000
     });
     $('.slideshow_9').cycle({
         fx: 'fade',
         timeout: 7000
     });
     $('.slideshow_12').cycle({
         fx: 'fade',
         timeout:4000
     });
 }








