
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// weitzner.js
// Javascript functions for Weitzner Limited website
//
// FASTBOIL                     1.0         26/02/2010
// http://www.fastboil.net
// hot@fastboil.net
//
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


var fullWidth=0;
var fullHeight=0;
var topBarVisible=false;
var hmargin = 0;
var vmargin = 0;

var minWidth = 1060;
var minHeight = 800;
var imgRatio = 800/1060;

var timeoutHome;
var delayHome = 2000;

window.onresize = function(){setLayout();};

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function setLayout
// Object : Setting layout
// FASTBOIL                     1.0         26/02/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function setLayout() {
  hmargin = 0;
  if (self.innerHeight) { // all except Explorer
    fullWidth = self.innerWidth;
    fullHeight = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    fullWidth = document.documentElement.clientWidth;
    fullHeight = document.documentElement.clientHeight;
  }
  else if (document.body) { // other Explorers
    fullWidth = document.body.clientWidth;
    fullHeight = document.body.clientHeight;
  }

  if (fullWidth<minWidth) fullWidth = minWidth;
  if (fullHeight<minHeight) fullHeight = minHeight;

  hideSpotLight();

  if (fullWidth>0 && fullHeight>0) {
    if (fullWidth > document.getElementById('main').offsetWidth) hmargin = Math.round((fullWidth - document.getElementById('main').offsetWidth)/2);
    document.getElementById('main').style.marginLeft = hmargin+'px';

    if (fullHeight > document.getElementById('main').offsetHeight) vmargin = Math.round((fullHeight - document.getElementById('main').offsetHeight)/2);
    document.getElementById('fullw').style.marginTop = vmargin+'px';

    // image new size from available space and image ratio
    cRatio = fullHeight/fullWidth;
    if (cRatio>=imgRatio) {
      imgHeight = fullHeight;
      imgWidth = Math.round(imgHeight/imgRatio);
    }
    else {
      imgWidth = fullWidth;
      imgHeight = Math.round(imgRatio*imgWidth);
    }
    // resize image
    if (document.getElementById('bgimg')) {
      document.getElementById('bgimg').width = imgWidth;
      document.getElementById('bgimg').height = imgHeight;
    }
    // resize & position image container
    if (document.getElementById('image_o')) {
      document.getElementById('image_o').style.width = fullWidth+'px';
      document.getElementById('image_o').style.height = fullHeight+'px';
      document.getElementById('image_i').style.width = imgWidth+'px';
      document.getElementById('image_i').style.height = imgHeight+'px';
      if (imgWidth==fullWidth) {
        document.getElementById('image_i').style.left = '0px';
        document.getElementById('image_i').style.top = -Math.abs(Math.round((fullHeight-imgHeight)/2))+'px';
      }
      else if (imgHeight==fullHeight) {
        document.getElementById('image_i').style.top = '0px';
        document.getElementById('image_i').style.left = -Math.abs(Math.round((fullWidth-imgWidth)/2))+'px';
      }
    }
  }

  if (topBarVisible) {
    iWidth = document.getElementById('menu_i').offsetWidth;
    document.getElementById('menu_o').style.width = (hmargin+iWidth)+'px';
    document.getElementById('topbar').style.width = (hmargin+iWidth+document.getElementById('logo').offsetWidth)+'px';
  }
  else {
    if (document.getElementById('WeitznerHomeVideoPlayer')) setHomeVideo();
    if (document.getElementById('WeitznerStyleBoardModule')) setStyleBoard();
    if (document.getElementById('WeitznerPinupBoardModule')) setPinupBoard();
    if (document.getElementById('contentItemResumeCharacteristic')) initAscenseur('contentItemResumeCharacteristic');
    if (document.getElementById('col2')) initAscenseur('col2');
    if (document.getElementById('divsector')) initAscenseur('divsector');

    timeoutHome = setTimeout('clickLogo(\'\',\'\',\'\',\'\')',delayHome);
  }
  setAscenseurItemRefs();
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function clickLogo
// Object :
// FASTBOIL                     1.0         26/02/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function clickLogo(urlBG,urlM,urlC,urlN) {
  clearTimeout(timeoutHome);

  if (!topBarVisible) {
    topBarVisible = true;
    showTopBar();
    if (!spotLightVisible) showSpotLight();
  }
  else {
    if (urlBG!='' && urlM!="" && urlC!="" && urlN!="") menu(urlBG,urlM,urlC,urlN);
  }
}

