var isIe=(document.all)?true:false; 
function mousePosition(ev){ 
	if(ev.pageX || ev.pageY){ 
		return {x:ev.pageX, y:ev.pageY}; 
	} 
	return { 
		x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,y:ev.clientY + document.body.scrollTop - document.body.clientTop 
	}; 
} 

function setSelectState(state){
	var objl=document.getElementsByTagName('select');
	for(var i=0;i<objl.length;i++){
		objl[i].style.visibility=state;
	}
}

//弹出方法 
function showMessageBox(wTitle,content,pos,wWidth){ 
	closeWindow(); 
	var bWidth=parseInt(document.body.scrollWidth); 
	var bHeight=parseInt(document.body.scrollHeight); 
	if(isIe){
		setSelectState('hidden');
	}
	var back=document.createElement("div"); 
	back.id="back"; 
	var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;"; 
	styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;"; 
	back.style.cssText=styleStr; 
	document.body.appendChild(back); 
	showBackground(back,10); 

	var mesW=document.createElement("div"); 
	mesW.id="mesWindow"; 
	mesW.className="mesWindow";
	
	var mesTop=document.createElement("div"); 
	mesTop.className="mesWindowTop";
	mesW.appendChild(mesTop);

	var mesTable=document.createElement("table"); 
	mesTable.setAttribute("width","100%");
	mesTable.setAttribute("height","100%");
	mesW.appendChild(mesTable);

	var mesTableBody=document.createElement("tbody"); 
	mesTable.appendChild(mesTableBody);

	var row=document.createElement("tr"); 
	mesTableBody.appendChild(row);

	var cellBlank=document.createElement("td"); 
	cellBlank.setAttribute("width","1%");
	row.appendChild(cellBlank);

	var cell0=document.createElement("td"); 
	cell0.setAttribute("align","left");
	var em=document.createElement("em"); 
	em.appendChild(document.createTextNode(wTitle));
	cell0.appendChild(em);
	row.appendChild(cell0);

	var cell1=document.createElement("td"); 
	cell1.setAttribute("align","right");
	row.appendChild(cell1);

	var closeButton=document.createElement("input"); 
	closeButton.setAttribute("type","button");
	closeButton.setAttribute("value","关闭");
	closeButton.setAttribute("title","关闭窗口");
	closeButton.className="close";
	closeButton.onclick=function(){
		closeWindow();
	};
	cell1.appendChild(closeButton);

	var mesContent=document.createElement("div");
	mesContent.setAttribute("id","mesWindowContent");
	mesContent.className="mesWindowContent";
	mesContent.appendChild(content);
	mesW.appendChild(mesContent);

	var mesWindow=document.createElement("div");
	mesWindow.className="mesWindowBottom";
	mesW.appendChild(mesWindow);
 
	styleStr="left:"+(((pos.x-wWidth)>0)?(pos.x-wWidth):pos.x)+"px;top:"+(pos.y)+"px;position:absolute;width:"+wWidth+"px;"; 
	mesW.style.cssText=styleStr; 
	document.body.appendChild(mesW); 
} 

function showMessageBox2(wTitle,content,pos,wWidth){ 
	closeWindow(); 
	var bWidth=parseInt(document.body.scrollWidth); 
	var bHeight=parseInt(document.body.scrollHeight); 
	if(isIe){
		setSelectState('hidden');
	}
	var back=document.createElement("div"); 
	back.id="back"; 
	var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;"; 
	styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;"; 
	back.style.cssText=styleStr; 
	document.body.appendChild(back); 
	showBackground(back,10); 
	styleStr="left:"+(((pos.x-wWidth)>0)?(pos.x-wWidth):pos.x)+"px;top:"+(pos.y)+"px;position:absolute;width:"+wWidth+"px;"; 
	content.style.cssText=styleStr;
	document.body.appendChild(content);
	
} 

//让背景渐渐变暗 
function showBackground(obj,endInt) { 
	if(isIe) { 
		obj.filters.alpha.opacity+=1; 
		if(obj.filters.alpha.opacity<endInt){ 
			setTimeout(function(){showBackground(obj,endInt)},0); 
		} 
	}else{ 
		var al=parseFloat(obj.style.opacity);al+=0.01; 
		obj.style.opacity=al; 
		if(al<(endInt/100)) {
			setTimeout(function(){showBackground(obj,endInt)},2);
		} 
	} 
} 
//关闭窗口 
function closeWindow() { 
	if(document.getElementById('back')!=null) { 
		document.getElementById('back').parentNode.removeChild(document.getElementById('back')); 
	} 
	if(document.getElementById('mesWindow')!=null) { 
		document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow')); 
	}  
	if(isIe){
		setSelectState('');
	}
}
function Position(x,y){
	this.x=x;
	this.y=y;
}