﻿var AlertWindow = {
    FrameHTMLCode :"",
    AlertMessage :"",
    AlertMessageColor :"#FF0000",
    AlertMessageWeight :"BOLD",
    AlertMessageHref : "",
    AlertMeesageIsA : false,
    MessageUrl : "",
    AlertMessageSize : 14,
    WindowTitle : "",
    WindowTitleSize : 14,
    WindowTitleString : "",
    AlertMessageString : "",
    ButtonComfirmRefreshPage : false,
    
    Refresh:function(){
        AlertWindow.WindowTitleString       = "<span style=\"font-size:"+AlertWindow.WindowTitleSize+"px;\"><B>"+AlertWindow.WindowTitle+"</B></span>";
          
        if(AlertWindow.AlertMeesageIsA){
            AlertWindow.AlertMessageString        = "<span style=\"font-size:"+AlertWindow.AlertMessageSize+"px;font-weight:"+AlertWindow.AlertMessageWeight+";color:"+AlertWindow.AlertMessageColor+"\"><a href=\""+AlertWindow.MessageUrl+"\">"+AlertWindow.AlertMessage+"</a></span>";
        }else{
            AlertWindow.AlertMessageString        = "<span style=\"font-size:"+AlertWindow.AlertMessageSize+"px;font-weight:"+AlertWindow.AlertMessageWeight+";color:"+AlertWindow.AlertMessageColor+"\">"+AlertWindow.AlertMessage+"</span>";
        }
    },
    
    init:function(){
        AlertWindow.Refresh();
        
        AlertWindow.FrameHTMLCode       = "<div id=\"AlertWindowbg\" class=\"AlertWindowbg\">"+
        "</div><div id=\"AlertWindowsDiv\" class=\"mydiv\" style=\"display:none;\">"+
"<table width=\"400\" border=\"0\" align=\"center\" bgcolor=\"#FFFFFF\" cellpadding=\"0\" cellspacing=\"0\" class=\"tbl_6\" style=\"margin:12px 12px 0px 12px\">"+
  "<tr>"+
    "<td height=\"24\" align=\"left\" bgcolor=\"#ddf1d8\" class=\"f_14\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"+
        "<tr>"+
          "<td>&nbsp;<span id=\"TitleContent\">"+AlertWindow.WindowTitleString+"</span></td>"+
          "<td align=\"right\"><table width=\"24\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"+
              "<tr>"+
                "<td><div align=\"left\"><a href=\"#\"><img src=\"../images/close.gif\" width=\"20\" height=\"20\" onclick=\"AlertWindow.Hidden()\" style=\"cursor:hand\"/></a></div></td>"+
              "</tr>"+
          "</table></td>"+
        "</tr>"+
      "</table></td>"+
  "</tr>"+
  "<tr>"+
    "<td valign=\"top\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">"+
      "<tr>"+
        "<td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"10\">"+
          "<tr>"+
            "<td>"+
                "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" bgcolor=\"#DDF1D8\">"+
                  "<tr>"+
                    "<td bgcolor=\"#FFFFFF\"><table width=\"98%\" border=\"0\" align=\"center\" cellpadding=\"1\" cellspacing=\"1\">"+
                        "<tr>"+
                          "<td width=\"100%\" height=\"60\" bgcolor=\"#FFFFFF\"><div align=\"center\" id=\"MessageContent\">"+
                            AlertWindow.AlertMessageString+
                            "</div></td>"+
                        "</tr>"+
                        "<tr>"+
                          "<td bgcolor=\"#FFFFFF\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"+
                              "<tr>"+
                                "<td><div align=\"center\">"+
                                    "<input name=\"button\" type=\"button\" class=\"input_btn1\" id=\"button\" value=\"  确 定  \" onclick=\"AlertWindow.Hidden()\"/>"+
                                  "</div></td>"+
                                "</tr>"+
                          "</table></td>"+
                        "</tr>"+
                    "</table></td>"+
                  "</tr>"+
                "</table>"+
                 "</td>"+
          "</tr>"+
        "</table>          </td>"+
      "</tr>"+
    "</table></td>"+
  "</tr>"+
"</table>"+
"</div><iframe id=\"AlertWindowpopIframe\" class=\"AlertWindowpopIframe\" frameborder=\"0\" ></iframe>";
        
        //显示AlertWindow
        document.write(AlertWindow.FrameHTMLCode);
        
    },

    Show:function(){
        /*Refresh Recompute Display Information(WindowTitleString/AlertMEssageString)*/
        AlertWindow.Refresh();
        
        /*Fill New Information to HTMLFrame*/
        document.getElementById("TitleContent").innerHTML    =   AlertWindow.WindowTitleString;   
        document.getElementById("MessageContent").innerHTML     =   AlertWindow.AlertMessageString ;
        
        /*Display AlertWindow*/
        document.getElementById("AlertWindowsDiv").style.display='block';
        document.getElementById("AlertWindowpopIframe").style.display='block';
        document.getElementById("AlertWindowbg").style.display='block';
    },
    Hidden:function(){
        document.getElementById("AlertWindowsDiv").style.display='none';
        document.getElementById("AlertWindowpopIframe").style.display='none';
        document.getElementById("AlertWindowbg").style.display='none';
        if(AlertWindow.ButtonComfirmRefreshPage){
            location.reload();
        }
    },
    LoadCss : function(id,url)
	{
		var h = document.getElementsByTagName("head")[0];
	    var link = document.createElement("link");
	    link.id= id;
		link.type ="text/css";
		link.rel = "STYLESHEET";
		link.href = url;
	    h.appendChild(link);
	},
	ImportCss:function(){
	    AlertWindow.LoadCss("AlertWindowCss","../js/AlertWindow.css");
	}
	
}
AlertWindow.ImportCss();