var removeDom = new Object();
function popClosetony(obj)
	{
		if(obj) document.body.removeChild(obj);
		alreadyexit = false;
		$('shadow').hide();
		$('shadow1').hide();
		removeDom = null;
	}
function mousemove(o)
	{
		var moveable = false;
		var popX = popY = popClientX = popClientY = 0;
		if(!o) return false;
		var popTitle = o;
		//开始记录
		popTitle.attachEvent('onmousedown',function()
														 {
														 	if(event.button==1)
															{
																if(!moveable)
																{
																popTitle.setCapture();
																var popParent = popTitle.parentNode;
																if(o == $('popuTitle')) popParent = popTitle.parentNode.parentNode;
																popClientX = event.clientX;
																popClientY = event.clientY;
																popX = parseInt(popParent.style.left);
																popY = parseInt(popParent.style.top);
																moveable = true;
																}
															}
														 });
		//开始拖动
		popTitle.attachEvent('onmousemove',function()
														 {
															if(moveable)
															{
																var popParent = popTitle.parentNode;
																if(o == $('popuTitle')) popParent = popTitle.parentNode.parentNode;
																popParent.style.left = popX + event.clientX - popClientX;
																popParent.style.top = popY + event.clientY -popClientY;
																if($('phone-alert-bg')) $('phone-alert-bg').style.left = popX + event.clientX - popClientX;
																if($('phone-alert-bg')) $('phone-alert-bg').style.top = popY + event.clientY -popClientY;
															} 
													});
		//停止拖动
		popTitle.attachEvent('onmouseup',function()
													   {
														if(moveable)
														{
															var popParent = popTitle.parentNode;
															if(o == $('popuTitle')) popParent = popTitle.parentNode.parentNode;
															popTitle.releaseCapture();
															moveable = false;
														}   
													});
	}
	
String.prototype.alert=function(o){
		if(!$('shadow')) return false;
		el=document.createElement('div');
		el.id = 's_alert';
		w = document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.clientWidth;
		h = document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight;
		var top = "130px";
		var left = (w -parseInt(arguments[2]))/2;
		left+="px";
		var style_l = "<span class='popSysSpan'>";
		var style_r = "</span>";
		if(arguments[1] == 'warning') style_l = "<span class='popSys'>";style_r = "</span>";
		if(arguments[3]) try{var intH = parseInt(arguments[3]);}catch(e){alert("严禁外部提交！");}
		arguments[2]?width = arguments[2]:width = '265px';
		arguments[3]?height = intH+'px':height = 'auto';
		var s="<div style='position:absolute;left:"+left+";top:"+top+";width:"+width+";height:"+height+";z-index:9999999'><div class='popLef'></div><div class='popTitle' id='popTitle' style='cursor:move;width:"+(width-20)+"px;'>"+style_l+o+style_r+"<div class='popClose' id='popClose' style='background:url(/images/icons/popClose.gif) no-repeat;margin-right:0px;' onmouseover='this.style.background=\"url(/images/icons/popClose-c.gif) no-repeat\"'onmouseout='this.style.background=\"url(/images/icons/popClose.gif) no-repeat\"' title='关闭'></div></div><div class='popRig'></div><div class='clear'></div><div class='popBody' style='width:"+(width-2)+"px;'><table width='100%' border='0' cellspacing='0' cellpadding='0'>";
		for(j=4;j<arguments.length;j+=2)
		{
			s+='<tr><td align="'+arguments[j]+'" valign="top">'+arguments[j+1]+'</td></tr>';
		}
		s+="</table></div><div class='popBLef'></div><div class='popBot' style='width:"+(width-20)+"px;'></div><div class='popBRig'>"
		el.innerHTML=s;
		document.body.appendChild(el);
		$('shadow').show();
		$('shadow1').show();
		mousemove($('popTitle'));
		Event.observe('popClose','click',popClosetony.bind(this,el));
		if($('uPoPClose')) Event.observe('uPoPClose','click',popClosetony.bind(this,el));
		removeDom = el;
		el=null;
	}
	
	//create DOM for String.alert
	function createDOM()
	{
		  //1.类型,2.Type,3.样式,4.可变样式,5.ID,6.值域,7.focus隐匿,8.追加Style,9.返回数据
		var _type = _className = _changeCN = _id = _value = hide = input_type = _dom = style = '';
		if(arguments[0]) _type = arguments[0];
		if(arguments[1]) input_type = "type='"+arguments[1]+"'";
		if(arguments[2]) _className = "class='"+arguments[2]+"'";
		if(arguments[3]) _changeCN = "onmousedown='this.className=\""+arguments[3]+"\"' onmouseup='this.className=\""+arguments[2]+"\"'"
		if(arguments[4]) _id = "id='"+arguments[4]+"'";
		if(arguments[5]) _value = arguments[5];
		if(arguments[5]&&_type == 'input') _value = "value='"+arguments[5]+"'";		
		if(arguments[6]) hide = "hideFocus='true'";
		if(arguments[7]) style = "style='"+arguments[7]+"'";
		
		switch(_type)
		{
			case "input":_dom = "<input "+_id+" "+input_type+" "+_className+" "+_changeCN+" "+_value+" "+hide+" "+style+" />";break;
			case "span" :_dom = "<span "+_id+" "+_className+" "+style+">"+_value+"</span>";
		}
		return _dom;
		
	}
	
function hAlert(str){
	if($('uPoPClose')) return;
	var node = Builder.node("div",str);
	$(node).setStyle({ marginBottom:'20px', marginTop:'10px'});
	var s ='';
	var s1=createDOM('input','button','listFressInput','','uPoPClose','确定','true');
	s.alert('系统提示','warning','300','','center',str,'center',s1);
}
