// JScript File
/********************************************************************/
//                          Show Modal Box                           /
/********************************************************************/
var scrollTop;

function revealModal(modalID, containerID, containerWidth)
{      
    scrollTop = document.body.scrollTop;
    
    document.getElementById(modalID).style.top = document.body.scrollTop;
    document.getElementById(modalID).style.display = "block";
    document.getElementById(modalID).style.visibility = "visible"; /*Added for VS designer Support*/
    document.getElementById(modalID).style.zIndex = "150"; /*Added for VS designer Support*/
    document.getElementById(modalID).style.overflow = "auto";
    document.getElementById(containerID).style.width = containerWidth + "px";
    document.getElementById(containerID).style.display = "block";
    document.getElementById(containerID).style.visiblility = "visible"; /*Added for VS designer Support*/
    document.getElementById(containerID).style.zIndex = "150"; /*Added for VS designer Support*/
    
    // Calculate position for modal
    var top = Math.ceil((getHeight() - document.getElementById(containerID).offsetHeight) / 2) + document.body.scrollTop;
    var left = Math.ceil((getWidth() - document.getElementById(containerID).offsetWidth) / 2);           

    document.getElementById(containerID).style.top = top + 'px';
    document.getElementById(containerID).style.left = left + 'px';
                
    document.body.style.overflow = "hidden";
    document.body.scrollTop = scrollTop;
}
        
/********************************************************************/
//                         Hide Modal Box                           /
/********************************************************************/
function hideModal(modalID, containerID)
{
    document.getElementById(modalID).style.display = "none";
    document.getElementById(containerID).style.display = "none";
                
    document.body.style.overflow = "auto";
    document.body.scrollTop = scrollTop;
}

function getWidth()
{
    var width = 0;
    
    if( typeof( window.innerWidth ) == 'number' ) 
    {
        //Non-IE
        width = window.innerWidth;
    } 
    else if( document.documentElement && ( document.documentElement.clientWidth ) ) 
    {
        //IE 6+ in 'standards compliant mode'
        width = document.documentElement.clientWidth;
    }
    else if( document.body && ( document.body.clientWidth ) ) 
    {
        //IE 4 compatible
        width = document.body.clientWidth;
    }
    
    return width;
}

function getHeight()
{
    var height = 0;
    
    if( typeof( window.innerWidth ) == 'number' ) 
    {
        //Non-IE
        height = window.innerHeight;
    } 
    else if( document.documentElement && ( document.documentElement.clientHeight ) ) 
    {
        //IE 6+ in 'standards compliant mode'
        height = document.documentElement.clientHeight;
    }
    else if( document.body && ( document.body.clientHeight ) ) 
    {
        //IE 4 compatible
        height = document.body.clientHeight;
    }
    
    return height;
}

/*Hide modal on ESC keypress*/
//<body onkeypress="return keycheck(event);">
function keycheck(event)
{
    if(event.keyCode==27)
     {
        hideModal('modalPage', 'assignmentModal');
        hideModal('modalPage', 'classModal');
        hideModal('modalPage', 'studentModal');
     }
}

