﻿var PopMessageBox = 
{

    Load:false,
    Title: "",
    Message: "",
    
    CreateMessageBox : function ()
    {    
        if(!PopMessageBox.Load)
        {        
            $("div.mwrapper").append('<div class="tp_rw"><div class="tp_lf lt_grn title"><strong></strong></div><div class="tp_ry lt_grn close" style="cursor:pointer;">Close</div></div><div class="md_rw"><div class="logo"><img src="../images/menu/logo.gif" /></div><div class="msgtxt grey14 message"><strong></strong></div><div class="msgtxt"><img src="../images/ok.gif" style="cursor:pointer;" />&nbsp;</div></div><div class="fp_rw"></div>');
//            $("div.mwrapper div.close,div.mwrapper div.md_rw div.msgtxt img").click(function()
//            {            
//            $("div.mwrapper").hide();
//            }
            $("div.mwrapper div.close,div.mwrapper div.md_rw div.msgtxt img").click(function()
            {
                if(PopMessageBox.title == "Item")
                {                
                     $("div.mwrapper").hide();
                     
                     Template.Reset = true;
                     Template.ResetItem();                
                     Template.Reset = false;
                     Template.GetItems();
                     
                }
                else
                {
                $("div.mwrapper").hide();
                }
            
            });
        }
    },
    
    ShowMessage: function()
    {           
       
        $("div.mwrapper div.title strong").html("").html(PopMessageBox.title);      
        
        $("div.mwrapper div.message strong").html("").html(PopMessageBox.message);
        
        var TopLeft = $.fn.popCenter($("div.mwrapper").width(),$("div.mwrapper").height());

        $("div.mwrapper").css({"top":""+TopLeft[0]+"px","left":""+TopLeft[1]+"px"});
        
        $("div.mwrapper").show().oneTime("50ms", function() 
        {
       
                $(document).bind('keypress', function(e)
                { 
                    var code = (e.keyCode ? e.keyCode : e.which);
                    if(code == 13 || code == 27) 
                    {
                        $("div.mwrapper").hide(); 
                        $(document).unbind( "keypress" );
                    }
                });
        });
    }
};

$(document).ready(function () 

{$("div.mwrapper").hide();
    PopMessageBox.CreateMessageBox();
    
});


