jQuery.msgBox=msg;
function msg(a){function k(){i&&(a.beforeClose(),$("div.msgBox,div.msgBoxBackGround").fadeOut("fast"),setTimeout(function(){$("div.msgBox,div.msgBoxBackGround").remove()},200),setTimeout(a.afterClose,200),i=!1)}function m(){var a=document;return Math.max(Math.max(a.body.scrollHeight,a.documentElement.scrollHeight),Math.max(a.body.offsetHeight,a.documentElement.offsetHeight),Math.max(a.body.clientHeight,a.documentElement.clientHeight))}var e,b,i=!1;b=typeof a;var g={content:"string"==b?a:"Message",
title:"Warning",type:"alert",errorStyle:!1,autoClose:!1,timeOut:0,showButtons:!0,closeButton:!0,buttons:"string"!=b&&!1==a.closeButton?[{value:"Ok"}]:null,inputs:[{type:"text",name:"userName",header:"User Name"},{type:"password",name:"password",header:"Password"}],success:function(){},beforeShow:function(){},afterShow:function(){},beforeClose:function(){},afterClose:function(){}},a="string"==b?g:a;b=null==a.parentWindow?window:a.parentWindow;e=null==a.imageDir?"msgBox/":a.imageDir;if(null!=a.type)switch(a.type){case "alert":a.title=
null==a.title?"Warning":a.title;break;case "info":a.title=null==a.title?"Information":a.title;break;case "error":a.title=null==a.title?"Error":a.title;break;case "confirm":a.title=null==a.title?"Confirmation":a.title;a.buttons=null==a.buttons?[{value:"Yes"},{value:"No"},{value:"Cancel"}]:a.buttons;break;case "prompt":a.title=null==a.title?"Log In":a.title,a.buttons=null==a.buttons?[{value:"Login"},{value:"Cancel"}]:a.buttons}a.timeOut=null==a.timeOut?null==a.content?500:70*a.content.length:a.timeOut;
a=$.extend(g,a);a.autoClose&&setTimeout(k,a.timeOut);var d=null==a.image?"":a.image;if(""==d)switch(a.type){case "alert":d="alert.png";break;case "info":d="info.png";break;case "error":d="error.png";break;case "confirm":d="confirm.png";break;default:d="alert.png"}var l="";$(a.buttons).each(function(a,c){l+='<input class="msgButton" type="button" name="'+c.value+'" value="'+c.value+'" />'});var j="";$(a.inputs).each(function(a,c){var b=c.type;j="checkbox"==b||"radio"==b?j+('<div class="msgInput"><input type="'+
c.type+'" name="'+c.name+'" '+(null==c.checked?"":"checked ='"+c.checked+"'")+' value="'+("undefined"==typeof c.value?"":c.value)+'" /><text>'+c.header+"</text></div>"):j+('<div class="msgInput"><span class="msgInputHeader">'+c.header+'</span><input type="'+c.type+'" name="'+c.name+'" value="'+("undefined"==typeof c.value?"":c.value)+'" /></div>')});var g=a.errorStyle?" Alert":" Prompt",f='<div class="msgBoxTitle'+g+'">'+a.title;!0==a.closeButton&&(f+='<input type="button" name="X" value="X" />');
f+="</div>";e='<div class="msgBoxContainer"><div class="msgBoxImage"><img src="'+e+d+'"/></div><div class="msgBoxContent'+g+'"><p><span>'+a.content+"</span></p></div></div>";var d='<div class="msgBoxButtons">'+l+"</div>",h='<div class="msgBoxInputs">'+j+"</div>";0==$("div.msgBox").length?"prompt"==a.type?($("html").append('<div class="msgBoxBackGround"></div><div class="msgBox'+g+'">'+f+"<div>"+e+(a.showButtons?d+"</div>":"</div>")+"</div>"),$("div.msgBoxImage").remove(),$("div.msgBoxButtons").css({"text-align":"center",
"margin-top":"5px"}),$("div.msgBoxContent").css({width:"100%",height:"100%"}),$("div.msgBoxContent").html(h)):$("html").append('<div class="msgBoxBackGround"></div><div class="msgBox'+g+'">'+f+"<div>"+e+(a.showButtons?d+"</div>":"</div>")+"</div>"):"prompt"==a.type?($("div.msgBox").html(f+"<div>"+e+(a.showButtons?d+"</div>":"</div>")),$("div.msgBoxImage").remove(),$("div.msgBoxContent").css("width","100%"),$("div.msgBoxContent").html(h)):$("div.msgBox").html(f+"<div>"+e+(a.showButtons?d+"</div>":
"</div>"));g=$("div.msgBox").width();e=$("div.msgBox").height();d=$(b).height();f=$(b).width();b==window?b=h=0:(h=-$(document).scrollTop()+$(b).offset().top,b=-$(document).scrollLeft()+$(b).offset().left);e=h+d/2-e/2;b=b+f/2-g/2;i||(a.beforeShow(),MouseHover("div.msgBox input[type='button']"),$("div.msgBoxBackGround").css({display:"none",opacity:null==a.opacity?$("div.msgBoxBackGround").css("opacity"):a.opacity,width:$(document).width(),height:m()}),$("div.msgBox").css({display:"none",opacity:1,top:e,
left:b}),$("div.msgBoxBackGround,div.msgBox").fadeIn("fast"),setTimeout(a.afterShow,200),i=!0);$("input.msgButton, div.msgBoxTitle input[type='button']").click(function(b){b.preventDefault();b=$(this).val();if("prompt"!=a.type)a.success(b);else{var c=[];$("div.msgInput input").each(function(){var a=$(this).attr("name"),b=$(this).val(),d=$(this).attr("type");"checkbox"==d||"radiobutton"==d?c.push({name:a,value:b,checked:$(this).attr("checked")}):c.push({name:a,value:b})});a.success(b,c)}k()});$("div.msgBoxBackGround").click(function(){!a.showButtons||
a.autoClose?k():$("div.msgBox").fadeOut("fast").fadeIn("fast")})};

