var e; var intPos; var blnPXMessageShown=false; var blnMouseDown=false; var blnButtonClick=false;
var intMouseInDiv; var intDivHeight; var intScrollBarHeight; var intMaxDivTop; var intDocHeight; var intScrollRatio; var intTotalMove=parseFloat(0);
window.onresize = scrollEvent;
window.onscroll = scrollEvent;
window.onload = winInit;

function goToPage(strPage) {
  document.getElementById('divScrollBlock').style.top='22px';
  var objIFrame = document.getElementById('frameMain');
  if (objIFrame) {
    objIFrame.src=strPage;
    objIFrame.contentWindow.focus();
  }
}
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return [ scrOfY ];
}
function getSizeY() {
  var myHeight = 0;
  if( typeof( window.innerHeight ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return [ myHeight ];
}
function getSizeX() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return [ myWidth ];
}
function scrollEvent() {
  var intY = getScrollXY();
  var intY2 = getSizeY();
  var intPo =	(parseFloat(intY)+parseFloat(intY2)-25);
  if (document.getElementById('tableBottom')){document.getElementById('tableBottom').style.top=intPo+'px';}
  if (document.getElementById('frameMain')){document.getElementById('frameMain').style.height=parseFloat(intPo-150)+'px';}
  if (document.getElementById('divScrollBar')){document.getElementById('divScrollBar').style.height=parseFloat(intPo-150)+'px';}
  if (document.getElementById('divScrollBlock')){document.getElementById('divScrollBlock').style.top='22px';}
  screenWidth();
  blockHeight();
  document.getElementById('frameMain').contentWindow.window.scrollBy(0,-100000);
}
function winInit() {
  scrollEvent();
}
function mouseDown() {
  intMouseInDiv=parseFloat(e.clientY-parseFloat(document.getElementById('divScrollBlock').style.top));
  intDivHeight=parseFloat(document.getElementById('divScrollBlock').style.height);
  intScrollBarHeight=parseFloat(document.getElementById('divScrollBar').style.height);
  intMaxDivTop=parseFloat(intScrollBarHeight - intDivHeight);
    //alert(parseFloat(document.getElementById('frameMain').contentWindow.document.documentElement.scrollTop));
  blnMouseDown=true;
}
function mouseUp() {
  blnMouseDown=false;
}
function scroll() {
  var intMouseY = e.clientY;
  var intBlockNewTop = parseFloat(intMouseY-intMouseInDiv);
    scrollTo(intBlockNewTop);
}
function clickButtonScroll(intDirectionTo) {
  intDivHeight=parseFloat(document.getElementById('divScrollBlock').style.height);
  intScrollBarHeight=parseFloat(document.getElementById('divScrollBar').style.height);              //44
  intMaxDivTop=parseFloat(intScrollBarHeight - intDivHeight);
  var intMousePos = e.clientY;
  var intBlockPos = parseFloat(document.getElementById('divScrollBlock').style.top);
  var intBlockHeightMove = parseFloat(document.getElementById('divScrollBlock').style.height);
  blnMouseDown=true;
  scrollTo(parseFloat(intBlockPos+((intDirectionTo/intScrollRatio)*50)));
  blnMouseDown=false;
}
function clickScroll() {
  if (blnButtonClick==false) {
    intDivHeight=parseFloat(document.getElementById('divScrollBlock').style.height);
    intScrollBarHeight=parseFloat(document.getElementById('divScrollBar').style.height);              //44
    intMaxDivTop=parseFloat(intScrollBarHeight - intDivHeight);
    var intMousePos = e.clientY;
    var intBlockPos = parseFloat(document.getElementById('divScrollBlock').style.top);
    var intBlockHeightMove = parseFloat(document.getElementById('divScrollBlock').style.height);
    blnMouseDown=true;
    if (intMousePos<=(intBlockPos+156)) {
      scrollTo(parseFloat(intBlockPos-(intBlockHeightMove-3)));
    } else if (intMousePos>=(intBlockPos+intBlockHeightMove+160)) {
      scrollTo(parseFloat(intBlockPos+(intBlockHeightMove-3)));
    }
    blnMouseDown=false;
  }
  blnButtonClick=false;
}
function keyScroll(intKey) {
  intDivHeight=parseFloat(document.getElementById('divScrollBlock').style.height);
  intScrollBarHeight=parseFloat(document.getElementById('divScrollBar').style.height);
  intMaxDivTop=parseFloat(intScrollBarHeight - intDivHeight);
  var intBlockPos = parseFloat(document.getElementById('divScrollBlock').style.top);
  var intBlockHeightMove = parseFloat(document.getElementById('divScrollBlock').style.height);
  blnMouseDown=true;
  if (intKey==1) {
    scrollTo(parseFloat(intBlockPos-(intBlockHeightMove-3)));
  } else if (intKey==2) {
    scrollTo(parseFloat(intBlockPos+(intBlockHeightMove-3)));
  }
  blnMouseDown=false;
}
function mouseScroll(intDirectionTo) {
  intDivHeight=parseFloat(document.getElementById('divScrollBlock').style.height);
  intScrollBarHeight=parseFloat(document.getElementById('divScrollBar').style.height);
  intMaxDivTop=parseFloat(intScrollBarHeight - intDivHeight);
  var intBlockPos = parseFloat(document.getElementById('divScrollBlock').style.top);
  //var intBlockHeightMove = parseFloat(document.getElementById('divScrollBlock').style.height);
  blnMouseDown=true;
  //alert(intScrollRatio);
  scrollTo(parseFloat(intBlockPos-(intDirectionTo/intScrollRatio)));
  blnMouseDown=false;
}
function scrollTo(intTo) {
  if (!(intTo>=0 || intTo<=0)) { blnMouseDown=false;}
  if (blnMouseDown==true) {
    var intBlockNewTop = parseFloat(intTo);
    if (intBlockNewTop<=22) {
      intBlockNewTop=22;
    } 
    if (parseFloat(intBlockNewTop)>=parseFloat(intMaxDivTop-29)) {
      intBlockNewTop=parseFloat(intMaxDivTop-29);
    }
    document.getElementById('divScrollBlock').style.top=intBlockNewTop+'px';
    var intDocNewTop=parseFloat((intBlockNewTop-22)*intScrollRatio);
    if (document.getElementById('frameMain').contentWindow.window.pageYOffset) {
      var intDocCurPos=parseFloat(document.getElementById('frameMain').contentWindow.window.pageYOffset);
    } else if (1==1) {
      var intDocCurPos=parseFloat(document.getElementById('frameMain').contentWindow.document.documentElement.scrollTop);
    }
    var intScroolBy = parseFloat(intDocNewTop-intDocCurPos);
    document.getElementById('frameMain').contentWindow.window.scrollBy(0,intScroolBy);
  }
}
function blockHeight() {
  var objFrameMain = document.getElementById('frameMain').contentWindow;
  if (objFrameMain) {
    if (objFrameMain.document.height) {
      intDocHeight=parseFloat(objFrameMain.document.height);
    } else {
      intDocHeight=parseFloat(objFrameMain.document.body.clientHeight);//documentElement.scrollTop);
    }
    if (document.getElementById('divScrollBlock')){
      var intFrameHeight = parseFloat(document.getElementById('frameMain').style.height);
      if (intFrameHeight<=intDocHeight) {
        document.getElementById('divScrollBar').style.display='block';
      } else {
        document.getElementById('divScrollBar').style.display='none';
      }
      var intBlockHeight = parseFloat((intFrameHeight-50)/(intDocHeight/intFrameHeight));
      document.getElementById('divScrollBlock').style.height=intBlockHeight+'px';
      document.getElementById('divScrollBlock').style.backgroundPosition='0px '+parseFloat(intBlockHeight/2-17)+'px';
      intScrollRatio=parseFloat(intDocHeight / (intFrameHeight-50)); // het kan zijn dat hier nog -40 bij moet
    }
    blockTop();
  }
}
function blockTop() {
  var objFrameMain = document.getElementById('frameMain').contentWindow;
  if (objFrameMain) {
    var ScrollTop = objFrameMain.document.body.scrollTop;
    if (ScrollTop == 0) {
      if (objFrameMain.window.pageYOffset) {
        ScrollTop = objFrameMain.window.pageYOffset;
      } else {
        ScrollTop = (objFrameMain.document.body.parentElement) ? objFrameMain.document.body.parentElement.scrollTop : 0;
      }
    }
    if (ScrollTop<=0) { ScrollTop=0; }
    blnMouseDown=true;
    var intBlockTop = parseFloat(ScrollTop / intScrollRatio);
    scrollTo(intBlockTop+22);
    blnMouseDown=true;
  }
}
function MenuItemOver(objTD) {
  objTD.className='MenuItemOver';
}
function MenuItemOut(objTD) {
  objTD.className='MenuItem';
}
function screenWidth() {
  var blnNormal=(getSizeX()>=1000);
  if (blnNormal==false){
    var intSpacePixels = 0;
    document.getElementById('TopText').className='TopTextSmall';
    document.getElementById('MenuBar').className='MenuBarSmall';
    document.getElementById('MainRight').style.width=parseFloat(intSpacePixels)+20+'px';
    document.getElementById('BottomBar').className='BottomRowSmall';
  } else {
    var intSpacePixels = 100;
    document.getElementById('TopText').className='TopText';
    document.getElementById('MenuBar').className='MenuBar';
    document.getElementById('BottomBar').className='BottomRow';
    document.getElementById('MainRight').style.width=intSpacePixels+'px';
  }
  document.getElementById('TopSpaceLeft').style.width=intSpacePixels+'px';
  document.getElementById('TopSpaceRight').style.width=intSpacePixels+'px';
  document.getElementById('MenuLineLeft').style.width=intSpacePixels+'px';
  document.getElementById('MenuLineRight').style.width=intSpacePixels+'px';
  document.getElementById('MenuLeft').style.width=intSpacePixels+'px';
  document.getElementById('MenuRight').style.width=intSpacePixels+'px';
  document.getElementById('MainLeft').style.width=intSpacePixels+'px';
  if (getSizeX()<800) {
    var strAgent = navigator.userAgent;
    if (strAgent.match('MSIE')=='MSIE') {
      if (blnPXMessageShown==false) {
        alert('Voor de opmaak van deze site, dient u browser een minimale resolutie van 800 pixels breed te hebben.\n\nU wordt geadviseerd om de browser te maximaliseren.');
        blnPXMessageShown= true;
      }
    } else {
      window.resizeTo(825,window.outerHeight);
    }
  }
}

