﻿
//Get window size
function windowHeight() {
    var height = 0;
    if( typeof( window.innerHeight ) == '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 parseInt(height);
}

var calls = 0

//adjust footer
function AdjustFooter(evt)
{    
    var bodyHeight = Sys.UI.DomElement.getBounds(window.document.body).height ;
    var contentDiv =  Sys.UI.DomElement.getBounds($get('contentDiv')).height ;
    var missingHeight = windowHeight() - bodyHeight - 20;
    
    if(contentDiv > windowHeight() || (missingHeight < 0 && calls == 0) )
    return;
    
    //if(calls == 0) alert(windowHeight()  + " - " + bodyHeight + " = " + missingHeight  + " | " + contentDiv );
     if(calls < 1)
       {
            calls++;
       }
       else
       {
       //alert(windowHeight()  + " - " + bodyHeight + " = " + missingHeight  + " | " + contentDiv )
       // calls = 0;
       }
    
    
    
    if((contentDiv + missingHeight ) > 0)  
    {        
        //alert(windowHeight()  + " - " + bodyHeight + " = " + missingHeight)
        $get('contentDiv').style.height =  (contentDiv + missingHeight) + "px";
    }
} 

function disableContextMenu(element) {
    //alert('k');
    element.oncontextmenu = function() {
        return false;
    }
}


function onLoad(evnt)
{
    AdjustFooter(0);
    disableContextMenu(window);
}

function onUnload(evnt)
{
    try{
        Sys.UI.DomEvent.removeHandler(window, "resize", AdjustFooter);
    }catch(e){}
}


if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();