function addLoader(funcToStart) {
	if (funcToStart!=undefined) {
		if (window.onload) {
			var zfunc=window.onload	
			window.onload=function () {funcToStart();zfunc()}
		} else {
			window.onload=funcToStart
		}
	}
}
function addUnLoader(funcToStop) {
	if (window.onunload) {
		var zfunc=window.onunload	
		window.onunload=function () {zfunc();funcToStop()}
	} else {
		window.onunload=funcToStop
	}
}
Date.prototype.sqlDate=function() {
	var r=[]
	r.push(this.getFullYear())
	r.push(((this.getMonth()<9)?"0":"")+(this.getMonth()+1))
	r.push(((this.getDate()<10)?"0":"")+this.getDate())
	return r.join("-")
}
Date.prototype.sqlDateTime=function() {
	var r=[]
	r.push(((this.getHours()<10)?"0":"")+(this.getHours()))
	r.push(((this.getMinutes()<10)?"0":"")+this.getMinutes())
	r.push(((this.getSeconds()<10)?"0":"")+this.getSeconds())
	return this.sqlDate()+" "+r.join(":")
}
function $o(id) {return document.getElementById(id)}
function $t(o,id) {return o.getElementsByTagName(id)}
function $b(id) {return document.createElement(id)}
function $ct(t) {return document.createTextNode(t)}
function $ae(o,eName,f) {
	if(window.addEventListener){ // Mozilla, Netscape, Firefox
		o.addEventListener(eName, f, false);
	} else { // IE
		o.attachEvent('on'+eName, f);
	}
}
function sc(o,ncn,ocn) {
	if (o) {
		if (ocn!=undefined) {
			if(ocn!="") {
				var re=new RegExp("\\b"+ocn+"\\b","gi")
				var i=o.className.search(re)
				if (i!=-1) {o.className=o.className.replace(re,"")}
			}
		}
		if (ncn!="") {
			var re=new RegExp("\\b"+ncn+"\\b","gi")
			var i=o.className.search(re)
			if (i==-1) {o.className=o.className.replace(/\s*$/,'')+" "+ncn}
		}
	}
}

String.prototype.parseJSON = function () {
    try {
        return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
                this.replace(/"(\\.|[^"\\])*"/g, ''))) &&
            eval('(' + this + ')');
    } catch (e) {
        return false;
    }
};
webKitVersion=getWKVersion()
function getWKVersion() {
	var webKitFields = RegExp("( AppleWebKit/)([^ ]+)").exec(navigator.userAgent)
	if (!webKitFields || webKitFields.length < 3) {
		return 0
	} else {
		return  webKitFields[2].split(".")[0]*1
	}	
}
var oObjMng=new Array()
function postLoad() {
	for (var i=0;i<oObjMng.length;i++) {
		if (oObjMng[i].postInit) {oObjMng[i].postInit()}
	}
}
function postUnload() {
	for (var i=0;i<oObjMng.length;i++) {
		if (oObjMng[i].unload) {oObjMng[i].unload()}
	}
}
addLoader(postLoad)
addUnLoader(postUnload)

var readyDone=false
var readyReady=false
var readyFunctionList=[]
function addReady(funToCall) {
	if (readyFunctionList) {readyFunctionList.push(funToCall)}	
}
function callReadyFn() {
	if (!readyReady) {
		readyReady=true
		if (readyFunctionList) {
			for(var i=0;i<readyFunctionList.length;i++) {
				readyFunctionList[i].call()	
			}
			readyFunctionList=null
		}
	}
}
function setReadyDoc() {
	if (readyDone) {return}
	readyDone=true
	if(window.addEventListener){
		document.addEventListener("DOMContentLoaded", function() {
			document.removeEventListener("DOMContentLoaded",arguments.callee,false)
			callReadyFn()
		}, false);
	} else { // IE
		document.attachEvent("onreadystatechange", function() {
			if (document.readyState==="complete") {
				document.detachEvent("onreadystatechange",arguments.callee)
				callReadyFn()
			}
		 });
		if (document.documentElement.doScroll&&window==window.top) (function() {
				if (readyReady) {return}
				try {
					document.documentElement.doScroll("left")
				} catch(error) {
					setTimeout(arguments.callee,0)
					return
				}
				callReadyFn()
			})()
	}
	addLoader(callReadyFn)
}
setReadyDoc()
