


function Browser() {
	var ua, s, i;
	this.isIE		= false;	// Internet Explorer
	this.isNS		= false;	// Netscape
	this.version = null;
	ua = navigator.userAgent;

	s = "MSIE";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isIE = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	s = "Netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	// Treat any other "Gecko" browser as NS 6.1.
	s = "Gecko";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = 6.1;
		return;
	}
}
var browser = new Browser();



function $(el){
	return typeof el == 'string' ? document.getElementById(el) : el;
}
Array.prototype.forEach = function(callback,thisObject){
	for(var i=0,len=this.length;i<len;i++)
		callback.call(thisObject,this[i],i,this)
};
Function.prototype.bind = function(object) {
	var __method = this;
	return function() {
		__method.apply(object, arguments);
	}
}
Function.prototype.bindAsEventListener = function(object) {
	var __method = this;
	return function(event) {
		return __method.call(object, event || window.event);
	}
}



/* get offset */
function getPageOffset(el){
	var x = 0, y = 0;
	do {
		x += el.offsetLeft || 0;
		y += el.offsetTop || 0;
		el = el.offsetParent;
	} while (el);
	return [x, y];
}
function getPageOffsetLeft(el) {
	var x = 0;
	do {
		x += el.offsetLeft || 0;
		el = el.offsetParent;
	} while (el);
	return x;
}
function getPageOffsetTop(el) {
	var y = 0;
	do {
		y += el.offsetTop || 0;
		el = el.offsetParent;
	} while (el);
	return y;
}
function getPositionEndOffset(el){
	var x = 0, y = 0;
	do {
		y += el.offsetTop  || 0;
		x += el.offsetLeft || 0;
		el = el.offsetParent;
		if (el){
			p = el.getStyle(el, 'position');
			if(p == 'relative' || p == 'absolute') break;
		}
	} while (el);
	return [x, y];
}


function getContainerWith(el, tagName, className) {
	while (el != null) {
		if (el.tagName != null && el.tagName == tagName &&
				hasClassName(el, className))
			return el;
		el = el.parentNode;
	}
	return el;
}


function getOffsetParent(el){
	if (el.offsetParent) return el.offsetParent;
	if (el == document.body) return el;

	while ((el = el.parentNode) && el != document.body)
		if (el.getStyle(el, 'position') != 'static')
			return el;
	return document.body;
}






/* class name */

function hasClassName(el, classname) {
	var el = $(el);
	if(el.className == null) return false;
	var list = el.className.split(/\s+/);
	for(var i = 0; i < list.length; i++)
		if (list[i] == classname)
			return true;
	return false;
}


function removeClassName(el, classname) {
	var el = $(el);
	if(el.className == null) return;
	var newList = [];
	var curList = el.className.split(/\s+/);

	for(var i = 0; i < curList.length; i++)
		if(curList[i] != classname)
			newList[newList.length] = curList[i];
			//newList.push(curList[i]);
	el.className = newList.join(" ");
}


function getStyle(o,s){
	var res;
	try{
		if (document.defaultView && document.defaultView.getComputedStyle){
			res = document.defaultView.getComputedStyle(o, null).getPropertyValue(s);
		} else {
			if (o.currentStyle){
				var camelized = s.replace(/-([^-])/g, function(a,b){return b.toUpperCase()});
				res = o.currentStyle[camelized];
			}
		}
		return res;
	} catch(e){}
	return "";
}


function setStyle( element, styles ){
	if(!element) return;
	for( var key in styles ){
		element.style[key] = styles[key];
	}
}




function MM_openBrWindow(theURL,winName,features) { //v2.0
  w=window.open(theURL,winName,features);
  w.focus();
}



function jumpUrl(selection) {
	var url=selection[selection.selectedIndex].value;
	if(url!=""){
	location.href=url;
	}
}

