//----------------------------------------------

//  Main Navigation

//----------------------------------------------

var up_ico=new Array();

var down_ico=new Array();

up_ico[0]="http://www.bmw.co.th/_share/up_a.gif";
up_ico[1]="http://www.bmw.co.th/_share/up_b.gif";
down_ico[0]="http://www.bmw.co.th/_share/down_a.gif";
down_ico[1]="http://www.bmw.co.th/_share/down_b.gif";

var ico;

ico=up_ico;



var menuOpen = false;

var  currentHighLight;

function closeMenu(menuID) {

  if (menuID == 'close') {

   if (menuOpen) {

      resizeLayer('firstNavi', null, 101)

      resizeLayer(parent.frames['mainNavigationIFrame'].parent.document.getElementById('mainNavigationIFrame'), null, 101)

      setZIndex(parent.frames['mainNavigationIFrame'].parent.document.getElementById('mainNavi'), 919);

      setVisibility('bmw' + menuOpen,0);

      setCurtain(0);

      if ((menuOpen == 'usedvehicle') || (menuOpen == 'owner') || (menuOpen == 'insights')){

        setClassName('nav'+menuOpen,'mainNavi');

      } else {

        setClassName('nav'+menuOpen,'mainNaviVehicles');

      }

      menuOpen = false;

    }

  }

}

function openMenu(menuID) {

  if (parent.frames['mainNavigationIFrame'].parent.document.getElementById('changeToHighend')) { // remove Layer to highendVersion

    oldDiv=parent.frames['mainNavigationIFrame'].parent.document.getElementById('changeToHighend');

    parent.frames['mainNavigationIFrame'].parent.document.getElementsByTagName("body")[0].removeChild(oldDiv);

  }

  readLeft  = getDivInformation('div'+menuID,'offsetLeft');

  readLeft2 = getDivInformation('divusedvehicle','offsetLeft');

  if(typeof readLeft2 == 'undefined') {

    readLeft2 = getDivInformation('divowner','offsetLeft');

  }

  if(typeof readLeft2 == 'undefined') {

    readLeft2 = getDivInformation('divinsights','offsetLeft');

  }

  readTop = getDivInformation('div'+menuID,'offsetTop');

  navioffsetTop = 49;

  navioffsetLeft = 0;

  if (browserId == 'MSIE') {

    navioffsetLeft = -1;

  }

  for(i=0;i < 2;i++){

    if ((menuID == 'usedvehicle') || (menuID == 'owner') || (menuID == 'insights')){

       moveObject('bmw'+menuID,readLeft2 +navioffsetLeft, navioffsetTop);

    } else {

       moveObject('bmw'+menuID,readLeft + navioffsetLeft, navioffsetTop);

    }

  }

  if (menuOpen != menuID) {

    resizeLayer('firstNavi', null, 380);

    resizeLayer(parent.document.getElementById('mainNavigationIFrame'), null, 380);

    aktuallyHi = document.getElementById('nav'+menuID).className;

    if (aktuallyHi == 'mainNaviHighlight') {

      currentHighLight = menuID;

    }

    setVisibility('bmw'+menuID,1);

    setCurtain(1);

    setZIndex(parent.document.getElementById('mainNavi'),920);

    if (menuOpen) {

      setVisibility('bmw'+menuOpen,0);

      if ((menuOpen == 'usedvehicle') || (menuOpen == 'owner') || (menuOpen == 'insights')){

        setClassName('nav'+menuOpen,'mainNavi');

      } else {

        setClassName('nav'+menuOpen,'mainNaviVehicles');

      }

	    if (currentHighLight == menuOpen){

        setClassName('nav'+menuOpen,'mainNaviHighlight');

      }

    }

    setClassName('nav'+menuID,'mainNaviClicked');

    menuOpen = menuID;

  } else{

    resizeLayer('firstNavi', null, 101);

    resizeLayer(parent.document.getElementById('mainNavigationIFrame'), null, 101);

    setVisibility('bmw'+menuID,0);

    setCurtain(0);

    setZIndex(parent.document.getElementById('mainNavi'),919);

    if ((menuID == 'usedvehicle') || (menuID == 'owner') || (menuID == 'insights')){

      setClassName('nav'+menuID,'mainNavi');

    } else {

      setClassName('nav'+menuID,'mainNaviVehicles');

    }

	  if (currentHighLight == menuOpen){

      setClassName('nav'+menuOpen,'mainNaviHighlight');

    }

    menuOpen = false;

  }

}

