﻿function addLoadEvent(func) 
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function') 
		window.onload = func;
	else 
	{
		window.onload = function() {
			if (oldonload) 
			{
				oldonload();
			}
			func();
		}
	}
}

function addScrollEvent(func) 
{
	var oldonscroll = window.onscroll;
	if (typeof window.onscroll != 'function') 
		window.onscroll = func;
	else 
	{
		window.onscroll = function() {
			if (oldonscroll) 
			{
				oldonscroll();
			}
			func();
		}
	}
}


var linkbuttonID;
function enterTriggers(lb, e)
{
	if (!e)
		e = window.event;
	if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13))
	{
		if (window.__doPostBack)
		{
		    linkbuttonID = lb;
		    if (window.WebForm_DoPostBackWithOptions && window.WebForm_PostBackOptions)
			    setTimeout("WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(linkbuttonID, '', true, '', '', false, true));", 50);
			else
			    setTimeout("__doPostBack(linkbuttonID, '');", 50);
		}
		return false;
	}
	else
		return true; 
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
	{
	    while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
	}
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function clearChildNodes(node) 
{
    if (node && node.hasChildNodes && node.removeChild) 
        while (node.hasChildNodes()) 
            node.removeChild(node.firstChild);
}

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
        } while (obj = obj.offsetParent);
    }
    return [curleft, curtop];
}
