//------------------------------------------------------------------------------
//  WAX 1.5 - general-purpose web application library
//  Copyright (C) 2000-2006 SnapWorks
//  Website : http://www.snap-works.com/
//  Email   : info@snap-works.com
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//  Browser detection
//------------------------------------------------------------------------------

var Browsers = {
    Other   : 0,
    Gecko   : 1,
    MSIE    : 2,
    Opera   : 3
}

var browser = Browsers.Other;
    
if (window.opera) {
    browser = Browsers.Opera;
} else if (navigator.userAgent.match(/Gecko/)) {
    browser = Browsers.Gecko;
} else if(window.clipboardData) {
    browser = Browsers.MSIE;
}

//------------------------------------------------------------------------------
//  void ExtendClass(Object superClass, Object baseClass)
//------------------------------------------------------------------------------
function ExtendClass(superClass, baseClass) // {{{
{
    function inheritance() {}
    inheritance.prototype = baseClass.prototype;
    superClass.prototype = new inheritance();
    superClass.prototype.constructor = superClass;
} // }}}

//------------------------------------------------------------------------------
//  DomNode $(id)
//  Return dom node by id.  
//------------------------------------------------------------------------------
function $(id)
{
    return document.getElementById(id);
}


function registerStartupFunction(func) {
	
	var currentOnLoadFunc = window.onload;
	
	if (! window.onload) {
		window.onload = func;
	} else {
		window.onload = function() {
			currentOnLoadFunc();
			func();
		}
	}
}


//	Get absolute left of object
//
function getAbsoluteLeft( obj ) {
	objLeft = obj.offsetLeft;
	while( obj.offsetParent != null) {
		objParent = obj.offsetParent;
		objLeft += objParent.offsetLeft;
		obj = objParent;
	}
	return objLeft;
}

//	Get absolute top of object
//
function getAbsoluteTop( obj ) {
     objTop = obj.offsetTop;
     while( obj.offsetParent != null) {
          objParent = obj.offsetParent;
          objTop += objParent.offsetTop;
          obj = objParent;
     }
     return objTop;
}

//------------------------------------------------------------------------------
//  void applyAlpha(DomNode node, int alpha)
//  Apply alpha to given node.  
//------------------------------------------------------------------------------
function applyAlpha(node, alpha)
{
    alpha = Math.round(alpha);
	
    if (null != node.style.opacity) {
        node.style.opacity = alpha / 255;
    } else if (null != node.filters) {
        node.style.filter = 'alpha(opacity='+alpha * (100/255)+')';
    } else if (null != node.style.MozOpacity) {
        node.style.MozOpacity = alpha / 255;
    } else if (null != node.style.KhtmlOpacity) {
        node.style.KhtmlOpacity = alpha / 255;
    }
}