function setCurtain(mode){

  // please modificate also the setCurtain function in the narrowband_bottom.html

  if ((parent.useCurtain) && (parent.useCurtain == "true")){

     if (mode == 1){

       setVisibility(parent.document.getElementById('iFrameContainer'),0);

       moveObject(parent.document.getElementById('iFrameContainer'),((window.screen.width*2)*(-1)));

       setVisibility(parent.document.getElementById('curtain'),null,'block');

    } else {

       setVisibility(parent.document.getElementById('curtain'),null,'none');

       if (typeof parent.leftPos !='undefined') {

         moveObject(parent.document.getElementById('iFrameContainer'),parent.leftPos);

       }

       else {

         moveObject(parent.document.getElementById('iFrameContainer'),0);

       }

       setVisibility(parent.document.getElementById('iFrameContainer'),1);



    }

  }

}

function openMenuOver(menuID) {

  if ((menuOpen) && (menuOpen != menuID)){

    openMenu(menuID)

  }

}

function highlightMainNavigation(){

  if(parent.name=='frameContent'){

    var links=buildLinkList();

    var evaluatedLinks = evaluateHighlighting(parent.location.href,links);

    var highlightedIndex=-1;

    var bestmatch=999;

    for(i=0;i < evaluatedLinks.length;i++){

      if(evaluatedLinks[i] < bestmatch) {

        bestmatch=evaluatedLinks[i];

        highlightedIndex=i;

        if(evaluatedLinks[i]==-2) {

          break;

        }

      }

    }

    if(highlightedIndex!=-1){

      document.getElementsByTagName('a')[highlightedIndex].className='mainNaviHighlight';

      if(document.getElementsByTagName('a')[highlightedIndex].getAttribute('navParent')){

        setClassName(document.getElementsByTagName('a')[highlightedIndex].getAttribute('navParent'),'mainNaviHighlight');

      }

      if(document.getElementsByTagName('a')[highlightedIndex].getAttribute('navHeader')){

        setClassName(document.getElementsByTagName('a')[highlightedIndex].getAttribute('navHeader'),'mainNaviHighlight');

        if (document.getElementsByTagName('a')[highlightedIndex+1]) {

          document.getElementsByTagName('a')[highlightedIndex+1].className='mainNaviHighlight';

        }

      }

    }

  }

}

function positionLayers() {

  var layerList = new Array();

      layerList = new Array('bmw1series','bmw3series','bmw5series','bmw6series','bmw7series','bmwx3','bmwx5','bmwz4','bmwmseries');

  var layerList2 = new Array();

      layerList2 = new Array('bmwusedvehicle','bmwowner','bmwinsights');

  for(i=0;i < layerList.length;i++){

    if (document.getElementById(layerList[i])) {

      readLeft = getDivInformation(layerList[i],'offsetLeft');

      moveObject(layerList[i],readLeft+24,49);

    }

  }

  for(i=0;i < layerList2.length;i++){

    if (document.getElementById(layerList2[i])) {

      readLeft2 = getDivInformation(layerList2[0],'offsetLeft');

      moveObject(layerList2[i],readLeft2+24,49);

    }

  }

}

//----------------------------------------------

//  Module Navigation

//----------------------------------------------

var oldOne = '';

var oldSubOne = '';

var ulHeight = undefined;

var naviSummaryHeight = 100;

checkClient();

var myTabIndex = 1000;

