﻿/*
V.08033109
A.Zed Gu
D.Eachnet Javascript Object
Copyright (c) 2008, Eachnet All rights reserved.
*/
var _doc = (document.compatMode != "BackCompat") ? document.documentElement : document.body;

String.prototype.int = function() {
	return parseInt(this,10);
};
Number.prototype.px = function() {
	return this + "px";
};
Number.prototype.int = function() {
		return parseInt(this,10);
};

var $ = function(p) {
	if (typeof(p) == 'string') {
		return document.getElementById(p);
	}
};
var $t = function(p,o) {
	if (typeof(p) == 'string') {
		if (o) {
			return $(o).getElementsByTagName(p);
		} else {
			return document.getElementsByTagName(p);
		}
	}
}
var $c = function(p) {
	var a = [];
	for (var i=0; i<$(p).childNodes.length; i++) {
		if ($(p).childNodes[i].nodeType == 1) {
			a.push($(p).childNodes[i]);
		}
	}
	return a;
};
var ejs = {
	path: function() {
		return this.filter(/e\.js(\?.*)?$/).match(/(.*)\/e\.js/)[1] + '/';
	},
	require: function() {
		eval("var tS = /" + arguments[0] + "/;");
		if (this.filter(/(.*).js/).match(tS) != arguments[0] || arguments[2]) {
			if (typeof(arguments[1]) != "string") {
				arguments[1] = this.path();
			}
			var tA = arguments[0].split('.');
			var p = "";
			for (var i=0; i<tA.length-2; i++) {
				p += tA[i]+"/";
			}
			document.write('<script type="text/javascript" src="' + arguments[1] + p + tA[tA.length-2] + '.js?v=' + tA[tA.length-1] + '"></script>');
		}
	},
	load: function() {
		var s = this.filter(/e\.js\?(.*)?$/);
		if (typeof(s) == "string") {
			var a = s.match(/\.*f=(.*)/);
			var p = s.match(/&\.*p=(.*)/);
			if (a) {
				var f = a[1].split(',');
				if (p != null) {p = p[1];}
				for (var i = 0; i < f.length; i++) {
					this.require(f[i],p,true);
				}
			}
		}
	},
	filter: function(p) {
		var t = false;
		var s = $t("script");
		for (var i = 0;i<s.length;i++) {
			if (s[i].src && s[i].src.match(p)) {
				t = s[i].src;
				break;
			}
		}
		return t;
	}
};
ejs.load();

var userAgent = navigator.userAgent.toLowerCase();
var ejo = {
	onload: function(p) {
		this.on(window,'load',p);
	},
	browser: {
		version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
		safari: /webkit/.test(userAgent),
		opera: /opera/.test(userAgent),
		ie: /msie/.test(userAgent) && !/opera/.test(userAgent),
		moz: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
	},
	on: function(element, eventName, eventAction) {
		if (document.attachEvent) {
			element.attachEvent('on'+eventName, eventAction);
		} else {
			element.addEventListener(eventName, eventAction, false);
		}
	}
};
var ejc = {
	load: function(tKey) {
		var tC = document.cookie.split('; ');
		var tO = {};
		var a = null;
		for (var i = 0; i < tC.length; i++) {
			a = tC[i].split('=');
			tO[a[0]] = a[1];
		}
		return tO;
	},
	set: function() {
		var d = new Date();
		var i = arguments.length;
		var key = i>0 ? arguments[0] : 'undefined';
		var value = i>1 ? arguments[1] : '';
		var expires = i>2 ? d.setTime(d.getTime() + (arguments[2] * 1000 * 60)) : null;
		var path = i>3 ? arguments[3] : null;
		var domain = i>4 ? arguments[4] : null;
		document.cookie = key + '=' + escape(value) + ((expires == null) ? '' : (';expires=' + d.toGMTString())) + ((path == null) ? '' : (';path=' + path)) + ((domain == null) ? '' : (';domain=' + domain));
		return this.get(key);
	},
	get: function(tKey) {
		if (this.load()[tKey]) {
			return decodeURI(this.load()[tKey]);
		} else {
			return false;
		}
	},
	del: function(tKey) {
		if (this.get[tKey]) {
			var d = new Date();
			document.cookie = tKey + '=null; expires=' + d.setTime(d.getTime()).toGMTString();
		}
	},
	destroy: function() {
		var d = new Date();
		for (var key in this.load()) {
			document.cookie = this.load()[key] + ';expires=' + d.setTime(d.getTime()).toGMTString();
		}
	}
}
