Date.prototype.prettyMonth=function(){return['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][this.getMonth()];};var EventStream=Cls.extend({fullTemplate:null,shortTemplate:null,MAX_SEQUENTIAL_TWEETS:3,mostRecentTimestamp:null,intervalFunction:function(){},defaultInterval:10000,interval:10000,decay:1.5,checkForNewInterval:null,newEntryNotifier:null,showNotifications:true,callbacks:{missing:function(){}},understoodTypes:['rsvp_reply_yes','rsvp_reply_no','rsvp_reply_maybe','rsvp_change_yes','rsvp_change_no','rsvp_change_maybe','registration','extension','view_web','view_email','photo_gallery','flickr_gallery','contact_update','do_not_send','collect_money','email_bounce','ctp_donation','invitation_updated','guest_list_management','post_to_twitter','public_comment','private_message','guests_added','date_time_changed','venue_updated','web_page_updated','amazon_registry','ctp_registry','twittered','you_tube','design_updated','guest_list_management','old_news','created'],notificationTypes:['view_web','view_email','rsvp_change_maybe','rsvp_change_no','rsvp_change_yes','rsvp_reply_maybe','rsvp_reply_no','rsvp_reply_yes'],linkOutTypes:['photo_gallery','flickr_gallery','ctp_registry','amazon_registry','private_message','email_bounce'],toggleText:uPing.eventHash.product=='events'||uPing.eventHash.product=='yahoo_events'?{hide:'hide RSVPs',show:'show RSVPs'}:{hide:'hide notifications',show:'show notifications'},init:function(el,mode){this.mode=mode;this.cachedTimestamps=[];this.fullTemplate=tmpl('stream_item');this.shortTemplate=tmpl('short_stream_item');this.el=el.find('#items');this.newEntryNotifier=$j("<div id='report_update_notice'></div>");this.load();var self=this;if(mode=='landing'){this.showNotifications=false;}
$j('.stream_load_new_items').live('click',function(){self.newEntryNotifier.remove();self.update();});$j('.stream_link_out').live('click',function(){var kind=$j(this).attr('rel');callback=self.callbacks[(typeof self.callbacks[kind]=='undefined')?'missing':kind];callback();});this.setupTwitterForm();this.enableUpdater();$j('#toggle_notifications').click(function(){self.toggleNotifications($j(this));});},registerCallbacks:function(obj){$j.extend(this.callbacks,obj);},enableUpdater:function(){if(this.mode=='landing'){return;}
var self=this;self.intervalFunction=function(){self.newEntryCount();self.checkForNewInterval=setTimeout(self.intervalFunction,self.interval);self.interval=self.interval*self.decay;}
this.checkForNewInterval=setTimeout(self.intervalFunction,self.defaultInterval);},disableUpdater:function(){if(this.mode=='landing'){return;}
this.interval=this.defaultInterval;clearInterval(this.checkForNewInterval);},update:function(callback){this.interval=this.defaultInterval;clearTimeout(this.checkForNewInterval);this.checkForNewInterval=setTimeout(this.intervalFunction,this.interval);this.load({load_only_new:true,callback:callback});},load:function(opts){var opts=opts||{};var load_only_new=opts.load_only_new||false;var callback=opts.callback||function(){};var self=this;function onSuccess(r){self.newEntryNotifier.remove();try{for(var i=r.length;i>0;i--){var entry=r[i-1];if(!entry){continue;}
self.cachedTimestamps.unshift(entry.utc);self.mostRecentTimestamp=Math.max(self.mostRecentTimestamp,entry.utc);self.addEntry(entry,load_only_new);}
if(!load_only_new){self.loadTweets(uPing.eventHash.twitter_search);}}catch(e){console.log("OMG ",e);}
callback();};var opts={url:$j('#stream_url').val(),type:'get',dataType:'json',success:onSuccess};if(self.mostRecentTimestamp){$j.extend(opts,{data:'since='+(self.mostRecentTimestamp/1000)+'&mode='+self.mode});}
$j.ajax(opts);},toggleNotifications:function(link){this.showNotifications=!this.showNotifications;if(!this.showNotifications){$j('ul#items li.short_stream_item').slideUp();link.html(this.toggleText.show);}
else{$j('ul#items li.short_stream_item').slideDown();link.html(this.toggleText.hide);}},newEntryCount:function(){var self=this;$j.ajax({url:$j('#stream_count_url').val(),type:'get',data:'since='+(self.mostRecentTimestamp/1000)+'&mode='+self.mode,dataType:'json',success:function(r){r=parseInt(r,10);if(r>0){self.interval=self.defaultInterval;var s=r==1?'':'s';self.newEntryNotifier.html("<a class='stream_load_new_items' href='javascript:void(0);'>show "+r+" new item"+s+"</a>").prependTo(self.el);}
else{self.newEntryNotifier.remove();}}});},addEntry:function(entry,highlight_new){var self=this;if($j.inArray(entry.kind,this.understoodTypes)==-1){return;}
if(entry.host_only&&self.mode!='manage'){return;}
entry.mode=self.mode;var rendered=$j.inArray(entry.kind,self.notificationTypes)!=-1?self.shortTemplate(entry):self.fullTemplate(entry);var row=$j(rendered);row.find('.reply_private').click(function(){var target=$j(this).attr('rel');var url=$j('#private_messages_url').val();window.location.href=url+'#'+target;return false;}).end().find('.view_private').click(function(){$j(this).siblings().andSelf().toggle();}).end().find('.delete_column').click(function(){var el=$j(this);el.css({backgroundImage:"url(https://wac.edgecastcdn.net/8000D3/www.pingg.com/images/indicator.gif)"});self.removeRecord(el.parent());});if(highlight_new){this.el.prepend(row);var originalColor=row.css('background-color');row.css({backgroundColor:"rgb(255,255,225)"}).animate({backgroundColor:originalColor},3000,function(){row.css({backgroundColor:null});});if(!this.showNotifications&&$j.inArray(entry.kind,this.notificationTypes)!=-1){setTimeout(function(){row.slideUp();},10000);}}
else{if(!this.showNotifications&&$j.inArray(entry.kind,this.notificationTypes)!=-1){row.hide();}
this.el.prepend(row);}},removeRecord:function(el){$j.ajax({url:$j('#stream_remove_url').val(),type:'post',data:'record_id='+el.attr('id').split('_')[1],dataType:'json',success:function(r){if(r.ok){el.animate({opacity:0,height:0},'fast',function(){$j(this).remove();});}
else{el.css({backgroundImage:null});}}});},loadTweets:function(q){var self=this;self.el.find('li.stream_twitter').animate({opacity:0,height:0},function(){$j(this).remove();});if(q==null||q==""){return;}
$j.getJSON('http://search.twitter.com/search.json?callback=?',{q:q,rpp:50},function(json){var tweetTemplate=tmpl('twitter_item');function addMoreLink(target,selector,count){var seeMore=$j(tmpl('twitter_more',{counter:count-self.MAX_SEQUENTIAL_TWEETS}));seeMore.hide().insertBefore(target).animate({opacity:'show',height:'show'}).find('.more_link').click(function(ev){seeMore.fadeOut('fast',function(){$j('.'+selector).fadeIn('normal');});ev.preventDefault();});};function insertTweets(tweets,target){if(tweets.length==0){return;}
var groupClass=tweets[0].id+"_more";for(var j=0;j<tweets.length;j++){var tweet=tweets[j];var tweetTime=new Date(tweet.created_at);if(j==self.MAX_SEQUENTIAL_TWEETS){addMoreLink(target,groupClass,tweets.length);}
var tweetRow=$j(tweetTemplate({id:tweet.id,text:tweet.text,utc:tweetTime.getTime(),timestamp:tweetTime,name:tweet.from_user,profile_image_url:tweet.profile_image_url,group:groupClass}));tweetRow.hide().insertBefore(target);if(j<self.MAX_SEQUENTIAL_TWEETS){tweetRow.animate({opacity:'show',height:'show'});}}}
var i=0;var start=0;$j.each(self.cachedTimestamps,function(){var hasSegment=false;for(i=start;i<json.results.length;i++){var tweet=json.results[i];var tweetTime=new Date(tweet.created_at);if(tweetTime.getTime()>this){hasSegment=true;if(i==json.results.length-1){var target=self.el.find("li.stream_item[rel="+this+"]");insertTweets(json.results.slice(start,i),target);start=json.results.length;}}
else{if(hasSegment){var target=self.el.find("li.stream_item[rel="+this+"]");insertTweets(json.results.slice(start,i),target);start=i;}
break;}}});if(start<json.results.length-1){var ts=self.cachedTimestamps[self.cachedTimestamps.length-1];self.el.append('<li class="last_item"></li>');var target=self.el.find("li.last_item");insertTweets(json.results.slice(start,json.results.length),target);target.remove();}});},setupTwitterForm:function(){var self=this;$j('#twitter_options_form').asAjaxForm({loading:function(){$j('#twitter_options_indicator').fadeIn();},success:function(data){$j('#twitter_options_indicator').hide();setTimeout(function(){$j('#twitter_options_message').fadeOut('slow');},2000);$j('#twitter_options_message').html(data.message).fadeIn('slow');self.loadTweets(data.q);$j('#twitter_options_saved').val(data.q);}});$j('#twitter_options_button').click(function(ev){$j('#twitter_options_form').submit();ev.preventDefault();});}});var GiftRegistryItems=function(){var list_id,list_locale;return{showAmazon:function(){var el_list_id=$('amazon_wish_list_id');var el_list_locale=$('amazon_wish_list_locale');if(el_list_id&&el_list_locale){this.list_id=el_list_id.getValue().strip();this.list_locale=el_list_locale.getValue().strip();var url='/awsproxy/items?format=json';$('items_list').update('<img src="https://wac.edgecastcdn.net/8000D3/www.pingg.com/images/indicator.gif" /> Loading ... ');var request=new Ajax.Request(url,{asynchronous:true,evalScripts:false,parameters:{list_id:this.list_id,locale:this.list_locale},onSuccess:function(xhr){GiftRegistryItems.show(xhr);}});}},showCTP:function(){if($('ctp_list_name')){var url=$('ctp_list_url').getValue();var req=new Ajax.Request(url);}},show:function(xhr){var response=xhr.responseText.evalJSON();var list='';var item_count=0;response.items.each(function(item){if(item.title&&item.small_image&&item.url){list+='<div class="amazon_item">';list+='<b>'+item.title+'</b><br />';list+='<img src="'+item.small_image.url+'" width="'+item.small_image.width+'"  height="'+item.small_image.height+'" /><br />';if(item.price){list+='$'+item.price.amount.toFixed(2)+' <br /> ';}
if(item.quantity_desired>item.quantity_received){list+='<a href="'+item.url+'" target="_blank">Buy This On Amazon</a>';}
else{list+='Already Bought';}
list+="</div>\n\n";if(item_count%1){list+='<br style="clear: both;" />';}
item_count++;}});list+='<br /><br />';$('items_list').update(list);var name=$('amazon_wish_list_name').innerHTML.strip();name+=' ('+response.total_items+' items)';$('amazon_wish_list_name').update(name);}};}();var GuestList=function(){return{load:function(){if($('guest_list_load_url')){var url=$('guest_list_load_url').getValue();var req=new Ajax.Request(url);}},showAll:function(options){var chunkStart=25,rsvp='yes';if((typeof(options)!='undefined')){if(options.rsvp){rsvp=options.rsvp;chunkStart=$('rsvp_list_'+options.rsvp).childElements().size();}
if(parseInt(options.chunkStart)){chunkStart=parseInt(options.chunkStart);}}
if($('guest_list_show_all_url')){var url=$('guest_list_show_all_url').getValue().strip();if($('rsvp_list_'+rsvp+'_show_all')){$('rsvp_list_'+rsvp+'_show_all').hide();$('rsvp_list_'+rsvp+'_loading').show();$('rsvp_list_'+rsvp+'_loading_update').show();}
var req=new Ajax.Request(url,{parameters:{chunkStart:chunkStart,rsvp:rsvp}});}}};}();var PrivateMessage=function(){var chars_left_el,msg_el,counter,max_chars;return{init:function(){this.chars_left_el=$('private_message_chars_left');this.msg_el=$('guest[note]');this.msg_el.observe('keyup',PrivateMessage.charCounter.bindAsEventListener(PrivateMessage)).observe('keypress',PrivateMessage.updateCharCount.bindAsEventListener(PrivateMessage));this.max_chars=(this.msg_el.maxlength)?parseInt(this.msg_el.maxlength,10):parseInt(this.msg_el.value.length,10)+parseInt(this.chars_left_el.innerHTML,10);},updateCharCount:function(e){this.chars_left_el.innerHTML=this.max_chars-parseInt(this.msg_el.value.length,10);},charCounter:function(e){if(parseInt(this.msg_el.value.length,10)>this.max_chars){this.msg_el.value=this.msg_el.value.substring(0,this.max_chars);this.msg_el.scrollTop=this.msg_el.scrollHeight;}
this.updateCharCount();}};}();var MapData=function(){var map;var place;var marker};var GoogleVenueMap=function(){return{show:function(){if(typeof(GBrowserIsCompatible)!='undefined'&&GBrowserIsCompatible()&&MapData.place){var zoom=MapData.place.zoom;if(parseInt(zoom)<1){zoom=15;}
MapData.map=new GMap2(document.getElementById("google_map"));var point=new GLatLng(MapData.place.latlon[0],MapData.place.latlon[1]);MapData.map.setCenter(new GLatLng(MapData.place.center[0],MapData.place.center[1]),zoom);var marker=new GMarker(point,{clickable:true});GEvent.addListener(marker,"click",function(){html="<div class=\"address_details\">"+MapData.place.venue.escapeHTML()+"</div><br /><div class=\"address_label\">Address:</div><div class=\"address_details\">"+MapData.place.address.escapeHTML()+"</div><br/><a href=\""+MapData.place.direction+"\" target=\"blank\">Find directions</a>"
marker.openInfoWindowHtml(html);});MapData.map.addOverlay(marker);MapData.map.addControl(new GLargeMapControl());}},delayed:function(){if(typeof(GBrowserIsCompatible)!='undefined'){if(Prototype.Browser.WebKit){setTimeout('GoogleVenueMap.show();',1000);}
else{GoogleVenueMap.show();}
Event.observe(window,'unload',GUnload);}
else{setTimeout('GoogleVenueMap.delayed();',1000);}},load:function(){var gmap_script_src=$('gmap_script_src').value;gmap_script_src+='&async=2&callback=GoogleVenueMap.delayed'
var gmap_script=document.createElement('script');gmap_script.src=gmap_script_src;gmap_script.type='text/javascript';$$('head').first().insert({'bottom':gmap_script});}};}();var YAHOO=window.YAHOO||{};var YahooVenueMap=function(){return{show:function(){if(MapData.place){var zoom=MapData.place.zoom;if(parseInt(zoom)<1){zoom=15;}
MapData.map=new YMap('yahoo_map');MapData.map.addTypeControl();MapData.map.addZoomLong();MapData.map.addPanControl();MapData.map.setMapType(YAHOO_MAP_REG);var centerGeoPoint=new YGeoPoint(MapData.place.center[0],MapData.place.center[1])
MapData.map.drawZoomAndCenter(centerGeoPoint,zoom);MapData.marker=new YMarker(MapData.place.address_to_locate);MapData.map.addOverlay(MapData.marker);YEvent.Capture(MapData.marker,"MouseClick",function(){html="<div class=\"address_details\">"+MapData.place.venue.escapeHTML()+"</div><br /><div class=\"address_label\">Address:</div><div class=\"address_details\">"+MapData.place.address.escapeHTML()+"</div><br/><a href=\""+MapData.place.direction+"\" target=\"blank\">Find directions</a>"
MapData.marker.openSmartWindow(html);});}},delayed:function(){if(typeof(YMap)!='undefined'){if(Prototype.Browser.WebKit){setTimeout('YahooVenueMap.show();',1000);}
else{YahooVenueMap.show();}}
else{setTimeout('YahooVenueMap.delayed();',1000);}},load:function(){var yahoo_js_set=["http://l.yimg.com/d/lib/common/utils/2/dom_2.0.1-b2.js","http://l.yimg.com/d/lib/common/utils/2/event_2.0.0-b2.js","http://l.yimg.com/d/lib/common/utils/2/dragdrop_2.0.1-b4.js","http://l.yimg.com/d/lib/common/utils/2/animation_2.0.1-b2.js","http://l.yimg.com/d/lib/map/js/api/ymapapi_3_8_2_3.js"];yahoo_js_set.each(function(ymap_script_src){var ymap_script=document.createElement('script');ymap_script.src=ymap_script_src;ymap_script.type='text/javascript';$$('head').first().insert({'bottom':ymap_script});});setTimeout('YahooVenueMap.delayed();',1000);}};}();var RSVP=function(){var send_private_message_url;return{saveLock:false,init:function(){this.boundRsvpPicker=this.rsvpPicker.bindAsEventListener(RSVP,false,true);this.boundSendPrivateMessage=this.sendPrivateMessage.bindAsEventListener(RSVP);this.boundRsvpPickerSaveAll=this.rsvpSaveAllButton.bindAsEventListener(RSVP);this.boundClearError=this.clearError.bindAsEventListener(RSVP);this.bindListeners();this.lastParams="";this.input_hints=[];if($('party_container')){this.initParty();}},initParty:function(){if($('party_size_select')){this.createInputHints();this.changePartySize();}},bindListeners:function(){if($$('.rsvp_radio_group').any()){$$('.rsvp_radio_group').invoke('observe','click',this.boundRsvpPicker);}
if($('send_private_message_btn')){this.send_private_message_url=$('send_private_message_url').getValue();$('send_private_message_btn').observe('click',this.boundSendPrivateMessage);}
if($('rsvp_save_all_btn')){$('rsvp_save_all_btn').observe('click',this.boundRsvpPickerSaveAll);}},unbindListeners:function(){if($$('.rsvp_radio_group').any()){$$('.rsvp_radio_group').invoke('stopObserving','click',this.boundRsvpPicker);}
if($('send_private_message_btn')){this.send_private_message_url=$('send_private_message_url').getValue();$('send_private_message_btn').stopObserving('click',this.boundSendPrivateMessage);}
if($('rsvp_save_all_btn')){$('rsvp_save_all_btn').stopObserving('click',this.boundRsvpPickerSaveAll);}
if(!window.location.href.match(/\/quick/)&&$('extra_guests')&&$('extra_guests').tagName.toLowerCase()=='input'){$('extra_guests').stopObserving('blur',this.boundRsvpPicker);$('extra_guests').stopObserving('focus',this.boundClearError);}
if($('extra_guests')&&$('extra_guests').tagName.toLowerCase()=='select'){$('extra_guests').stopObserving('change',this.boundRsvpPicker);$('extra_guests').stopObserving('click',this.boundClearError);}},sendPrivateMessage:function(){if($('update_rsvp_error')){$('update_rsvp_error').update('&nbsp;');}
RSVP.clearError();Modal.show({title:'Send Private Message',url:this.send_private_message_url,height:300,width:350});},sendFirstRsvp:function(rsvp){var onLoading=function(){if($('rsvp_save_indicator')){$('rsvp_save_indicator').show();}}
var onComplete=function(){RSVP.saveLock=false;if($('rsvp_save_indicator')){$('rsvp_save_indicator').hide();}
$('rsvp_bottom_container').show();}
if($('update_rsvp_error')){$('update_rsvp_error').update('&nbsp;');}
if(!RSVP.saveLock){RSVP.saveLock=true;var url=$('rsvp_url').getValue();var req=new Ajax.Request(url,{parameters:{rsvp:rsvp},onLoading:onLoading,onComplete:onComplete});}},rsvpPicker:function(ev,sync,from_radio_click,from_quick_rsvp_blur,from_quick_rsvp_submit,from_save_all_btn){if($('update_rsvp_error')){$('update_rsvp_error').update('&nbsp;');}
RSVP.clearError();if(!RSVP.saveLock){var params=$('rsvp_form').serialize();if(RSVP.lastParams!=params){RSVP.lastParams=params;RSVP.saveLock=true;if(ev&&ev.element&&ev.element()==$('rsvp_save_all_btn')){from_radio_click=false;}
if(from_radio_click){params+="&from_radio_click=1";}
if(from_quick_rsvp_blur){params+="&from_quick_rsvp_blur=1";}
if(from_quick_rsvp_submit){params+="&from_quick_rsvp_submit=1";}
var rsvp_form_el=$('rsvp_form');var req=new Ajax.Request(rsvp_form_el.action,{asynchronous:!sync,parameters:params,onLoading:function(){if($('rsvp_save_indicator')){$('rsvp_save_indicator').show();}},onComplete:function(){RSVP.saveLock=false;if($('rsvp_save_indicator')){$('rsvp_save_indicator').hide();}}});}
else if(from_quick_rsvp_submit){window.location=from_quick_rsvp_submit;}
else if(from_save_all_btn){if($('rsvp_recorded_feedback')){$('rsvp_recorded_feedback').update('RSVP saved');}}
return true;}},rsvpSaveAllButton:function(ev){this.rsvpPicker(ev,false,false,false,false,true);},quickRsvpBlur:function(){this.rsvpPicker(false,true,false,true,false);return true;},quickRsvpSubmit:function(url){RSVP.rsvpPicker(false,false,false,false,url);return true;},clearError:function(ev){if($('rsvp_recorded_feedback')){$('rsvp_recorded_feedback').update('&nbsp;');}},createInputHints:function(){this.input_hints=[];$$('#party_container input[type=text]').each(function(input){input.writeAttribute('size','20');this.input_hints.push(new Pingg.InputHint(input));},this);},changePartySize:function(){var party_size=parseInt($('party_size_select').getValue());if(isNaN(party_size)){alert("That is not a number!!!!");return false;}
if(party_size==1){$('guest_names').hide();}
else{$('guest_names').show();}
var party_els=$$('#party_container input[party_member=true][type=text]');for(var i=1;i<=8;i++){var target=party_els[i-1]
if(i>party_size||party_size==1){target.hide();target.up('li').hide();target.setValue(Pingg.CONSTANTS['party']['default_name']);}
else{target.up('li').show();target.show();}}
this.party_size=party_size
$('party_container').show();},saveParty:function(){var success=function(transport){$('party_container').update(transport.responseText);this.createInputHints();this.changePartySize();$('party_size_indicator').hide();window.location=$('landing_url').value;}
$('party_size_indicator').show();$('rsvp_party_form').down('form').request({onSuccess:success.bindAsEventListener(this)})},updatePartySize:function(){var url=$('change_party_size_url').getValue();var party_size=parseInt($('party_size_select').getValue());var onSuccess=function(transport){var party_els=$$('#party_container input[party_member=true][type=text]');var names=party_els.slice(0,party_size).collect(function(name){return name.getValue();});$('party_container').update(transport.responseText);party_els.slice(0,party_size).zip(names).each(function(item){var new_name=item[0].getValue();var old_name=item[1];if(new_name==Pingg.CONSTANTS['party']['default_name']&&old_name!=Pingg.CONSTANTS['party']['default_name']){item[0].value=old_name;}});this.createInputHints();this.changePartySize();$('party_size_indicator').hide();if(party_size==1){$$('.qrsvp_party_button').invoke('hide');$$('.qrsvp_continue').invoke('show');}
else{$$('.qrsvp_party_button').invoke('show');$$('.qrsvp_continue').invoke('hide');}};var onFailure=function(transport){var message=transport.responseText;$('update_rsvp_error').update(message);Element.update.delay(5,'update_rsvp_error','');$('party_size_indicator').hide();$('party_size_select').setValue(this.party_size);};$('party_size_indicator').show();var req=new Ajax.Request(url,{parameters:{party_size:party_size},onSuccess:onSuccess.bindAsEventListener(this),onFailure:onFailure.bindAsEventListener(this)});return true;}}}();var EventFund=function(){var digitFilter;return{init:function(){this.digitFilter=this.allowOnlyDigits.bindAsEventListener(this);this.attachDigitListeners();},payNow:function(){var amount=0;if((parseInt($('cm_amount_input').getValue())>0)){amount=parseInt($('cm_amount_input').getValue());}
if(amount==0){$('cm_amount_input').addClassName('redborder');$('cm_amount_error').show();}
else{$('cm_amount_input').removeClassName('redborder');$('cm_amount_error').hide();$('paypal_form_amount').value=amount;$('cm_contribute_form').submit();}},attachDigitListeners:function(){if($('cm_amount_input')){$('cm_amount_input').observe('keydown',this.digitFilter);}},detachDigitListeners:function(){if($('cm_amount_input')){$('cm_amount_input').stopObserving('keydown',this.digitFilter);}},allowOnlyDigits:function(e){switch(e.keyCode){case Event.KEY_BACKSPACE:case Event.KEY_TAB:case Event.KEY_RETURN:case Event.KEY_ESC:case Event.KEY_LEFT:case Event.KEY_UP:case Event.KEY_RIGHT:case Event.KEY_DOWN:case Event.KEY_DELETE:case Event.KEY_HOME:case Event.KEY_END:case Event.KEY_PAGEUP:case Event.KEY_PAGEDOWN:return true;break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 96:case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:case 105:return true;break;default:e.stop();return false;break;}}}}();var Sharing=function(){return{init:function(){$$('.forward_invitation_field').each(function(el){el.writeAttribute('defaultvalue',el.getValue());});$$('.forward_invitation_field').invoke('observe','focus',this.focusListener.bindAsEventListener(this));$$('.forward_invitation_field').invoke('observe','blur',this.blurListener.bindAsEventListener(this));if($('invite_guest_submit')){$('invite_guest_submit').observe('click',this.submit.bindAsEventListener(this));}
if($('sharing_on_fb_button')){$('sharing_on_fb_button').observe('click',this.shareOnFacebook.bindAsEventListener(this));}},shareOnFacebook:function(ev){$('invite_guest_msg').update('&nbsp;')
window.open($('sharing_on_fb_button').href,'share_on_facebook','height=500,width=600,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0');ev.stop();},focusListener:function(ev){el=ev.element();el.removeClassName('grey');if(el.getValue()==el.readAttribute('defaultvalue')){el.writeAttribute('value','');el.value='';}},blurListener:function(ev){el=ev.element();if(el.getValue().blank()||el.getValue().length<1){el.addClassName('grey');el.writeAttribute('value',el.readAttribute('defaultvalue'));el.value=el.readAttribute('defaultvalue');}},reset:function(){$$('.forward_invitation_field').invoke('clear');$$('.forward_invitation_field').each(function(el){el.addClassName('grey');el.writeAttribute('value',el.readAttribute('defaultvalue'));el.value=el.readAttribute('defaultvalue');});},submit:function(ev){$('invite_guest_msg').update('&nbsp;')
if($('forward_invitation_contact_email').getValue()!=$('forward_invitation_contact_email').readAttribute('defaultvalue')){var params=new Hash();$$('.forward_invitation_field').each(function(el){if(!el.getValue().blank()&&el.getValue()!=el.readAttribute('defaultvalue')){params.set(el.readAttribute('name'),el.getValue());}});if(params.keys().size()>0){$('invite_guest_indicator').show();var req=new Ajax.Request($('forward_guest_form').action,{parameters:params.toQueryString(),onComplete:function(){$('invite_guest_indicator').hide();}});}}
else{$('invite_guest_msg').update('Please enter a valid email address.');}}}}();var SignUp=function(){return{init:function(){$$('.sign_up_field').each(function(el){el.writeAttribute('defaultvalue',el.getValue());});$$('.sign_up_field').invoke('observe','focus',this.focusListener.bindAsEventListener(this));$$('.sign_up_field').invoke('observe','blur',this.blurListener.bindAsEventListener(this));if($('guest_registry_submit')){$('guest_registry_submit').observe('click',this.submitListener.bindAsEventListener(this));}},focusListener:function(ev){el=ev.element();el.removeClassName('grey');if(el.getValue()==el.readAttribute('defaultvalue')){el.writeAttribute('value','');el.value='';}},blurListener:function(ev){el=ev.element();if(el.getValue().blank()||el.getValue().length<1){el.addClassName('grey');el.writeAttribute('value',el.readAttribute('defaultvalue'));el.value=el.readAttribute('defaultvalue');}},submitListener:function(ev){$('guest_registry_errors').update('&nbsp;');var params=new Hash();params.set($('register_as_guest_form_email').readAttribute('name'),$('register_as_guest_form_email').getValue());$$('.sign_up_field').each(function(el){if(!el.getValue().blank()&&el.getValue()!=el.readAttribute('defaultvalue')){params.set(el.readAttribute('name'),el.getValue());}});params.set($('register_as_guest_form_email').readAttribute('name'),$('register_as_guest_form_email').getValue());if($('register_as_guest_form_country')){params.set($('register_as_guest_form_country').readAttribute('name'),$('register_as_guest_form_country').getValue());}
var email_field=$('register_as_guest_form_email');if(!email_field.getValue().blank()&&email_field.getValue()!=email_field.readAttribute('defaultvalue')){$('guest_registry_indicator').show();var req=new Ajax.Request($('register_as_guest_form').action,{parameters:params.toQueryString(),onComplete:function(){$('guest_registry_indicator').hide();}});}
else{$('guest_registry_errors').update('Please enter a valid email address.');}},reset:function(){$$('.sign_up_field').invoke('clear');$$('.sign_up_field').each(function(el){el.addClassName('grey');el.writeAttribute('value',el.readAttribute('defaultvalue'));el.value=el.readAttribute('defaultvalue');});}}}();var IEFixes=function(){return{init:function(){if(!Prototype.Browser.IE){$$('.rounded_container').invoke('setStyle',{border:"1px solid silver"});}}};}();(function($){$.fn.expandingContent=function(settings){settings=$.extend({partialClass:'partial_content',fullClass:'full_content',moreClass:'more',lessClass:'less'},settings);return this.each(function(){var container=$(this);var full=container.find('.'+settings.fullClass);if(!full.is(':visible')){var partial=container.find('.'+settings.partialClass).show();var more=container.find('.'+settings.moreClass).show();var less=container.find('.'+settings.lessClass).hide();container.find('.'+settings.moreClass).click(function(ev){partial.hide();full.show();more.hide();less.show();ev.preventDefault();});container.find('.'+settings.lessClass).click(function(ev){partial.show();full.hide();more.show();less.hide();ev.preventDefault();});}});}})(jQuery);var eventStream;Event.observe(window,'load',function(){if($j('#landing_stream_container').length>0){eventStream=new EventStream($j('#landing_stream_container'),'landing');var photoCallback=function(){$j.scrollTo($j('#pictures-video'));};var registryCallback=function(){$j.scrollTo($j('#gift-registry'));};eventStream.registerCallbacks({photo_gallery:photoCallback,flickr_gallery:photoCallback,ctp_registry:registryCallback,amazon_registry:registryCallback});}
initLightbox();Clickables.init();RSVP.init();EventFund.init();Sharing.init();SignUp.init();IEFixes.init();$j('div#details div.more_info_container').expandingContent();$$("#pingg-rsvp-ad-wrap a").each(function(anchor){if(anchor.readAttribute('target')!='_new'){anchor.writeAttribute('target','_top');}})
if($('photo_share_viewer'))
{var psi=new PhotoShareViewer('photo_share_viewer');EventPhotoGallery.init(psi);psi.show();}
if($('google_map')){$('google_map_container').observe('landing_module:loaded',GoogleVenueMap.load);}
if($('yahoo_map')){$('yahoo_map_container').observe('landing_module:loaded',YahooVenueMap.load);YAHOO.namespace=function(_1){if(!_1||!_1.length){return null;}
var _2=_1.split(".");var _3=YAHOO;for(var i=(_2[0]=="YAHOO")?1:0;i<_2.length;++i){_3[_2[i]]=_3[_2[i]]||{};_3=_3[_2[i]];}
return _3;};YAHOO.namespace("util");YAHOO.namespace("widget");YAHOO.namespace("example");}
$$('.web_content').invoke('fire','landing_module:loaded');$j('#record_comment').asAjaxForm({loading:function(){eventStream.disableUpdater();$j('#record_comment_indicator').fadeIn('fast');},success:function(json){eventStream.update(function(){eventStream.enableUpdater();$j('#record_comment_indicator').fadeOut('fast');$j('#record_comment textarea#comment').val('');});}});});var timeZoneOffset=(new Date()).getTimezoneOffset();var EventPhotoGallery=function(){return{init:function(psv){this.viewer=psv;this.flickr=null;},flickrIdOnFocus:function(el){if(el.value=='Flickr screen name'||el.readAttribute('value')=='Flickr screen name'){el.value='';el.setAttribute('value','');el.removeClassName('grey');}},search:function(){$$('html').each(function(el){el.setStyle({overflow:'hidden'});});var parameters=Form.serialize('exernal_photo_search_form',true);parameters.initial_load='true';this.flickr=null;Modal.show({title:'Flickr Browser',url:'/photo_share_items/search',height:390,params:parameters,beforeClose:function(){$$('html').each(function(el){el.setStyle({overflow:'auto'});});}});return false;}};}();var PhotoGallery=Class.create({initialize:function(id,searchUrl){this.searchUrl=searchUrl;this.id=id;this.galleryEl=$$("#"+id+" .gallery")[0];;this.currentChunk=0;this.chunkSize=12;this.currentState=[];this.nbResults=0;this.loadLock=false;this.stopLoad();},clear:function(){if(this.galleryEl){this.galleryEl.update("");this.galleryEl.stopObserving('scroll',this.scrollHandler);}
this.scrollHandler=null;},createRequest:function(url,username){throw new Error("Method not implemented!");},drawGallery:function(xhr){if(xhr.status==200&&xhr.responseText=="error"){this.clear();$("results_text").update("0 Results");this.galleryEl.update('<div class="no_results">No search results</div>');}
else if(xhr.status==502){this.clear();this.galleryEl.update('<div style="width:250px;text-align:center;margin:0 auto;"><br style="line-height: 120px;" /><br />'+xhr.responseText+'</div>');}
else{var loaderEl=$$("#"+this.id+" .gallery .gallery_loader")[0];if(loaderEl){loaderEl.remove();}
this.currentChunk++;this.galleryEl.insert({bottom:xhr.responseText});$('select_button').observe('click',this.selectItems);this.loadLock=false;this.nbResults=$(this.id+"_nb_results").value;$(this.id).down('#results_text').update(this.nbResults+" results");}
this.stopLoad();},ajaxLoad:function(){var factor=((this.currentChunk-1)+0.75)/this.currentChunk;var scrollbar=this.galleryEl;if(scrollbar.scrollTop+scrollbar.offsetHeight>parseInt(scrollbar.scrollHeight*factor)){this.loadChunk();}},loadChunk:function(){if(this.nbResults>this.chunkSize*this.currentChunk&&!this.loadLock){this.loadLock=true;this.update(this.currentState.url,this.currentState.searchHash);}},onLightboxLoad:function(){this.lightbox=true;},onLightboxUnload:function(){this.lightbox=false;},update:function(url,searchHash){this.currentState.url=url;this.currentState.searchHash=searchHash;this.scrollHandler=this.ajaxLoad.bindAsEventListener(this);this.startLoad();this.createRequest(url,searchHash);this.galleryEl.observe('scroll',this.scrollHandler);},updateResults:function(e){this.nbResults=parseInt(e.target.value);$$("#"+this.id+" .results_msg")[0].update(this.nbResults+" Results");},search:function(searchHash){this.currentChunk=0;this.clear();this.update(this.searchUrl,searchHash)},startLoad:function(){this.loadLock=true;var indicator=PhotoGallery.indicator.evaluate({});this.galleryEl.insert({bottom:indicator});},stopLoad:function(){},setChecked:function(id){el=$('flickr_select_'+id);if(el.checked==false){el.toggleCheck('on').up().addClassName('on');}
else{el.toggleCheck('off').up().removeClassName('on');}},selectItems:function(){$("flickr_gallery_indicator").show();var photos_to_add=[];var anchors=$$('#flickr_gallery .gallery .thumb a');var media_type=anchors[0].readAttribute('rel').match(/set|single/)[0];anchors.each(function(el){var ref_id=el.readAttribute('set_id');if($('flickr_select_'+ref_id).checked){photos_to_add.push(ref_id);}});new Ajax.Request($('photo_share_items_url').value+"?cb="+(new Date()).getTime(),{onComplete:function(){Modal.hide();EventPhotoGallery.viewer.reload();eventStream.update();},parameters:{media_type:media_type,"photos[]":photos_to_add}});}});PhotoGallery.indicator=new Template('<div class="gallery_loader"><img src="https://wac.edgecastcdn.net/8000D3/www.pingg.com/images/ajax-load-indicator.gif" width="20px" height="20px" /><div class="gallery_loader_text">Loading</span></div>');var FlickrGallery=Class.create(PhotoGallery,{createRequest:function(url,searchHash){searchHash.offset=this.currentChunk*this.chunkSize;searchHash.limit=this.chunkSize;var ajaxReq=new Ajax.Request(url,{method:'get',onComplete:this.drawGallery.bindAsEventListener(this),parameters:searchHash})},drawGallery:function($super,xhr){$super(xhr);}});var PhotoShareViewer=Class.create({initialize:function(id){this.el_id=id;this.landing_page=$(id).hasClassName('landing');},show:function(){var d=new Date();var req=new Ajax.Request($('photo_share_items_url').getValue()+"?cb="+d.getTime()+"&from_landing="+this.landing_page,{method:'get',onSuccess:this.draw.bindAsEventListener(this)});var indicator=PhotoGallery.indicator.evaluate({});$(this.el_id).innerHTML=indicator;},draw:function(xhr){$(this.el_id).update(xhr.responseText);this.showOrHideCarousel();myPhotoShareLightbox.bind();myLightbox.bind();return true;},showOrHideCarousel:function(){var photos=$('photos_container')?$('photos_container').childElements().length:0;var youtube=$$('.youtube_attachment object, .youtube_attachment embed').any();if(photos>0||youtube){$(this.el_id).show();}
else{$(this.el_id).hide();}},reload:function(){this.show();}});var PhotoShareLightbox=Class.create(Lightbox,{initialize:function(){if($('topNavSelect')){$('topNavSelect').observe('click',this.select.bindAsEventListener(this));}
return;},start:function(imageLink){$$('embed, object, #leaderboard-wrap, .double_click_ad').invoke('hide');imageLink=Element.extend(imageLink);if(imageLink.tagName=='DIV'){imageLink=imageLink.up().select('a[view=true]').first();}
this.activated=true;$('lightboxImage').hide();$('lightboxIframe').show();var rel=imageLink.rel;this.photoShare=null;this.photoShare=[]
this.photoShare.ps_type=rel.match(/flickr|photobucket/)[0];this.photoShare.media_type=rel.match(/set|single/)[0];this.photoShare.ref_id=imageLink.readAttribute('set_id');isWebPagePhoto=imageLink.readAttribute('view')=='false'?false:true;if(isWebPagePhoto){$('topNavSelect').hide();$('topNavSelectImg').hide();}
else{$('topNavSelect').show();$('topNavSelectImg').show();}
var arrayPageSize=getPageSize();Element.setHeight('overlay',arrayPageSize[1]);new Effect.Appear('overlay',{duration:overlayDuration,from:0.0,to:overlayOpacity});if(Prototype.Browser.Gecko&&navigator.userAgent.match(/Mac/)&&navigator.userAgent.match(/Firefox\/2/))
$$('.gallery').invoke('hide');$('hoverNav').hide();if(this.photoShare.ps_type=='flickr')
{if(this.photoShare.media_type=='set')
{$('lightboxImage').hide();$('lightboxIframe').show();$('lightboxIframe').replace("<iframe id='lightboxIframe' height='500px' width='500px' scrolling='no' src='http://www.flickr.com/slideShow/index.gne?set_id="+imageLink.readAttribute('set_id')+"'></iframe>")
var arrayPageScroll=getPageScroll();var lightboxTop=arrayPageScroll[1]+(arrayPageSize[3]/10)-40;Element.setTop('lightbox',lightboxTop);Element.show('lightbox');myPhotoShareLightbox.resizeImageContainer(500,500);Element.hide('loading');}
else if(this.photoShare.media_type=='single')
{$('lightboxIframe').hide();$('lightboxImage').show();var arrayPageScroll=getPageScroll();var lightboxTop=arrayPageScroll[1]+(arrayPageSize[3]/10)-40;Element.setTop('lightbox',lightboxTop);Element.show('lightbox');imgSrc=imageLink.readAttribute('href');if(animate){Element.show('loading');}
Element.hide('lightboxImage');Element.hide('hoverNav');Element.hide('prevLink');Element.hide('nextLink');Element.hide('imageDetails');imgPreloader=new Image();Element.setSrc('lightboxImage',imgSrc);imgPreloader.onload=function(){$('lightboxImage').width=imgPreloader.width;$('lightboxImage').height=imgPreloader.height;myPhotoShareLightbox.resizeImageContainer(imgPreloader.width,imgPreloader.height,{});myPhotoShareLightbox.showImage({});imgPreloader.onload=function(){};}
imgPreloader.src=imgSrc;}}},bind:function(){var anchors=document.getElementsByTagName('a');for(var i=0;i<anchors.length;i++){var anchor=anchors[i];var relAttribute=String(anchor.getAttribute('rel'));if(anchor.getAttribute('href')&&(relAttribute.toLowerCase().match('photo_share'))){anchor.onclick=function(){myPhotoShareLightbox.start(this);return false;};}}
$$('.flickr.photo.set .overlay').each(function(el){if(Prototype.Browser.IE){el.remove();}
else{el.observe('click',function(){myPhotoShareLightbox.start(this);return false;});}});},select:function($super){if(!this.activated)
return;var photoShareError=function(xhr){msg='We are unable to add your Flickr photo(s) at this time. <br /><br />Please try again later.';if(xhr.responseText!=null||xhr.responseText!="")
msg=xhr.responseText;Modal.show({title:'Error',width:300,height:200,content:msg});}
if(this.photoShare.ps_type=='flickr')
{var d=new Date();var ajaxReq=new Ajax.Request($('photo_share_items_url').value+"?cb="+d.getTime(),{onComplete:EventPhotoGallery.viewer.reload.bindAsEventListener(EventPhotoGallery.viewer),parameters:{media_type:this.photoShare.media_type,ref_id:this.photoShare.ref_id},onFailure:photoShareError});}
myPhotoShareLightbox.end();this.activate=false;eventStream.update();},showImage:function(){Element.hide('loading');new Effect.Appear('lightboxImage',{duration:resizeDuration,queue:'end'});},resizeImageContainer:function(imgWidth,imgHeight,opts){this.widthCurrent=Element.getWidth('outerImageContainer');this.heightCurrent=Element.getHeight('outerImageContainer');var widthNew=(imgWidth+(borderSize*2));var heightNew=(imgHeight+(borderSize*4));this.xScale=(widthNew/this.widthCurrent)*100;this.yScale=(heightNew/this.heightCurrent)*100;wDiff=this.widthCurrent-widthNew;hDiff=this.heightCurrent-heightNew;if(!(hDiff==0)){new Effect.Scale('outerImageContainer',this.yScale,{scaleX:false,duration:resizeDuration,queue:'front'});}
if(!(wDiff==0)){new Effect.Scale('outerImageContainer',this.xScale,{scaleY:false,delay:resizeDuration,duration:resizeDuration});}
if((hDiff==0)&&(wDiff==0)){if(navigator.appVersion.indexOf("MSIE")!=-1){pause(250);}else{pause(100);}}
Element.setHeight('prevLink',imgHeight);Element.setHeight('nextLink',imgHeight);}});Pingg.Drawer=Class.create({opened:false,created:false,afterOpen:null,error_template:new Template("<div class='error'> #{error}</div>"),initialize:function(dom_id){this.dom_id=dom_id;this.input_hints=[];},close:function(){if(this.opened){$(this.dom_id).slideUp({duration:0.2});}
this.opened=false;},open:function(party_size){if(!this.opened){if(!this.created){this.setup();}
$(this.dom_id).setStyle({height:''});$(this.dom_id).slideDown({duration:0.4});}
this.opened=true;if(this.afterOpen){this.afterOpen();}},setup:function(){this.created=true;this.createInputHints();},createInputHints:function(){$$('#'+this.dom_id+' input[type=text]').each(function(input){this.input_hints.push(new Pingg.InputHint(input));},this);},toggle:function(party_size){if(this.opened)
this.close();else
this.open(party_size);},reset:function(){this.input_hints.each(function(input){input.reset();},this);}});Pingg.PartyDrawer=Class.create(Pingg.Drawer,{initialize:function($super,dom_id,name_id,email_id){this.name_id=name_id;this.email_id=email_id;$(name_id).observe('change',this.leaderNameUpdated.bindAsEventListener(this));$super(dom_id);},open:function($super,party_size){var targets=$$('#'+this.dom_id+' input[party_member=true][type=text]');for(var i=1;i<=8;i++)
{var target=targets[i-1];if(i>party_size){target.setValue(Pingg.CONSTANTS['party']['default_name']);target.hide();target.up('li').hide();}
else{target.show();target.up('li').show();}}
var h=$(this.dom_id).getHeight()*-1;if(this.opened){h+=3;}
if(Prototype.Browser.IE){$(this.dom_id).setStyle({top:'7px'});h-=5;$(this.dom_id).setStyle({left:'-2px'});}
else if(Prototype.Browser.WebKit){$(this.dom_id).setStyle({top:'4px'});}
$(this.dom_id).setStyle({marginBottom:h+'px'});$super(party_size);},lostFocus:function(event){$(this.email_id).focus();},getPartyLeader:function(){return $$('#'+this.dom_id+' input[party_member=true][type=text][primary=true]')[0];},leaderNameUpdated:function(event){var party_name=Event.element(event).getValue();if(this.getPartyLeader().getValue().match(Pingg.CONSTANTS['party']['default_pattern'])){this.getPartyLeader().setValue(Event.element(event).getValue());}}});Pingg.GuestListInfoDrawer=Class.create(Pingg.Drawer,{initialize:function($super,contact_id,guest_id,email,sms,print){this.dom_id=guest_id+"_info_drawer";this.guest_id=guest_id;this.contact_id=contact_id;this.requestContent(email,sms,print);$super(this.dom_id);},requestContent:function(email,sms,print){var onSuccess=function(transport){this.valid_content=true;this.hideLoader();var form=transport.responseText;$(this.dom_id).update(form);if(Prototype.Browser.IE&&navigator.userAgent.match(/MSIE 6/)){$$("#"+this.dom_id+" input[type=text]").each(function(input){var size=parseInt(input.readAttribute('size'));input.writeAttribute('size',size-3);});}
$$("#"+this.dom_id+" a.save")[0].observe('click',this.save.bindAsEventListener(this));this.open();}
var onFailure=function(){this.valid_content=false;this.hideLoader();this.dom_id.update(this.error_template.evaluate({error:transport.responseText}));this.open();};var req=new Ajax.Request(["/account/contacts/",this.contact_id,"/edit_with_drawer"].join(''),{method:'get',onSuccess:onSuccess.bindAsEventListener(this),onFailure:onFailure.bindAsEventListener(this),parameters:{email:email,sms:sms,print:print}});this.showLoader();},showLoader:function(){$(this.guest_id+'_load_indicator').show();$(this.guest_id+'_remove_btn').hide();},hideLoader:function(){$(this.guest_id+'_load_indicator').hide();$(this.guest_id+'_remove_btn').show();},open:function($super){$(this.dom_id).up('td').addClassName('drawer_container');$(this.dom_id).up('tr').previous().addClassName('active_info');$(this.dom_id)
if(!this.valid_content){this.requestContent();}
else{$super();}},close:function($super){$(this.dom_id).up('td').removeClassName('drawer_container');if($(this.guest_id+'_party_drawer')&&!$(this.guest_id+'_party_drawer').visible()){$(this.dom_id).up('tr').previous().removeClassName('active_row');}
$(this.dom_id).up('tr').previous().removeClassName('active_info');$super();},save:function(event){var url=$(this.contact_id+'_update_contact_url').getValue();var onSuccess=function(transport){var json=transport.responseText.evalJSON();var checkboxes={sms:$(json.guest_id+'_send_sms_cbx'),print:$(json.guest_id+'_send_print_cbx')};if(checkboxes.sms&&checkboxes.print){checkboxes.sms.toggleCheck(json.send_sms);checkboxes.print.toggleCheck(json.send_print);}
if(typeof(PrintGuestList)!='undefined'){PrintGuestList.update(json.guest_id,json);}
this.close();this.hideLoader();};var onFailure=function(transport){$(this.contact_id+'_error_msg').update(transport.responseText).show().fade({duration:25});this.hideLoader();};var req=new Ajax.Request(url,{method:'post',parameters:Form.serialize($('contact_data_'+this.contact_id)),onSuccess:onSuccess.bindAsEventListener(this),onFailure:onFailure.bindAsEventListener(this)});this.showLoader();if(event){Event.stop(event);}}});Pingg.GuestListPartyDrawer=Class.create(Pingg.Drawer,{initialize:function($super,party_id){this.email_id=party_id+"_email";this.dom_id=party_id+"_party_drawer";this.party_id=party_id;this.valid_content=false;this.requestContent();$super(this.dom_id);},requestContent:function(){var onFailure=function(transport){this.valid_content=false;this.hideLoader();this.dom_id.update(this.error_template.evaluate({error:transport.responseText}));this.open();};var onSuccess=function(transport){this.valid_content=true;var form=transport.responseText;$(this.dom_id).update(form);$$("#"+this.dom_id+" a.save")[0].observe('click',this.save.bindAsEventListener(this));this.open();};this.showLoader();var req=new Ajax.Request(["/guests/",this.party_id,"/party_members/edit_party"].join(''),{method:'get',onSuccess:onSuccess.bindAsEventListener(this),onFailure:onFailure.bindAsEventListener(this)});},showLoader:function(){if($(this.party_id+'_load_indicator')){$(this.party_id+'_load_indicator').show();}
if($(this.party_id+'_remove_btn')){$(this.party_id+'_remove_btn').hide();}},hideLoader:function(){if($(this.party_id+'_load_indicator')){$(this.party_id+'_load_indicator').hide();}
if($(this.party_id+'_remove_btn')){$(this.party_id+'_remove_btn').show();}},open:function($super){$(this.dom_id).up('td').addClassName('drawer_container');$(this.dom_id).up('tr').previous().addClassName('active_party');if(!this.valid_content){this.requestContent();}
else{this.hideLoader();$$('td.party_size_visible').each(function(cell){var select=cell.down('select');select.hide();cell.down('span').update(select.getValue()).show();cell.removeClassName('party_size_visible');});$$('#'+this.party_id+'_party_size span')[0].hide();$$('#'+this.party_id+'_party_size select')[0].show();$(this.party_id+'_party_size').addClassName('party_size_visible');this.changePartySize();$super();}},changePartySize:function(){var party_size=parseInt($$('#'+this.party_id+"_party_size select")[0].getValue());if(isNaN(party_size)){alert("That is not a number!!!!");return false;}
for(var i=1;i<=8;i++)
{var target=$$('#'+this.dom_id+' input[party_member=true][type=text]')[i-1]
if(i>party_size||party_size==1){target.hide();target.up('li').hide();target.setValue(Pingg.CONSTANTS['party']['default_name'])}
else{target.show();}}},save:function(){var onSuccess=function(transport){var form=transport.responseText;$(this.dom_id).update(form);$$("#"+this.dom_id+" a.save")[0].observe('click',this.save.bindAsEventListener(this));this.createInputHints();this.changePartySize();this.hideLoader();this.close();};this.save_with_call_back(onSuccess);},save_without_close:function(){var onSuccess=function(transport){var form=transport.responseText;$(this.dom_id).update(form);$$("#"+this.dom_id+" a.save")[0].observe('click',this.save.bindAsEventListener(this));this.createInputHints();this.changePartySize();this.hideLoader();};this.save_with_call_back(onSuccess);},save_with_call_back:function(callback){var onFailure=function(){$(this.dom_id).insert(this.error_template.evaluate({error:"There was a problem saving your party.  Please try again."}));this.hideLoader();};$(this.dom_id).down('form').request({onSuccess:callback.bindAsEventListener(this),onFailure:onFailure.bindAsEventListener(this)});this.showLoader();this.markAsParty();this.hideSelect();},markAsParty:function(){var guest=$('name_guest_'+this.party_id)||$('name_event_host_'+this.party_id);guest.writeAttribute('party','true');},markAsGuest:function(){var guest=$('name_guest_'+this.party_id)||$('name_event_host_'+this.party_id);guest.writeAttribute('party','false');},hideSelect:function(){var el=$$('#'+this.party_id+'_party_size')[0];el.down('select').hide();el.down('span').update(el.down('select').getValue()).show();},close:function($super){var hidden=true;$(this.dom_id).up('tr').previous().removeClassName('active_party');$(this.dom_id).up('td').removeClassName('drawer_container');$$('#'+this.party_id+'_party_size span')[0].show();$$('#'+this.party_id+'_party_size select')[0].hide();if($(this.party_id+"_info_drawer")&&!$(this.party_id+'_info_drawer').visible()){$(this.dom_id).up('tr').previous().removeClassName('active_row');}
$super();}});Pingg.InputHint=Class.create({initialize:function(dom_el){this.dom_el=dom_el;this.default_text=dom_el.readAttribute('default');if(this.dom_el.getValue()==""&&this.default_text!=null){this.dom_el.setValue(this.default_text);}
this.dom_el.stopObserving('focus').stopObserving('blur').observe('focus',this.focusHandler.bindAsEventListener(this)).observe('blur',this.blurHandler.bindAsEventListener(this));if(this.dom_el.getValue()==this.default_text||this.dom_el.getValue()==""){this.dom_el.addClassName('grey')}},focusHandler:function(el){if(this.dom_el.getValue()==this.default_text){this.dom_el.setValue("");}
this.dom_el.removeClassName('grey');},reset:function(){if(this.default_text!=null){this.dom_el.setValue(this.default_text);}},blurHandler:function(el){if(this.dom_el.getValue()==this.default_text||this.dom_el.getValue()==""){this.dom_el.setValue(this.default_text);this.dom_el.addClassName('grey');}}});
