Rgm.ImageSubmit=Class.create();Rgm.ImageSubmit.prototype={initialize:function(selectors,bAjax){var els=$$(selectors);var i,len=els.length;this.isAjax=bAjax;for(i=0;i<len;i++){els[i].parent=this;Event.observe(els[i],'click',this.onImgClick.bind(this));if(this.isAjax&&Utils.isIE){this.addInputListeners(els[i].form,this);}}},addInputListeners:function(frm,imgSub){(Form.getInputs(frm)).each(function(elem){Event.observe(elem,'keydown',imgSub.onKeydown.bind(imgSub));});},onImgClick:function(evt){var elem=Event.element(evt);elem.disabled=true;this.submitForm(evt,elem);setTimeout(function(){elem.disabled=false;},2000);},onKeydown:function(evt){var elem=Event.element(evt);if(evt.keyCode==13){this.submitForm(evt,elem);}},submitForm:function(ev,el){var elem=el;if(elem.form.onsubmit&&this.isAjax)
{elem.form.onsubmit();Event.stop(ev);}else{elem.form.submit();}}}
Rgm.Placement=Class.create();Rgm.Placement.prototype={initialize:function(positionCode,options){this.positionCode=positionCode;this.options={spacingPixels:5,align:Rgm.Placement.ALIGN_LEFT_EDGE,offsetHorizontal:0,offsetVertical:0};Object.extend(this.options,options||{});},placeElement:function(element){switch(this.positionCode){case Rgm.Placement.CENTER_CODE:Utils.centerInWindow(element);break;case Rgm.Placement.DO_NOT_POSITION_CODE:break;case Rgm.Placement.LEFT_CODE:var relatedElement=$(this.options.relatedElementId);var relatedOffset=this.getOffsetFor(relatedElement);var elementWidth=Utils.widthWithBorders(element);element.style.position="absolute";var leftAlignX=(relatedOffset[0]-this.options.offsetHorizontal-this.options.spacingPixels-elementWidth);element.style.left=leftAlignX+"px";element.style.top=relatedOffset[1]+"px";break;case Rgm.Placement.BELOW_CODE:var relatedElement=$(this.options.relatedElementId);var relatedOffset=this.getOffsetFor(relatedElement);var relatedHeight=Utils.heightWithBorders(relatedElement);var relatedWidth=Utils.widthWithBorders(relatedElement);var elementWidth=Utils.widthWithBorders(element);element.style.position="absolute";var leftAlignX=(relatedOffset[0]+this.options.offsetHorizontal);var rightAlignX=(relatedOffset[0]+relatedWidth-elementWidth+this.options.offsetHorizontal);switch(this.options.align){case Rgm.Placement.ALIGN_LEFT_EDGE:element.style.left=leftAlignX+"px";break;case Rgm.Placement.ALIGN_RIGHT_EDGE:element.style.left=(rightAlignX<0?leftAlignX:rightAlignX)+"px";break;default:throw new Error("Unknown alignment - "+this.options.align);}
element.style.top=(relatedOffset[1]+relatedHeight+this.options.offsetVertical+this.options.spacingPixels)+"px";break;default:throw new Error("Unknown position code - "+this.positionCode);}},getOffsetFor:function(element){return Position.cumulativeOffset(element);}};Rgm.Placement.CENTER_CODE="center";Rgm.Placement.DO_NOT_POSITION_CODE="noposition";Rgm.Placement.BELOW_CODE="below";Rgm.Placement.LEFT_CODE="left";Rgm.Placement.ALIGN_LEFT_EDGE="leftedge";Rgm.Placement.ALIGN_TOP_EDGE="topedge";Rgm.Placement.ALIGN_RIGHT_EDGE="rightedge";Rgm.Placement.CENTER_IN_WINDOW=new Rgm.Placement(Rgm.Placement.CENTER_CODE);Rgm.Placement.DO_NOT_POSITION=new Rgm.Placement(Rgm.Placement.DO_NOT_POSITION_CODE);Rgm.Placement.belowElement=function(elementId,options){return Rgm.Placement.getPlacementElement(Rgm.Placement.BELOW_CODE,elementId,options);}
Rgm.Placement.getPlacementElement=function(placement,elementId,options){options.relatedElementId=elementId;return new Rgm.Placement(placement,options);}
Rgm.Placement.toTheLeftOfElement=function(elementId,options){options.relatedElementId=elementId;options.align=Rgm.Placement.ALIGN_TOP_EDGE;return new Rgm.Placement(Rgm.Placement.LEFT_CODE,options);}
Rgm.Popup=Class.create();Rgm.Popup.prototype={initialize:function(popupElementId,options){this.popupElementId=popupElementId;this.options={placement:Rgm.Placement.CENTER_IN_WINDOW,maskOpacity:0.5,maskElementId:"mask",maskZindex:3500,maskBackgroundColor:"#FFFFFF",popupZindex:4000,popupCssClass:"popup",scrollableElementIds:[]};Object.extend(this.options,options||{});this._initializePopupElement();},showPopup:function(){this.options.placement.placeElement(this.popupElement);Element.show(this.popupElement);Element.hideScrollbarsUnderElement(this.popupElement,this.options.scrollableElementIds);Element.reveal(this.popupElement);},showMask:function(){this._initializeMaskElement();if(Utils.isIE&&BrowserDetect.version<7)
this._createIframeShim();Element.reveal(this.maskElement);Element.hideScrollbarsUnderElement(this.maskElement,this.options.scrollableElementIds);},showPopupWithMask:function(){this.showMask();this.showPopup();},hide:function(){Element.conceal(this.popupElement);Element.hide(this.popupElement);if(this.maskElement){Element.conceal(this.maskElement);}
Element.unhideScrollbars(this.options.scrollableElementIds);},remove:function(hideMask){Element.remove(this.popupElement);if(hideMask&&this.maskElement){Element.conceal(this.maskElement);}},_initializeMaskElement:function(){var pageDimensions=Utils.pageDimensions();this.maskElement=$(this.options.maskElementId);if(this.maskElement==null){this.maskElement=document.createElement('div');document.body.appendChild(this.maskElement);document.body.style.height="100%";this.maskElement.id=this.options.maskElementId;this.maskElement.style.backgroundColor=this.options.maskBackgroundColor;this.maskElement.style.height=pageDimensions.height+'px';this.maskElement.style.width=pageDimensions.width+'px';this.maskElement.style.position="absolute";this.maskElement.style.top="0px";this.maskElement.style.left="0px";Element.setOpacity(this.maskElement,this.options.maskOpacity);this.maskElement.style.zIndex=this.options.maskZindex.toString();Element.conceal(this.maskElement);}},_initializePopupElement:function(){this.popupElement=$(this.popupElementId);if(this.popupElement==null){this.popupElement=document.createElement('div');document.body.appendChild(this.popupElement);this.popupElement.id=this.popupElementId;}
this.popupElement.className=this.options.popupCssClass;this.popupElement.style.zIndex=this.options.popupZindex.toString();Element.hide(this.popupElement);Element.conceal(this.popupElement);},_createIframeShim:function()
{var e=this.maskElement,f=document.createElement('IFRAME');f.style.position='absolute';f.style.top=e.style.top;f.style.left=e.style.left;f.style.zIndex=parseInt(e.style.zIndex)-1;f.style.width=e.style.width;f.style.height=e.style.height;f.frameBorder='0';f.src='/images/blank.gif';f.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';e.appendChild(f);}};Rgm.Dialog=Class.create();Rgm.Dialog.prototype={initialize:function(popupElementId,options){this.super_initialize(popupElementId,options);var closeButton=Element.create('div');closeButton.className='close_link';closeButton.id=this.popupElementId+'_close_link';Event.observe(closeButton,'click',this.hide.bind(this));$(popupElementId).appendChild(closeButton);var dialogContents=Element.create('div');dialogContents.id=popupElementId+'_contents';$(popupElementId).appendChild(dialogContents);}};Object.overrides(Rgm.Dialog,Rgm.Popup);Rgm.CharCounter=Class.create();Rgm.CharCounter.prototype={initialize:function(textElemId,msgLyrId,msg,maxChars,editorType){this.textElemId=textElemId;this.textElem=$(textElemId);this.msgLyr=$(msgLyrId);this.msg=msg;this.maxChars=maxChars;this.editorType=editorType;if(this.isFCKEditor()){Event.observe(window,'load',function(){var fckEditor=this.getFCKEditor();fckEditor.Events.AttachEvent('OnSelectionChange',this.updateCounter.bind(this));fckEditor.Events.AttachEvent('OnFocus',this.updateCounter.bind(this));this.updateCounter();}.bind(this));}else{Event.observe(this.textElem,'keyup',this.onTextKeyup.bind(this));Event.observe(this.textElem,'focus',this.onTextFocus.bind(this));this.updateCounter();}},onTextKeyup:function(){this.updateCounter();},onTextFocus:function(){this.updateCounter();},updateCounter:function(){var len=this.maxChars-this.elemValue().length;if(len<=0){len=0;this.truncateValue()}
if(this.isFCKEditor()&&len<=0){this.msgLyr.innerHTML='<span style="color:red">Text is too long</span>'}else{this.msgLyr.innerHTML=this.msg.replace("{NUMB}",len);}},elemValue:function(){if(this.isFCKEditor()){data=this.getFCKEditor().GetData();return data==null?"":data}else{return this.textElem.value;}},truncateValue:function(){if(this.isFCKEditor()){}else{this.textElem.value=this.textElem.value.substr(0,this.maxChars);}},isFCKEditor:function(){return this.editorType=='fck';},getFCKEditor:function(){return FCKeditorAPI.GetInstance(this.textElemId);}}
Rgm.HeightResizer=Class.create();Rgm.HeightResizer.prototype={initialize:function(){this.elements=[];this.elementHeights=[];this.numElements=arguments.length;for(var i=0;i<this.numElements;++i){this.elements.push($(arguments[i]));this.elementHeights.push(Utils.height(arguments[i]));}
this.origMaxHeight=Math.max.apply(null,this.elementHeights);},adjustMaxHeight:function(ht){var tmpElementHeights=[];for(var i=0;i<this.numElements;++i){tmpElementHeights[i]=this.elementHeights[i]+ht;}
return Math.max.apply(null,tmpElementHeights);},setHeight:function(elem,ht){if(Utils.isIE&&BrowserDetect.version<7){$(elem).style.height=ht+"px";}else{$(elem).style.minHeight=ht+"px";}},balanceHeights:function(newHeight){for(var i=0;i<this.numElements;++i){this.setHeight(this.elements[i],this.origMaxHeight)}},expandTo:function(newHeight){for(var i=0;i<this.numElements;++i){var padding=Utils.heightPaddingAndBorders(this.elements[i]);this.setHeight(this.elements[i],newHeight-padding)}},subscribe:function(evt,callback)
{Rgm.CustomEvent.observe(evt,callback.bind(this))},resize:function(opts)
{var cmd=opts['cmd'],ht=opts['height'];if(cmd=='expand'){this.expandTo(this.adjustMaxHeight(ht));}else{this.balanceHeights();}}}
function showPopup(popupId,top_fixed){document.body.style.height='100%';var pageDims=Utils.pageDimensions();var mask;var wHeight;var pageScrollHeight;var popupHeightFromTop;if(Utils.isIE){ieApplyZIndex(popupId,2000)
mask=createIeMask(popupId,pageDims);}else{mask=$('popup_mask');mask.style.backgroundColor='#ffffff';mask.style.height=pageDims.height+'px';mask.style.width=pageDims.width+'px';mask.style.position='absolute';mask.style.top='0px';mask.style.left='0px';Element.setOpacity(mask,0.5);mask.style.zIndex='1000';}
Element.reveal(mask);Element.hideScrollbarsUnderElement(mask,[]);$(popupId).show();if(Utils.isIE){wHeight=document.documentElement.clientHeight;pageScrollHeight=document.body.scrollTop;}else{wHeight=window.innerHeight;pageScrollHeight=window.pageYOffset;}
popupHeightFromTop=($(popupId).offsetParent.offsetTop+$(popupId).offsetTop+$(popupId).offsetHeight-pageScrollHeight);if(top_fixed!=null){$(popupId).style.top=top_fixed+"px";}else{if((popupHeightFromTop>wHeight)&&(wHeight>$(popupId).offsetHeight)){$(popupId).style.top=-(popupHeightFromTop-wHeight+$(popupId).offsetTop)+"px";}else{if($(popupId).offsetHeight>wHeight){$(popupId).style.top=-($(popupId).offsetParent.offsetTop+$(popupId).offsetTop-($(popupId).offsetHeight+wHeighT))+"px";}}}}
function hidePopup(popupId){if(Utils.isIE){Element.remove($('IEmask'));ieApplyZIndex(popupId,'')}else{Element.conceal($('popup_mask'));}
$(popupId).hide();}
function createIeMask(popupId,pageDims){var popup_parent=$(popupId+'_parent');IEmask=document.createElement('div');popup_parent.appendChild(IEmask);IEmask.id='IEmask';IEmask.style.backgroundColor='#ffffff';IEmask.style.height=pageDims.height*3+'px';IEmask.style.width=pageDims.width*3+'px';IEmask.style.position='absolute';IEmask.style.top=-pageDims.height+'px';IEmask.style.left=-pageDims.width+'px';Element.setOpacity(IEmask,0.5);IEmask.style.zIndex='1000';Element.conceal(IEmask);return IEmask;}
var ieApplyZIndexSavedElements=new Array();function ieApplyZIndex(elementId,zindex){zindex=((undefined==zindex)?1:zindex);ieApplyZIndexSavedElements.each(function(element_array){element_array[0].style.zIndex=element_array[1];});ieApplyZIndexSavedElements.clear();$(elementId).ancestors().each(function(ancestor){if(ancestor.getStyle('position')=='relative'){ieApplyZIndexSavedElements.push([ancestor,ancestor.style.zIndex]);ancestor.style.zIndex=zindex;}
if(ancestor==$(document.body)){throw $break;}});}