function writeModuleNavigation(){

  ulHeight = (naviSummaryHeight);

  var contentUrl=getServerRelativeContentUrl();

  writeContent  = '<div id="navigation">';

  writeContent += '  <ul>';

  for (i = 0; i < moduleLink.length; i++) {

    if (i==moduleLink.length-1) {

      writeContent += '    <li style="border-bottom:1px solid #ffffff;">';

    } else {

      writeContent += '    <li>';

    }

    writeContent += '      <div id="div'+i+'ScrollParent" style="position:relative; left:0px; top:0px; width:191px; height:'+ulHeight+'%; overflow:hidden;display:block;">';

    writeContent += '        <div id="div'+i+'ScrollControl" style="position:absolute; right:0px;  top:0px;  width:12px;  height:'+ulHeight+'%;  visibility:hidden; background-image: url('+backgroundGif+');">';

    writeContent += '          <div style="position:absolute;top:'+(ulHeight/2-8)+'%">';

    writeContent += '           <div style="position:absolute;top:0"><a href="javascript:stop();" onMouseDown="up(2,'+i+');" onMouseUp="stop();" onFocus="this.blur();"><img src="'+scrollerUpGif+'"   width="12" height="12" border="0" id="ScrollerArrowUp"></a></div>';

    writeContent += '           <div style="position:absolute;top:12"><a href="javascript:stop();" onMouseDown="down(2,'+i+');" onMouseUp="stop();"  onFocus="this.blur();"><img src="'+scrollerDownGif+'" width="12" height="11" border="0" id="ScrollerArrowDown"></a></div>';

    writeContent += '         </div>';

    writeContent += '        </div>';

    writeContent += '        <div id="div'+i+'ScrollChild" onclick="getLastHeight(this,'+i+');" style="position:absolute; left:0px; top:0px; width:176px; visibility:inherit;">';

    if (moduleLink[i][0][0][1] != '') {

      writeContent += '          <a href="'+moduleLink[i][0][0][1]+'"  id="link'+i+'" onclick="blockFolding();">';

    } else if (moduleLink[i][1]) {

      writeContent += '          <a href="javascript:setBlock(\''+i+'\');"  id="link'+i+'">';

    } else {

      writeContent += '          <a href="javascript://"  id="link'+i+'">';

    }

    writeContent +=              moduleLink[i][0][0][0]+'<br><span id="copyLink'+i+'" style="-line-height:13px;">'+moduleLink[i][0][0][2]+'</span>';

    writeContent += '          </a>';

    writeContent += '          <ul id="ulId'+i+'">';

    for (j = 1; j < moduleLink[i].length; j++) {

      if (moduleLink[i][j][0][2] != '') {

        writeContent += '            <li class="firstData">'+moduleLink[i][j][0][2]+'</li>';

      }

      if (j==1) {

       liClass =   ' class="firstData"';

      } else {

       liClass =   '';

      }

      writeContent += '            <li'+liClass+'>';

      if (moduleLink[i][j][0][1] != '') {

        writeContent += '              <a href="'+moduleLink[i][j][0][1]+'"  id="link'+i+'-'+j+'" onclick="blockFolding();">'+moduleLink[i][j][0][0]+'</a>';

      } else if (moduleLink[i][j][1]) {

        writeContent += '              <a href="javascript:setSubBlock(\''+i+'-'+j+'\');"  id="link'+i+'-'+j+'">'+moduleLink[i][j][0][0]+'</a>';

      } else {

        writeContent += '              <a href="javascript://" id="link'+i+'-'+j+'"  onclick="blockFolding();">'+moduleLink[i][j][0][0]+'</a>';

      }

      if (moduleLink[i][j][1]) {

        writeContent += '              <ul id="ulId'+i+'-'+j+'" style="display:none;">';

      }

      for (k = 1; k < moduleLink[i][j].length; k++) {

        if (moduleLink[i][j][k][2] == 'newGroup'){

          liSubClass = ' class="newGroup"';

        } else {

          liSubClass = '';

        }

        writeContent +=   '              <li'+liSubClass+'><a href="'+moduleLink[i][j][k][1]+'"  id="link'+i+'-'+j+'-'+k+'" onclick="blockFolding();">'+moduleLink[i][j][k][0]+'</a></li>';

      }

      if (moduleLink[i][j][1]) {

        writeContent += '              </ul>';

      }

      writeContent += '            </li>';

    }

    writeContent += '          </ul>';

    writeContent += '        </div>';

    writeContent += '      </div>';

    writeContent += '    </li>';

  }

  writeContent += '    </ul>';

  writeContent += '    <div id="buttonClose"><a href="javascript:moveMenu();" ><img src="'+dropperGif+'" alt="" onMouseOver="swap_over();" onMouseOut="swap_out();"><img src="'+up_ico[0]+'" id="aim" name="aim" onMouseOver="swap_over();" onMouseOut="swap_out();"></a></div>';

  writeContent += '  </div>';

  writeIntoLayer('naviClipArea',writeContent);

  //alert("Hello aim");

}