var timeoutTopBar;
var delayTopBar = 10;
var stepTopBar = 10000; //10;

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function showTopBar
// Object :
// FASTBOIL                     1.0         26/02/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function showTopBar() {
  oWidth = document.getElementById('menu_o').offsetWidth;
  iWidth = document.getElementById('menu_i').offsetWidth;
  if (oWidth<(hmargin+iWidth)) {
    newWidth = oWidth+stepTopBar;
    if (newWidth>=(hmargin+iWidth)) {
      document.getElementById('menu_o').style.width = (hmargin+iWidth)+'px';
      document.getElementById('topbar').style.width = (hmargin+iWidth+document.getElementById('logo').offsetWidth)+'px';

      showContent();
//      if (document.getElementById('WeitznerHomeVideoPlayer')) setHomeVideo();
//      if (document.getElementById('WeitznerStyleBoardModule')) setStyleBoard();
//      if (document.getElementById('WeitznerPinupBoardModule')) setPinupBoard();
//      if (document.getElementById('contentItemResumeCharacteristic')) initAscenseur('contentItemResumeCharacteristic');
//      if (document.getElementById('col2')) initAscenseur('col2');

    }
    else {
      document.getElementById('menu_o').style.width = (newWidth)+'px';
      timeoutTopBar = setTimeout('showTopBar()',delayTopBar);
    }
  }
}

