﻿// JScript File
//-----------------------------------------------------------------------------
// Author   : Vinay
// Date     : 17-Feb-2009
// Purpose  : This script is to show a pop-up Calender.
//-----------------------------------------------------------------------------
function OpenCal(obj)
{
    var imgbox=document.getElementById("imgbox");
    imgbox.style.visibility='visible';
    imgbox.style.left=(getElementLeft(obj)+5) +'px';
    imgbox.style.top=(getElementTop(obj)+15) + 'px';
}  
function OpenAgreement(obj)
{
    var imgbox=document.getElementById("imgbox");
    imgbox.style.visibility='visible';
    imgbox.style.left=(getElementLeft(obj)+5) +'px';
    imgbox.style.top=(getElementTop(obj)-400) + 'px';
}
function OpenPackages(obj)
{
    var imgbox=document.getElementById("pHelpbox");
    imgbox.style.visibility='visible';
    imgbox.style.left=(getElementLeft(obj)+5) +'px';
    imgbox.style.top=(getElementTop(obj)+15) + 'px';
    return false;
}
function OpenSubscription(obj)
{
    var imgbox=document.getElementById("sHelpbox");
    imgbox.style.visibility='visible';
    imgbox.style.left=(getElementLeft(obj)+5) +'px';
    imgbox.style.top=(getElementTop(obj)+15) + 'px';
    return false;
}
function Close(obj)
{
    document.getElementById(obj).style.visibility='hidden';
    return false;
}
function Out()
{
    document.getElementById("imgbox").style.visibility='hidden';
    return false;
}
function CloseCal()
{
    document.getElementById("imgbox").style.visibility='hidden';
    return true;
}

function getElementLeft(elm) 
{
    var x = 0;

    //set x to elm’s offsetLeft
    x = elm.offsetLeft;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
     {
        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
     }
     
     return x;
}

function getElementTop(elm) 
{
    var y = 0;

    //set x to elm’s offsetLeft
    y = elm.offsetTop;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
     {
        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
     }
     
     return y;
}