function swap_over(){	

	if(aim.src==up_ico[0]){

		aim.src=up_ico[1];

	}

	if(aim.src==down_ico[0]){

		aim.src=down_ico[1];

	}

}

function swap_out(){	

	if(aim.src==up_ico[1]){

		aim.src=up_ico[0];

	}

	if(aim.src==down_ico[1]){

		aim.src=down_ico[0];

	}	

}



var currentChildObj;

var currentChildObjIndexm;

function getLastHeight(obj,nr) {

  currentChildObj = obj;

  currentChildObjIndex = nr;

}

var modulNaviOpen = true;

function moveMenu () {

  navHeight = getDivInformation('navigation','height');

  newSpeed = 20;

  if (typeof getDivInformation('navigation', 'offsetTop') != 'undefined' && getDivInformation('navigation', 'offsetTop') < 0) {

    openNaviEvent();

    modulNaviOpen = true;

	//======== open menu =======

	aim.src=up_ico[0];

  } else {

    setTimeout("closeNaviEvent()",200);

    setTimeout("modulNaviOpen = false",200);

	//======== close menu =======

	aim.src=down_ico[0];

  }

  if (navHeight >= naviSummaryHeight-9) {

    newSpeed = 40;

  }

  if (browserId != 'MSIE' && modulNaviOverImage == true) {

    newSpeed = 100;

  }

  moveObject('navigation','',14-navHeight,newSpeed,1);

}

function closeModulNavi () {

  if (currentPositions['navigation'][1] != 0) {

    moveMenu();

    modulNaviOpen = false;

  }

}

function openModulNavi () {

  if (currentPositions['navigation'][1] == 0) {

    moveMenu();

    modulNaviOpen = true;

  }

}

function openNaviEvent() {

  ;

}

function closeNaviEvent() {

  ;

}

// - - - - - SCROLLER - - - - - - //

function up(setspeed,n) {

  divNum = n;

  speed = setspeed;

  eval(stop());

  if (getDivInformation('div'+n+'ScrollChild','offsetTop') < 0) {

    moveObject('div'+n+'ScrollChild','',(getDivInformation('div'+n+'ScrollChild','offsetTop') + setspeed));

  }

  goup = setTimeout("up(speed,divNum)", 1);

}

function down(setspeed,n) {

  divNum = n;

  speed = setspeed;

  eval(stop());

  if (getDivInformation('div'+n+'ScrollChild','offsetTop') > - getDivInformation('div'+n+'ScrollChild','height') + getDivInformation('div'+n+'ScrollParent','height')) {

    moveObject('div'+n+'ScrollChild','',(getDivInformation('div'+n+'ScrollChild','offsetTop') - setspeed));

  }

  godown = setTimeout("down(speed,divNum)", 1);

}

function stop() {

  if (goup) {

    clearTimeout(goup);

  }

  if (godown) {

    clearTimeout(godown);

  }

}

function initScroller() {

  for (var i=0; i < initScroller.arguments.length; i++) {

    parentLayerName = initScroller.arguments[i] + "ScrollParent";

    childLayerName  = initScroller.arguments[i] + "ScrollChild";

    if(getDivInformation(initScroller.arguments[i] + 'ScrollChild','height') > getDivInformation(initScroller.arguments[i] + 'ScrollParent','height')) {

      setVisibility(initScroller.arguments[i]+"ScrollControl",1);

      moveObject('navigation','',1,'',1);

      moveObject('navigation','',1,'',1);

    } else {

      setVisibility(initScroller.arguments[i]+"ScrollControl",0);

    }

  }

}

// - - - - - //SCROLLER - - - - - - //

var tempBlockNum = '';

var tempBlockSubNum = '';

var currentMatch = null;

var currentIndex;

if (typeof modulnavHeightTeasermode == 'undefined') {

//  var modulnavHeightTeasermode = 274;
  var modulnavHeightTeasermode = 320;

}

