var _jsCommand;
function alert(){
	var str=arguments[0];
	if(arguments.length>1) _jsCommand=arguments[1];
	if (window.top!=window.self)
	{
		window.top.alert(str,_jsCommand);
		return false;
	}
	if ( document.getElementById("msgDiv")!=null)
	{
		setTimeout(function(){alert(str,_jsCommand)},500);
		return false;
	}
	
	var msgw;
	msgw=400;//提示窗口的宽度
	
	var bgObj=document.createElement("div");
	bgObj.setAttribute("id","alertBgMaskDiv");
	bgObj.style.position="absolute";
	bgObj.style.background="#000000";
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=10,finishOpacity=90)";
	bgObj.style.opacity="0.1";
	bgObj.style.top="0";
	bgObj.style.left="0";
	bgObj.style.width="100%";
	if (document.documentElement.clientHeight<document.documentElement.scrollHeight){
	    bgObj.style.height=document.documentElement.scrollHeight + "px";
	}
	else{
	    bgObj.style.height=document.documentElement.clientHeight + "px";
	}
	bgObj.style.zIndex = "10000";
	document.body.appendChild(bgObj);
	
	alertStr=""+
	"     <div id=\"tip_title1\" class=\"tip_title1\">"+
	"	      <b>51myhome提示信息<\/b>"+
	"	 <\/div>"+
	"	 <div class=\"tip_title2\" id=\"alertTitleClose\">"+
	"          <a href=\"javascript:void(0)\" id=\"msgTitleClose\" ><\/a>"+
	"	 <\/div>"+
	"	 <div class=\"tip_content\">";
	alertEndStr=" <\/div>"+
	"";
	 
	var msgObj=document.createElement("div");
	msgObj.setAttribute("id","msgDiv");
	msgObj.setAttribute("align","center");
	if (document.documentElement.offsetWidth>screen.width)
	{
		msgObj.style.left = document.documentElement.scrollLeft+(screen.width-msgw)/2+"px";
	}
	else
	{
		msgObj.style.left = (document.documentElement.offsetWidth-msgw)/2+"px";
	}
	msgObj.style.width = msgw + "px";
	msgObj.style.textAlign = "center";
	msgObj.style.lineHeight ="25px";
	msgObj.style.zIndex = "10001";
    msgObj.className="tip_container1";
	msgObj.innerHTML=alertStr+str+alertEndStr;
	document.body.appendChild(msgObj);
	var title=document.getElementById("alertTitleClose");
	title.onclick=function(){
		if(bgObj!=null)	bgObj.parentNode.removeChild(bgObj);
		if(title!=null) title.parentNode.removeChild(title);
		if(msgObj!=null) document.body.removeChild(msgObj);
		if(_jsCommand!="" && _jsCommand!="undefined") 
			eval(_jsCommand);
	};
}

alert.closeAlert=function()
{
	var arrCloseDiv=["upWindow","iframexMask","bgMaskDiv","msgDiv","bgdiv","addEditDiv","alertBgMaskDiv"];
	for(var i=0;i<arrCloseDiv.length;i++)
	{
		var obj=document.getElementById(arrCloseDiv[i]);
		if(obj!=null)
			obj.parentNode.removeChild(obj);
	}
};

//--------------------------------------------------
//	弹出DIV
//	参数:
//	1.文本或者HTML代码，将显示在此Div里
//	2.JS语句,关闭这个DIV时将执行此语句
//	3.自定义参数多个参数之间逗号隔开,下面的是没有参数的默认值
//-------------------------------------------------------------------

