﻿var popup;
function ShowCal(e, inputName, divName)
{
    if (!e)
        e = window.event;
    if (!popup)
        popup = new RadCalendar.Popup();

        
    var inputBox = document.getElementById(inputName);
    var x = PositionX(inputBox);
    var y = PositionY(inputBox) + inputBox.offsetHeight;
    popup.Show(x, y, document.getElementById(divName));
    if (e)
    {
        e.cancelBubble = true;
        if (e.preventDefault) e.preventDefault();
    }
}

function HideCal()
{
    if (popup && popup.IsVisible())
    {
        popup.Hide();
    }
}
    
function PositionX(inputElement) 
{
    var offsetLeft = 0;
    if (inputElement.offsetParent)
    {
        while (inputElement.offsetParent)
        {
            offsetLeft += inputElement.offsetLeft;
            inputElement = inputElement.offsetParent;
        }
    }
    else if (inputElement.x)
    {
        offsetLeft += inputElement.x;
    }
    return offsetLeft;
}
function PositionY(inputElement) 
{
    var offsetTop = 0;
    if (inputElement.offsetParent)
    {
        while (inputElement.offsetParent)
        {
            offsetTop += inputElement.offsetTop;
            inputElement = inputElement.offsetParent;
        }
    }
    else if (inputElement.y)
    {
        offsetTop += inputElement.y;
    }
    return offsetTop;
}

function onDateClick(renderDay)
{     
    HideCal();    
}