function setBlock(numb) {

//numb=1500;

  tempBlockNum = numb;

  if(oldOne != numb) {

    if (oldOne != '') {

      setVisibility('div'+oldOne+'ScrollControl',0);

      setVisibility('ulId'+oldOne,null,'none');

      moveObject('div'+oldOne+'ScrollChild',0,0);

    }

    for (i = 0; i < moduleLink.length; i++) {

      setVisibility('copyLink'+i,null,'none');

      if(document.getElementById('div'+i+'ScrollParent')){

        resizeLayer('navigation', null,434);

        resizeLayer('div'+i+'ScrollParent', null, getDivInformation('link'+i,'height'));

      }

      if (moduleLink[numb][1]){

        if(typeof currentChildObj == 'undefined') {

          currentChildObj = document.getElementsByTagName('div')['div'+numb+'ScrollParent'];

        }

        if (typeof currentChildObjIndex == 'undefined'){

          currentChildObjIndex = numb;

        }

        var newModulheight = 0;

        var modulheightRest = 0;

        for (a = 0; a < moduleLink.length; a++) {

          if (typeof eval(document.getElementsByTagName('div')['div'+a+'ScrollParent']) == 'object' && a != currentChildObjIndex && (getDivInformation(eval(document.getElementsByTagName('div')['div'+a+'ScrollParent']),'height') < 100)) {

            if (browserId == 'MSIE') {

              modulheightRest += getDivInformation(eval(document.getElementsByTagName('div')['div'+a+'ScrollParent']),'height') + 11;

            } else {

              modulheightRest += getDivInformation(eval(document.getElementsByTagName('div')['div'+a+'ScrollParent']),'height') + 10;

            }

          }

        }

        newModulheight = getDivInformation(currentChildObj,'height');

        if (browserId == 'MSIE') {

          resizeLayer('div'+numb+'ScrollParent', null, 440 - (modulheightRest + 24));

        } else {

          resizeLayer('div'+numb+'ScrollParent', null, 440 - (modulheightRest + 24));

        }

      }

    }

    setVisibility('ulId'+numb,null,'block');

    oldOne = numb;

    initScroller('div'+numb);

  } else {

    for (i = 0; i < moduleLink.length; i++) {

      if (typeof moduleLink[currentIndex] != 'undefined' && moduleLink[currentIndex][0][0][3] == true) {

        setVisibility('copyLink'+i,null,'block');

      }

      if (browserId == 'MSIE') {

        if (i == currentIndex) {

          resizeLayer('div'+i+'ScrollParent', null, 13);

        } else {

          resizeLayer('div'+i+'ScrollParent', null, getDivInformation('div'+i+'ScrollChild','height')+1);

        }

        resizeLayer('navigation', null, modulnavHeightTeasermode);

      } else {

        if (i == currentIndex && moduleLink[currentIndex][0][0][3]==true) {

          resizeLayer('div'+i+'ScrollParent', null, getDivInformation('div'+i+'ScrollChild','height'));

        } else if (i == currentIndex){

          resizeLayer('div'+i+'ScrollParent', null, getDivInformation('div'+i+'ScrollChild','height')+2);

        } else {

          resizeLayer('div'+i+'ScrollParent', null, getDivInformation('div'+i+'ScrollChild','height')+2);

        }

        resizeLayer('navigation', null,modulnavHeightTeasermode -3);

      }

    }

    if(oldOne!='') {

    	setVisibility('ulId'+oldOne,null,'none');

      if (browserId == 'MSIE') {

        resizeLayer('div'+oldOne+'ScrollParent', null, getDivInformation('div'+oldOne+'ScrollChild','height')+1);

      } else {

        resizeLayer('div'+oldOne+'ScrollParent', null, getDivInformation('div'+oldOne+'ScrollChild','height')+2);

      }

      initScroller('div'+oldOne);

    }

    oldOne = '';

  }

}

function setSubBlock(subNumb) {

  tempBlockSubNum = subNumb;

  if(oldSubOne != subNumb) {

    if (oldSubOne != '') {

      if (document.getElementById('ulId'+oldSubOne)){

        setVisibility('ulId'+oldSubOne,null,'none');

      }

    }

    if (document.getElementById('ulId'+subNumb)){

      setVisibility('ulId'+subNumb,null,'block');

    }

    oldSubOne = subNumb;

    subNumb = subNumb.split('-')[0];

    initScroller('div'+subNumb);

  } else {

    setVisibility('ulId'+subNumb,null,'block');

    setVisibility('div'+oldOne+'ScrollControl',0);

    moveObject('div'+oldOne+'ScrollChild',0,0);

    setVisibility('ulId'+oldSubOne,null,'none');

    oldSubOne = oldSubOne.split('-')[0];

    initScroller('div'+oldSubOne);

    oldSubOne = '';

  }

}

