


// Scroll NewsStrip - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

var timeoutNewsStrip;
var initScroll = new Array();
var posOrigin = 10000;
var scrolling;
var delayNewsStrip = 5;
var stepNewsStrip = 5;

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         27/11/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function nsScrollLeft(srcOff,srcOn,myDiv,longScroll,offset,init) {
  document.stripleft.src = srcOn;
  if (initScroll[myDiv]==null) initScroll[myDiv]=init;
  scrolling = initScroll[myDiv];

  if(scrolling >= 5) {
    document.getElementById(myDiv).style.marginLeft = "-"+(scrolling-=stepNewsStrip)+"px";
    initScroll[myDiv] = scrolling;
  }
  else {
    document.stripleft.src = srcOff;
    return;
  }
  if(longScroll == true) {
    timeoutNewsStrip = setTimeout("nsScrollLeft('"+srcOff+"','"+srcOn+"','"+myDiv+"',true,"+offset+","+init+")", delayNewsStrip);
  }
  else
    document.stripleft.src = srcOff;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         27/11/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function nsScrollRight(srcOff,srcOn,myDiv,longScroll,offset,init) {
  document.stripright.src = srcOn;
  if (initScroll[myDiv]==null) initScroll[myDiv]=init;
  scrolling = initScroll[myDiv];

  if(scrolling < (document.getElementById(myDiv).offsetWidth-offset)) {
    document.getElementById(myDiv).style.marginLeft = "-"+(scrolling+=stepNewsStrip)+"px";
    initScroll[myDiv] = scrolling;
  }
  else {
    document.stripright.src = srcOff;
    return;
  }
  if(longScroll == true) {
    timeoutNewsStrip = setTimeout("nsScrollRight('"+srcOff+"','"+srcOn+"','"+myDiv+"',true,"+offset+","+init+")", delayNewsStrip);
  }
  else
    document.stripright.src = srcOff;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         27/11/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function checkNewsStrip(offset) {
  if (document.getElementById('newsStripContent')) {
    if (document.getElementById('newsStripContent').offsetWidth<offset) {
      if (document.getElementById('newsStripLeft')) hidediv('newsStripLeft');
      if (document.getElementById('newsStripRight')) hidediv('newsStripRight');
    }
  }
}

var timeoutGrid = new Array();
var delayHideGrid = 500;

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         30/11/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function showLotGridImage(idLot) {
  if (document.getElementById('gridimg'+idLot)) {
    timeoutGrid[idLot] = setTimeout("showdiv('gridimg"+idLot+"')",delayHideGrid);
  }
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         30/11/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function showLotGridText(idLot) {
  if (timeoutGrid[idLot]) clearTimeout(timeoutGrid[idLot]);
  if (document.getElementById('gridtxt'+idLot)) {
    hidediv('gridimg'+idLot);
  }
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         01/12/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function phareSubmit(idlot) {
    if (document.getElementById("idlot")) {
        document.getElementById("idlot").value = idlot;
        document.fphare.submit();
    }
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         07/12/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function showConference(ayear) {

  if (document.getElementById("confmenudate_"+ayear)) {

    var arrdiv = document.getElementsByTagName("DIV");
    for (i=0;i<arrdiv.length;i++) {
      if (arrdiv[i].id.substr(0,7)=="conf_o_") arrdiv[i].style.height = "0px";
    }
    document.getElementById("conf_o_"+ayear).style.height = document.getElementById("conf_i_"+ayear).offsetHeight+'px';

    var arrmenu = document.getElementsByTagName("SPAN");
    for (i=0;i<arrmenu.length;i++) {
      if (arrmenu[i].id.substr(0,13)=="confmenudate_") arrmenu[i].className = "rouillac_conference_menudate";
    }
    document.getElementById("confmenudate_"+ayear).className = "rouillac_conference_menudate_selected";
  }

}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         10/12/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function removeSpaces(string) {
 return string.split(' ').join('');
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         10/12/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function checkOrderForm(alertMsg) {

  var lblClassError = 'error';
  var arrInput = new Array('lastname','firstname','address','postcode','city','country','phone1','email','limit','docrib','docid');

  allOK = true;
  for (i=0;i<=arrInput.length-1;i++) {
    if (removeSpaces(eval("document.frmOrderForm."+arrInput[i]+".value"))=='') {
      allOK = false;
      lblClass = lblClassError;
    }
    else
      lblClass = '';
    if (document.getElementById("lbl"+arrInput[i])) {
      document.getElementById("lbl"+arrInput[i]).className = lblClass;
    }
  }

  if (!document.frmOrderForm.acceptcgv.checked) {
    allOK = false;
    if (document.getElementById("lblacceptcgv")) {
      document.getElementById("lblacceptcgv").className = lblClassError;
    }
  }
  else {
    if (document.getElementById("lblacceptcgv")) {
      document.getElementById("lblacceptcgv").className = '';
    }
  }

  if (!allOK)
    alert(alertMsg);
  else
    document.frmOrderForm.submit();
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         16/12/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function checkSendToAFriendForm(alertMsg) {

  var lblClassError = 'error';
  var arrInput = new Array('fromname','fromemail','toemail');

  allOK = true;
  for (i=0;i<=arrInput.length-1;i++) {
    if (removeSpaces(eval("document.frmSendToAFriendForm."+arrInput[i]+".value"))=='') {
      allOK = false;
      lblClass = lblClassError;
    }
    else
      lblClass = '';
    if (document.getElementById("lbl"+arrInput[i])) {
      document.getElementById("lbl"+arrInput[i]).className = lblClass;
    }
  }

  if (!allOK)
    alert(alertMsg);
  else
    document.frmSendToAFriendForm.submit();
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function
// Object :
// FASTBOIL                     1.0         16/12/2009
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function fbPlayerMp3(aMp3,aDiv) {
  var flashvars={url:aMp3};
  var params={
      width: "400",
      height: "30",
      quality: "high",
      pluginspage: "http://www.macromedia.com/go/getflashplayer",
      align: "middle",
      play: "false",
      loop: "false",
      scale: "showall",
      wmode: "transparent",
      devicefont: "false",
      bgcolor: "999999",
      menu: "false",
      allowFullScreen: "false",
      allowScriptAccess: "sameDomain",
      movie: "fastboilMp3Player",
      salign: ""
  };
  var attributes={};
  swfobject.embedSWF("fastboilMp3Player.swf", aDiv, "400", "30", "10.0.0", "expressInstall.swf", flashvars, params, attributes);
}

/* Zoom sur les lots */

//Position en X de la souris
function getMouseX(e) {
  if (!e) var e = window.event;
  if(window.opera)
    return e.clientX;
  else if(document.all)
    return document.body.scrollLeft+e.clientX;
  else if(document.layers||document.getElementById)
    return e.pageX;
}

//Position en Y de la souris
function getMouseY(e) {
  if (!e) var e = window.event;
  if(window.opera)
    return e.clientY;
  else if(document.all)
    return document.body.scrollTop+e.clientY;
  else if(document.layers||document.getElementById)
    return e.pageY;
}

function posObj(obj,e,spicWidth,spicHeight,lpicWidth,lpicHeight,zoom) {
  mouseX = getMouseX(e);
  mouseY = getMouseY(e);
  var curleft = curtop = 0;
  if(obj.offsetParent) {
    curleft= obj.offsetLeft;
    curtop = obj.offsetTop;
    while(obj = obj.offsetParent) {
      curleft+=obj.offsetLeft;
      curtop+=obj.offsetTop;
    }
  }
  // Position du curseur sur la page moins la position de l'image sur la page = position du curseur sur l'image
  PosMouseOnPicX = mouseX - curleft;
  PosMouseOnPicY = mouseY - curtop;
  OffsetLPicX = -Math.round(PosMouseOnPicX*(lpicWidth-zoom)/spicWidth);
  OffsetLPicY = -Math.round(PosMouseOnPicY*(lpicHeight-zoom)/spicHeight);
  offsetZoom = Math.round(zoom/2);
  document.getElementById("zoom").style.left = Math.min(spicWidth-zoom-2,Math.max(0,PosMouseOnPicX-offsetZoom))+'px';
  document.getElementById("zoom").style.top = Math.min(spicHeight-zoom-2,Math.max(0,PosMouseOnPicY-offsetZoom))+'px';
  document.getElementById("large").style.left = OffsetLPicX+'px';
  document.getElementById("large").style.top = OffsetLPicY+'px';
}

var zoomVisible = false;

function showZoom() {
  if (zoomVisible)
    hidediv('zoom');
  else
    showdiv('zoom');
  zoomVisible=!zoomVisible;
}

function hideZoom() {
  if (zoomVisible) {
    hidediv('zoom');
    zoomVisible=false;
  }
}

/* - - - - - */









function hidediv(myId) {
    if (document.getElementById) { // DOM3 = IE5, NS6
      if (document.getElementById(myId)) document.getElementById(myId).style.visibility = 'hidden';
    }
    else {
        if (document.layers) { // Netscape 4
          if (document.layer[myId]) document.layer[myId].visibility = 'hidden';
        }
        else { // IE 4
          if (document.all[myId]) document.all[myId].style.visibility = 'hidden';
        }
    }
}

function showdiv(myId) {
    if (document.getElementById) { // DOM3 = IE5, NS6
        if (document.getElementById(myId)) document.getElementById(myId).style.visibility = 'visible';
    }
    else {
        if (document.layers) { // Netscape 4
          if (document.layer[myId]) document.layers[myId].visibility = 'visible';
        }
        else { // IE 4
          if (document.all[myId]) document.all[myId].style.visibility = 'visible';
        }
    }
}




function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}













// Slider text - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

var slider = new Array();
          
// scroll the element vertically based on its width and the slider maximum value
function scrollVertical(value, element, nom) {
  element.scrollTop = Math.round(value*slider[nom].scrollMax);
}

function monter(nom) {
  slider[nom].setValueBy(-40/slider[nom].scrollMax);
}
          
function descendre(nom) {
  slider[nom].setValueBy(40/slider[nom].scrollMax);
}
          
// mouse wheel code from http://adomas.org/javascript-mouse-wheel/
function handle(delta,nom) {
  slider[nom].setValueBy(-(delta*60)/slider[nom].scrollMax);
}
      
function initSlider0(adiv) {
  var max = $(adiv+'_main').scrollHeight-$(adiv+'_main').offsetHeight;
  s = new Control.Slider('contentText_slider_ascenseur', 'contentText_slider_chemin', {
    axis: 'vertical',
    onSlide: function(v) { scrollVertical(v, $(adiv+'_main'), 'contentText');  },
    onChange: function(v) { scrollVertical(v, $(adiv+'_main'), 'contentText'); }
  });
  s.scrollMax = max;
  slider['contentText']=s;
}
      
function wheel0(event) { 
  var delta = 0;
  if (!event) /* For IE. */
    event = window.event;
  if (event.wheelDelta) { /* IE/Opera. */
    delta = event.wheelDelta/120;
  /** In Opera 9, delta differs in sign as compared to IE. */
  if (window.opera)
    delta = -delta;
  }
  else if (event.detail) { /** Mozilla case. */
    /** In Mozilla, sign of delta is different than in IE.
      * Also, delta is multiple of 3. */
    delta = -event.detail/3;
  }
      
/** If delta is nonzero, handle it.
  * Basically, delta is now positive if wheel was scrolled up,
  * and negative, if wheel was scrolled down. */
  if (delta)
    handle(delta,'contentText');
      
/** Prevent default actions caused by mouse wheel.
  * That might be ugly, but we handle scrolls somehow
  * anyway, so don't bother here..
  */
  if (event.preventDefault)
    event.preventDefault();
              
  event.returnValue = false;
}
          
function initMouseWheel0(adiv) {
  // mozilla
  Event.observe(adiv+'_main', 'DOMMouseScroll', wheel0);
  // IE/Opera
  Event.observe(adiv+'_main', 'mousewheel', wheel0);
}
      
function initAscenseur(adiv) {

  if (document.getElementById('rouillac_content_2')
    && document.getElementById(adiv+'_container')
    && document.getElementById(adiv+'_main')
    && document.getElementById(adiv+'_slider')
    && document.getElementById(adiv+'_slider_chemin')) {

    //theHeight = 500;
    theHeight = document.getElementById('contentText_container').offsetHeight;
    content2Height = document.getElementById('rouillac_content_2').offsetHeight-40;
    if (content2Height > theHeight) theHeight = content2Height;

    document.getElementById(adiv+'_container').style.height = theHeight+'px';
    document.getElementById(adiv+'_main').style.height = theHeight+'px';
    document.getElementById(adiv+'_slider').style.height = theHeight+'px';
    document.getElementById(adiv+'_slider_chemin').style.height = theHeight+'px';

    if ($(adiv+'_main').scrollHeight > $(adiv+'_main').offsetHeight) {
      $(adiv+'_slider').style.display='block';
      divTexte = $(adiv+'_main');
      largeur = divTexte.offsetWidth;
      largeur2 = largeur-10;
      divTexte.style.width = largeur2+'px';
      initSlider0(adiv);
      initMouseWheel0(adiv);
    }
  }
}














// Ajax - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function fbGetUrlDiv(id,url,innerhtml) {
  if (document.getElementById(id)) {
    var xReq=getXmlHttpRequest();
    var obj=document.getElementById(id);
    if (innerhtml != '') fbShowWaiting(obj,innerhtml);
    xReq.open("GET",url,true);
    xReq.onreadystatechange=function(){fbEventGetUrlDiv(xReq,id);};
    xReq.send(null);
  }
}

function fbEventGetUrlDiv(xRequest,anId) {
    if (xRequest.readyState==4) {
        document.getElementById(anId).innerHTML=xRequest.responseText;
    }
}

function fbShowWaiting(obj,innerhtml) {
    obj.innerHTML=innerhtml;
}

function getXmlHttpRequest() {
    if (window.XMLHttpRequest) // Firefox
    {
       return(new XMLHttpRequest());
    }
    else if (window.ActiveXObject) // Internet Explorer
    {
        try
        {
            return(new ActiveXObject("Msxml2.XMLHTTP"));
        } 
        catch (e)
        {
            try
            {
                return(new ActiveXObject("Microsoft.XMLHTTP"));
            }
            catch (e)
            {
                alert("Your browser does not support XMLHTTPRequest...");
            }
        }
    }
    else
    { // XMLHttpRequest non supporté par le navigateur
       alert("Your browser does not support XMLHTTPRequest...");
    }
}

function fbSendAjaxFormTargetDiv(idForm,baseurl,targetId,innerhtml) {
    var xReq=getXmlHttpRequest();
    var i;
    var url="";
    var myForm=document.getElementById(idForm);

    if (myForm) {
        var first=true;
        for(i=0;i<myForm.elements.length;i++) {
            var elmt=myForm.elements[i];
            var type=elmt.nodeName.toLowerCase();
            var ok=true;

            if (type=="input") {
                switch (elmt.type.toLowerCase()) {
                case "radio":
                case "checkbox":
                    if (!elmt.checked) ok=false;
                    break;

                case "submit":
                case "image":
                    ok=false;
                    break;
                }
            }
            else if ((type!="select") && (type!="textarea")) ok=false;
            if (ok) {
                if (first) first=false;
                else url+="&";
                url+=elmt.name+"="+elmt.value.replace(/%/g,"%25").replace(/&/g,"%26").replace(/=/g,"%3D").replace(/ /g,"%20");
            }
        }
    }

    var obj=document.getElementById(targetId);
    if (innerhtml != '') fbShowWaiting(obj,innerhtml);

    xReq.open("POST",baseurl,true);
    xReq.onreadystatechange=function(){fbEventGetUrlDiv(xReq,targetId);};
    xReq.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 
    xReq.send(url);
}







function fbShowcase(url,innerhtml) {
  if (document.getElementById('showcase')) {
    var xReq=getXmlHttpRequest();
    var obj=document.getElementById('showcase');
    if (innerhtml != '') fbShowWaiting(obj,innerhtml);
    xReq.open("GET",url,true);
    xReq.onreadystatechange=function(){fbEventShowcase(xReq);};
    xReq.send(null);
  }
}

function fbEventShowcase(xRequest) {
    if (xRequest.readyState==4) {
        document.getElementById('showcase').innerHTML=xRequest.responseText;
    }
}


