function msg(a){function v(){$("div.msgBox").fadeOut(200).fadeIn(200)}function u(){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))}function t(){if(!b){return}a.beforeClose();$("div.msgBox").animate({opacity:0,top:q-50,left:r},200);$("div.msgBoxBackGround").fadeOut(300);setTimeout(function(){$("div.msgBox,div.msgBoxBackGround").remove()},300);setTimeout(a.afterClose,300);b=false}function s(){if(b){return}$("div.msgBox").css({opacity:0,top:q-50,left:r});$("div.msgBoxBackGround").css({opacity:a.opacity});a.beforeShow();$("div.msgBoxBackGround").css({width:$(document).width(),height:u()});$("div.msgBox,div.msgBoxBackGround").fadeIn(0);$("div.msgBox").animate({opacity:1,top:q,left:r},200);setTimeout(a.afterShow,200);b=true;$(window).bind("resize",function(a){var b=$("div.msgBox").width();var c=$("div.msgBox").height();var d=$(window).height();var e=$(window).width();var f=d/2-c/2;var g=e/2-b/2;$("div.msgBox").css({top:f,left:g})})}var b=false;var c=typeof a;var d={content:c=="string"?a:"Message",title:"Warning",type:"alert",autoClose:false,timeOut:0,showButtons:true,buttons:[{value:"Continuar"}],inputs:[{type:"text",name:"userName",header:"User Name"},{type:"password",name:"password",header:"Password"}],success:function(a){},beforeShow:function(){},afterShow:function(){},beforeClose:function(){},afterClose:function(){},opacity:.1};a=c=="string"?d:a;if(a.type!=null){switch(a.type){case"alert":a.title=a.title==null?"Warning":a.title;break;case"info":a.title=a.title==null?"Information":a.title;break;case"error":a.title=a.title==null?"Error":a.title;break;case"confirm":a.title=a.title==null?"Confirmation":a.title;a.buttons=a.buttons==null?[{value:"Yes"},{value:"No"},{value:"Cancel"}]:a.buttons;break;case"prompt":a.title=a.title==null?"Log In":a.title;a.buttons=a.buttons==null?[{value:"Login"},{value:"Cancel"}]:a.buttons;break;default:e="alert.png"}}a.timeOut=a.timeOut==null?a.content==null?500:a.content.length*70:a.timeOut;a=$.extend(d,a);if(a.autoClose){setTimeout(t,a.timeOut)}var e="";switch(a.type){case"alert":e="alert.png";break;case"info":e="info.png";break;case"error":e="error.png";break;case"confirm":e="confirm.png";break;default:e="alert.png"}var f="";$(a.buttons).each(function(a,b){f+='<input class="msgButton" type="button" name="'+b.value+'" value="'+b.value+'" />'});var g="";$(a.inputs).each(function(a,b){var c=b.type;if(c=="checkbox"||c=="radiobutton"){g+='<div class="msgInput">'+'<input type="'+b.type+'" name="'+b.name+'" '+(b.checked==null?"":"checked ='"+b.checked+"'")+' value="'+(typeof b.value=="undefined"?"":b.value)+'" />'+"<text>"+b.header+"</text>"+"</div>"}else{g+='<div class="msgInput">'+'<span class="msgInputHeader">'+b.header+"<span>"+'<input type="'+b.type+'" name="'+b.name+'" value="'+(typeof b.value=="undefined"?"":b.value)+'" />'+"</div>"}});var h='<div class="msgBoxBackGround"></div>';var i='<div class="msgBoxTitle">'+a.title+"</div>";var j='<div class="msgBoxContainer"><div class="msgBoxImage"><img src="includes/js/3Party/alertBox/Images/'+e+'"/></div><div class="msgBoxContent"><p><span>'+a.content+"</span></p></div></div>";var k='<div class="msgBoxButtons">'+f+"</div>";var l='<div class="msgBoxInputs">'+g+"</div>";if($("div.msgBox").length==0){if(a.type=="prompt"){$("html").append(h+'<div class="msgBox">'+i+"<div>"+j+(a.showButtons?k+"</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(l)}else{$("html").append(h+'<div class="msgBox">'+i+"<div>"+j+(a.showButtons?k+"</div>":"</div>")+"</div>")}}else{if(a.type=="prompt"){$("div.msgBox").html(i+"<div>"+j+(a.showButtons?k+"</div>":"</div>"));$("div.msgBoxImage").remove();$("div.msgBoxContent").css("width","100%");$("div.msgBoxContent").html(l)}else{$("div.msgBox").html(i+"<div>"+j+(a.showButtons?k+"</div>":"</div>"))}}var m=$("div.msgBox").width();var n=$("div.msgBox").height();var o=$(window).height();var p=$(window).width();var q=o/2-n/2;var r=p/2-m/2;s();$("input.msgButton").click(function(b){b.preventDefault();var c=$(this).val();if(a.type!="prompt"){a.success(c)}else{var d=[];$("div.msgInput input").each(function(a,b){var c=$(this).attr("name");var e=$(this).val();var f=$(this).attr("type");if(f=="checkbox"||f=="radiobutton"){d.push({name:c,value:e,checked:$(this).attr("checked")})}else{d.push({name:c,value:e})}});a.success(c,d)}t()});$("div.msgBoxBackGround").click(function(b){if(!a.showButtons||a.autoClose){t()}else{v()}})}jQuery.msgBox=msg;