var controlBlockNum = -99;

var controlSubBlockNum = -99;

function setModuleNavigationState(displayFolded){

  var contentLinkFull=getServerRelativeContentUrl();

  var navLinks = new Array();

  for (l = 0; l < moduleLink.length; l++) {

    for (m = 0; m < moduleLink[l].length; m++) {

      for (n = 0; n < moduleLink[l][m].length; n++) {

        navLinks.push(moduleLink[l][m][n][1]);

      }

    }

  }

  var evaluatedLinks = evaluateHighlighting(contentLinkFull, navLinks);

  var c=0;

  var bestmatch=999;

  var highlightedIndex = new Array(3);

  for (l = 0; l < moduleLink.length; l++) {

    for (m = 0; m < moduleLink[l].length; m++) {

      for (n = 0; n < moduleLink[l][m].length; n++) {

        if(evaluatedLinks[c] < bestmatch) {

          bestmatch=evaluatedLinks[c];

          highlightedIndex[0]=l;

          highlightedIndex[1]=m;

          highlightedIndex[2]=n;

        }

        if(bestmatch==-2) {

          break;

        }

        c++;

      }

      if(bestmatch==-2) {

        break;

      }

    }

    if(bestmatch==-2) {

      break;

    }

  }

  if(bestmatch!=999){

    currentMatch = moduleLink[highlightedIndex[0]][highlightedIndex[1]][highlightedIndex[2]][1];

    currentIndex = highlightedIndex[0];

    if (   moduleLink[highlightedIndex[0]][highlightedIndex[1]][highlightedIndex[2]] == moduleLink[highlightedIndex[0]][0][0]

      && !moduleLink[highlightedIndex[0]][1]

      && moduleLink[highlightedIndex[0]][highlightedIndex[1]][highlightedIndex[2]][3] == true) {

      setBlock('');

      setColor('link'+highlightedIndex[0],'#003399');

    } else {

      setBlock(''+highlightedIndex[0]);

      setColor('link'+highlightedIndex[0],'#003399');

      if (highlightedIndex[1] !=0) {

        setSubBlock(highlightedIndex[0]+'-'+highlightedIndex[1]);

        setColor('link'+highlightedIndex[0]+'-'+highlightedIndex[1],'#003399');

        if (highlightedIndex[2] !=0) {

          setColor('link'+highlightedIndex[0]+'-'+highlightedIndex[1]+'-'+highlightedIndex[2],'#003399');

        }

      }

    }

  } else {

    setBlock('0');

  }

  if(displayFolded){

    moveMenu();

  }

}

function initialiseModuleNavigation(displayFolded){

  if(!arrayPrepared){



    for (l = 0; l < moduleLink.length; l++) {

      for (m = 0; m < moduleLink[l].length; m++) {

        for (n = 0; n < moduleLink[l][m].length; n++) {

          moduleLink[l][m][n][1]	= buildValidServerRelativeUrl(moduleLink[l][m][n][1]);

        }

      }

    }

    arrayPrepared=true;

  }

  tempDisplayFolded = displayFolded;

  setModuleHeader(moduleNavigationDisplayed);

  if(moduleNavigationDisplayed){

    writeModuleNavigation();

    setModuleNavigationState(displayFolded);

  }

}

function getServerRelativeContentUrl(){

  var contentPage=self.location.href;

  var substract=self.location.host;

  return contentPage.substring(contentPage.indexOf(substract)+substract.length,contentPage.length);

}

var foldBack = false;

var noFolding = false;

var tempDisplayFolded, isFolding;

var isActiveFolding = true;

var arrayPrepared=false;

function blockFolding(){

  noFolding = true;

}

function moduleNaviReset(){

  if (foldBack == true && isActiveFolding == true && noFolding == false && modulNaviOpen == true) {

    if ((controlBlockNum != tempBlockNum) || (controlSubBlockNum != tempBlockSubNum)) {

      oldOne = '';

      oldSubOne = '';

      controlBlockNum = tempBlockNum;

      controlSubBlockNum = tempBlockSubNum;

      initialiseModuleNavigation(false);

    }

    clearTimeout(isFolding);

    isActiveFolding = false;

  } else {

    clearTimeout(isFolding);

    isActiveFolding = true;

  }

}

