﻿if (typeof YOUSHANG == "undefined") {
	/**
	 * The YOUSHANG global namespace object.  If YOUSHANG is already defined, the
	 * existing YOUSHANG object will not be overwritten so that defined
	 * namespaces are preserved.
	 * @class YOUSHANG
	 * @static
	 */
	var YOUSHANG = {};
}

window.$ = function() {
		var elements = new Array();
		for (var i = 0; i < arguments.length; i++) {
			var element = arguments[i];
			if (typeof element == 'string')
				element = document.getElementById(element);
			if (arguments.length == 1) 
				return element;
			elements.push(element);
		}
		return elements;
};
YOUSHANG.namespace = function() {
    var a=arguments, o=null, i, j, d;
    for (i=0; i<a.length; i=i+1) {
        d=a[i].split(".");
        o=YOUSHANG;

        // YAHOO is implied, so it is ignored if it is included
        for (j=(d[0] == "YOUSHANG") ? 1 : 0; j<d.length; j=j+1) {
            o[d[j]]=o[d[j]] || {};
            o=o[d[j]];
        }
    }

    return o;
};
YOUSHANG.base = function() {};
YOUSHANG.base.prototype = {
	addLoadEvent : function (func) {
		if(window.document.all){
			window.attachEvent("onload" ,func);
		}else{
			window.addEventListener("load",func,false);
		}
	},
	addListener : function (sType,fn,obj,parameter) {
		var me = this;
		this.parameter = parameter;
		obj["on"+sType] = function(e) {
			if(me.parameter) {
				fn(me.parameter);
			} else {
				fn();
			}
		};
	}
}
/*重写event事件，使FF支持event事件*/
function __firefox(){ 
	HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style); 
	window.constructor.prototype.__defineGetter__("event", __window_event); 
	Event.prototype.__defineGetter__("srcElement", __event_srcElement); 
} 
function __element_style(){ 
	return this.style; 
} 
function __window_event(){ 
	return __window_event_constructor(); 
} 
function __event_srcElement(){ 
	return this.target; 
} 
function __window_event_constructor(){ 
	if(document.all){ 
		return window.event; 
	} 
	var _caller = __window_event_constructor.caller; 
	while(_caller!=null){ 
		var _argument = _caller.arguments[0]; 
		if(_argument){ 
			var _temp = _argument.constructor; 
			if(_temp.toString().indexOf("Event")!=-1){ 
				return _argument; 
			} 
		} 
		_caller = _caller.caller; 
	} 
	return null; 
} 
if(window.addEventListener){ 
	__firefox(); 
}

