//lobaschuk@gmail.com
function msgbox(txt,ok_txt,data_param,timeAutoHide){
if(!ok_txt)ok_txt='Ok';
var cancel_txt='Cancel';
msgbox_remove();
var overlay=jQuery('
',{'id':'lea_msgbox','style':'display:none'}).appendTo('body');
msg.html(txt);
msgbox_resize(msg);
msg.fadeIn(300);
var btns=jQuery('
',{'id':'lea_msgbox_btns'}).appendTo(msg);
var msg_x=jQuery('
',{'data-param':data_param,'text':'x','id':'lea_msgbox_x','style':'position:absolute;top:5px;right:8px;font-size:18px;font-weight:bold;cursor:pointer;'}).appendTo(msg);
var msg_ok=jQuery('',{'data-param':data_param,'id':'lea_msgbox_ok','class':'lea_btn top_str','type':'submit','value': ok_txt}).appendTo(btns);
var msg_cancel=jQuery('
',{'data-param':data_param,'id':'lea_msgbox_cancel','class':'lea_btn'}).appendTo(btns);msg_cancel.html(''+cancel_txt+'');
overlay.bind('click',function(){msg_cancel.trigger('click');});
msg_ok.bind('click',function(){msgbox_onClose(msg);});
msg_cancel.bind('click',function(){msgbox_onClose(msg);});
msg_x.bind('click',function(){msg_cancel.trigger('click');});
jQuery(document).keydown(function(eventObject){if (eventObject.which==27){msgbox_onClose(msg);}});
if(timeAutoHide)setTimeout(function(){msgbox_onClose(msg);},timeAutoHide);
jQuery(window).resize(function(){msgbox_resize(msg);});
function msgbox_resize(msg){
msg_width=msg.width();
msg_height=msg.height();
var dv=20;
var dh=((jQuery(window).width()/2)+jQuery(document).scrollLeft())-msg_width/2;
msg.css({
'position':'fixed',
'top':dv,
'left':dh,
'z-index':'1002',
});
}
function msgbox_remove(){
jQuery('div#lea_msgbox_ok').remove();
jQuery('div#lea_msgbox_cancel').remove();
jQuery('div#lea_msgbox').remove();
jQuery('div#lea_overlay').remove();
}
function msgbox_onClose(msg){
msg.fadeOut(300,function(){
msgbox_remove();
});
jQuery('div#lea_overlay').remove();
}
}