/*
* CodeForce LLC
* jQuery waitUI plugin
* Version 2.33 (29-MAR-2010)
* @requires jQuery v1.2.3 or later
*
* Copyright (c) 2007-2008 M. Alsup
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Thanks to Amir-Hossein Sobhi for some excellent contributions!
*/
(function(a){if(/1\.(0|1|2)\.(0|1|2)/.test(a.fn.jquery)||/^1.1/.test(a.fn.jquery)){alert("waitUI requires jQuery v1.2.3 or later!  You are using v"+a.fn.jquery);return}a.fn._fadeIn=a.fn.fadeIn;var p=function(){};var o=document.documentMode||0;var u=a.browser.msie&&((a.browser.version<8&&!o)||o<8);var m=a.browser.msie&&/MSIE 6.0/.test(navigator.userAgent)&&!o;a.waitUI=function(A){n(window,A)};a.unwaitUI=function(A){s(window,A)};a.growlUI=function(E,B,D,C){var A=a('<div class="growlUI"></div>');if(E){A.append("<h1>"+E+"</h1>")}if(B){A.append("<h2>"+B+"</h2>")}if(D==undefined){D=3000}a.waitUI({message:A,fadeIn:700,fadeOut:1000,centerY:false,timeout:D,showOverlay:false,onUnblock:C,css:a.waitUI.defaults.growlCSS})};a.fn.waitui=function(A){return this.unwaitui({fadeOut:0}).each(function(){if(a.css(this,"position")=="static"){this.style.position="relative"}if(a.browser.msie){this.style.zoom=1}n(this,A)})};a.fn.unwaitui=function(A){return this.each(function(){s(this,A)})};a.waitUI.version=2.33;a.waitUI.defaults={message:"<h1>Please wait...</h1>",title:null,draggable:true,theme:false,includeThemeHeader:true,horizontalAlign:"center",verticalAlign:"middle",css:{padding:0,margin:0,top:"40%",left:"35%",textAlign:"center",color:"#000",border:"3px solid #aaa",backgroundColor:"#fff",cursor:"wait"},themedCSS:{top:"40%",left:"35%"},overlayCSS:{backgroundColor:"#000",opacity:0.6,cursor:"wait"},growlCSS:{width:"350px",top:"10px",left:"",right:"10px",border:"none",padding:"5px",opacity:0.6,cursor:"default",color:"#fff",backgroundColor:"#000","-webkit-border-radius":"10px","-moz-border-radius":"10px","border-radius":"10px"},iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank",forceIframe:false,baseZ:10000,centerX:true,centerY:true,allowBodyStretch:true,bindEvents:true,constrainTabKey:true,fadeIn:200,fadeOut:400,timeout:0,showOverlay:true,focusInput:true,applyPlatformOpacityRules:true,onBlock:null,onUnblock:null,quirksmodeOffsetHack:4};var q=null;var r=[];function n(F,N){var G=(F==window);var L=N&&N.message!==undefined?N.message:undefined;N=a.extend({},a.waitUI.defaults,N||{});N.overlayCSS=a.extend({},a.waitUI.defaults.overlayCSS,N.overlayCSS||{});var D=a.extend({},a.waitUI.defaults.css,N.css||{});var P=a.extend({},a.waitUI.defaults.themedCSS,N.themedCSS||{});L=L===undefined?N.message:L;if(G&&q){s(window,{fadeOut:0})}try{if(L&&typeof L!="string"&&(L.parentNode||L.jquery)){var M=L.jquery?L[0]:L;if(M!=null&&M!=undefined){var E={};a(F).data("waitUI.history",E);E.el=M;E.parent=M.parentNode;E.display=M.style.display;E.position=M.style.position;if(E.parent){E.parent.removeChild(M)}}}}catch(O){}var H=g(N,G,L,P,D);var I=H[0];var J=H[1];var K=H[2];c(I,J,K,G,N);J.css("height",w()+y());J.css("width",z()+x());if(L){if(N.theme&&N.includeThemeHeader){K.find(".ui-widget-content").append(L)}else{K.append(L)}if(L.jquery||L.nodeType){a(L).show()}}if((a.browser.msie||N.forceIframe)&&N.showOverlay){I.show()}if(N.fadeIn){var A=N.onBlock?N.onBlock:p;var B=(N.showOverlay&&!L)?A:p;var C=L?A:p;if(N.showOverlay){J._fadeIn(N.fadeIn,B)}if(L){K._fadeIn(N.fadeIn,C)}f(K,N)}else{if(N.showOverlay){J.show()}if(L){K.show();f(K,N)}if(N.onBlock){N.onBlock()}}h(1,F,N);if(G){q=K[0];r=a(":input:enabled:visible",q);if(N.focusInput){setTimeout(k,20)}}else{if(N.timeout){var Q=setTimeout(function(){G?a.unwaitUI(N):a(F).unwaitui(N)},N.timeout);a(F).data("waitUI.timeout",Q)}}}function f(B,C){var A=e(B,C);a(B).css("left",A[0]);a(B).css("top",A[1])}function c(F,G,H,A,I){var B=u&&(!a.boxModel||a("object,embed",A?null:el).length>0);if(m||B){if(A&&I.allowBodyStretch&&a.boxModel){a("html,body").css("height","100%")}if((m||!a.boxModel)&&!A){var J=v(el,"borderTopWidth"),E=v(el,"borderLeftWidth");var D=J?"(0 - "+J+")":0;var C=E?"(0 - "+E+")":0}a.each([F,G,H],function(L,M){var N=M[0].style;N.position="absolute";if(L<2){A?N.setExpression("height","Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:"+I.quirksmodeOffsetHack+') + "px"'):N.setExpression("height",'this.parentNode.offsetHeight + "px"');A?N.setExpression("width",'jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"'):N.setExpression("width",'this.parentNode.offsetWidth + "px"');if(C){N.setExpression("left",C)}if(D){N.setExpression("top",D)}}else{if(I.centerY){if(A){N.setExpression("top",'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"')}N.marginTop=0}else{if(!I.centerY&&A){var O=(I.css&&I.css.top)?parseInt(I.css.top):0;var K="((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "+O+') + "px"';N.setExpression("top",K)}}}})}}function b(){var A=new Object();A.left=0;A.top=0;A.width=0;A.height=0;A.rightx=0;A.bottomy=0;return A}function d(D){var A=b();try{var B=a(".jqrywaituicontent");var F=B.position();var E=a(B).offset();A.left=A.x=(F.left>=E.left?F.left:E.left);A.top=A.y=(F.top>=E.top?F.top:E.top);A.width=B.outerWidth();A.height=B.outerHeight();A.rightx=A.left+A.width;A.bottomy=A.top+A.height}catch(C){}return A}function e(B,C){elt=B;var A=d(elt);var E=0;var F=0;switch(C.horizontalAlign){case"left":break;case"center":E=(parseInt((z()/2))-parseInt((A.width/2)));E+=x();if(E<0){E=0}break;case"right":E=z()-A.width;break;case"centerpage":E=(parseInt((this.documentWidth()/2))-parseInt((A.width/2)));break}switch(C.verticalAlign){case"middle":F=(parseInt((w()/2))-parseInt((A.height/2)));F+=y();if(F<0){F=0}break;case"top":break;case"bottom":F=w()-A.height;break;case"middlepage":F=(parseInt((i()/2))-parseInt((A.height/2)));break}var D=new Array();D.push(E);D.push(F);return D}function w(){var B=0;try{return a(window).height()}catch(A){return 768}}function z(){try{return a(window).width()}catch(A){return 1024}}function i(){try{return a(document).height()}catch(A){return 768}}function j(){try{return a(document).width()}catch(A){return 1024}}function x(){try{return a(window).scrollLeft()}catch(A){}return 0}function y(){try{return a(window).scrollTop()}catch(A){}return 0}function g(I,C,H,K,B){var D=new Array();var L=I.baseZ;var E=(a.browser.msie||I.forceIframe)?a('<iframe class="waitUI jqrywaituiiframe" style="z-index:'+(L++)+';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+I.iframeSrc+'"></iframe>'):a('<div class="waitUI jqrywaituiiframe" style="display:none"></div>');var F=a('<div class="waitUI blockOverlay jqrywaituioverlay" style="z-index:'+(L++)+';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');if(I.theme){F=a('<div class="waitUI ui-widget-overlay jqrywaituioverlay" style="z-index:'+(L++)+';"></div>')}var G,J;if(I.theme&&C){if(I.includeThemeHeader){J='<div class="waitUI blockMsg ui-dialog ui-widget ui-corner-all jqrywaituicontent" style="z-index:'+L+';display:none;position:absolute"><div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(I.title||"&nbsp;")+'</div><div class="ui-widget-content ui-dialog-content"></div></div>'}else{J='<div class="waitUI blockMsg ui-widget ui-corner-all jqrywaituicontent" style="z-index:'+L+';display:none;position:absolute"></div>'}}else{if(I.theme){if(I.includeThemeHeader){J='<div class="waitUI blockMsg blockElement ui-dialog ui-widget ui-corner-all jqrywaituicontent" style="z-index:'+L+';display:none;position:absolute"><div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(I.title||"&nbsp;")+'</div><div class="ui-widget-content ui-dialog-content"></div></div>'}else{J='<div class="waitUI blockMsg blockElement ui-widget ui-corner-all jqrywaituicontent" style="z-index:'+L+';display:none;position:absolute"></div>'}}else{if(C){J='<div class="waitUI blockMsg blockPage jqrywaituicontent" style="z-index:'+L+';display:none;position:absolute"></div>'}else{J='<div class="waitUI blockMsg blockElement jqrywaituicontent" style="z-index:'+L+';display:none;position:absolute"></div>'}}}G=a(J);if(H){if(I.theme&&I.includeThemeHeader){G.css(K);G.addClass("ui-widget-content")}else{G.css(B)}}if(!I.applyPlatformOpacityRules||!(a.browser.mozilla&&/Linux/.test(navigator.platform))){F.css(I.overlayCSS)}if(a.browser.msie||I.forceIframe){E.css("opacity",0)}var D=[E,F,G],A=C?a("body"):a(el);a.each(D,function(){this.appendTo(A)});if(I.theme&&I.draggable&&a.fn.draggable&&I.includeThemeHeader){G.draggable({handle:".ui-dialog-titlebar",cancel:"li"})}D.push(E);D.push(F);D.push(G);return D}function s(C,F){var D=(C==window);var A=a(C);var B=A.data("waitUI.history");var G=A.data("waitUI.timeout");if(G){clearTimeout(G);A.removeData("waitUI.timeout")}F=a.extend({},a.waitUI.defaults,F||{});h(0,C,F);var E;if(D){E=a("body").children().filter(".waitUI").add("body > .waitUI")}else{E=a(".waitUI",C)}if(D){q=r=null}if(F.fadeOut){E.fadeOut(F.fadeOut);setTimeout(function(){t(E,B,F,C)},F.fadeOut)}else{t(E,B,F,C)}}function t(C,A,D,B){C.each(function(E,F){if(this.parentNode){this.parentNode.removeChild(this)}});if(A&&A.el){A.el.style.display=A.display;A.el.style.position=A.position;if(A.parent){A.parent.appendChild(A.el)}a(B).removeData("waitUI.history")}if(typeof D.onUnblock=="function"){D.onUnblock(B,D)}}function h(B,C,F){var D=C==window,A=a(C);if(!B&&(D&&!q||!D&&!A.data("waitUI.isBlocked"))){return}if(!D){A.data("waitUI.isBlocked",B)}if(!F.bindEvents||(B&&!F.showOverlay)){return}var E="mousedown mouseup keydown keypress";B?a(document).bind(E,F,l):a(document).unbind(E,l)}function l(B){if(B.keyCode&&B.keyCode==9){if(q&&B.data.constrainTabKey){var C=r;var D=!B.shiftKey&&B.target==C[C.length-1];var A=B.shiftKey&&B.target==C[0];if(D||A){setTimeout(function(){k(A)},10);return false}}}if(a(B.target).parents("div.blockMsg").length>0){return true}return a(B.target).parents().children().filter("div.waitUI").length==0}function k(A){if(!r){return}var B=r[A===true?r.length-1:0];if(B){B.focus()}}function v(A,B){return parseInt(a.css(A,B))||0}})(jQuery);
