function trim(s){
	return s.replace(/^\\s*/g,'').replace(/\\s*$/g,'');
}
/*
function $(s){
	return document.getElementById(s);
}
*/
var isIE = (document.all) ? true : false;

var $2 = function (id) {
    return "string" == typeof id ? document.getElementById(id) : id;
};
function selectAll(checkboxID,status){
	obj=document.getElementsByName(checkboxID);
	if( obj == null)
	return;
	if(obj.length > 0){
	for(i=0;i<obj.length;i++){
	obj.item( i ).checked = status;}
	}else{
	obj.checked = status;
	}
}
////
function ajax(waitId,type){
	var aj = new Object();
	
	aj.loading = '';//默认等待内容
	aj.waitId = waitId ? $2(waitId) : null;//等待内容所在的id对象
	aj.type = type ? type : 'HTML';//HTML/XML
	aj.sendString = '';//发送的内容
	aj.resultHandle = null;//结束时调用的对像
	
	aj.createXMLHttpRequest = function() {
		var request = false;
		if(window.XMLHttpRequest) {
			request = new XMLHttpRequest();
			if(request.overrideMimeType) {
				request.overrideMimeType('text/xml');
			}
		} else if(window.ActiveXObject) {
			var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];
			for(var i=0; i<versions.length; i++) {
				try {
					request = new ActiveXObject(versions[i]);
					if(request) {
						return request;
					}
				} catch(e) {}
			}
		}
		return request;
	}

	aj.XMLHttpRequest = aj.createXMLHttpRequest();
	aj.changedisplay=function(obj,display){
		obj.style.display = display;
	}
	aj.showLoading = function() {
		if(aj.waitId && (aj.XMLHttpRequest.readyState != 4 || aj.XMLHttpRequest.status != 200)) {
			aj.changedisplay(aj.waitId, '');
			aj.waitId.innerHTML = aj.loading;
		}
	}
	//返回状态的调用
	aj.processHandle = function() {
		if(aj.XMLHttpRequest.readyState == 4 && aj.XMLHttpRequest.status == 200) {
			if(aj.waitId) aj.changedisplay(aj.waitId, 'none');
			if(aj.type == 'HTML') {
				aj.resultHandle(aj.XMLHttpRequest.responseText, aj);
			} else if(aj.type == 'XML') {
				aj.resultHandle(aj.XMLHttpRequest.responseXML, aj);
			}
		}
	}
	aj.get = function(url, handle) {
		aj.showLoading();
		aj.targetUrl = url;
		aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
		aj.resultHandle = handle;
		if(window.XMLHttpRequest) {
			aj.XMLHttpRequest.open('GET',url);
			aj.XMLHttpRequest.send(null);
		} else {
			aj.XMLHttpRequest.open("GET", url, true);
			aj.XMLHttpRequest.send();
		}

	}
	aj.post = function(url, sendString, handle) {
		aj.showLoading();
		aj.targetUrl = url;
		aj.sendString = sendString;
		aj.XMLHttpRequest.onreadystatechange = aj.processHandle;
		aj.resultHandle = handle;
		aj.XMLHttpRequest.open('POST', url);
		aj.XMLHttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		aj.XMLHttpRequest.send(aj.sendString);
	}
	return aj;
}
function floatwin(action, param,w,h,str) {
	var objs = document.getElementsByTagName("OBJECT");
	if(action == 'open') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].style.visibility != 'hidden') {
				objs[i].setAttribute("oldvisibility", objs[i].style.visibility);
				objs[i].style.visibility = 'hidden';
			}
		}
		var clientWidth = document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
		//var clientWidth = document.body.clientWidth;
		var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
		var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
		var pmwidth = 800;
		var pmheight = clientHeight * 0.9;
		if(w>0)
			pmwidth=w;
		if(h>0)
			pmheight=h;
		if(!$2('pmlayer_bg')) {
			div = document.createElement('div');div.id = 'pmlayer_bg';
			div.style.position = 'absolute';
			div.style.left = div.style.top = '0px';
			div.style.width = '100%';
			div.style.height = (clientHeight > document.body.scrollHeight ? clientHeight : document.body.scrollHeight) + 'px';
			div.style.backgroundColor = '#000';
			div.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0,finishOpacity=100,style=0)';
			div.style.opacity = 0;
			div.style.zIndex = '998';
			document.body.appendChild(div);
			div = document.createElement('div');div.id = 'pmlayer';
			div.style.width = pmwidth + 'px';
			div.style.height =pmheight + 'px';
			div.style.left = ((clientWidth - pmwidth) / 2) + 'px';
			div.style.position = 'absolute';
			div.style.zIndex = '999';
			document.body.appendChild(div);
			$2('pmlayer').innerHTML = '<div style="width: 100%; margin: 5px auto; text-align: left; border:1px solid #cccccc; ">' +
				'<div id="floatwinbox" style=" height: 100%; position: relative; border:0px solid #fff; color:#ffffff;">' +
				'<div id="floatcontent"></div>';
		}
		$2('pmlayer_bg').style.display = '';
		if(str)
			$2("floatcontent").innerHTML='<div style="width:' + pmwidth + 'px;height:'+pmheight+'px;text-align:center;">'+str+'</div>';
		else{
			$2("floatcontent").innerHTML='<div id="fwLoad" style="position:absolute;z-index:1000;">Loading ...</div><iframe style="width:' + pmwidth + 'px;height:'+pmheight+'px; " allowTransparency="true" frameborder="0" id="fwIframe" src="'+param+'"></iframe>';
			
			if($2('fwIframe').attachEvent){
					$2('fwIframe').attachEvent("onload",function(){ $2('fwLoad').style.display="none";});
			}else{
				$2('fwIframe').onload=function(){$2('fwLoad').style.display="none";};
			}
		}
		$2('pmlayer').style.display = '';
		$2('pmlayer').style.width = pmwidth + 'px';
		$2('pmlayer').style.height =pmheight + 'px';
		$2('pmlayer').style.left = ((clientWidth - pmwidth) / 2) + 'px';
		if(clientHeight<pmheight)
			tmp='0px';
		else
			tmp=((clientHeight - pmheight) / 2 + scrollTop) + 'px';
		$2('pmlayer').style.top =tmp; 		
		document.body.style.overflow = "hidden";
		//document.body.scroll = "no";
	} else if(action == 'close') {
		for(i = 0;i < objs.length; i ++) {
			if(objs[i].attributes['oldvisibility']) {
				objs[i].style.visibility = objs[i].attributes['oldvisibility'].nodeValue;
				objs[i].removeAttribute('oldvisibility');
			}
		}
		$2('pmlayer').style.display = 'none';
		$2('pmlayer_bg').style.display = 'none';
		document.body.style.overflow = "hidden";
		//document.body.scroll = "auto";
	}
}
