/***********************************************************************/
/* LEMOOPOPUP.JS : LE MOO POPUP!                                       */
/* COPYRIGHT 2010 SPINNAKER 360 PTE LTD ALL RIGHTS RESERVED            */
/* THIS SCRIPT MAY NOT BE REPRODUCED OR DISTRIBUTED WITHOUT PERMISSION */
/***********************************************************************/
var popup=null;window.addEvent("domready",function(){popup=new LeMooPopup()});var LeMooPopup=new Class({Implements:[Options,Chain],options:{defaultWidth:200,defaultHeight:50,width:Number.NaN,height:Number.NaN,smokeScreenOpacity:0.6,transitDuration:200,transitAnimate:Fx.Transitions.Sine.easeOut,mode:"text",data:null,param:null,autoHeader:false,header:null,loadMessage:"<img src='images/spinnerSmall.gif' /> Loading..."},initialize:function(options){this.onEscapeTarget=Browser.isIE?document.body:document;this.smokeScreen=new Element("div",{id:"LMP_smokescreen"});
/*@cc_on
@if(@_jscript_version<=5.6)
this.smokeScreen.addClass("ie6");
@end
@*/
this.smokeScreen.fade("hide");this.smokeScreen.injectBottom(document.body);this.wrapper=new Element("div",{id:"LMP_wrapper"});this.contentsWrapper=new Element("div",{id:"LMP_contentsWrapper"});this.contentsWrapper.injectBottom(this.wrapper);this.wrapperTop=new Element("div",{id:"LMP_wrapperTop"});this.contents=new Element("div",{id:"LMP_contents"});this.wrapperBottom=new Element("div",{id:"LMP_wrapperBottom"});this.wrapperTop.set("html","<table class='fullflat'><tr><td id='LMP_wrapperTopLeft'></td><td id='LMP_wrapperTopCenter'>&nbsp;</td><td id='LMP_wrapperTopRight'></td></tr></table>");this.wrapperBottom.set("html","<table class='fullflat'><tr><td id='LMP_wrapperBottomLeft'></td><td id='LMP_wrapperBottomCenter'>&nbsp;</td><td id='LMP_wrapperBottomRight'></td></tr></table>");this.wrapperTop.injectBottom(this.contentsWrapper);this.contents.injectBottom(this.contentsWrapper);this.wrapperBottom.injectBottom(this.contentsWrapper);this.wrapper.fade("hide");this.wrapper.injectBottom(document.body);this.tempHolder=new Element("div",{id:"LMP_temp"});this.tempHolder.injectBottom(document.body);this.open=false},show:function(width,height){if(this.open){this.animateReset()}else{this.reset()}
/*@cc_on
@if(@_jscript_version<=5.6)
this.fixSmokeScreen();
@end
@*/
this.smokeScreen.fade(this.options.smokeScreenOpacity);this.wrapper.fade(1);
/*@cc_on
@if(@_jscript_version<=5.6)
this.killSelect();
@end
@*/
this.setTempContents();if(isFinite(width)&&isFinite(height)){this.options.width=width;this.options.height=height}else{this.options.width=Number.NaN;this.options.height=Number.NaN}this.showTransit.delay(500,this);this.boundOnEscape=this.onEscape.bind(this);$(this.onEscapeTarget).addEvent('keydown',this.boundOnEscape);this.open=true},hide:function(){ssTransit=new Fx.Morph(this.smokeScreen,{duration:this.options.transitDuration});wrapperTransit=new Fx.Morph(this.wrapper,{duration:this.options.transitDuration});ssTransit.start({opacity:[this.options.smokeScreenOpacity,0]});wrapperTransit.start({opacity:[1,0]}).chain(function(){this.contents.set("html","");this.wrapper.setStyle("display","none");
/*@cc_on
@if(@_jscript_version<=5.6)
this.resurrectSelect();
@end
@*/
$(this.onEscapeTarget).removeEvent('keydown',this.boundOnEscape);delete this.boundOnEscape;this.open=false;if(typeof this.onHide=="function"){this.onHide.bind(this);this.onHide();this.onHide=null}}.bind(this))},setMode:function(mode,data,param){switch(mode){default:case"text":this.options.mode="text";this.options.data=data;break;case"ajax":this.options.mode="ajax";this.options.data=data;this.options.param=param;break}},reset:function(){this.contents.set("html",this.options.loadMessage);this.wrapper.setStyle("display","block");this.contents.setStyles({"width":"auto","height":"auto"});this.contentsWrapper.setStyles({"width":this.options.defaultWidth,"height":this.options.defaultHeight});var pgWrapDimension=$('pageWrapper').getSize();var vpDimension=$(window).getSize();var popupDimension=this.contentsWrapper.getSize();var htAnchor=pgWrapDimension.y<=vpDimension.y?pgWrapDimension:vpDimension;var newHtPos=parseInt((htAnchor.y-popupDimension.y)/2);newHtPos=newHtPos<50?50:newHtPos;this.contentsWrapper.setStyle("top",newHtPos)},animateReset:function(){this.contents.set("html",this.options.loadMessage);var widthTransit=new Fx.Morph(this.contentsWrapper,{duration:this.options.transitDuration,transition:this.options.transitAnimate});var heightTransit=new Fx.Morph(this.contents,{duration:this.options.transitDuration,transition:this.options.transitAnimate});widthTransit.start({'width':this.options.defaultWidth}).chain(function(){heightTransit.start({'height':this.options.defaultHeight})}.bind(this))},setTempContents:function(){var tempContent=this.options.autoHeader?this.options.header:"";switch(this.options.mode){default:case"text":if(this.options.data===null){this.options.data=""}tempContent+=this.options.data;this.tempHolder.set("html",tempContent);break;case"ajax":this.options.param=this.options.param===null?"":this.options.param;new Request({url:this.options.data,async:false,onSuccess:function(responseText){tempContent+=responseText;this.tempHolder.set("html",tempContent)}.bind(this),onFailure:function(){tempContent+="An error occured while retrieving content...";this.tempHolder.set("html",tempContent)}.bind(this)}).post(this.options.param);break}},showTransit:function(){var pgWrapDimension=$('pageWrapper').getSize();var vpDimension=$(window).getSize();var contentDimension=this.contents.getSize();var newWidth=0,newHeight=0;if(isFinite(this.options.width)&&isFinite(this.options.height)){newWidth=this.options.width;newHeight=this.options.height}else{var tempDimension=this.tempHolder.getSize();newWidth=parseInt(tempDimension.x);newHeight=parseInt(tempDimension.y)}newWidth+=30;newHeight+=10;var htAnchor=pgWrapDimension.y<=vpDimension.y?pgWrapDimension.y:vpDimension.y;var newHtPos=parseInt((htAnchor-newHeight)/2);newHtPos=newHtPos<50?50:newHtPos;var transitPositionEffect=new Fx.Morph(this.contentsWrapper,{duration:this.options.transitDuration,transition:this.options.transitAnimate});var widthTransit=new Fx.Morph(this.contentsWrapper,{duration:this.options.transitDuration,transition:this.options.transitAnimate});var heightTransit=new Fx.Morph(this.contents,{duration:this.options.transitDuration,transition:this.options.transitAnimate});transitPositionEffect.start({"top":newHtPos}).chain(function(){widthTransit.start({'width':[contentDimension.x,newWidth]}).chain(function(){heightTransit.start({'height':[contentDimension.y,newHeight]}).chain(function(){this.contents.set("html",this.tempHolder.get("html"));this.tempHolder.set("html","");
/*@cc_on
@if(@_jscript_version<=5.6)
this.fixSmokeScreen();
@end
@*/
if(typeof this.onShow=="function"){this.onShow.bind(this);this.onShow();this.onShow=null}}.bind(this))}.bind(this))}.bind(this))},fixSmokeScreen:function(){var pgWrapDimension=$('pageWrapper').getSize();var vpDimension=$(window).getSize();var newHeight=pgWrapDimension.y>=vpDimension.y?pgWrapDimension.y:vpDimension.y;this.smokeScreen.setStyle("height",newHeight)},onEscape:function(ev){if(ev.key=='esc'){this.hide()}},killSelect:function(){var allSelect=$$('select');if(allSelect!==undefined&&allSelect!==null&&allSelect!=""){allSelect.each(function(el){el.setStyle("display","none")})}},resurrectSelect:function(){var allSelect=$$('select');if(allSelect!==undefined&&allSelect!==null&&allSelect!=""){allSelect.each(function(el){el.setStyle("display","block")})}}});
