/**
 * JS基本类 
 * 功能：
 *    1.浏览器兼容代码
 *    2.定义全局变量
 */
var ErrClosed = false;
if(ErrClosed){
	function killerrors(){return true;}
	window.onerror = killerrors;
}
if (typeof (Base) != 'function') {
	var Base = function() {
		this.browserName = detectBrowser();
		this.browserVersion = detectVersion();
		this.imgUrl = gSiteUrl+"/res/images/JsImages";
		function detectBrowser(){
			var browserAgent = navigator.userAgent.toLowerCase();
			if(browserAgent.indexOf("msie") != -1){
				return 'ie';//ie6.0-7
			}else if(browserAgent.indexOf("firefox") != -1){
				return 'firefox';
			}else if(browserAgent.indexOf("chrome") != -1){
				return 'chrome';
			}else if(browserAgent.indexOf("safari") != -1){
				return 'safari';
			}else if(browserAgent.indexOf("opera") != -1){
				return 'opera';
			}else if(browserAgent.indexOf("netscape") != -1){
				return 'netscape';
			}else{
				return null;
			}
		};
		function detectVersion(){
			var browserAgent = navigator.userAgent.toLowerCase();
			if(browserAgent.indexOf("msie") != -1){
				return parseFloat(navigator.appVersion.split("MSIE")[1]);  
			}else{
				return "";
			}
		}
		
		/**
		 * 页面ID是否存在
		 * @param stirng s 页面ID
		 * @return boolean
		 */
		this.exist = function(s){
			return $(s) != null;
		};
		
		this.setClassName = function(obj, className){
			if(this.browserName == 'ie'){
				obj.setAttribute("className", className);
			}else if(this.browserName == 'firefox'){
				obj.setAttribute("class", className);
			}else{
				obj.setAttribute("className", className);
				obj.setAttribute("class", className);
			}
		}
		
		this.test = function(){
			alert(this.imgUrl);
		};
	}	
};

/**
 * 继承
 * @param stirng sub
 * @param stirng sup
 * @return
 */
function extend(sub, sup) {
	var f = function() {};
	f.prototype = sup.prototype;
	sub.prototype = new f();
	sub.prototype.constructor = sub;

	sub.superclass = sup.prototype;
	if (sup.prototype.constructor == Object.prototype.constructor){
		sup.prototype.constructor = sup;
	}	
}
function printObj(obj){
	var str = '<table border=1>';
	for (var i in obj)
	{
	    str += '<tr><td>' + i + ' </td><td> ' + obj[i] + '</td></tr>';
	    i++;
	}
	str += '</table>';
	//var objdiv = document.createElement("DIV");
	//objdiv.id = 'testddd';
	$("#testddd").html(str);
}

/**
 * 数组中是否存在某个值
 */
Array.prototype.inArray = function (value) {
	for (var i=0,l = this.length ; i <l ; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
}; 

String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/g,"");
};

String.prototype.ltrim = function(){
	return this.replace(/(^\s*)/g,"");
};

String.prototype.rtrim = function(){
	return this.replace(/(\s*$)/g,"");
};  
