﻿var documentHeight = 0;

function redirectPage() 
{
      var hiddenValue = document.getElementById('pageValue').value;
      window.location.href = hiddenValue;
      CancelLightBox();
}
function ShowLightBox(objCtl) 
{
    var lightBox = document.getElementById('light');
    var blackBox = document.getElementById('fade');
    documentHeight = document.documentElement.scrollHeight - 1;    
    blackBox.style.height = documentHeight + 'px';
    window.scrollTo(0, 0);
    lightBox.style.top = '100px';
    lightBox.style.display = 'block';
    blackBox.style.display = 'block';
    document.getElementById('pageValue').value = objCtl;
    scroll();
   
}
function CancelLightBox() {
    var lightBox = document.getElementById('light');
    var blackBox = document.getElementById('fade');
    lightBox.style.display = 'none';
    blackBox.style.display = 'none';
}


function scroll() {
    //adding the event listerner for Mozilla
    if (window.addEventListener)
        document.addEventListener('DOMMouseScroll', moveObject, false);

    //for IE/OPERA etc
    document.onmousewheel = moveObject;
}
function moveObject(event) {
    var lightBox = document.getElementById('light');
    //var documentHeightNew = document.documentElement.scrollHeight;
    var delta = 0;

    if (!event) event = window.event;

    // normalize the delta
    if (event.wheelDelta) {

        // IE & Opera
        delta = event.wheelDelta / 60;

    } else if (event.detail) {

        // W3C
        delta = -event.detail / 2;
    }

    var currPos = lightBox.offsetTop;

    //calculating the next position of the object
    currPos = parseInt(currPos) - (delta * 45);
   
    if (currPos < 100) {
        currPos = 100;
    }

    if (currPos > documentHeight-350) {
        currPos = documentHeight -350;
        return true;
    }
    
    //moving the position of the object
    lightBox.style.top = (currPos) + 'px';
    
}

    


