GetMouse = function(e)
{
    var posx = 0;
    var posy = 0;
    if (!e) var e = window.event;
    
    if (e.pageX || e.pageY){
        posx = e.pageX;
        posy = e.pageY;
    }
    else if (e.clientX || e.clientY){
        posx = e.clientX + document.body.scrollLeft;
        posy = e.clientY + document.body.scrollTop;
    }
   
    var o = new Object()
    o.x = posx;
    o.y = posy;
   
    return o;
}
popHelp = function(doc)  
{ 	
    win=window.open(doc,'_blank','width=400,height=450,resizable=0,scrollbars=1,menubar=0');
}

submitOnEnter = function(e)
{
    var keycode;
    
    if (window.event) 
        keycode = window.event.keyCode;
    else if (e) 
        keycode = e.which;
    else 
        return true;
    
    if (keycode == 13)
    {
    	popUp();
    	return false;
    }
    else
	    return true;
}

window.onload = function()
{

  
            
    if(document.getElementById('TheRightCalander') && document.getElementById('TheLeftCalander'))
    {
        var leftCalander = document.getElementById('TheLeftCalander');
        var rightCalander = document.getElementById('TheRightCalander');
        
        var showLeftCalander = document.getElementById('ShowLeftCalander');
        var showRightCalander = document.getElementById('ShowRightCalander');
        
        showLeftCalander.onclick = function(event)
        {
            var mouse = GetMouse(event);
            
            leftCalander.style.display = 'block';
            leftCalander.style.position = 'absolute';
            
            leftCalander.style.left = mouse.x + 'px';
            leftCalander.style.top = mouse.y + 'px';
            if (document.forms[0].fromCalendarX != null)
            {
                document.forms[0].fromCalendarX.value = leftCalander.style.left;
                document.forms[0].fromCalendarY.value = leftCalander.style.top;
            }
        }
        
        showRightCalander.onclick = function(event)
        {
            var mouse = GetMouse(event);
            
            rightCalander.style.display = 'block';
            rightCalander.style.position = 'absolute';
            
            rightCalander.style.left = mouse.x + 'px';
            rightCalander.style.top = mouse.y + 'px';
            if (document.forms[0].toCalendarX != null)
            {
                document.forms[0].toCalendarX.value = rightCalander.style.left;
                document.forms[0].toCalendarY.value = rightCalander.style.top;
            }
        }   
    }
};

var WindowSize = 
{
    width : function() 
    {
        return this.f_filterResults (
            window.innerWidth ? window.innerWidth : 0,
            document.documentElement ? document.documentElement.clientWidth : 0,
            document.body ? document.body.clientWidth : 0
        );
    },
    
    height : function() 
    {
        return this.f_filterResults (
            window.innerHeight ? window.innerHeight : 0,
            document.documentElement ? document.documentElement.clientHeight : 0,
            document.body ? document.body.clientHeight : 0
        );
    },
    
    f_filterResults : function(n_win, n_docel, n_body) 
    {
        var n_result = n_win ? n_win : 0;
        if (n_docel && (!n_result || (n_result > n_docel)))
            n_result = n_docel;
        return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
    }
}; 