﻿// JScript File

function openDisclaimer()
{
    createLayer();
    createDiv("/Webpages/disclaimer.aspx",500,1000);
}

function openAbout()
{
    createLayer();
    createDiv("/Webpages/About.html",500,1300); 
}
function createDiv(strUrl,ht,wd)
{
    if(document.getElementById("footer_div"))
    {
        removeElement("footer_div");
    }
    var ObjDIV = document.createElement('div');
    ObjDIV.setAttribute('id','footer_div');
    
    ObjDIV.style.display = 'none';
    ObjDIV.style.position = 'absolute';
    ObjDIV.style.zIndex=2000;
    ObjDIV.style.width=wd+'px';
    ObjDIV.style.heigth=ht+'px';
    
    var top = posTop() + ((pageHeight() - ht) / 2);
    var left = posLeft() + ((pageWidth() - wd) / 2);
       
    ObjDIV.style.top=top+'px';
    ObjDIV.style.left=left+'px'; 
    
    var obody = document.getElementsByTagName('body')[0];
    obody.appendChild(ObjDIV);
    
    GetAjaxData(strUrl,populateFooterDiv); 
    document.onclick=closeFooterDiv;
    document.onkeypress=closeFooterDivOnEscape;
}

function populateFooterDiv(strData)
{
    document.getElementById("footer_div").innerHTML=strData;
    $("#footer_div").fadeIn("normal");
}

function closeFooterDiv(e) // This function will be called when user clicks somewhere else rather than close button
{
    var id;
    e = e ? e:window.event;
    
    if(e.target) // For firefox and other W3C compliant strict browsers
        id=e.target.id;
    else if(e.srcElement) // For IE
        id=e.srcElement.id;
  
    if(id=="overlay_img")
    {
       hideFooterDiv(); 
    }
}

function closeFooterDivOnEscape(e)
{
    var key;
    if (window.event) 
        {
            key = window.event.keyCode;
        }    
    else if (e) 
        {
            key = e.which;
        }    
    else 
        return;
    
    if(key == 27 || key==0) //That means escape key
    {
       // IE => 27
       // Mozilla (FireFox)=> 0       
       // Chrome => Does not call the keypress even when escape is pressed :( :(. So our this function will not work in chrome
       hideFooterDiv(); 
    }
}

function hideFooterDiv()
{
    $("#footer_div").fadeOut("normal",closeOverLay);
}