var timeoutContent;
var delayContent = 10;
var stepContent = 700; //10;

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function showContent
// Object :
// FASTBOIL                     1.0         26/02/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function showContent() {
  cHeight = document.getElementById('main_i').offsetHeight;
  mHeight = document.getElementById('main_o').offsetHeight;
  if (cHeight<mHeight) {
    newHeight = cHeight+stepContent;
    if (newHeight>=mHeight)
      document.getElementById('main_i').style.height = (mHeight)+'px';
    else {
      document.getElementById('main_i').style.height = (newHeight)+'px';
      timeoutContent = setTimeout('showContent()',delayContent);
    }
  }
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function menu
// Object :
// FASTBOIL                     1.0         08/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function menu(urlBG,urlM,urlC,urlN) {
  action = "";
  if (menu.arguments.length==5) action = arguments[4];
  hideSpotLight();
  if (document.images['bgimg']) document.images['bgimg'].src = urlBG;
  fbGetUrlDiv('menu_i',urlM,'');
  if (action=='')
    fbGetUrlDiv('main_i',urlC,' ');
  else
    fbGetUrlDivNext('main_i',urlC,' ',action);
  fbGetUrlDiv('spotlightcontent',urlN,'');
  if(pageTracker) pageTracker._trackPageview(urlM);
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function showZoom
// Object :
// FASTBOIL                     1.0         13/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function showZoom(id) {
  var arrayOfDivs = document.getElementsByTagName('div');
  var howMany = arrayOfDivs.length - 1;
  for (var i=0; i < howMany; i++) {
      var thisDiv = arrayOfDivs[i];
      var styleClassName = thisDiv.className;
      if (styleClassName=='itemResumeInstruction') thisDiv.className='itemResumeInstructionHidden';
      if (styleClassName=='itemResumeZoom') thisDiv.className='itemResumeZoomHidden';
      if (styleClassName=='itemResumeVideo') thisDiv.className='itemResumeVideoHidden';
  }
  pauseVideo();
  var zoom = document.getElementById('zoom_'+id);
  zoom.className="itemResumeZoom";
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function hideZoom
// Object :
// FASTBOIL                     1.0         13/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function hideZoom(id) {
  var zoom = document.getElementById('zoom_'+id);
  zoom.className="itemResumeZoomHidden";
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function showInstruction
// Object :
// FASTBOIL                     1.0         13/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function showInstruction(id) {
  var arrayOfDivs = document.getElementsByTagName('div');
  var howMany = arrayOfDivs.length - 1;
  for (var i=0; i < howMany; i++) {
      var thisDiv = arrayOfDivs[i];
      var styleClassName = thisDiv.className;
      if (styleClassName=='itemResumeInstruction') thisDiv.className='itemResumeInstructionHidden';
      if (styleClassName=='itemResumeZoom') thisDiv.className='itemResumeZoomHidden';
      if (styleClassName=='itemResumeVideo') thisDiv.className='itemResumeVideoHidden';
  }
  pauseVideo();
  var instruction = document.getElementById('instruction_'+id);
  instruction.className="itemResumeInstruction";
  initAscenseur('itemResumeInstruction');
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function hideInstruction
// Object :
// FASTBOIL                     1.0         13/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function hideInstruction(id) {
  var instruction = document.getElementById('instruction_'+id);
  instruction.className="itemResumeInstructionHidden";
  initAscenseur('contentItemResumeCharacteristic');
  handle(0,'contentItemResumeCharacteristic');
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function showVideo
// Object :
// FASTBOIL                     1.0         16/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function showVideo(id,url) {
  var arrayOfDivs = document.getElementsByTagName('div');
  var howMany = arrayOfDivs.length - 1;
  for (var i=0; i < howMany; i++) {
      var thisDiv = arrayOfDivs[i];
      var styleClassName = thisDiv.className;
      if (styleClassName=='itemResumeInstruction') thisDiv.className='itemResumeInstructionHidden';
      if (styleClassName=='itemResumeZoom') thisDiv.className='itemResumeZoomHidden';
      if (styleClassName=='itemResumeVideo') thisDiv.className='itemResumeVideoHidden';
  }
  var video = document.getElementById('video_'+id);
  video.className="itemResumeVideo";

  setVideo(url);
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function hideVideo
// Object :
// FASTBOIL                     1.0         16/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function hideVideo(id) {
  pauseVideo();
  var video = document.getElementById('video_'+id);
  video.className="itemResumeVideoHidden";
}

function getSWFByName(value) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[value];
    } 
    else {
    return document[value];
    }
}

function pauseVideo(){
    if (getSWFByName("WeitznerVideoPlayer")) getSWFByName("WeitznerVideoPlayer").pause();
}

function play(){
    if (getSWFByName("WeitznerVideoPlayer")) getSWFByName("WeitznerVideoPlayer").play();
}

