window.env=new function(){
    var ua = navigator.userAgent.toLowerCase();
    var s;
    (s = ua.match(/msie ([\d.]+)/)) ? this.ie = s[1] :
    (s = ua.match(/firefox\/([\d.]+)/)) ? this.firefox = s[1] :
    (s = ua.match(/chrome\/([\d.]+)/)) ? this.chrome = s[1] :
    (s = ua.match(/opera.([\d.]+)/)) ? this.opera = s[1] :
    (s = ua.match(/version\/([\d.]+).*safari/)) ? this.safari = s[1] : 0
};

function removeArray(array, attachId) {
	for ( var i = 0, n = 0; i < array.length; i++) {
		if (array[i] != attachId) {
			array[n++] = array[i];
		}
	}
	array.length -= 1;
}

Array.prototype.remove = function(obj) {
	return removeArray(this, obj);
};

function openUrl(url, opt) {
	if (opt == null || opt == null || opt == 0) // current window
		window.location = url;
	else if (opt == 1) // new window
		window.open(url);
	else if (opt == 2) { // background window
		window.open(url);
		self.focus();
	}
}

jQuery.fn.outerHTML = function(s) {
	return (s)
	? this.before(s).remove()
	: jQuery("<p>").append(this.eq(0).clone()).html();
};

function scroll2Top() {
	$('html, body').animate({scrollTop:0}, 'medium');
}

function scroll2Bottom() {
	$('html, body').animate({scrollTop:5000}, 'medium');
}

function getPara(name) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var results = regex.exec(window.location.href);
	if( results == null )
		return "";
	else
		return results[1];
}

function replaceTag(val) {
	return val.replace(/\[br\/\]/g, "<br/>").replace(/\[b\]/g, "<b>").replace(/\[\/b\]/g, "</b>")
}

function isLoginTimeout(resp) {
	if(resp.indexOf("id=\"login_tb\"") > -1)
		return true;
	return false;
}

jQuery.preloadImages = function() {
  	for(var i = 0; i<arguments.length; i++) {
    	jQuery("<img>").attr("src", arguments[i]);
  	}
}