var previousBox = '';

function initScroll( outerDiv , innerDiv ){

    var settings =  {
      width: 33,
      buttonUpHeight: 32,
      buttonDownHeight: 32,
      sliderTopHeight: 5,
      sliderBottomHeight: 5,
      baseImage: '/images/scrollbar/base.png',
      buttonUpImage: '/images/scrollbar/btup.png',
      buttonDownImage: '/images/scrollbar/btdown.png',
      sliderTopImage: '/images/scrollbar/slidertop.png',
      sliderMiddleImage: '/images/scrollbar/slidermiddle.png',
      sliderBottomImage: '/images/scrollbar/sliderbottom.png'
    };
 
 new Scrollbar(  $(outerDiv) , $(innerDiv) , settings );

}

function showContent ( el ) {
    var boxId = el.getAttribute('boxid');
    if( previousBox != '' && boxId != previousBox) {
        var prevBox = $('content' + previousBox);
        prevBox.setStyle({'display' : 'none'});
    }
    var currentBox = $('content' + boxId);
    if ( currentBox.getStyle('display') == "none" ) {
       currentBox.setStyle({'display' : 'block'});
       previousBox = boxId;
       if( el.getAttribute('scrolled') == 'no' ){
           initScroll( 'contentText' + boxId , 'text' + boxId );
           el.writeAttribute({'scrolled':'yes'});
        }
    } else {
       currentBox.setStyle({'display' : 'none'});
    }
}

function closeContent ( el ) {
    var boxId = el.getAttribute('boxid');
    var currentBox = $('content' + boxId);
    currentBox.setStyle({'display' : 'none'});
    previousBox = '';
}

function removeText() {
  var searchBar = $('searchbox');
  searchBar.value = '';
  searchBar.setStyle({'color' : '#000000'});
}

function setText() {
  var searchBar = $('searchbox');
  searchBar.value =  'Search..';
  searchBar.setStyle({'color' : '#a5adb1'});  
}

function formValidation(form){
if(form.searchbar.value.length==0){
alert("Er dient eerst een zoekterm te worden ingevuld");
return false;
}
form.searchbar.value="site:http://schaft.wp.donnie.lan.thefrontdoor.nl/sub"+form.q.value;
}

function setHeight() {
  
  var contentItem = $('leftTable');
  var itemHeight = contentItem.getHeight();
  var endHeight = itemHeight - 538;
  
  if ( endHeight < 0 ) {
    endHeight = 0;
  }
  $('growCell').style.height = endHeight + 'px';
 
  var menuContent = $('menucontent');
  var rightTableContent = $('subcontentright').innerHTML;
  
  if (menuContent.getHeight() < 414 && (rightTableContent == '' || rightTableContent.match( /^<br\/?>$/i )) ) {
    $('growCell').setStyle({'display' : 'none'});
    $('growCell2').setStyle({'display' : 'none'});
    $('contentRight').setStyle({'marginTop' : '0px'});
    $('contentRight').setStyle({'marginLeft' : '0px'});
  } else {
    $('growCell').style.height = endHeight + 'px';
  }
}






