var Clickables=function(){return{init:function(){$$('.clickable').each(function(el){el.observe('mouseover',Clickables.over.bindAsEventListener(Clickables)).observe('mouseout',Clickables.out.bindAsEventListener(Clickables));});},rebind:function(el){el=$(el);if(el){el.select('.clickable').each(function(elem){elem.observe('mouseover',Clickables.over.bindAsEventListener(Clickables)).observe('mouseout',Clickables.out.bindAsEventListener(Clickables));});}},reinit:function(el){el=$(el);if(el){el.select('.clickable').each(function(elem){elem.observe('mouseover',Clickables.over.bindAsEventListener(Clickables)).observe('mouseout',Clickables.out.bindAsEventListener(Clickables));});}},over:function(e){Event.element(e).addClassName('over_btn');},out:function(e){Event.element(e).removeClassName('over_btn');}};}();var HeaderLinkHovers=function(){return{init:function(){if(this.inviteTip==null){this.inviteTip=new Tip('create_invite_link',"invite guests online, in print, or both<br/>and easily manage RSVPs",{fixed:true,effect:Prototype.Browser.IE?false:'appear',className:'invite_header_bar_link_tip',offset:{x:-60,y:19}});}
if(this.ecardTip==null){this.ecardTip=new Tip('create_ecard_link',"announcements, greetings, save the dates,<br/>thank-you's... online, print, or both",{fixed:true,effect:Prototype.Browser.IE?false:'appear',className:'ecard_header_bar_link_tip',offset:{x:-80,y:19}});}}}}();var DashboardToolHovers=function(){return{init:function(){$$(".dashboard_tools li").each(function(elm){new Tip(elm,elm.down('a',0).readAttribute('rel'),{fixed:false,delay:500,className:'dashboard_tool_hover'});});}}}();if(document.observe){document.observe("dom:loaded",function(){if($("welcome-page")){HeaderLinkHovers.init();}});}
var GetStartedHovers=function(){return{init:function(){this.inviteTip=new Tip('create-invite',"invite guests online, in print, or both<br/>and easily manage RSVPs",{fixed:true,className:'get-started-invite-link-tip',offset:{x:-50,y:15},touchMyPosition:false});this.ecardTip=new Tip('create-ecard',"announcements, greetings, save the dates,<br/>thank-you's... online, print, or both",{fixed:true,className:'get-started-ecard-link-tip',offset:{x:-70,y:15},touchMyPosition:false});}}}();if(document.observe){document.observe("dom:loaded",function(){if($("partner-splash")){GetStartedHovers.init();}});}
var Tips={tips:[],zIndex:100000,add:function(tip){this.tips.push(tip);},remove:function(element){var tip=this.tips.find(function(t){return t.element==$(element);});if(!tip){return};this.tips=this.tips.reject(function(t){return t==tip;});tip.deactivate();if(tip.tooltip){tip.wrapper.remove();}
if(tip.underlay){tip.underlay.remove();}}};var Tip=Class.create();Tip.prototype={initialize:function(element,content){this.element=$(element);this.timeout=null;Tips.remove(this.element);this.content=content;this.options=Object.extend({className:'tooltip',duration:0.3,effect:false,hook:false,offset:(arguments[2]&&arguments[2].hook)?{x:0,y:0}:{x:16,y:16},fixed:false,target:this.element,title:false,touchMyPosition:true,viewport:true},arguments[2]||{});this.target=$(this.options.target);if(this.options.hook){this.options.fixed=true;this.options.viewport=false;}
if(this.options.effect){this.queue={position:'end',limit:1,scope:''}
var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";for(var i=0;i<6;i++){var r=Math.floor(Math.random()*c.length);this.queue.scope+=c.substring(r,r+1);}}
this.buildWrapper();Tips.add(this);this.activate();},activate:function(){this.eventShow=this.showTip.safeBind(this);this.eventHide=this.hideTip.safeBind(this);this.element.observe('mousemove',this.eventShow);this.element.observe('mouseout',this.eventHide);},deactivate:function(){this.element.stopObserving('mousemove',this.eventShow);this.element.stopObserving('mouseout',this.eventHide);},buildWrapper:function(){this.wrapper=document.createElement('div');Element.setStyle(this.wrapper,{position:'absolute',zIndex:Tips.zIndex+1,display:'none'});if(Prototype.Browser.IE){this.underlay=document.createElement('iframe');this.underlay.src='javascript:;';Element.setStyle(this.underlay,{position:'absolute',display:'none',border:0,margin:0,opacity:0.01,padding:0,background:'none',zIndex:Tips.zIndex});}},buildTip:function(){if(Prototype.Browser.IE){document.body.appendChild(this.underlay);}
this.tooltip=this.wrapper.appendChild(document.createElement('div'));this.tooltip.className=this.options.className;this.tooltip.style.position='relative';if(this.options.title){this.title=this.tooltip.appendChild(document.createElement('div'));this.title.className='title';Element.update(this.title,this.options.title);}
this.tip=this.tooltip.appendChild(document.createElement('div'));this.tip.className='content';Element.update(this.tip,this.content);document.body.appendChild(this.wrapper);var w=this.wrapper.getDimensions();this.wrapper.setStyle({width:w.width+'px',height:w.height+'px'});if(Prototype.Browser.IE)this.underlay.setStyle({width:w.width+'px',height:w.height+'px'});Element.hide(this.tooltip);},showTip:function(event){if(!this.tooltip){this.buildTip();}
this.positionTip(event);if(this.wrapper.visible()&&this.options.effect!='appear'){return;}
if(Prototype.Browser.IE)this.underlay.show();this.wrapper.show();if(!this.options.effect){var showFunc=function(){$$('.dashboard_tool_hover').invoke('hide');this.tooltip.show();}.bindAsEventListener(this);if(this.options.delay){if(this.timeout==null){this.timeout=setTimeout(showFunc,this.options.delay);}}
else{showFunc();}}else{if(this.activeEffect)Effect.Queues.get(this.queue.scope).remove(this.activeEffect);this.activeEffect=Effect[Effect.PAIRS[this.options.effect][0]](this.tooltip,{duration:this.options.duration,queue:this.queue});}},hideTip:function(event){if(!this.wrapper.visible()){return;}
if(this.timeout){clearTimeout(this.timeout);this.timeout=null;}
if(!this.options.effect){if(Prototype.Browser.IE){this.underlay.hide();}
this.tooltip.hide();this.wrapper.hide();}
else{if(this.activeEffect){Effect.Queues.get(this.queue.scope).remove(this.activeEffect);}
this.activeEffect=Effect[Effect.PAIRS[this.options.effect][1]](this.tooltip,{duration:this.options.duration,queue:this.queue,afterFinish:function(){if(Prototype.Browser.IE){this.underlay.hide();}
this.wrapper.hide();}.bind(this)});}},positionTip:function(event){var offset={'left':this.options.offset.x,'top':this.options.offset.y};var targetPosition=Position.cumulativeOffset(this.target);var tipd=this.wrapper.getDimensions();var pos={'left':(this.options.fixed)?targetPosition[0]:Event.pointerX(event),'top':(this.options.fixed)?targetPosition[1]:Event.pointerY(event)};pos.left+=offset.left;pos.top+=offset.top;if(this.options.hook){var dims={'target':this.target.getDimensions(),'tip':tipd};var hooks={'target':Position.cumulativeOffset(this.target),'tip':Position.cumulativeOffset(this.target)};for(var z in hooks){switch(this.options.hook[z]){case'topRight':hooks[z][0]+=dims[z].width;break;case'bottomLeft':hooks[z][1]+=dims[z].height;break;case'bottomRight':hooks[z][0]+=dims[z].width;hooks[z][1]+=dims[z].height;break;}}
pos.left+=-1*(hooks.tip[0]-hooks.target[0]);pos.top+=-1*(hooks.tip[1]-hooks.target[1]);}
if(!this.options.fixed&&this.element!==this.target){var elementPosition=Position.cumulativeOffset(this.element);pos.left+=-1*(elementPosition[0]-targetPosition[0]);pos.top+=-1*(elementPosition[1]-targetPosition[1]);}
if(this.options.touchMyPosition){var scroll=this.getScrollOffsets();var viewport=this.viewportSize();var pair={'left':'width','top':'height'};for(var z in pair){if((pos[z]+tipd[pair[z]]-scroll[z])>viewport[pair[z]]){pos[z]=pos[z]-tipd[pair[z]]-2*offset[z];}}}
var pleft=parseInt(pos.left);var ptop=parseInt(pos.top);this.wrapper.setStyle({left:pleft+'px',top:ptop+'px'});if(Prototype.Browser.IE){this.underlay.setStyle({left:pleft+'px',top:ptop+'px'});}},viewportWidth:function(){return(Prototype.Browser.Opera)?document.body.clientWidth:document.documentElement.clientWidth;},viewportHeight:function(){if(Prototype.Browser.Opera){return document.body.clientHeight;}
else if(Prototype.Browser.WebKit){return this.innerHeight;}
else{return document.documentElement.clientHeight;}},viewportSize:function(){return{'height':this.viewportHeight(),'width':this.viewportWidth()};},getScrollLeft:function(){return this.pageXOffset||document.documentElement.scrollLeft;},getScrollTop:function(){return this.pageYOffset||document.documentElement.scrollTop;},getScrollOffsets:function(){return{'left':this.getScrollLeft(),'top':this.getScrollTop()}}};Function.prototype.safeBind=function(){var __method=this,args=$A(arguments),object=args.shift();return function(){if(typeof $A=='function')
return __method.apply(object,args.concat($A(arguments)));}};
