with(cafemomjs){events.onReady(function(){var carouselDiv=dom.getEl('homeCarousel'),carousel;if(carouselDiv){carousel={slideWidth:880,slideAnimate:88,numSlides:Math.ceil(dom.getTags('li',carouselDiv).length/5),currentSlide:1,currentPos:0,slideContainer:dom.getTags('ul',carouselDiv)[0],prevControl:dom.getByClass('previous',carouselDiv)[0],nextControl:dom.getByClass('next',carouselDiv)[0],goPrev:function(){if(!this.interval&&this.currentSlide>1){--this.currentSlide;this.moveSlides();}},goNext:function(){if(!this.interval&&this.currentSlide<this.numSlides){++this.currentSlide
this.moveSlides();}},moveSlides:function(){if(this.currentSlide==1){dom.addClass(this.prevControl,'disabled');}
else{dom.removeClass(this.prevControl,'disabled');}
if(this.currentSlide==this.numSlides){dom.addClass(this.nextControl,'disabled');}
else{dom.removeClass(this.nextControl,'disabled');}
var endPos=0-(this.currentSlide-1)*this.slideWidth,fwd=endPos>this.currentPos,i=0;this.interval=setInterval(function(){i++;carousel.currentPos=fwd?carousel.currentPos+carousel.slideAnimate:carousel.currentPos-carousel.slideAnimate;dom.css(carousel.slideContainer,'left',carousel.currentPos+'px');if(carousel.currentPos==endPos){clearInterval(carousel.interval);carousel.interval=null;}},80);}};events.listen(carouselDiv,'click',function(ev){if(ev.target==carousel.prevControl&&carousel.currentSlide>1){carousel.goPrev();}
else if(ev.target==carousel.nextControl&&carousel.currentSlide<carousel.numSlides){carousel.goNext();}});}
var stirEmailField=dom.getEl('stir-newsletter-email');if(stirEmailField){events.listen(stirEmailField,'click',function(ev){ev=events.fixEvent(ev);if(stirEmailField.value=='enter your email address'){stirEmailField.value='';}});var stirFormSubmit=dom.getEl('stir-newsletter-submit');var newsletterError=dom.getEl('stir-newsletter-error');events.listen(stirFormSubmit,'click',function(ev){ev=events.fixEvent(ev);ev.stopPropagation();ev.preventDefault();var email=stirEmailField.value;if(email=='enter your email address'||email==''){dom.css(newsletterError,'display','block');return false;}else{var newsletterForm=dom.getEl('stir-newsletter-form');var newsletterSuccess=dom.getEl('stir-newsletter-success');dom.attr(stirFormSubmit,'disabled','disabled');ajax.post('/thestir/actions/newsletter_subscribe.php',function(data){if(data==-1){dom.attr(stirFormSubmit,'disabled',null);dom.css(newsletterSuccess,'display','none');dom.css(newsletterError,'display','block');}
else{dom.css(newsletterError,'display','none');dom.css(newsletterForm,'display','none');dom.css(newsletterSuccess,'display','block');}},{'submit':'ajax','email':email});return false;}});}});};(function(){with(cafemomjs){var bubbles={postNew:function(bubbleData,list,callback)
{ajax.post('/bubbles/actions/add_thought_bubble.php',function(res){res=ajax.parseJSON(res);if(res.success){bubbles.addNew(res.html,list);}
if(typeof callback=='function'){callback(res);}},bubbleData);},addNew:function(bubble,list)
{if(typeof bubble=='string')
bubble=dom.fromHTML(bubble);dom.insertBefore(bubble,list.firstChild);utils.fixPie(bubble);},postComment:function(commentData,list,callback)
{var tmpId=bubbles.addTmpComment(commentData,list);ajax.post('/bubbles/actions/add_comment.php',function(res){res=ajax.parseJSON(res);if(res.success){bubbles.addComment(res.html,list,tmpId);}
if(typeof callback=='function'){callback(res);}},commentData);},addTmpComment:function(commentData,list)
{var now=new Date(),tmpId='_tb_tmp_comment_'+now.getTime(),hours=now.getHours(),mins=now.getMinutes(),period='AM',fmtTime,node,tpl='<li class="bubble-comment rounded clearfix last tmp" id="TMPID"><a class="avatar" href="/home/SCREENNAME"><img alt="SCREENNAME" src="HOST/images/user/avatars/USERID_sm.jpg?1"></a><div class="comment-container"><span class="comment-content"><a href="/home/SCREENNAME">SCREENNAME</a>COPY</span><span class="comment-info"><span class="comment-posted">Today at TIME</span></span></div></li>';if(hours>11){period='PM';hours=hours%12;}
if(hours==0){hours=12;}
if(mins<10){mins='0'+mins;}
fmtTime=hours+':'+mins+' '+period;tpl=tpl.replace('TMPID',tmpId).replaceAll('SCREENNAME',SCREEN_NAME).replaceAll('USERID',USER_ID).replace('HOST',USER_IMAGE_HOST).replace('COPY',commentData['comment_copy'].replace(/<[^>]*>/,'')).replace('TIME',fmtTime);node=dom.fromHTML(tpl);dom.addEl(node,list);return tmpId;},addComment:function(comment,list,tmpId)
{if(typeof comment=='string')
comment=dom.fromHTML(comment);var tmpComment=dom.getEl(tmpId)
if(tmpComment){dom.replace(tmpComment,comment);}
else{dom.addEl(comment,list);}
if(list.lastChild){var lis=dom.getTags('li',list),nextToLast=lis.length-1;if(nextToLast>-1){dom.removeClass(lis[nextToLast],'last');}}},loadAllComments:function(bubbleId,callback)
{var commentList=dom.getEl('bubble-comments-'+bubbleId);if(commentList){ajax.get('/bubbles/actions/load_comments.php?status_update_id='+bubbleId,function(res){res=ajax.parseJSON(res);if(res.success){var newList=dom.fromHTML(res.html)
dom.replace(commentList,newList);utils.fixPie(commentList);}
if(typeof callback=='function'){callback(res);}});}},remove:function(bubbleId,callback)
{ajax.get('/bubbles/actions/delete_thought_bubble.php?status_update_id='+bubbleId,function(res){res=ajax.parseJSON(res);var deletedEl=null;if(res.success){deletedEl=dom.removeEl(dom.getEl('thought-bubble-'+bubbleId));}
if(typeof callback=='function'){callback(res,deletedEl);}});},removeComment:function(bubbleId,commentId,callback)
{ajax.get('/bubbles/actions/delete_comment.php?status_update_id='+bubbleId+'&object_comment_id='+commentId,function(res){res=ajax.parseJSON(res);var deletedEl=null,lis;if(res.success){deletedEl=dom.removeEl(dom.getEl('bubble-comment-'+commentId));lis=dom.getTags('li',dom.getEl('bubble-comments-'+bubbleId));if(lis.length){dom.addClass(lis[lis.length-1],'last');}}
if(typeof callback=='function'){callback(res,deletedEl);}});}};}
cafemomjs.bubbles=bubbles;})();with(cafemomjs){events.onReady(function(){var bubbleForm=dom.getEl('bubble-form'),bubbleContainer=dom.getEl('body');if(bubbleForm){var copyField=bubbleForm.elements['bubble[copy]'],mediaField=bubbleForm.elements['bubble[media]'],mediaVerifyField=bubbleForm.elements['bubble[media_verify]'],urlField=bubbleForm.elements['media_url'],linkForm=dom.getEl('bubble-link-form'),mediaPreview=dom.getEl('bubble-media-preview'),extraButtons=dom.getEl('bubble-extras'),uploadForm=dom.getEl('bubble-upload-form'),cancelLink=dom.getEl('cancel-link'),cancelLink2=dom.getEl('cancel-link2'),cancelPhoto=dom.getEl('cancel-photo'),addLink=dom.getEl('bubble-add-link'),addPhoto=dom.getEl('bubble-add-photo');bubbles.bubbleForm=bubbleForm;bubbleForm.resetAll=function(err){if(err)
dialog.alert(err);bubbleForm.reset();bubbleForm.resetPhoto();bubbleForm.resetMedia();dom.removeClass(copyField,'expanded');if(!supports.placeholders){placeholders.toggle(copyField,'on');}};bubbleForm.resetPhoto=function(err){if(err)
dialog.alert(err);mediaField.value=mediaVerifyField.value='';dom.addClass(uploadForm,'hidden');dom.removeClass(extraButtons,'hidden');dom.removeClass(mediaPreview,'loading');dom.html(mediaPreview,'');dom.addClass(cancelPhoto,'hidden');bubbleForm.disableEnableButtons('enable');};bubbleForm.resetMedia=function(err){if(err)
dialog.alert(err);mediaField.value=mediaVerifyField.value='';urlField.value='';dom.removeClass(linkForm,'added');dom.addClass(linkForm,'hidden');dom.removeClass(extraButtons,'hidden');dom.removeClass(mediaPreview,'loading');dom.html(mediaPreview,'');dom.addClass(cancelLink,'hidden');dom.addClass(cancelLink2,'hidden');dom.removeClass(copyField,'expanded');bubbleForm.disableEnableButtons('enable');};bubbleForm.setPhoto=function(media,verify){mediaField.value=JSON.stringify(media);mediaVerifyField.value=verify;dom.html(mediaPreview,'<div class="bubble-media"><img src="'+media.thumbnail+'" class="thumbnail"/></div>');dom.addClass(uploadForm,'hidden');dom.removeClass(mediaPreview,'loading');dom.removeClass(cancelPhoto,'hidden');bubbleForm.disableEnableButtons();};bubbleForm.disableEnableButtons=function(){var linksrc=addLink.src;arguments[0]=="enable"?linksrc=linksrc.replace(/bubble_btn_link_disable.png/,"bubble_btn_link.png"):linksrc=linksrc.replace(/bubble_btn_link.png/,"bubble_btn_link_disable.png");addLink.src=linksrc;arguments[0]=="enable"?addLink.disabled='':addLink.disabled='disabled';linksrc=addPhoto.src;arguments[0]=="enable"?linksrc=linksrc.replace(/bubble_btn_photo_disable.png/,"bubble_btn_photo.png"):linksrc=linksrc.replace(/bubble_btn_photo.png/,"bubble_btn_photo_disable.png");addPhoto.src=linksrc;arguments[0]=="enable"?addPhoto.disabled='':addPhoto.disabled='disabled';};dom.removeClass(extraButtons,'hidden');events.listen(bubbleForm,'keypress',function(ev){ev=events.fixEvent(ev);if(dom.attr(ev.target,'name')=='bubble[copy]'){ev.stopPropagation();if(ev.which&&ev.target.value.length==420){ev.preventDefault();}}});events.listen(bubbleForm,'click',function(ev){ev=events.fixEvent(ev);var targetName=dom.attr(ev.target,'name');switch(targetName){case"addPhoto":if(ev.target.disabled){return;}
window.frames['bubble-upload-frame'].uploadPhoto(function(loading){if(loading)
dom.addClass(mediaPreview,'loading');else
dialog.alert('You may only upload images.');},supports.fileInputClick);if(!supports.fileInputClick){dom.removeClass(uploadForm,'hidden');bubbleForm.disableEnableButtons();}
break;case"addLink":if(ev.target.disabled){return;}
bubbleForm.disableEnableButtons();dom.removeClass(linkForm,'hidden');dom.removeClass(cancelLink,'hidden');break;case"cancelUploadForm":case"cancelPhoto":if(mediaField.value.length)
dialog.confirm('Are you sure you want to remove this photo from your Thought Bubble?',function(c){if(c){bubbleForm.resetPhoto();}});else
bubbleForm.resetPhoto();break;case"cancelLink":if(mediaField.value.length)
dialog.confirm('Are you sure you want to remove this link from your Thought Bubble?',function(c){if(c){bubbleForm.resetMedia();}});else
bubbleForm.resetMedia();break;case"bubble[copy]":dom.addClass(ev.target,'expanded');break;case"postAgain":ev.stopPropagation();ev.preventDefault();dom.removeClass(bubbleForm,'posted');break;case"getMedia":ev.stopPropagation();ev.preventDefault();if(urlField.value.length){dom.addClass(mediaPreview,'loading');ajax.get('/bubbles/actions/get_media.php?url='+urlField.value,function(res){res=ajax.parseJSON(res);if(res.success){mediaField.value=JSON.stringify(res.media);mediaVerifyField.value=res.media_verify;dom.addClass(linkForm,'added');dom.html(mediaPreview,res.html);}
else{dialog.alert(res.message);}
dom.removeClass(mediaPreview,'loading');dom.addClass(cancelLink,'hidden');dom.removeClass(cancelLink2,'hidden');});}
break;case"shareThought":ev.stopPropagation();ev.preventDefault();if(!supports.placeholders){placeholders.toggle(copyField,'off');}
if(copyField.value.length||mediaField.value.length){bubbles.postNew({'bubble[copy]':copyField.value,'bubble[media]':mediaField.value,'bubble[media_verify]':mediaVerifyField.value,ajax:true,'form_location':bubbleForm.elements['form_location'].value,'verify_key':bubbleForm.elements['verify_key'].value},dom.getEl('bubble-list'),function(res){if(res.success){if(dom.getEl('no-bubbles')){dom.addClass(dom.getEl('no-bubbles'),'hidden');}
bubbleForm.resetAll();dom.addClass(bubbleForm,'posted');}
else{dialog.alert('Your thought bubble could not be posted.');}});}
else{}
if(!supports.placeholders){placeholders.toggle(copyField,'on');}
break;}});}
events.listen(bubbleContainer,'click',function(ev){ev=events.fixEvent(ev);var targetName=dom.attr(ev.target,'name')||'';if(targetName.substring(0,18)=='view-all-comments-'){bubbles.loadAllComments(targetName.substring(18),function(res){if(res.success){}
else if(res.error){dialog.alert(res.message);}});return;}
else if(targetName.substring(0,18)=='show-comment-form-'){var bubbleId=targetName.substring(18),bubble=dom.getEl('thought-bubble-'+bubbleId),commentForm=dom.getEl('bubble-comment-form-'+bubbleId);dom.addClass(bubble,'show-comment-form');utils.fixPie(commentForm);if(!supports.placeholders){placeholders.enable(commentForm.elements['comment_copy']);}
commentForm.elements['bubble-comment-add'].focus();return;}
else if(targetName.substring(0,15)=='comment-cancel-'){var bubbleId=targetName.substring(15),bubble=dom.getEl('thought-bubble-'+bubbleId);dom.removeClass(bubble,'show-comment-form');}
else if(targetName.substring(0,14)=='delete-bubble-'){dialog.confirm('Are you sure you want to delete your Thought Bubble?',function(c){if(c){var bubbleId=targetName.substring(14);bubbles.remove(bubbleId,function(res){if(res.success){}
else if(res.error){dialog.alert(res.message);}});}});}
else if(targetName.substring(0,15)=='delete-comment-'){dialog.confirm('Are you sure you want to delete your comment?',function(c){if(c){var ids=targetName.substring(15).split('-');bubbles.removeComment(ids[0],ids[1],function(res){if(res.success){}
else if(res.error){dialog.alert(res.message);}});}});}
else if(dom.hasClass(ev.target,'has-fullsize')){var fullsize=dom.attr(ev.target,'data-fullsize');if(fullsize){modal.lightboxImg(fullsize);}}
switch(targetName){case'bubble-comment-add':var commentForm=ev.target.form,commentField=commentForm.elements['comment_copy'],bubbleId=commentForm.elements['status_update_id'].value,commentList=dom.getEl('bubble-comments-'+bubbleId);if(!commentList){commentList=dom.makeEl('ul','bubble-comments',null,{id:'bubble-comments-'+bubbleId});dom.insertBefore(commentList,commentForm);}
if(!supports.placeholders){placeholders.toggle(commentField,'off');}
if(commentField.value.length){bubbles.postComment({'comment_copy':commentField.value,'status_update_id':bubbleId,'verify_key':commentForm.elements['verify_key'].value,ajax:true},commentList,function(res){if(res.success){}
else{dialog.alert('Your comment could not be posted.');}});commentForm.reset();}
if(!supports.placeholders){placeholders.toggle(commentField,'on');}
break;}});var mainDiv=dom.getEl('body');if(mainDiv){events.listen(mainDiv,'mouseover',function(ev){ev=events.fixEvent(ev);if(dom.hasClass(ev.target,'hoverBubbleIcon')){dom.addClass(ev.target.parentNode,'overHoverBubble');}});events.listen(mainDiv,'mouseout',function(ev){ev=events.fixEvent(ev);if(dom.hasClass(ev.target,'hoverBubble')){dom.removeClass(ev.target.parentNode,'overHoverBubble');}});}});}