function stop(){
    if (getSWFByName("WeitznerVideoPlayer")) getSWFByName("WeitznerVideoPlayer").stop();
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function setVideo
// Object :
// FASTBOIL                     1.0         16/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function setVideo(url) {
  var flashvars={videoSource:url};
  var params={
      width: "510", 
      height: "363", 
      quality: "high", 
      pluginspage: "http://www.macromedia.com/go/getflashplayer", 
      align: "middle", 
      play: "true", 
      loop: "true", 
      scale: "showall", 
      wmode: "transparent",
      devicefont: "false", 
      bgcolor: "FFFFFF", 
      menu: "false", 
      allowFullScreen: "false", 
      allowScriptAccess: "sameDomain", 
      movie: "WeitznerVideoPlayer", 
      salign: ""
  };
  var attributes={};
  swfobject.embedSWF("WeitznerVideoPlayer.swf", "WeitznerVideoPlayer", "510", "363", "10.0.0", "expressInstall.swf", flashvars, params, attributes);
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function setStyleBoard
// Object :
// FASTBOIL                     1.0         15/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function setStyleBoard() {
  var flashvars={dataProvider:"default.php?fct=datastyleboard"};
  var params={
      width: "930",
      height: "600",
      quality: "high", 
      pluginspage: "http://www.macromedia.com/go/getflashplayer", 
      align: "middle", 
      play: "true", 
      loop: "true", 
      scale: "showall", 
      wmode: "transparent",
      devicefont: "false", 
      bgcolor: "FFFFFF",
      menu: "false",
      allowFullScreen: "false", 
      allowScriptAccess: "sameDomain", 
      movie: "WeitznerStyleBoardModule", 
      salign: ""
  };
  var attributes={};
  swfobject.embedSWF("WeitznerStyleBoardModule.swf", "WeitznerStyleBoardModule", "930", "600", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function setPinupBoard
// Object :
// FASTBOIL                     1.0         30/04/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function setPinupBoard() {
  var flashvars={dataProvider:"default.php?fct=datapinupboard"};
  var params={
      src: "weitznerPinupBoard",
      width: "650",
      height: "590",
      align: "middle",
      id: "weitznerPinupBoard",
      quality: "high",
      bgcolor: "#999999",
      wmode: "transparent",
      name: "weitznerPinupBoard",
      allowScriptAccess: "sameDomain",
      type: "application/x-shockwave-flash",
      pluginspage: "http://www.adobe.com/go/getflashplayer"
  };
  var attributes={};
  swfobject.embedSWF("weitznerPinupBoard.swf", "WeitznerPinupBoardModule", "650", "590", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}

function setHomeVideo() {
  var flashvars={};
  var params={
    src: "WeitznerHomeVideoPlayer",
      width: "650",
      height: "385", 
      align: "middle", 
    id: "WeitznerHomeVideoPlayer",
      quality: "high",
      bgcolor: "869CA7", 
      wmode: "transparent", 
    name: "WeitznerHomeVideoPlayer",
      allowScriptAccess: "sameDomain", 
    type: "application/x-shockwave-flash",
      pluginspage: "http://www.macromedia.com/go/getflashplayer",
      play: "true",
      loop: "true", 
      scale: "showall", 
      devicefont: "false",
      menu: "false",
      allowFullScreen: "false", 
      movie: "WeitznerHomeVideoPlayer",
      salign: ""
  };
  var attributes={};
  swfobject.embedSWF("WeitznerHomeVideoPlayer.swf", "WeitznerHomeVideoPlayer", "650", "385", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function previousGalleryItem
// Object :
// FASTBOIL                     1.0         17/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var cCat = 0;
var cOrder = 1;
function previousGalleryItem(idCat,rank) {
  cpt = arguments.length;
  nbImg = (cpt-2)/4;
  if (idCat!=cCat) {
    cCat=idCat;
    cOrder=1;
  }
  if (cOrder==1) cOrder=nbImg; else cOrder--;
  rarg = (cOrder-1)*4+2;
  if (document.galitem && document.getElementById('galleryLegend')) {
    document.galitem.src= arguments[rarg];
    tmpStr=arguments[rarg+1];
    if (arguments[rarg+2]!="" && arguments[rarg+3]!="") tmpStr+='<br /><a href="'+arguments[rarg+3]+'">'+arguments[rarg+2]+'</a>';
    document.getElementById('galleryLegend').innerHTML=tmpStr;

    if (document.getElementById('galleryCpt')) document.getElementById('galleryCpt').innerHTML=cOrder+'/'+nbImg;
  }
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function nextGalleryItem
// Object :
// FASTBOIL                     1.0         17/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function nextGalleryItem(idCat,rank) {
  cpt = arguments.length;
  nbImg = (cpt-2)/4;
  if (idCat!=cCat) {
    cCat=idCat;
    cOrder=1;
  }
  if (cOrder==nbImg) cOrder=1; else cOrder++;
  rarg = (cOrder-1)*4+2;
  if (document.galitem && document.getElementById('galleryLegend')) {
    document.galitem.src= arguments[rarg];
    tmpStr=arguments[rarg+1];
    if (arguments[rarg+2]!="" && arguments[rarg+3]!="") tmpStr+='<br /><a href="'+arguments[rarg+3]+'">'+arguments[rarg+2]+'</a>';
    document.getElementById('galleryLegend').innerHTML=tmpStr;

    if (document.getElementById('galleryCpt')) document.getElementById('galleryCpt').innerHTML=cOrder+'/'+nbImg;
  }
}


var spotLightVisible = false;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function goSpotLight
// Object :
// FASTBOIL                     1.0         17/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function goSpotLight() {
  if (spotLightVisible)
    hideSpotLight();
  else
    showSpotLight();
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function showSpotLight
// Object :
// FASTBOIL                     1.0         17/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function showSpotLight() {
  if (document.getElementById('spotlight')) {
    if (!spotLightVisible) {
      var reg = new RegExp("(px)", "g");
      myMarginStr = document.getElementById('main').style.marginLeft;
      myMargin = parseInt(myMarginStr.replace(reg,""));
      myMargin+= 80;
      document.getElementById('spotlight').style.width = (fullWidth-myMargin+10)+'px'; /* +10 = +tabShadowwidth */
      document.getElementById('spotlight').style.left = (myMargin-10)+'px'; /* -10 = -tabShadowwidth */
      document.getElementById('spotlight_i').style.width = (fullWidth-myMargin-30+10)+'px'; /* -30+10 = -tabwidth+tabShadowwidth */
      spotLightVisible = true;
    }
  }
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function hideSpotLight
// Object :
// FASTBOIL                     1.0         17/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function hideSpotLight() {
  if (document.getElementById('spotlight')) {
    //if (spotLightVisible) {
      document.getElementById('spotlight').style.width = '0px';

      document.getElementById('spotlight').style.width = '30px'; /* 30 = tabwidth */
      document.getElementById('spotlight').style.left = (fullWidth-30)+'px';

      spotLightVisible = false;
    //}
  }
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function getMouseCoordinates
// Object :
// FASTBOIL                     1.0         17/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var divCreated = 0;
var divAlt;
var divInnerHTML = "";

function getMouseCoordinates(event) {
  if (divInnerHTML!="") {
    ev = event || window.event;

    myLeft = ev.clientX+20;
    myTop = ev.clientY+20;
    myWidth = 150;
    myHeight = 150;
    //myLeft = Math.max(0,Math.min(myLeft,document.body.clientWidth - myWidth));
    myTop = Math.max(0,Math.min(myTop,document.body.clientHeight - myHeight));
    showAlt(myLeft,myTop,myWidth,myHeight);
  }
  else
    hidediv('divalt');
}
function showAlt(left,top,width,height) {
  if (divCreated==0) {
    divCreated++;
    divAlt = document.createElement('div');
    divAlt.setAttribute('id', 'divalt');
    divAlt.style.position = 'absolute';
    document.getElementById('full').appendChild(divAlt);
    divAlt.style.backgroundColor = '#FFFFFF';
    divAlt.style.borderColor = '#5A4A42';
    divAlt.style.borderStyle = 'solid';
    divAlt.style.borderWidth = '1px';
    divAlt.style.padding = '5px';
  }
  if (divAlt) {
    divAlt.style.top = myTop+'px';
    divAlt.style.left = myLeft+'px';
    divAlt.innerHTML = divInnerHTML;
    showdiv('divalt');
  }
}
function setInnerHTML(myStr) {
  divInnerHTML = myStr;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function getShowroom
// Object :
// FASTBOIL                     1.0         17/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function getShowroom(url,id) {
  fbGetUrlDiv('showroomfull',url+id,'');
}

var arrCheckSearchItem = Array();
var timeoutSearch;
var delayCheckSearch = 2000;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function checkSearchItem
// Object :
// FASTBOIL                     1.0         17/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function checkSearchItem(id,chkOff,chkOn,urlform) {
  if (document.getElementById('imgsearchitem_'+id)) {
    clearTimeout(timeoutSearch);
    var checked = 0;
    if (inArray(id,arrCheckSearchItem))
      checked = arrCheckSearchItem[id];
    else
      arrCheckSearchItem[id] = 0;
    document.getElementById('imgsearchitem_'+id).src = (checked==1)?chkOff:chkOn;
    arrCheckSearchItem[id] = (checked==1)?0:1;
    document.formsearch['searchitem_'+id].value = (checked==1)?0:1;
    timeoutSearch = setTimeout('fbSendAjaxFormTargetDiv(\'formsearch\',\''+urlform+'\',\'col21full\',\'\')',delayCheckSearch);
  }
}

function checkSearchKeywords(urlform) {
  clearTimeout(timeoutSearch);
  timeoutSearch = setTimeout('fbSendAjaxFormTargetDiv(\'formsearch\',\''+urlform+'\',\'col21full\',\'\')',delayCheckSearch);
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function processSearch
// Object :
// FASTBOIL                     1.0         17/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function processSearch(idForm,baseurl,targetId,innerhtml) {
  clearTimeout(timeoutSearch);
  fbSendAjaxFormTargetDiv(idForm,baseurl,targetId,innerhtml);
}

var refineVisible=0;
var timeoutHideRefineSearch;
//var stepHideRefineSearch=10;
var stepHideRefineSearch=1000;
var delayHideRefineSearch=2;
var timeoutShowRefineSearch;
//var stepShowRefineSearch=5;
var stepShowRefineSearch=1000;
var delayShowRefineSearch=2;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function refineSearch
// Object :
// FASTBOIL                     1.0         17/03/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function refineSearch(urlform,chkOff,refineOpen,refineClose) {
  if (document.getElementById('swcat_o') && document.getElementById('swcat_i')) {
    cHeightI = document.getElementById('swcat_i').offsetHeight;
    cHeightO = document.getElementById('swcat_o').offsetHeight;

    if (refineVisible==0) {
      document.getElementById('postsearch_o').style.height = '0px';
      document.getElementById('imgrefinesearch').src = refineOpen;
      refineVisible = 1;
      clearTimeout(timeoutHideRefineSearch);
      slideShowRefineSearch(cHeightI);
    }
    else {
      document.getElementById('imgrefinesearch').src = refineClose;
      refineVisible = 0;
      clearTimeout(timeoutShowRefineSearch);
      slideHideRefineSearch();
      for (key in arrCheckSearchItem) {
        if (document.getElementById('imgsearchitem_'+key)) {
          document.getElementById('imgsearchitem_'+key).src = chkOff;
          arrCheckSearchItem[key] = 0;
          document.formsearch['searchitem_'+key].value = 0;
        }
      }
      fbSendAjaxFormTargetDiv('formsearch',urlform,'col21full','')
    }
  }
}

function slideShowRefineSearch(max) {
  cHeightO = document.getElementById('swcat_o').offsetHeight;
  newHeight = cHeightO+stepShowRefineSearch;
  if (newHeight>max)
    document.getElementById('swcat_o').style.height = max+'px';
  else {
    document.getElementById('swcat_o').style.height = newHeight+'px';
    timeoutShowRefineSearch = setTimeout('slideShowRefineSearch('+max+')',delayShowRefineSearch);
  }
}

function slideHideRefineSearch() {
  cHeightO = document.getElementById('swcat_o').offsetHeight;
  newHeight = cHeightO-stepHideRefineSearch;
  if (newHeight<0) {
    document.getElementById('swcat_o').style.height = '0px';
      document.getElementById('postsearch_o').style.height = document.getElementById('postsearch_i').offsetHeight+'px';
  }
  else {
    document.getElementById('swcat_o').style.height = newHeight+'px';
    timeoutHideRefineSearch = setTimeout('slideHideRefineSearch()',delayHideRefineSearch);
  }
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function inArray
// Object :
// FASTBOIL                     1.0         23/04/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function inArray(needle,arr) {
  for (key in arr) {
    if (key==needle) return true;
  }
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// function setAscenseurItemRefs
// Object :
// FASTBOIL                     1.0         23/04/2010
// http://www.fastboil.net
// hot@fastboil.net
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function setAscenseurItemRefs() {
  if (document.getElementById('divitemrefs') && document.getElementById('divitemcontent')) {
      rHeight = document.getElementById('divitemcontent').offsetHeight;
      rHeight-= document.getElementById('divitemdesc').offsetHeight;
      rHeight-= document.getElementById('divitemlinks').offsetHeight;
      rHeight-= 30;
      document.getElementById('divitemrefs_main').style.height = rHeight+'px';
      document.getElementById('divitemrefs_container').style.height = rHeight+'px';
      document.getElementById('divitemrefs_slider').style.height = rHeight+'px';
      document.getElementById('divitemrefs_slider_chemin').style.height = rHeight+'px';
      initAscenseur('divitemrefs');
  }
}


//============================================================================//
//                            Ajax                                            //
//============================================================================//

function fbGetUrlDivNext(id,url,innerhtml,action) {
  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(){fbEventGetUrlDivNext(xReq,id,action);};
    xReq.send(null);
  }
}

function fbEventGetUrlDivNext(xRequest,anId,action) {
  if (xRequest.readyState==4) {
    document.getElementById(anId).innerHTML=xRequest.responseText;
    if (action!="") eval(action);
  }
}

function fbGetUrlDiv(id,url,innerhtml) {
  setInnerHTML('');
  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) {
    if (anId=='spotlightcontent') {
      cStr = document.getElementById(anId).innerHTML;
      rS = cStr.indexOf("<!-- ",0); rE = cStr.indexOf(" -->",rS);
      cId = cStr.substr(rS+5,rE-rS-5);
      nStr = xRequest.responseText;
      rS = nStr.indexOf("<!-- ",0); rE = nStr.indexOf(" -->",rS);
      nId = nStr.substr(rS+5,rE-rS-5);
      if (cId!=nId) {
        document.getElementById(anId).innerHTML=xRequest.responseText;
        goSpotLight();
      }
    }
    else {
      document.getElementById(anId).innerHTML=xRequest.responseText;
      if (document.getElementById('WeitznerHomeVideoPlayer')) setHomeVideo();
      if (document.getElementById('WeitznerStyleBoardModule')) setStyleBoard();
      if (document.getElementById('WeitznerPinupBoardModule')) setPinupBoard();
      if (document.getElementById('contentItemResumeCharacteristic')) initAscenseur('contentItemResumeCharacteristic');
      if (document.getElementById('showroomlist')) initAscenseur('showroomlist');
      if (document.getElementById('col2')) initAscenseur('col2');
      if (document.getElementById('col1')) initAscenseur('col1');
      if (document.getElementById('divsector')) initAscenseur('divsector');
      setAscenseurItemRefs();
    }
  }
}

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 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';
        }
    }
}

