﻿    function addEvent(elm, evType, fn)
	{
	    if (elm.addEventListener)
	    {
		    elm.addEventListener(evType, fn, false);
		    return true;
	    }
	    else if (elm.attachEvent)
	    {
		    var r = elm.attachEvent('on' + evType, fn);
		    return r;
	    }
	    else
	    {
		    elm['on' + evType] = fn;
	    }
    }
        
    function NMMessageBox(_Type, _Title, _Msg, _Func1, _Width, _Height,_Func2)
    {    
        _Type = _Type ? _Type.toLowerCase() : "" ; 
        
        if (_Type == "" || ( _Type != "confirm" && _Type != "confirm2" && _Type != "confirm3" && _Type != "popup" && _Type != "function" && _Type != "function2" && _Type != "blank"))
        {
            alert("Check Parameters[ Type ]");
            return;
            if ( _Title == "" || !_Title  ||  _Msg == "" || !_Msg )
            { 
                alert("Check Parameters[ Title, Msg ]");
                return;
            }                       
        }
        else if ( _Type == "popup" )
        { 
           if (_Msg )
            {
                alert("Check Parameters[ Msg ]");
                return;
            }
        }
        var sHTML = ""
        sHTML += "<div id=\"DivDimBox\" class=\"bx_dimmed\"><iframe src=\"\" scrolling=\"no\" id=\"DivDimIfr\"></iframe></div>";

            
        if ( _Type == "popup" )
        {
            sHTML += _Msg;
        }
        else
        {
            sHTML += "<div style=\"display:block;\" class=\"lyr_alert\">";
            sHTML += "<div id=\"lp\" class=\"lp_alert lp_alert2\" style=\"top:200px\">";
           	sHTML += "<p class=\"tt\">"+_Title+"</p>";
		   	sHTML += "<table class=\"msg_bx\">";
			sHTML += "<tr>";
			sHTML += "<td>";
			//sHTML += "<p class=\"bold\">" + _Title +"</p>";
			sHTML += "<p>" +_Msg+"</p>";
			sHTML += "</td>";
			sHTML += "</tr>";
			sHTML += "</table>";
            sHTML += "<div class=\"lp_btm\"> ";       
            if(_Func1 && _Type == "confirm")
            {
                sHTML += "<span class=\"button bt2\"><button type=\"button\" onclick=\"location.href=\'" + _Func1 + "\'\" style=\"width:77px;\">OK</button></span>";
                sHTML += "<span class=\"button bt1\"><button type=\"button\" onclick=\"Cji_DivHide('DivLayer');\" style=\"width:77px;\">Cancel</button></span>";

            }
            else if(_Func1 && _Type == "confirm2")
            {
                sHTML += "<span class=\"button bt2\"><button type=\"button\" onclick=\"location.href=\'" + _Func1 + "\';\" style=\"width:77px;\">OK</button></span>";         
            }
            else if(_Func1 && _Type == "confirm3")
            {
                sHTML += "<span class=\"button bt2\"><button type=\"button\" onclick=\"Cji_DivHide('DivLayer');" + _Func1 + ";\" style=\"width:77px;\">OK</button></span>";         
            }
            else if(_Func1 && _Type == "function")
            {
                sHTML += "<span class=\"button bt2\"><button type=\"button\" onclick=\"" + _Func1 + ";Cji_DivHide('DivLayer');\" style=\"width:77px;\">OK</button></span>";
                sHTML += "<span class=\"button bt1\"><button type=\"button\" onclick=\"Cji_DivHide('DivLayer');\" style=\"width:77px;\">Cancel</button></span>";       
            }
            else if(_Func1 && _Func2 && _Type == "function2")
            {
                sHTML += "<span class=\"button bt2\"><button type=\"button\" onclick=\"" + _Func1 + "\" style=\"width:77px;\">OK</button></span>";
                sHTML += "<span class=\"button bt1\"><button type=\"button\" onclick=\"" + _Func2 + "\" style=\"width:77px;\">Cancel</button></span>";       
            } 
            else if(_Func1 && _Type == "blank")
            {
                sHTML += "<span class=\"button bt2\"><button type=\"button\" onclick=\"Cji_DivHide('DivLayer');\" style=\"width:77px;\">OK</button></span>";         
            }
            else
            {
                sHTML += "<span class=\"button bt2\"><button type=\"button\" onclick=\"Cji_DivHide('DivLayer');\" style=\"width:77px;\">OK</button></span>";     
            }
            sHTML += "</div>";
            if(_Func2 == "unClose"){
            	sHTML += "";
            }else{
            	sHTML += "<a href=\"javascript:Cji_DivHide('DivLayer');\" class=\"close\">close this layer</a>";
            }
            sHTML += "</div>";
            sHTML += "</div>";
            
        }          
        
        try{            
            if(document.getElementById("DivLayer") == null)
            {    
                var alertLayer = document.createElement("DIV");            
                alertLayer.id = "DivLayer";
                document.body.appendChild(alertLayer);
            }else{
            document.getElementById("DivLayer").innerHTML = "";}
            document.getElementById("DivLayer").innerHTML = sHTML;       
            document.getElementById("DivLayer").style.display = "block";            
        }catch(e){}
        
        ResizeDimmed();
    }
    
   
