(function(){
		var zk = {};
		window.zk = zk;
		zk.extend = function( abstractObj, extendObj ) {
			if ( !! abstractObj && !! extendObj && zk.isFunction(abstractObj) && typeof extendObj === "object" ){
				for ( var prototype in extendObj ){
					abstractObj.prototype[prototype] = extendObj[prototype];
				}
			}else if (  !! abstractObj && !! extendObj && typeof abstractObj === "object" && typeof extendObj === "object"  ){
				for ( prototype in extendObj ){
					abstractObj[prototype] = extendObj[prototype];
				}
			}
			return abstractObj;
		};
		zk.createFun = function(){
			return function( params ){
				if ( !! this.initialize ) {
					this.initialize( params );
				}
			};
		};
		zk.isArray = function( obj ){
			return Object.prototype.toString.call(obj) === "[object Array]";
		};
		zk.isFunction = function( obj ){
			return Object.prototype.toString.call(obj) === "[object Function]";
		};
		zk.getElements = function( selector, context ){
			var regx_id = /^\s*#([a-zA-Z_]\w*)\s*$/;
			var regx_eles = /^\s*([a-zA-Z_]\w*)\s*/;

			context = context || document;
			selector = selector || document;

			if ( typeof selector === "object" ) {
				return selector;
			}

			if ( typeof selector === "string" )
			{
				var match = regx_id.exec( selector );
				if ( match ){
					return context.getElementById( match[1] );
				}
				match = regx_eles.exec( selector );
				if ( match ){
					return context.getElementsByTagName( match[1] );
				}
			}
			return null;
		};
		zk.cookie = zk.extend(
			{},
			{
				set:function (name,value,days,path,domain) {
					var expires = "";
			        if (days) {
			            var date = new Date();
			            date.setTime(date.getTime()+(days*24*60*60*1000));
			            expires = "; expires="+date.toGMTString();
			        }
				    if(path===undefined || path ===null || path===""){path="/";}
			        document.cookie = name+"="+value+expires+";path="+path + (domain === null ? "" : ";domain=" + domain);
			    },
			    get:function (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;
			    }
			}
		);
		zk.script = zk.extend(
			{},{
				add : function(src, id, fun){
				    var script = document.createElement("script");
				    script.type = "text/javascript";
				    script.src = src;
				    if(id){
				    	script.id = id;
				    }
				    script.onreadystatechange = function(){
						if(fun && (script.readyState == "complete" || script.readyState == "loaded")){
							fun();
						}
				    };
				    script.onload = function(){
				        if(fun){
							fun();
				        }
				    };
				    document.getElementsByTagName('head')[0].appendChild(script);
				},
				remove : function(id){
					var obj = (typeof id == "string") ? zk.$D("#" + id) : id;
					if(obj && obj.parentNode){
						obj.parentNode.removeChild(obj);
					}
				}
			}
		);
		zk.ajax = function(url, method, data, fun) {
			var xmlHttp;
			if(window.ActiveXObject){
	            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	        }else if(window.XMLHttpRequest){
	            xmlHttp = new XMLHttpRequest();
	        }
			var _data = {
				getJson : function(){
					var retVal = null;
					eval("retVal = " + xmlHttp.responseText);
					return retVal;
				},
				getText : function(){
					return xmlHttp.responseText;
				}
			};
			var onstate = function(){
				var _this = this;
				return function(){
					if(xmlHttp.readyState == 4 && xmlHttp.status == 200 ){
						if(fun){
							fun(_data);
						}
					}
				};
			};
			if ( xmlHttp ) {
				xmlHttp.onreadystatechange = onstate();
				xmlHttp.open(method, url);
				if(method == "post"){
					xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				}
	            xmlHttp.send(data);
			}
		};
		zk.events = zk.extend(
			{},
			{
				eregx : /^(?:on)?(mouseover|mouseout|mousedown|mouseup|mousemove|click|load|change|focus)/,
				attach : function( obj, eventName, eventHandle )
				{
					if ( !! obj )
					{
						var regx = zk.$E.eregx, _eventName;
						var eventMatchs = eventName.match( regx );
						if ( !! eventMatchs && zk.isFunction( eventHandle ) )
						{
							if ( !! obj.attachEvent )
							{
								_eventName = eventMatchs[0];
								obj.attachEvent( _eventName, eventHandle );
								return true;
							}
							else if ( !! obj.addEventListener )
							{
								_eventName = eventMatchs[1];
								obj.addEventListener( _eventName, eventHandle, false );
								return true;
							}
						}
					}
					return false;
				},
				detach : function( obj, eventName, eventHandle )
				{
					if ( !! obj )
					{
						var regx = zk.$E.eregx, _eventName;
						var eventMatchs = eventName.match( regx );
						if ( !! eventMatchs && zk.isFunction( eventHandle ) )
						{
							if ( !! obj.detachEvent )
							{
								_eventName = eventMatchs[0];
								obj.detachEvent( _eventName, eventHandle );
								return true;
							}
							else if ( !! obj.removeEventListener )
							{
								_eventName = eventMatchs[1];
								obj.removeEventListener( _eventName, eventHandle, false );
								return true;
							}
						}
					}
					return false;
				},
				cancelBubble : function( e ){
					if( !! e ){
						if(e.stopPropagation){
							e.stopPropagation();
						} else {
							e.cancelBubble = true;
						}
					}
				},
				cancel : function( e )
				{
					if ( !! e )
					{
						if ( !! window.event )
						{
							e.returnValue = false;
							return true;
						}
						else if( !! e.preventDefault )
						{
							e.preventDefault();
							return true;
						}
					}
					return false;
				}
			}
		);
		zk.$D = zk.getElements;
		zk.$E = zk.events;
	})();