// Slider text - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

var slider = new Array();
var mydiv="";
          
// 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(adiv+'_slider_ascenseur', adiv+'_slider_chemin', {
    axis: 'vertical',
    onSlide: function(v) { scrollVertical(v, $(adiv+'_main'), adiv);  },
    onChange: function(v) { scrollVertical(v, $(adiv+'_main'), adiv); }
  });
  s.scrollMax = max;
  slider[adiv]=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,mydiv);
    //handle(delta,'contentItemResumeCharacteristic');

/** 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) {
  mydiv = adiv;
  if (document.getElementById(adiv+'_container')
    && document.getElementById(adiv+'_main')
    && document.getElementById(adiv+'_slider')
    && document.getElementById(adiv+'_slider_chemin')) {

//if (adiv=="divsector")
//alert(adiv+": "+$(adiv+'_main').scrollHeight+" - "+$(adiv+'_main').offsetHeight);

    if ($(adiv+'_main').scrollHeight > $(adiv+'_main').offsetHeight) {
      $(adiv+'_slider').style.display='block';
      cdiv = $(adiv+'_main');
      width1 = cdiv.offsetWidth;
      width2 = width1-10;
      cdiv.style.width = width2+'px';
      initSlider0(adiv);
      initMouseWheel0(adiv);
    }
  }
}
function setFocusAscenseur(adiv) {
  mydiv = adiv;
}




