/* Copyright (c) 1995-2008 Choice Hotels International, Inc. All Rights Reserved. */
var PopupWindow=$Class.create({_ctor:function(options){this.imagepath=options.imgpath||"";this.popwin=this._createWindow(options);document.body.appendChild(this.popwin);this.toplevel=[this.popwin];this.delayed=[];this.anchoroff=[0,0];this.popped_up=false;var arrowimg=null;var arrowimgsize=null;switch(options.arrow){case "top":{this.anchoroff[1]=28;this.arrowoff=[0,0];arrowimg=["poptop.png","poptopshad.png"];arrowimgsize=[100,38];break}case "bottom":{this.anchoroff[1]=-28;this.arrowoff=[-100,-38];arrowimg=["popbottom.png","popbottomshad.png"];arrowimgsize=[100,38];break}case "left":{this.anchoroff[0]=28;this.arrowoff=[0,-100];arrowimg=["popleft.png","popleftshad.png"];arrowimgsize=[38,100];break}case "right":{this.anchoroff[0]=-28;this.arrowoff=[-38,-100];arrowimg=["popright.png","poprightshad.png"];arrowimgsize=[38,100];break}}if(arrowimg){var zindex=501;var imgs=new Array;for(var i=0;i<arrowimg.length;i++){if(arrowimg[i]){var img=this._createTransImg(arrowimg[i]);imgs.push(img);img.style.position="absolute";img.style.visibility="hidden";img.style.top=0;img.style.left=0;img.style.zIndex=zindex;img.style.width=arrowimgsize[0];img.style.height=arrowimgsize[1];this.delayed.push(img);document.body.appendChild(img)}zindex=490}this.popwin.positioner.addFunction(imgs,this._positionArrow.bind(this))}if(options.arrow&&options.shadowType){switch(options.shadowType){case "drop":;case "bl":;this.dropshadow=[-10,10];break;case "br":;this.dropshadow=[10,10];break;case "tl":;this.dropshadow=[-10,-10];break;case "tr":;this.dropshadow=[10,-10];break}}var shadow=this._createShadow(options.shadowType);if(shadow){this.toplevel.push(shadow);document.body.appendChild(shadow)}this.dragable=(options.dragable&&WindowDrager)?new WindowDrager(this,[this.popwin,shadow]):null;if(window.ActiveXObject){this.iframe=document.createElement("iframe");this.iframe.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)";this.iframe.setAttribute("src","javascript:false");this.iframe.setAttribute("scrolling","no");this.iframe.setAttribute("frameborder","0");this.iframe.style.display="none";this.iframe.style.border="4px solid green";this.iframe.style.zIndex=480;this.iframe.style.position="absolute";if($pageLoaded)document.body.appendChild(this.iframe);if(this.dragable)this.dragable.addElement(this.iframe);this.popwin.positioner.addElement(this.iframe,-10,0,20,0)}this._setAnchor(0,0,0,0)},dispose:function(){if(this.popwin.parentNode)this.popwin.parentNode.removeChild(this.popwin);if(this.iframe)this.iframe=null;this.dragable=null;this.toplevel=null;this.imagepath=null;this.popwin=null;this.anchoroff=null;this.arrowimg=null;this.arrowimgsize=null;this.disposeElements(this.delayed);this.disposeElements(this.toplevel)},_disposeElements:function(elems){if(elems){for(var i=elems.length-1;i>=0;i--){if(elems[i].parentNode)elems[i].parentNode.removeChild(elems[i])}}},popup:function(anchor_x,xjust,anchor_y,yjust,options){this._clearPopupTimer();this.mousein=true;this._setAnchor(anchor_x,xjust,anchor_y,yjust);if(options.autopop){var outdelay=options.outdelay||0;var winelems=this.toplevel.concat(this.delayed);if(this.apopelems!=null){this.apopelems.splice(0,winelems.length);this._removeEventHandler(this.apopelems,"mouseover",this.overhandler);this._removeEventHandler(this.apopelems,"mouseout",this.outhandler)}else {this.overhandler=this._onMouseOver.bind(this);this.outhandler=this._onMouseOut.bind(this,outdelay);this._addEventHandler(winelems,"mouseover",this.overhandler);this._addEventHandler(winelems,"mouseout",this.outhandler)}this.apopelems=winelems.concat(options.autopop);this._addEventHandler(options.autopop,"mouseover",this.overhandler);this._addEventHandler(options.autopop,"mouseout",this.outhandler)}if(options.indelay&&(options.indelay>0)){this.popuptimer=window.setTimeout(this._autoPopup.bind(this,anchor_x,xjust,anchor_y,yjust,options),options.indelay)}else this._popupNow(anchor_x,xjust,anchor_y,yjust,options)},_popupNow:function(anchor_x,xjust,anchor_y,yjust,options){if(!$pageLoaded)return ;options.method="pop";if(this.iframe&&(this.iframe.parentNode==null))document.body.appendChild(this.iframe);if(options&&(options.method=="resize")){if(!this.expander){var width,height;if(this.newcontent){width=this.newcontent[1];height=this.newcontent[2]}this.expander=new WindowExpander(this,this.popwin.className+"_expander",options.width||400,options.height||400,anchor_x,xjust,anchor_y,yjust);this.expander.setRate(options.upincr||6,options.uprate||40,options.downincr||4,options.downrate||20);this.expander.addListener("windowOpened",this._windowOpened.bind(this));this.expander.addListener("windowClosed",this._windowClosed.bind(this));this.expander.popup()}}else if(options&&(options.method=="fade")){var seq=new Sequencer();for(var i=this.toplevel.length-1;i>=0;i--)seq.addAction(new Fader(this.toplevel[i],0,100));for(var i=this.delayed.length-1;i>=0;i--)seq.addAction(new Fader(this.delayed[i],0,100));this._setElemVisibility(this.toplevel,true);this._setElemVisibility(this.delayed,true);seq.sequence(2000);this._windowOpened(this)}else {this._setElemVisibility(this.toplevel,true);this._setElemVisibility(this.delayed,true);if(this.iframe)this.iframe.style.display="inline";this._windowOpened(this)}},getWindowElement:function(){return this.popwin},constrainPopupArea:function(body,view){this.constrainb=body;this.constrainv=view},addWindowListener:function(event,listener){if(!this.listeners)this.listeners=new EventListeners(null);this.listeners.add(event,listener)},isPoppedUp:function(){return this.popped_up},getContent:function(){return this.content.firstChild},setContent:function(content,width,height){if(this.isPoppedUp())this._setContent(content,width,height);else this.newcontent=[content,width,height]},updateWindow:function(){PopupWindow._positionChanged(this.popwin)},popdown:function(){if(!$pageLoaded)return ;this._setElemVisibility(this.delayed,false);if(this.expander&&this.popped_up)this.expander.popdown();else this._windowClosed()},_positionArrow:function(elems,xpos,ypos,width,height){var left=this.anchor_x-this.anchoroff[0]+this.arrowoff[0];var top=this.anchor_y-this.anchoroff[1]+this.arrowoff[1];elems[0].style.left=left;elems[0].style.top=top;elems[1].style.left=left+this.dropshadow[0];elems[1].style.top=top+this.dropshadow[1]},_adjustAnchor:function(initial,terminal){this.anchor_x+=terminal.getX()-initial.getX();this.anchor_y+=terminal.getY()-initial.getY()},_setContent:function(content,width,height){while(this.content.lastChild)this.content.removeChild(this.content.lastChild);if(content){if(content instanceof Array){for(var i=0;i<content.length;i++)this.content.appendChild(content[i])}else this.content.appendChild(content)}else this._setElemVisibility(this.delayed,false);if(width==null)this.content.style.width="auto";else if(width>=0)this.content.style.width=width;if(height==null){this.content.style.height="auto";this.content.style["min-height"]="140"}else if(height>=0)this.content.style.height=height;if(this.content.offsetWidth<150)this.content.style.width=150;if(this.content.offsetHeight<150)this.content.style.height=150;this.popwin.style.left=Math.round(this.anchor_x-(this.xjust*this.popwin.offsetWidth));this.popwin.style.top=Math.round(this.anchor_y-(this.yjust*this.popwin.offsetHeight));if(this.constrainb||this.constrainv){var left,top,right,bottom;if(this.constrainb){left=0;top=0;right=document.body.offsetWidth;bottom=document.body.offsetHeight}else {left=-1000000;top=-1000000;right=1000000;bottom=1000000}if(this.constrainv){var width,height;if((typeof window.innerHeight)!="undefined"){width=window.innerWidth;height=window.innerHeight}else if((typeof document.body.clientHeight)!="undefined"){width=document.body.clientWidth;height=document.body.clientHeight}if(width){left=Math.max(left,document.body.scrollLeft);top=Math.max(top,document.body.scrollTop);right=Math.min(right,width+document.body.scrollLeft);bottom=Math.min(bottom,height+document.body.scrollTop)}}this._constrainLocation(left,top,right,bottom,10)}PopupWindow._positionChanged(this.popwin)},_constrainLocation:function(left,top,right,bottom,offset){if((right!=null)&&((this.popwin.offsetLeft+this.popwin.offsetWidth)>right))this.popwin.style.left=right-this.popwin.offsetWidth-offset;if((bottom!=null)&&((this.popwin.offsetTop+this.popwin.offsetHeight)>bottom))this.popwin.style.top=bottom-this.popwin.offsetHeight-offset;if((left!=null)&&(this.popwin.offsetLeft<left))this.popwin.style.left=left+offset;if((top!=null)&&(this.popwin.offsetTop<top))this.popwin.style.top=top+offset},_addEventHandler:function(objs,name,handler){for(var i=objs.length-1;i>=0;i--)Event.addEventHandler(objs[i],name,handler,false)},_removeEventHandler:function(objs,name,handler){for(var i=objs.length-1;i>=0;i--)Event.removeEventHandler(objs[i],name,handler)},_setElemVisibility:function(group,visible){var value=visible?"visible":"hidden";for(var i=0;i<group.length;i++){group[i].style.visibility=value;if(visible&&!group[i].parentNode)document.body.appendChild(group[i])}},_createWindow:function(options){var windiv=document.createElement("div");windiv.positioner=new ElemPositioner();if(options.className)windiv.className=options.className;windiv.style.position="absolute";windiv.style.visibility="hidden";windiv.style.zIndex=1500;windiv.style.top=0;windiv.style.left=0;if(options.corners){windiv.style.backgroundColor="transparent";windiv.appendChild(this._createCornerHeader(options.corners[0],options.corners[1]))}if(options.titlebar){var bar=document.createElement("div");bar.className="titlebar";bar.style.height=10;bar.style.marginTop=3;bar.style.marginLeft=5;bar.style.marginRight=options.closable?18:5;windiv.appendChild(bar)}if(options.closable){var img;img=document.createElement("img");img.src=this.imagepath+"closewin.gif";img.style.padding="3px";img.style.position="absolute";img.style.top=6;img.style.right=8;img.style.cursor="pointer";img.onclick=this.popdown.bind(this);windiv.appendChild(img)}this.content=document.createElement("div");if(options.contentClassName)this.content.className=options.contentClassName;else if(options.className)this.content.className=options.className+"_content";this.content.style.width="100%";windiv.appendChild(this.content);if(options.corners){windiv.appendChild(this._createCornerHeader(options.corners[2],options.corners[3]));var indiv=document.createElement("div");indiv.style.position="absolute";indiv.style.top=0;indiv.style.bottom=0;indiv.style.zIndex=-1;indiv.className="filler";windiv.appendChild(indiv);if(window.ActiveXObject)windiv.positioner.addElement(indiv,null,null,-24,0)}return windiv},_createShadow:function(type){if((type=="bl")||(type=="tl")||(type=="br")||(type=="tr"))type="drop";if((type=="xz")||(type=="xy")||(type=="drop")){var imgnames=null;var imgsizes=null;switch(type){case "xz":;imgnames=[["ushadowl.png","ushadowm.png","ushadowr.png"]];imgsizes=[[[26,31],[null,31],[26,31]]];break;case "xy":;case "drop":;imgnames=[["shadowtl.png","shadowt.png","shadowtr.png"],["shadowl.png",null,"shadowr.png"],["shadowbl.png","shadowb.png","shadowbr.png"]];var cnrsz=[15,15];var xstretch=[null,15];var ystretch=[15,null];imgsizes=[[cnrsz,xstretch,cnrsz],[ystretch,null,ystretch],[cnrsz,xstretch,cnrsz]];break}var stable=this._createShadowTable(imgnames,imgsizes);stable.style.position="absolute";stable.style.visibility="hidden";stable.style.zIndex=490;switch(type){case "xz":;this.popwin.positioner.addElement(stable.rows[0].cells[1].firstChild,null,null,-33,null);stable.style.height=31;stable.style.left=-3;stable.style.bottom=-35;break;case "xy":;case "drop":;var delta=0;var xoff=this.dropshadow?this.dropshadow[0]:-10;var yoff=this.dropshadow?this.dropshadow[1]:10;if(type=="xy"){delta=20;yoff=-10}this.popwin.positioner.addElement(stable,xoff,yoff,null,null);delta-=30;this.popwin.positioner.addElement(stable.rows[1].cells[1],null,null,delta,delta);this.popwin.positioner.addElement(stable.rows[0].cells[1].firstChild,null,null,delta,null);this.popwin.positioner.addElement(stable.rows[1].cells[0].firstChild,null,null,null,delta);this.popwin.positioner.addElement(stable.rows[1].cells[2].firstChild,null,null,null,delta);this.popwin.positioner.addElement(stable.rows[2].cells[1].firstChild,null,null,delta,null);break}return stable}return null},_createShadowTable:function(imgnames,imgsizes){var stable=document.createElement("table");stable.cellSpacing=0;stable.cellPadding=0;var sbody=document.createElement("tbody");stable.appendChild(sbody);for(var rownum=0;rownum<imgnames.length;rownum++){sbody.insertRow(rownum);var row=sbody.rows[rownum];for(var colnum=0;colnum<imgnames[rownum].length;colnum++){row.insertCell(colnum);var imgname=imgnames[rownum][colnum];var img=imgname?this._createTransImg(imgname):document.createTextNode(" ");var size=imgsizes[rownum][colnum];if(size){if(size[0]){img.style.width=size[0];row.cells[colnum].style.width=size[0]}if(size[1]){img.style.height=size[1];row.cells[colnum].style.height=size[1]}}row.cells[colnum].appendChild(img)}}return stable},_createCornerHeader:function(leftimg,rightimg){var div=document.createElement("div");div.style.backgroundColor="transparent";div.style.textAlign="left";var img=this._createTransImg(leftimg);img.style.display="inline";img.style.width=12;img.style.height=12;img.style.left=0;div.appendChild(img);img=this._createTransImg(rightimg);img.style.position="absolute";img.style.display="inline";img.style.width=12;img.style.height=12;img.style.right=0;div.appendChild(img);return div},_createTransImg:function(imgname){return PopupWindow.createTransparentImage(this.imagepath+imgname)},_setAnchor:function(anchor_x,xjust,anchor_y,yjust){this.anchor_x=anchor_x+this.anchoroff[0];this.anchor_y=anchor_y+this.anchoroff[1];this.xjust=xjust;this.yjust=yjust},_showWindow:function(){if(this.iframe)this.iframe.style.display="inline";this._setElemVisibility(this.toplevel,true)},_hideWindow:function(){this._setElemVisibility(this.delayed,false);this._setElemVisibility(this.toplevel,false);if(this.iframe)this.iframe.style.display="none"},_onMouseOver:function(ev){this.mousein=true},_onMouseOut:function(outdelay,ev){var target=ev.relatedTarget||ev.toElement;for(var i=this.apopelems.length-1;i>=0;i--){if(target===this.apopelems[i])return }for(var elem=target;elem&&(elem.tagName!="BODY");elem=elem.parentNode){if((elem===this.popwin)||(elem===this.shadow))return }this._clearPopupTimer();this.mousein=false;if(outdelay>0){if(this.popdowntimer)window.clearTimeout(this.popdowntimer);this.popdowntimer=window.setTimeout(this._checkAutoPopDown.bind(this),outdelay)}else this.popdown()},_clearPopupTimer:function(){if(this.popuptimer){window.clearTimeout(this.popuptimer);this.popuptimer=null;this._windowCanceled()}},_autoPopup:function(anchor_x,xjust,anchor_y,yjust,options){this._clearPopupTimer();if(this.mousein)this._popupNow(anchor_x,xjust,anchor_y,yjust,options)},_checkAutoPopDown:function(){if(!this.mousein)this.popdown()},_windowOpened:function(popwin){this.popped_up=true;this._setContent(null,null,null);this._showWindow();if(this.newcontent){this._setContent.apply(this,this.newcontent);this.newcontent=null}this._setElemVisibility(this.delayed,true);if(this.listeners)this.listeners.fireEvent("windowOpened",this)},_windowClosed:function(popwin){this.popped_up=false;if(this.expander){this.expander.dispose();this.expander=null}this._hideWindow();if(this.listeners)this.listeners.fireEvent("windowClosed",this)},_windowCanceled:function(){if(this.listeners)this.listeners.fireEvent("windowCanceled",this)}});PopupWindow.createTransparentImage=function(imgpath){var img;if(navigator&&(navigator.userAgent.toLowerCase().indexOf("msie")>=0)){img=document.createElement("div");img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+imgpath+"',sizingMethod='scale')"}else {img=document.createElement("img");img.src=imgpath}return img};PopupWindow._positionChanged=function(elem){if(elem.positioner){elem.positioner.adjustSizes(elem.offsetLeft,elem.offsetTop,elem.offsetWidth,elem.offsetHeight)}};var WindowExpander=$Class.create({_ctor:function(popwin,classname,width,height,anchor_x,xjust,anchor_y,yjust){this.popwin=popwin;this.win=document.createElement("div");this.win.style.visibility="hidden";this.win.style.position="absolute";this.win.style.top=0;this.win.style.left=0;this.win.style.zIndex=501;this.win.className=classname;this.listeners=new EventListeners(null);this.interval=0;this.iid=null;this.width=width;this.height=height;this.anchor_x=anchor_x;this.anchor_y=anchor_y;this.xjust=xjust;this.yjust=yjust;this.up_incr=6;this.up_rate=40;this.down_incr=4;this.down_rate=20},dispose:function(){this._resetTimer();document.body.removeChild(this.win);this.popwin=null;this.win=null;this.listeners=null},setRate:function(upincr,uprate,downincr,downrate){this.up_incr=upincr;this.up_rate=uprate;this.down_incr=downincr;this.down_rate=downrate},addListener:function(event,listener){if(listener)this.listeners.add(event,listener)},popup:function(){if(this.interval==0){this._resetTimer();this._setupTimer(1,this.up_rate)}},popdown:function(){this.popwin._hideWindow();if(this.interval==this.up_incr){this.interval=this.down_incr;this._resetTimer();this._setupTimer(-1,this.down_rate)}},_setupTimer:function(incr,period){var expandWin=this._setWindowSize.bind(this,incr);expandWin();this.iid=window.setInterval(expandWin,period)},_resetTimer:function(){if(this.iid!=null){window.clearInterval(this.iid);this.iid=null}},_setVisible:function(visible){this.win.style.visibility=visible?"visible":"hidden";if(visible&&!this.win.parentNode)document.body.appendChild(this.win)},_setWindowSize:function(incr){var ivals=(incr>0)?this.up_incr:this.down_incr;this.interval+=incr;var width=Math.round((this.width/ivals)*this.interval);var height=Math.round((this.height/ivals)*this.interval);this.win.style.width=width;this.win.style.height=height;this.win.style.left=Math.round(this.anchor_x-(this.xjust*width));this.win.style.top=Math.round(this.anchor_y-(this.yjust*height));if(incr>0){if(this.interval==1)this._setVisible(true);else if(this.interval==this.up_incr){this._resetTimer();this._setVisible(false);this.listeners.fireEvent("windowOpened",this.popwin)}}else {if(this.interval==(this.down_incr-1))this._setVisible(true);else if(this.interval==0){this._resetTimer();this._setVisible(false);this.listeners.fireEvent("windowClosed",this.popwin)}}}});var WindowDrager=null;if(typeof Dragable!="undefined"){WindowDrager=$Class.extend(Dragable,{_ctor:function(popwin,dragees){Dragable.prototype._ctor.call(this,dragees,null);this.popwin=popwin},draggingEnded:function(initial,terminal){this.popwin._adjustAnchor(initial,terminal)}})}var ElemPositioner=$Class.create({_ctor:function(){this.elements=new Array},addElement:function(elem,offset_x,offset_y,owidth,oheight){this.elements.push([elem,offset_x,offset_y,owidth,oheight])},addFunction:function(elem,func){this.elements.push([elem,func])},adjustSizes:function(xpos,ypos,width,height){for(var i=this.elements.length-1;i>=0;i--){var rec=this.elements[i];if(rec.length>2){if(rec[1]!=null)rec[0].style.left=xpos+rec[1];if(rec[2]!=null)rec[0].style.top=ypos+rec[2];if(rec[3]!=null)rec[0].style.width=Math.max(0,width+rec[3]);if(rec[4]!=null)rec[0].style.height=Math.max(0,height+rec[4])}else rec[1](rec[0],xpos,ypos,width,height)}}});