String.prototype.trim = function() {
	a = this.replace(/^\s+/, ''); return a.replace(/\s+$/, '');
};
function $(idname){
	if (document.getElementById){ return document.getElementById(idname); } 
	else if (document.all) { return document.all[idname];} 
	else if (document.layers) {	return document.layers[idname];	}
	else { return null; }
};
function $$(idname){
	return document.frames?document.frames[idname]:$(idname).contentWindow;
}
function $t(parentobj, tag){
	if (typeof parentobj.getElementsByTagName != 'undefined') {return parentobj.getElementsByTagName(tag);}
	else if (parentobj.all && parentobj.all.tags){return parentobj.all.tags(tag);}
	else {return null;}
};
function $x(parentobj, tag) {
	var tags = $t(parentobj, tag);
	return tags[0].firstChild.nodeValue;
}
function $c(s){
	return document.createElement(s);
};
function is_null(val){
	return (val == "" || val == null || val == "undefined");
};
function str_len(key){
	var l=escape(key),len; 
	len=l.length-(l.length-l.replace(/\%u/g,"u").length)*4;
	l=l.replace(/\%u/g,"uu");
	len=len-(l.length-l.replace(/\%/g,"").length)*2;
	return len;
};
function show_error(msg, errid) {
var divBody = '\
		<div style="padding-top:3px; background:#fef0ad">\
			<img src="http://image2.sina.com.cn/pfp/i/v2/v2_sc_ico.gif" width="21" height="18" align="absmiddle" hspace="6">\
			' + msg + '\
		</div>\
	';
	if (is_null(errid)) errid = "dialogError";	
	$(errid).innerHTML = divBody;$(errid).style.display = 'block';
	set_focus(errid);
};
function hidden_error(errid) {
	try {
		$("dialogError").style.display = 'none';
	}catch (e){};
	try {
		$(errid).style.display = 'none';
	}catch (e){}
};
function set_focus(idname){
	if (!is_null(idname)) {
		try {$(idname).focus();}catch (e){}
	}
};


function VS_Ajax(async) {
	this.async = async ? true : false;
};
VS_Ajax.prototype.init = function(){
	try {
		this.handler = new XMLHttpRequest();
		return true;
	} catch(e) {
		try {
			this.handler = new ActiveXObject('Microsoft.XMLHTTP');
			return true;
		} catch(e) {
			try {
				this.handler = new ActiveXObject('Msxml2.XMLHTTP');
				return true;
			} catch(e) {
				return false;
			}
		}
	}
};
VS_Ajax.prototype.not_ready = function(){
	return (this.handler.readyState && (this.handler.readyState < 4));
};
VS_Ajax.prototype.onreadystatechange = function(event){
	if (!this.handler) {
		this.init();
	}
	if (typeof event == 'function') {
		this.handler.onreadystatechange = event;
	} else {
		alert('XML Sender OnReadyState event Must function');
	}
};
VS_Ajax.prototype.post = function(desturl, datastream){
	if (!this.handler){
		this.init();
	}
	if (!this.not_ready()){
		this.handler.open('POST', desturl, this.async);
		if (typeof(this.handler.setRequestHeader) != "undefined"){
			this.handler.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		}
		this.handler.send(datastream);
		if (!this.async && this.handler.readyState == 4 && this.handler.status == 200){
			return true;
		}
	}
	return false;
};
VS_Ajax.prototype.get = function(desturl, datastream){
	if (!this.handler){
		this.init();
	}
	if (!this.not_ready()){
		this.handler.open('GET', desturl + "?" + datastream, this.async);
		this.handler.send(null);
		if (!this.async && this.handler.readyState == 4 && this.handler.status == 200){
			return true;
		}
	}
	return false;
};


var agt = navigator.userAgent.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);
var is_ie = (agt.indexOf("msie") != -1) && document.all && !is_opera;
var is_ie5 = (agt.indexOf("msie 5") != -1) && document.all;
var uniqnum_counter = (new Date).getTime();
var is_regexp = (window.RegExp) ? true : false;
var gidname = '';

function exist(s)
{
	return $(s)!=null;
}
function removeNode(s)
{
	if(exist(s))
	{
		$(s).innerHTML = '';
		$(s).removeNode?$(s).removeNode():$(s).parentNode.removeChild($(s));
	}
}
function myInnerHTML(idname, html)
{
	if (exist(idname))
	{
		$(idname).innerHTML = html;
	}
}

