//------------------------------------------------------------------------------
// 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 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;
    }
}


//------------------------------------------------------------------------------
//  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;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}












