namespace("UPC.widget.modalWindow");UPC.widget.modalWindow.Base=function(){};UPC.widget.modalWindow.Base.prototype={BaseDefaultOptions:{width:400,height:300,useAJAX:false,destroyOnClose:false,id:"ch_modal_window",className:"ch_modal_window",clickOverlayToClose:true,hoverOverlayToClose:false,parentElement:null,okButton:{label:"Ok",show:true},cancelButton:{label:"Cancel",show:true},position:{},baseZIndex:3000,onShow:Prototype.emptyFunction,onHide:Prototype.emptyFunction,onClickOk:Prototype.emptyFunction,onClickCancel:Prototype.emptyFunction},content:"",contentURL:null,mainElement:null,overlay:null,active:false,baseInitialize:function(content,options){this.options=Object.extend({},this.BaseDefaultOptions);this.options.parentElement=document.body;if(typeof options=="object"){this.options=Object.extend(this.options,options)}if(this.options.useAJAX){this.contentURL=content;this._loadContent()}else{this.content=content}if(Element.getStyle(this.options.parentElement,"position")==""||Element.getStyle(this.options.parentElement,"position")=="static"){Element.setStyle(this.options.parentElement,{position:"relative"})}var ie=false
/*@cc_on || true @*/
;this.isIE6=ie&&(document.implementation!=null)&&(document.implementation.hasFeature!=null);this.isIE55=false;return true},show:function(){this._disablePageScroll();if(this.overlay==null){this._buildOverlay()}if(this.mainElement==null){this._buildWindow()}this.overlay.show();this.mainElement.show();this._onShow();this.active=true;Event.observe(window,"keypress",this._onKeyPressHandler.bindAsEventListener(this))},hide:function(){this._enablePageScroll();if(this.options.destroyOnClose){this._destroy()}else{this.overlay.hide();this.mainElement.hide()}this._onHide();this.active=false;Event.stopObserving(window,"keypress",this._onKeyPressHandler.bindAsEventListener(this))},_buildOverlay:function(){try{if((this.overlay=$(this.options.id+"_overlay"))==null){this.overlay=document.createElement("div");this.options.parentElement.insertBefore(this.overlay,this.options.parentElement.firstChild);this.overlay.id=this.options.id+"_overlay";Element.addClassName(this.overlay,this.options.className+"_overlay");var browser=this._getBrowserSize();this.overlay.setStyle({width:(browser.width+50)+"px",height:(browser.height+50)+"px",position:"absolute",left:0,top:0,display:"none",zIndex:this.options.baseZIndex-1});this.options.baseZIndex++;if(this.isIE6||this.isIE55){this.options.parentElement.select("select").invoke("setStyle",{visibility:"hidden"})}if(this.options.hoverOverlayToClose){Event.observe(this.overlay,"mouseover",this._onClickCancel.bindAsEventListener(this))}else{if(this.options.clickOverlayToClose){Event.observe(this.overlay,"click",this._onClickCancel.bindAsEventListener(this))}}}}catch(e){this._dispatchError(e)}},_buildWindow:function(){try{var container=document.createElement("div");container.id=this.options.id+(Math.round(Math.random()*100000));container.className=this.options.className;if(this.position==null){this._getPosition()}var content=document.createElement("div");content.id=container.id+"_content";content.className=this.options.className+"_content";content.innerHTML=this.content;if(this.options.okButton.show){var okButton=document.createElement("a");okButton.id=container.id+"_ok";okButton.className=this.options.className+"_ok";okButton.innerHTML=this.options.okButton.label;okButton.href="#";this.okButton=content.appendChild(okButton);Event.observe(this.okButton,"click",this._onClickOk.bindAsEventListener(this))}if(this.options.cancelButton.show){var cancelButton=document.createElement("a");cancelButton.id=container.id+"_cancel";cancelButton.className=this.options.className+"_cancel";cancelButton.innerHTML=this.options.cancelButton.label;cancelButton.href="#";this.cancelButton=content.appendChild(cancelButton);Event.observe(this.cancelButton,"click",this._onClickCancel.bindAsEventListener(this))}container.appendChild(content);this.mainElement=this.options.parentElement.insertBefore(container,this.options.parentElement.firstChild);var style={width:this.options.width+"px",height:(this.options.height=="auto"?this.options.height:(this.options.height+"px")),display:"none",position:"absolute",top:this.position.top,left:this.position.left,zIndex:this.options.baseZIndex};Element.setStyle(container,style);if(this.options.height=="auto"){var height=this.mainElement.getHeight();if(this.parentElement==document.body){var parentSize=this._getBrowserSize()}else{var parentSize=this.options.parentElement.getDimensions()}this.mainElement.setStyle({top:Math.round((parentSize.height-height)/2)+"px"})}}catch(e){alert(e.number+" "+e.message)}},_destroy:function(){if(this.options.okButton.show){Event.stopObserving(this.okButton,"click",this._onClickOk.bindAsEventListener(this));delete this.okButton}if(this.options.cancelButton.show){Event.stopObserving(this.cancelButton,"click",this._onClickCancel.bindAsEventListener(this));delete this.cancelButton}if(this.isIE6||this.isIE55){this.options.parentElement.select("select").invoke("setStyle",{visibility:"visible"})}this.options.parentElement.removeChild(this.mainElement);this.options.parentElement.removeChild(this.overlay);delete this.mainElement;delete this.overlay},_disablePageScroll:function(){this._pageScrollStyle={overflow:document.body.getStyle("overflow"),height:document.body.getStyle("height"),width:document.body.getStyle("width")};var browser=this._getBrowserSize();var scrollbarW=15;var pageScrollStyle={overflow:"hidden",height:browser.height+"px",width:browser.width-scrollbarW+"px"};document.body.setStyle(pageScrollStyle)},_enablePageScroll:function(){if(typeof this._pageScrollStyle!="undefined"){document.body.setStyle(this._pageScrollStyle);$$("html").first().setStyle({overflow:"auto"})}},_fixOverlayIE:function(){if(navigator.appVersion.indexOf("MSIE")>0&&navigator.userAgent.indexOf("Opera")<0){var iframe=document.createElement("iframe");iframe.src="about:blank";iframe.frameBorder=0;iframe.scrolling="no";var browser=this._getBrowserSize();iframe.setStyle({width:(browser.width+50)+"px",height:(browser.height+50)+"px",position:"absolute",left:0,top:0,display:"none",zIndex:this.options.baseZIndex});this.options.baseZIndex++;this.iframe=this.options.parentElement.insertBefore(iframe,this.options.parentElement.firstChild)}},_getBrowserSize:function(){if(typeof window.innerHeight!="undefined"){return{width:window.innerWidth,height:window.innerHeight}}else{if(typeof document.documentElement!="undefined"){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}else{return{width:document.body.clientWidth,height:document.body.clientHeight}}}},_loadContent:function(){new Ajax.Request(this.contentURL,{onSuccess:this._processAjaxContent.bind(this),onFailure:this._dispatchError.bind(this)})},_processAjaxContent:function(transport){this.content=transport.responseText;this.show()},_onShow:function(){if(this.options.onShow!=Prototype.emptyFunction){this.options.onShow()}},_onHide:function(){if(this.options.onHide!=Prototype.emptyFunction){this.options.onHide()}},_onClickOk:function(){if(this.options.onClickOk!=Prototype.emptyFunction){this.options.onClickOk()}this.hide()},_onClickCancel:function(){if(this.options.onClickCancel!=Prototype.emptyFunction){this.options.onClickCancel()}this.hide()},_onResizeHandler:function(e){this._onClickCancel()},_onKeyPressHandler:function(e){if(this.active){keyPressed=e.keyCode||e.which;if(keyPressed==Event.KEY_ESC&&this.options.cancelButton.show){this._onClickCancel()}if(keyPressed==Event.KEY_RETURN&&this.options.okButton.show){this._onClickOk()}}},_getPosition:function(){if(this.position==null){this.position={}}if(this.parentElement==document.body){var parentSize=this._getBrowserSize()}else{var parentSize=this.options.parentElement.getDimensions()}var posLeft,posTop;if(typeof this.options.position.left!="undefined"){posLeft=this.options.position.left}else{posLeft=Math.round((parentSize.width-this.options.width)/2)+"px"}if(typeof this.options.position.top!="undefined"){posTop=this.options.position.top}else{if(this.options.height=="auto"){posTop=Math.round(parentSize.height/4)+"px"}else{posTop=Math.round((parentSize.height-this.options.height)/2)+"px"}}this.position=Object.extend(this.position,{left:posLeft,top:posTop});return true},_dispatchError:function(e){}};UPC.widget.modalWindow.Balloon=Class.create();UPC.widget.modalWindow.Balloon.prototype=Object.extend(new UPC.widget.modalWindow.Base(),{initialize:function(content,options,event){if(typeof options=="undefined"){options={}}options.hoverOverlayToClose=true;options.okButton={show:false};options.cancelButton={show:false};options.height="normal";var off=Event.element(event).cumulativeOffset();options.position={top:off.top+"px",left:off.left+"px"};this.baseInitialize(content,options);return this}});UPC.widget.modalWindow.Confirm=Class.create();UPC.widget.modalWindow.Confirm.prototype=Object.extend(new UPC.widget.modalWindow.Base(),{initialize:function(content,options){this.baseInitialize(content,options);return this}});UPC.widget.modalWindow.Alert=Class.create();UPC.widget.modalWindow.Alert.prototype=Object.extend(new UPC.widget.modalWindow.Base(),{initialize:function(content,options){if(typeof options=="undefined"){options={}}options.cancelButton={label:"",show:false};this.baseInitialize(content,options);return this},_onKeyPressHandler:function(e){if(this.active){keyPressed=e.keyCode||e.which;if(keyPressed==Event.KEY_ESC||keyPressed==Event.KEY_RETURN){this._onClickOk()}}}});namespace("UPC.widget");UPC.widget.Tooltip=function(){var mainElement=null;var currentTrigger=null;var timer=null;var mouttimer=null;var contentTemplate=new Template('<div id="tooltip-content">#{content}</div>');var config=null;var options=null;var effectDuration=0.15;function initialize(_options){if(typeof(UPC.util.Configuration)=="undefined"){return false}config=UPC.util.Configuration;options=_options;mainElement=_getConfigValue("ttElement");if(mainElement==null){throw"UPC.widget.Tooltip: main element could not be found."}mainElement.hide();this.contentTemplate=_getConfigValue("contentTemplate")||this.contentTemplate;return this}function _getConfigValue(key){if(options!=null){return options[key]||$(config.getConfigValue("Tooltip."+key))}else{return $(config.getConfigValue("Tooltip."+key))}}function show(e,content,atPos,el){clearTimeout(mouttimer);if(mainElement.visible()){clearTimeout(mouttimer);mainElement.hide()}currentTrigger=(e!=null)?e.element():el;if(typeof(content)=="string"){mainElement.innerHTML=contentTemplate.evaluate({content:content})}else{return false}clearTimeout(mouttimer);var showDelay=_getConfigValue("showDelay");if(showDelay>0){if(atPos==null&&currentTrigger!=null){currentTrigger.observe("mousemove",_update)}timer=setTimeout(function(){_makeTooltipVisible(e,atPos);var autoDismiss=_getConfigValue("autoDismissDelay");if(autoDismiss){timer=setTimeout(_autoHide,autoDismiss)}},showDelay)}else{_makeTooltipVisible(e,atPos);timer=setTimeout(_autoHide,_getConfigValue("autoDismissDelay"))}_bindMouseoutEvent();return true}function _update(e){_updateTipPosition(e,null)}function _updateTipPosition(ev,atPos){var offset=_offset(atPos);var widthPx=_getConfigValue("width");var width=(widthPx)?widthPx+"px":"auto";var left=null;var top=null;if(atPos==null){var position=[ev.pointerX(),ev.pointerY()];left=position[0]+offset[0];top=position[1]+offset[1]}else{left=((widthPx)?(atPos.left-(widthPx/2)):atPos.left)+offset[0];top=(atPos.top-mainElement.getHeight())+offset[1]}mainElement.setStyle({position:"absolute",left:left+"px",top:top+"px",width:width})}function _makeTooltipVisible(ev,atPos){if(!mainElement.visible()){currentTrigger.stopObserving("mousemove");if(atPos){_updateTipPosition(ev,atPos)}try{if(!Prototype.Browser.IE){Effect.toggle(mainElement.id,"appear",{duration:effectDuration})}else{mainElement.show()}}catch(ReferenceError){mainElement.show()}}}function _bindMouseoutEvent(){currentTrigger.observe("mouseout",function(){clearTimeout(timer);if(mainElement.visible()){clearTimeout(mouttimer);mouttimer=setTimeout(function(){hide()},500)}else{clearTimeout(timer);clearTimeout(mouttimer)}if(currentTrigger!=null){currentTrigger.stopObserving("mouseout")}})}function hide(e){clearTimeout(timer);clearTimeout(mouttimer);if(currentTrigger!=null){currentTrigger.stopObserving("mousemove");currentTrigger.stopObserving("mouseout");currentTrigger=null}if(!mainElement.visible()){return}try{if(!Prototype.Browser.IE){Effect.toggle(mainElement.id,"appear",{duration:effectDuration})}else{mainElement.hide()}}catch(ReferenceError){mainElement.hide()}}function _offset(atPos){var o=_getConfigValue("offset");if(atPos==null&&o[0]==0&&o[0]==0){o=[0,16]}return o}function _autoHide(){clearTimeout(timer);if(!mainElement.visible()){return}try{Effect.toggle(mainElement.id,"appear",{duration:effectDuration})}catch(ReferenceError){mainElement.hide()}if(currentTrigger!=null){currentTrigger.stopObserving("mouseout");currentTrigger.stopObserving("mousemove");currentTrigger=null}}return{init:initialize,show:show,hide:hide}}();namespace("UPC.widgets");UPC.widgets.WordPopup=Class.create(Autocompleter.Base,{initialize:function(select,update,options,callback){options.onShow=function(element,update){var posOffset=element.positionedOffset();update.style.cssText="left:"+posOffset.left+"px;"};options.onHide=function(element,update){if(Prototype.Browser.IE){document.getElementById(update.id).style.display="none"}else{Effect.Fade(update,{duration:0.15})}};this.selectEl=$(select);this.element=this.selectEl.previous();this.element.id=this.selectEl.id+"_combo";var inputClasses=Element.classNames(select);this.baseInitialize(this.selectEl.id+"_combo",update,options);this.selectOptionReplacements=[];var optionList=this.selectEl.getElementsByTagName("option");var node;for(var i=0;i<optionList.length;i++){node=optionList[i];this.selectOptionReplacements.push('<li id="'+node.value+'" value="'+node.value+'">'+node.innerHTML+"</li>")}this.values="<ul>"+this.selectOptionReplacements.join("")+"</ul>";this.setSelectedIndex(options.selectedIndex,optionList);Event.observe(this.element,"click",this.activate.bindAsEventListener(this));Event.observe(this.element,"mouseout",this.mouseOut.bindAsEventListener(this));this.callback=callback||Prototype.emptyFunction},getUpdatedChoices:function(){this.updateChoices(this.values);Event.observe(this.update,"mouseout",this.mouseOut.bindAsEventListener(this))},render:function(){if(Element.getStyle(this.update,"display")=="none"){this.options.onShow(this.element,this.update)}this.active=true;if(Prototype.Browser.IE6){var li=this.update.getElementsByTagName("li");for(var i=0;i<li.length;i++){li[i].onmouseover=function(){this.className+=" ie6HoverFix"};li[i].onmouseout=function(){this.className=this.className.replace(new RegExp(" ie6HoverFix\\b"),"")}}}},onClick:function(event){var element=Event.element(event);this.index=element.autocompleteIndex;this.selectEntry();this.hide()},mouseOut:function(ev){if(this.hasFocus){var dropDownElement=this.update.childElements()[0];var inside=Position.within(dropDownElement,ev.pointerX(),ev.pointerY());if(!inside){this.onBlur();Event.stopObserving(this.update,"mouseout")}}},addObservers:function(element){Event.observe(element,"click",this.onClick.bindAsEventListener(this))},updateElement:function(updatedElement){this.element.innerHTML=updatedElement.innerHTML;this.afterUpdateElement(this.element,updatedElement)},afterUpdateElement:function(text,li){this._updateSelect(li.id)},_updateSelect:function(value){if(value!=this.selectEl.value){UPC.apps.epg.DataController.toggleLoader(true);var options=$A(this.selectEl.getElementsByTagName("option"));for(var i=0;i<options.length;i++){var thisOption=options[i].value;if(thisOption==value){this.selectEl.selectedIndex=i;this.callback.defer(this.selectEl);break}}}else{}},setSelectedIndex:function(index,nodes){this.selectEl.selectedIndex=(index!=null)?index:this.selectEl.selectedIndex;nodes=nodes||$A(this.selectEl.getElementsByTagName("option"));this.element.innerHTML=nodes[this.selectEl.selectedIndex].text},setValues:function(){return this.values}});