alert.popDiv=function(){

	var msgw;
	msgw=400;//提示窗口的宽度
	titleheight=25;//提示窗口标题高度
	titleText="51myhome提示信息";
	msgID="msgDiv";
	titleID="msgTitle";
	msgZindex="9005";
	bgZindex="9000";
	
	var str=arguments[0];
	if(str=="") str="正在读取，请稍候...";
	if(arguments.length>1) _jsCommand=arguments[1];

	if (window.top!=window.self)
	{
		window.top.alert(str,_jsCommand);
		return false;
	}
	while ( document.getElementById(msgID)!=null)
	{
		setTimeout(function(){alert(str,_jsCommand)},500);
		return false;
	}
	if(arguments.length>2)
	{
		parametArr=arguments[2].split(",");
		for(var i=0;i<parametArr.length;i++)
		{
			temp=parametArr[i].split("=");
			switch  (temp[0])
			{
				case "width":
				{
					msgw=temp[1];
					break;
				}
				case "height":
				{
					msgh=temp[1];
					break;
				}
				case "titleText":
				{
					titleText=temp[1];
					break;
				}
				case "msgID":
				{
					msgID=temp[1];	
					break;
				}
				case "titleID":
				{
					titleID=temp[1];
					break;
				}
				case "msgZindex":
				{
					msgZindex=temp[1];	
					break;
				}
				case "bgZindex":
				{
					bgZindex=temp[1];
					break;
				}
			}
		}	
	}
	
	var bgObj=document.createElement("div");
	bgObj.setAttribute('id','bgMaskDiv');
	bgObj.style.position="absolute";
	bgObj.style.background="#000000";
	bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=10,finishOpacity=90)";
	bgObj.style.opacity="0.1";
	bgObj.style.top="0";
	bgObj.style.left="0";
	bgObj.style.width="100%";
	if (document.documentElement.clientHeight<document.documentElement.scrollHeight){
	    bgObj.style.height=document.documentElement.scrollHeight + "px";
	}
	else{
	    bgObj.style.height=document.documentElement.clientHeight + "px";
	}
	bgObj.style.zIndex = bgZindex;
	document.body.appendChild(bgObj);
	
	var msgObj=document.createElement("div");
	var iframex=document.createElement("iframe");
	iframex.setAttribute("id","iframexMask");
	msgObj.setAttribute("id",msgID);
	msgObj.setAttribute("align","center");
	msgObj.className="tip_container1";
	
	alertStr=""+
	"     <div class=\"tip_title1\">"+
	"	      <b>"+titleText+"<\/b>"+
	"	 <\/div>"+
	"	 <div class=\"tip_title2\">"+
	"          <a href=\"javascript:void(0);\" id=\"TitleClose\" onclick=\"alert.closeAlert()\"><\/a>"+
	"	 <\/div>"+
	"	 <div class=\"tip_content\"  id=\"msgTxt\" >";
	alertEndStr="<\/div>"+
	"";
	
	if (document.documentElement.offsetWidth>screen.width)
	{
		msgObj.style.left = document.documentElement.scrollLeft+(screen.width-msgw)/2+"px";
	}
	else
	{
		msgObj.style.left = (document.documentElement.offsetWidth-msgw)/2+"px";
	}
	msgObj.style.width = msgw + "px";
	msgObj.style.textAlign = "center";
	msgObj.style.lineHeight ="25px";
	msgObj.style.zIndex = msgZindex;
	
   	iframex.style.width=msgObj.style.width;
	iframex.style.height=msgObj.style.height;
	iframex.style.position="fixed";
	iframex.style.left=msgObj.style.left;
	iframex.style.top=msgObj.style.top;
	iframex.style.border=0;
	iframex.style.zIndex=msgObj.style.zIndex-1;
	
	document.body.appendChild(iframex);
	msgObj.innerHTML=alertStr+str+alertEndStr;
	document.body.appendChild(msgObj);
	var title=document.getElementById("TitleClose");
	title.onclick=function(){

		if(bgObj!=null)	bgObj.parentNode.removeChild(bgObj);
		if(title!=null) title.parentNode.removeChild(title);		
		if(msgObj!=null) document.body.removeChild(msgObj);
		if(iframex!=null) document.body.removeChild(iframex);

		if(_jsCommand!="" && _jsCommand!="undefined") 
			
			eval(_jsCommand);
		};

	var txt=document.getElementById("msgTxt");
	txt.style.overflowX ="hidden";
	txt.style.overflowY ="auto";
	txt.style.textAlign = "left";
};

alert.popDivClose = function(DivID)
{
	if(DivID=="")DivID="upWindow";
	var obj=document.getElementById(DivID);
	if(obj!=null) obj.parentNode.removeChild(obj);
	var iframexx=document.getElementById("iframexMask");
	if(iframexx!=null) iframexx.parentNode.removeChild(iframexx);
	var bgMaskDiv=document.getElementById("bgMaskDiv");
	if (bgMaskDiv!=null) bgMaskDiv.parentNode.removeChild(bgMaskDiv);
};

function ShowMsgBox(ShowStr,Action,ShowType){
    var strButton_OK="<input type=\"button\" value=\"$ShowType1$\" onclick=\"$Action$alert.closeAlert();\">";
    var strButton_Cancel="<input type=\"button\" value=\"$ShowType2$\" onclick=\"alert.closeAlert();\">";
    var strShowArr="";
    switch (ShowType)
    {
        case 0://无按钮
            alert(ShowStr);
            break;
        case 1://确定与取消按钮
            strShowArr="<br /><br />" + strButton_OK + "&nbsp;&nbsp;" + strButton_Cancel;
            strShowArr=strShowArr.replace("$ShowType1$","确定");
            strShowArr=strShowArr.replace("$ShowType2$","取消");
            strShowArr=strShowArr.replace("$Action$",Action);
            alert(ShowStr+strShowArr);
            break;
        case 2://是与否按钮
            strShowArr="<br /><br />" + strButton_OK + "&nbsp;&nbsp;" + strButton_Cancel;
            strShowArr=strShowArr.replace("$ShowType1$","是");
            strShowArr=strShowArr.replace("$ShowType2$","否");
            strShowArr=strShowArr.replace("$Action$",Action);
            alert(ShowStr+strShowArr);
            break;
        case 3://只有确定按钮
            strShowArr="<br /><br />" + strButton_OK;
            strShowArr=strShowArr.replace("$ShowType1$","确定");
            strShowArr=strShowArr.replace("$Action$",Action);
            alert(ShowStr+strShowArr);
            break;
        default://默认为只有确定按钮
            strShowArr="<br /><br />" + strButton_Cancel;
            strShowArr=strShowArr.replace("$ShowType2$","确定");
            alert(ShowStr+strShowArr);
            break;
    }
}

function CloseMsgBox(){
    alert.closeAlert();
}