var Spry;if(!Spry){Spry={}}if(!Spry.Widget){Spry.Widget={}}Spry.Widget.BrowserSniff=function(){var i=navigator.appName.toString();var e=navigator.platform.toString();var c=navigator.userAgent.toString();this.mozilla=this.ie=this.opera=this.safari=false;var g=/Opera.([0-9\.]*)/i;var d=/MSIE.([0-9\.]*)/i;var f=/gecko/i;var h=/(applewebkit|safari)\/([\d\.]*)/i;var a=false;if((a=c.match(g))){this.opera=true;this.version=parseFloat(a[1])}else{if((a=c.match(d))){this.ie=true;this.version=parseFloat(a[1])}else{if((a=c.match(h))){this.safari=true;if(parseFloat(a[2])<420){this.version=2}else{this.version=3}}else{if(c.match(f)){var j=/rv:\s*([0-9\.]+)/i;a=c.match(j);this.mozilla=true;this.version=parseFloat(a[1])}}}}this.windows=this.mac=this.linux=false;this.Platform=c.match(/windows/i)?"windows":(c.match(/linux/i)?"linux":(c.match(/mac/i)?"mac":c.match(/unix/i)?"unix":"unknown"));this[this.Platform]=true;this.v=this.version;if(this.safari&&this.mac&&this.mozilla){this.mozilla=false}};Spry.is=new Spry.Widget.BrowserSniff();Spry.Widget.PopupDialog=function(b,a){a=Spry.Widget.Utils.firstValid(a,{});this.init(b,a)};Spry.Widget.PopupDialog.prototype.init=function(f,a){var e=Spry.Widget.Utils;this.popupdialogElement=e.getElement(f);if(typeof this.popupdialogElement=="undefined"||!this.popupdialogElement){this.showError('The element "'+f+'" do not exists in the page');return false}this.currentState=0;this.useEffect=false;this.shieldListenersAttached=false;this.bodySizeListenersAttached=false;this.shieldExists=false;e.setOptions(this,a);this.popupdialogElement.style.position="absolute";this.popupdialogElement.style.top="0px";this.popupdialogElement.style.left="-10000px";this.popupdialogElement.style.zindex="500";this.popupdialogElement.style.height="100%";this.popupdialogElement.style.width="100%";this.popupVPosition="middle";this.popupHPosition="center";this.shieldLayer=document.createElement("div");if(typeof this.focusElement!="undefined"&&this.focusElement.length>0){if(this.focusElement.indexOf("#")==0){this.focusElement=this.focusElement.substring(1)}}this.animator=null;if(this.useEffect){switch(this.useEffect.toString().toLowerCase()){case"fade":this.useEffect="Fade";break;default:this.useEffect=false}}var c="";var d="";this.popupbox_elements=this.popupdialogElement.getElementsByTagName("*");for(var b=0;b<this.popupbox_elements.length;b++){if(this.popupbox_elements[b].className=="popupBox"){this.popupBox=c=this.popupbox_elements[b];this.popupBox.style.position="absolute";if(this.popupVPosition=="middle"){if(Spry.is.ie&&(Spry.is.version=="6"||Spry.is.version=="7")){this.popupBox.style.top=((screen.availHeight-180-this.popupBox.offsetHeight)/2)+"px"}else{this.popupBox.style.top=((this.popupdialogElement.offsetHeight-this.popupBox.offsetHeight)/2)+"px"}}if(this.popupHPosition=="center"){this.popupBox.style.left=((this.popupdialogElement.offsetWidth-this.popupBox.offsetWidth)/2)+"px"}}if(this.popupbox_elements[b].className=="popupBar"){d=this.popupbox_elements[b]}}if(this.allowDrag){this.initDragPopUp();if(c!=""&&d!=""){d.style.cursor="move";MoveEngine.init(d,c)}}};Spry.Widget.PopupDialog.addLoadListener=function(a){if(typeof window.addEventListener!="undefined"){window.addEventListener("load",a,false)}else{if(typeof document.addEventListener!="undefined"){document.addEventListener("load",a,false)}else{if(typeof window.attachEvent!="undefined"){window.attachEvent("onload",a)}}}};Spry.Widget.PopupDialog.prototype.showPopupDialog=function(){this.currentState=1;var d=(Spry.is.safari)?document.body:document.documentElement;this.popupdialogElement.style.visibility="hidden";this.popupdialogElement.style.left="0px";this.popupdialogElement.style.zIndex="9999";this.popupdialogElement.style.display="block";this.popupdialogElement.style.top=d.scrollTop+"px";this.createShieldLayer(this.popupdialogElement);var b=Spry.Widget.Utils.addEventListener;var e=Spry.Widget.Utils.addEventListener;var a=this;if(!this.modal){if(!this.shieldListenersAttached){b((Spry.is.ie&&Spry.is.version=="6")?this.shieldLayer:this.popupdialogElement,"click",function(g){var f=(Spry.is.ie&&(Spry.is.version=="6"||Spry.is.version=="7"))?((parseInt(a.popupBox.style.top)+a.popupBox.offsetTop)/2):a.popupBox.offsetTop;if((g.clientX<a.popupBox.offsetLeft)||(g.clientX>a.popupBox.offsetLeft+a.popupBox.offsetWidth)||(g.clientY<f)||(g.clientY>f+a.popupBox.offsetHeight)){a.displayPopupDialog(false)}return true},false);this.shieldListenersAttached=true}}if(!this.bodySizeListenersAttached){e(window,"resize",function(f){a.sizeShieldLayer();a.SyncSizePopUp();if(d.scrollHeight<=a.shieldLayer.offsetHeight+10){a.popupdialogElement.style.top=d.scrollTop+"px"}else{a.popupdialogElement.style.top="0px"}a.popupBox.style.left=((a.popupdialogElement.offsetWidth-a.popupBox.offsetWidth)/2)+"px";return true},false);this.bodySizeListenersAttached=true}if(!this.allowScroll){if(Spry.is.mozilla){var c=d.scrollTop}document.body.parentNode.style.overflow="hidden";a.sizeShieldLayer();if(Spry.is.mozilla){d.scrollTop=c}}else{document.body.parentNode.style.overflow="";e(window,"scroll",function(f){a.sizeShieldLayer();if(d.scrollHeight<=a.shieldLayer.offsetHeight+10){a.popupdialogElement.style.top=d.scrollTop+"px";return true}},false)}if(Spry.is.ie&&Spry.is.version=="6"){this.createIframeLayer(this.popupdialogElement)}if(this.useEffect){if(typeof this.showEffect=="undefined"){this.showEffect=new Spry.Widget.PopupDialog[this.useEffect](this.popupdialogElement,{from:0,to:1})}this.showEffect.start()}else{this.currentState=0}this.popupdialogElement.style.visibility="visible";if(typeof(this.focusElement)!="undefined"&&this.focusElement!=""&&document.getElementById(this.focusElement)!=null){document.getElementById(this.focusElement).focus()}this.SyncSizePopUp()};Spry.Widget.PopupDialog.prototype.hidePopupDialog=function(b){this.currentState=2;if(Spry.is.mozilla){var a=document.documentElement.scrollTop}this.removeShieldLayer();document.body.parentNode.style.overflow="";if(Spry.is.safari){scrollBy(0,1);scrollBy(0,-1)}if(this.useEffect&&!b){if(typeof this.hideEffect=="undefined"){this.hideEffect=new Spry.Widget.PopupDialog[this.useEffect](this.popupdialogElement,{from:1,to:0})}this.hideEffect.start()}else{if(typeof this.showEffect!="undefined"){this.showEffect.stop()}this.popupdialogElement.style.visibility="hidden";this.popupdialogElement.style.left="-10000px";this.currentState=0}if(Spry.is.mozilla){document.documentElement.scrollTop=a}if(Spry.is.ie&&Spry.is.version=="6"){this.removeIframeLayer(this.popupdialogElement)}};Spry.Widget.PopupDialog.prototype.displayPopupDialog=function(a){if(this.popupdialogElement){if(this.currentState==0){if(a){this.currentState=1;if(this.hideTimer){clearInterval(this.hideTimer);delete (this.hideTimer)}var b=this;this.showTimer=setTimeout(function(){b.showPopupDialog()},0)}else{this.currentState=2;if(this.showTimer){clearInterval(this.showTimer);delete (this.showTimer)}var b=this;this.hideTimer=setTimeout(function(){b.hidePopupDialog()},0)}}}};Spry.Widget.PopupDialog.prototype.destroy=function(){for(var a in this){try{if(typeof this.k=="object"&&typeof this.k.destroy=="function"){this.k.destroy()}delete this.k}catch(b){}}};Spry.Widget.PopupDialog.prototype.checkDestroyed=function(){if(!this.popupdialogElement||this.popupdialogElement.parentNode==null){return true}return false};Spry.Widget.PopupDialog.prototype.createIframeLayer=function(a){if(typeof this.iframeLayer=="undefined"){var b=document.createElement("iframe");b.tabIndex="-1";b.src='javascript:"";';b.scrolling="no";b.frameBorder="0";b.className="iframePopupDialog";a.parentNode.appendChild(b);this.iframeLayer=b}this.iframeLayer.style.left=a.offsetLeft+"px";this.iframeLayer.style.top=a.offsetTop+"px";this.iframeLayer.style.width=a.offsetWidth+"px";this.iframeLayer.style.height=a.offsetHeight+"px";this.iframeLayer.style.display="block"};Spry.Widget.PopupDialog.prototype.removeIframeLayer=function(a){if(this.iframeLayer){this.iframeLayer.style.display="none"}};Spry.Widget.PopupDialog.prototype.createShieldLayer=function(a){if(!this.shieldExists){this.shieldLayer.tabIndex="-1";this.shieldLayer.className="shieldPopupDialog";this.shieldLayer.innerHTML="&nbsp;";this.shieldLayer.style.zindex="499";this.shieldLayer.style.position="absolute";this.shieldLayer.style.top="0px";a.parentNode.appendChild(this.shieldLayer)}this.shieldLayer.style.left="0px";this.shieldExists=true;this.shieldLayer.style.display="inline";this.sizeShieldLayer()};Spry.Widget.PopupDialog.prototype.removeShieldLayer=function(){if(this.shieldExists){this.shieldLayer.style.left="-10000px"}};Spry.Widget.PopupDialog.prototype.sizeShieldLayer=function(){var a=(Spry.is.safari)?document.body:document.documentElement;if(Spry.is.ie&&(Spry.is.version=="6"||Spry.is.version=="7")){this.shieldLayer.style.height=Number(a.offsetHeight)+"px"}else{this.shieldLayer.style.height="100%"}this.shieldLayer.style.width=Number(a.scrollWidth)+"px";if(a.scrollHeight>this.shieldLayer.offsetHeight){this.shieldLayer.style.height=Number(a.scrollHeight)+"px"}};Spry.Widget.PopupDialog.prototype.SyncSizePopUp=function(f){var c=(Spry.is.safari)?document.body:document.documentElement;var a=this;if(Ext!="undefined"){var d=Ext.get(this.popupdialogElement);var b=d.getY();var c=(Spry.is.safari)?document.body:document.documentElement;d.center(c);d.setY(b-125)}if(c.scrollHeight<=a.shieldLayer.offsetHeight+10){a.popupdialogElement.style.top=c.scrollTop+"px"}else{a.popupdialogElement.style.top="0px"}a.popupBox.style.left=((a.popupdialogElement.offsetWidth-a.popupBox.offsetWidth)/2)+"px";return true};Spry.Widget.PopupDialog.prototype.initDragPopUp=function(){var c=this.popupdialogElement;var a=this.shieldLayer;var b=(Spry.is.safari)?document.body:document.documentElement;MoveEngine={obj:null,init:function(d,e){d.onmousedown=MoveEngine.start;d.box=e&&e!=null?e:d;d.xMapper=null;d.yMapper=null;d.box.onDragStart=new Function();d.box.onDragEnd=new Function();d.box.onDrag=new Function()},start:function(f){var g=MoveEngine.obj=this;g.minX=0;g.maxX=screen.availWidth-g.box.offsetWidth-34;g.minY=0;g.maxY=c.offsetHeight-g.box.offsetHeight-20;if(Spry.is.ie&&(Spry.is.version=="6"||Spry.is.version=="7")){g.maxY=screen.availHeight-g.box.offsetHeight-160}f=MoveEngine.fixE(f);var h=parseInt(g.box.style.top);var d=parseInt(g.box.style.left);g.box.onDragStart(d,h);g.lastMouseX=f.clientX;g.lastMouseY=f.clientY;if(g.minX!=null){g.minMouseX=f.clientX-d+g.minX}if(g.maxX!=null){g.maxMouseX=g.minMouseX+g.maxX-g.minX}if(g.minY!=null){g.minMouseY=f.clientY-h+g.minY}if(g.maxY!=null){g.maxMouseY=g.minMouseY+g.maxY-g.minY}document.onmousemove=MoveEngine.drag;document.onmouseup=MoveEngine.end;return false},drag:function(i){i=MoveEngine.fixE(i);var j=MoveEngine.obj;var g=i.clientY;var h=i.clientX;var l=parseInt(j.box.style.top);var f=parseInt(j.box.style.left);var d,k;if(j.minX!=null){h=Math.max(h,j.minMouseX)}if(j.maxX!=null){h=Math.min(h,j.maxMouseX)}if(j.minY!=null){g=Math.min(g,j.maxMouseY)}if(j.maxY!=null){g=Math.max(g,j.minMouseY)}d=f+(h-j.lastMouseX);k=l+(g-j.lastMouseY);if(j.xMapper){d=j.xMapper(l)}else{if(j.yMapper){k=j.yMapper(f)}}j.box.style.left=d+"px";j.box.style.top=k+"px";j.lastMouseX=h;j.lastMouseY=g;j.box.onDrag(d,k);a.style.width=Number(b.scrollWidth)+"px";return false},end:function(){document.onmousemove=null;document.onmouseup=null;MoveEngine.obj.box.onDragEnd(parseInt(MoveEngine.obj.box.style.left),parseInt(MoveEngine.obj.box.style.top));MoveEngine.obj=null},fixE:function(d){if(typeof d=="undefined"){d=window.event}if(typeof d.layerX=="undefined"){d.layerX=d.offsetX}if(typeof d.layerY=="undefined"){d.layerY=d.offsetY}return d}}};Spry.Widget.PopupDialog.prototype.showError=function(a){alert("Spry.Widget.PopupDialog ERR: "+a)};Spry.Widget.PopupDialog.Animator=function(b,c){this.timer=null;this.fps=60;this.duration=500;this.startTime=0;this.transition=Spry.Widget.PopupDialog.Animator.defaultTransition;this.onComplete=null;if(typeof b=="undefined"){return}this.element=Spry.Widget.Utils.getElement(b);Spry.Widget.Utils.setOptions(this,c,true);this.interval=this.duration/this.fps;this.popupbox_elements=this.element.getElementsByTagName("*");for(var a=0;a<this.popupbox_elements.length;a++){if(this.popupbox_elements[a].className=="popupBox"){this.popupBox=this.popupbox_elements[a]}}};Spry.Widget.PopupDialog.Animator.defaultTransition=function(d,b,a,c){d/=c;return b+((2-d)*d*a)};Spry.Widget.PopupDialog.Animator.prototype.start=function(){var a=this;this.startTime=(new Date).getTime();this.beforeStart();this.timer=setInterval(function(){a.stepAnimation()},this.interval)};Spry.Widget.PopupDialog.Animator.prototype.stop=function(){if(this.timer){clearTimeout(this.timer)}eval(this.element.id+".currentState = 0");this.timer=null};Spry.Widget.PopupDialog.Animator.prototype.stepAnimation=function(){};Spry.Widget.PopupDialog.Animator.prototype.beforeStart=function(){if(this.timer){clearTimeout(this.timer)}};Spry.Widget.PopupDialog.Animator.prototype.destroy=function(){for(var a in this){try{delete this.k}catch(b){}}};Spry.Widget.PopupDialog.Fade=function(a,b){Spry.Widget.PopupDialog.Animator.call(this,a,b);if(Spry.is.ie){this.origOpacity=this.element.style.filter}else{this.origOpacity=this.element.style.opacity}};Spry.Widget.PopupDialog.Fade.prototype=new Spry.Widget.PopupDialog.Animator();Spry.Widget.PopupDialog.Fade.prototype.constructor=Spry.Widget.PopupDialog.Fade;Spry.Widget.PopupDialog.Fade.prototype.stepAnimation=function(){var e=(new Date).getTime();var a=e-this.startTime;var c,f;if(a>=this.duration){this.beforeStop();this.stop();return}var b=this.transition(a,this.from,this.to-this.from,this.duration);if(Spry.is.ie){var d=this.popupBox.currentStyle.filter.replace(/alpha\s*\(\s*opacity\s*=\s*[0-9\.]{1,3}\)/,"");this.popupBox.style.filter=d+"alpha(opacity="+parseInt(b*100,10)+")"}else{this.element.style.opacity=b}this.element.style.visibility="visible";this.element.style.display="block"};Spry.Widget.PopupDialog.Fade.prototype.beforeStop=function(){if(this.from>this.to){eval(this.element.id+".hidePopupDialog(true)")}if(Spry.is.mozilla){this.element.style.filter=this.origOpacity}else{this.element.style.opacity=this.origOpacity}};if(!Spry.Widget.Utils){Spry.Widget.Utils={}}Spry.Widget.Utils.setOptions=function(d,c,a){if(!c){return}for(var b in c){if(a&&c[b]==undefined){continue}d[b]=c[b]}};Spry.Widget.Utils.getElement=function(a){if(a&&typeof a=="string"){return document.getElementById(a)}return a};Spry.Widget.Utils.firstValid=function(){var c=null;var b=Spry.Widget.Utils.firstValid;for(var d=0;d<b.arguments.length;d++){if(typeof(b.arguments[d])!="undefined"){c=b.arguments[d];break}}return c};Spry.Widget.Utils.addEventListener=function(c,b,d,a){try{if(c.addEventListener){c.addEventListener(b,d,a)}else{if(c.attachEvent){c.attachEvent("on"+b,d)}}}catch(f){}};
