var showalert = function(msg){ jalert(msg, "warm reminder"); } window.alert=showalert; window.countertimer={}; $.alerts={ verticaloffset:-75,horizontaloffset:0,repositiononresize:true,overlayopacity:0.5,overlaycolor:'#fff',draggable:true,okbutton:' ok ',cancelbutton:' cancel ',dialogclass:null,alert:function(message,title,callback){ if(title==null)title='alert'; if(callback){ $.alerts._show(title,message,null,'confirm',function(result){ if(callback)callback(result); }); }else{ $.alerts._show(title,message,null,'alert',function(result){ if(callback)callback(result); }); } } ,_show:function(title,msg,value,type,callback){ $.alerts._hide(); $.alerts._overlay('show'); $("body").append(''); if($.alerts.dialogclass)$("#popup_container").addclass($.alerts.dialogclass); var pos=('undefined' == typeof(document.body.style.maxheight))?'absolute':'fixed'; $("#popup_container").css({ //position:pos,zindex:99999,padding:0,margin:0 }); $("#popup_title").text(title); $("#popup_content").addclass(type); $("#popup_message").text(msg); $("#popup_message").html($("#popup_message").text().replace(/\n/g,'
')); $("#popup_container").css({ //minwidth:$("#popup_container").outerwidth(),maxwidth:$("#popup_container").outerwidth(), //minwidth:'290px',maxwidth:'290px', }); $.alerts._reposition(); $.alerts._maintainposition(true); switch(type){ case'alert':$("#popup_message").append(''); $("#popup_ok").click(function(){ $.alerts._hide(); callback(true) }); $("#popup_ok").focus().keypress(function(e){ if(e.keycode==13||e.keycode==27)$("#popup_ok").trigger('click') }); break case'confirm':$("#popup_message").append(''); $("#popup_ok").click(function(){ $.alerts._hide(); callback(true) }); $("#popup_cancel").click(function(){ $.alerts._hide(); callback(false) }); $("#popup_ok").focus().keypress(function(e){ if(e.keycode==13||e.keycode==27)$("#popup_ok").trigger('click') }); break }; if($.alerts.draggable){ try{ $("#popup_container").draggable({ handle:$("#popup_title") }); $("#popup_title").css({ cursor:'move' }) } catch(e){} } } ,_hide:function(){ $("#popup_container").remove(); $.alerts._overlay('hide'); $.alerts._maintainposition(false) } ,_overlay:function(status){ switch(status){ case'show':$.alerts._overlay('hide'); $("body").append(''); $("#popup_overlay").css({ position:'absolute',zindex:99998,top:'0px',left:'0px',width:'100%',height:$(document).height(),background:$.alerts.overlaycolor,opacity:$.alerts.overlayopacity }); break; case'hide':$("#popup_overlay").remove(); break } } ,_reposition:function(){ var top=(($(window).height()/ 2) - ($("#popup_container").outerheight() /2))+$.alerts.verticaloffset; var left=(($(window).width()/ 2) - ($("#popup_container").outerwidth() /2))+$.alerts.horizontaloffset; if(top<0)top=0; if(left<0)left=0; if('undefined' == typeof(document.body.style.maxheight))top=top+$(window).scrolltop(); $("#popup_container").css({ //top:top+'px',left:left+'px' //top:'50px',left:left+'px' }); $("#popup_overlay").height($(document).height()) } ,_maintainposition:function(status){ if($.alerts.repositiononresize){ switch(status){ case true:$(window).bind('resize',function(){ $.alerts._reposition() }); break; case false:$(window).unbind('resize'); break } } } }; jalert=function(message,title,callback){ $.alerts.alert(message,title,callback) }