sb.dom.toggle=function(el){el=$(el);if(el.style){el.style.display=(el.getStyle('display')==='none')?'block':'none'}return el};sb.findText=function(obj,handler){this.obj=obj;if(typeof(handler)=='function'){this.handler=handler}this.getAll()};sb.findText.prototype={textNodes:[],getAll:function(){var i,x,allTags=this.obj.getElementsByTagName("*");for(i=0;i<allTags.length;i++){for(x=0;x<allTags[i].childNodes.length;x++){switch(allTags[i].nodeName){case"IMG":case"SCRIPT":case"STYLE":break;default:if(allTags[i].childNodes[x].nodeType==3){if(!allTags[i].childNodes[x].data.match(/^[\n|\s]$/,'')){this.textNodes.push(allTags[i].childNodes[x])}}break}}}this.handleText()},handleText:function(){if(typeof this.handler=='function'){for(var x=0;x<this.textNodes.length;x++){this.handler(this.textNodes[x])}}}};var sj={links:[],ajax:{searchName:new sb.ajax({url:'../data/searchName.php',method:'get',handler:function(r){$('#nameGuess').innerHTML="visit "+r.username+"'s journal";$('#nameGuess').onclick=function(){window.location='../journals/index.php?u='+r.username}}}),latestEntries:new sb.ajax({debug:0,method:'get',url:'../data/latest_entries.php',handler:function(r){$('#latest').innerHTML+=r;$('#load').innerHTML=''}}),usersOnline:new sb.ajax({url:'../data/usersOnline.php',format:'json',handler:function(online){try{var us=(online.peeps.length==1)?'':'s';var gs=(online.guests==1)?'':'s';var bs=(online.bots==1)?'':'s';$('#mem_online').innerHTML=online.peeps.length+' e:peep'+us+' / '+online.guests+' guest'+gs+' / '+online.bots+' bot'+bs;online.peeps.forEach(sj.createMiniPic);var peep_pics=$('#upics_online','img');peep_pics.forEach(function(v){$('#latest a').forEach(function(n){if(n.innerHTML.replace(new RegExp("\\*",'ig'),'').match(new RegExp(v.title,'ig'))){n.className="highlight"}else{n.className=''}});if(!online.peeps.inArray(v.title)){sb.dom.remove(v)}})}catch(e){}}})},getUsersOnline:function(){sj.ajax.usersOnline.fetch();window.setTimeout(function(){},60000)},resetLatestEntries:function(){$('#latest').innerHTML='';sj.ajax.latestEntries.data={s:0,l:12};sj.ajax.latestEntries.fetch();return false},showMoreEntries:function(){$('#load').innerHTML='<blink>loading...</blink>';sj.ajax.latestEntries.data={s:$('#latest a').length(),l:20};sj.ajax.latestEntries.fetch('../data/latest_entries.php')},hiliteText:function(str,obj){function markMe(str,obj){if(str){var str_match=new RegExp("("+str+")","ig");obj.innerHTML=obj.innerHTML.replace(str_match,'<u class="highlight">'+str+'</u>')}}function changeText(node){var sp=new sb.element({tag:'span'});sp.appendChild(txt(node.data));var terms=$_GET['s'].split(' ');terms.forEach(function(term){markMe(term,sp)});sp.replace(node);sp=null}var myNodes=new sb.findText($('#journals'),changeText)},openWindow:{app:function(){window.open(this.url,'_blank');return false},blank:function(){window.open(this.href,'_blank');return false},comment_link:function(){var href=(typeof this.src=='undefined')?this.href:this.parentNode.href;win(href,515,360);return false},cat_link:function(){win(this.href,515,800);return false},send_data:function(){win(this.alt,515,360);return false},pmobl:function(){win('../help/index.php?q=pmobl',840,570);return false},print:function(){win('../journals/print.php?'+this.parentNode.title,600,800);return false},post_it:function(){win(this.href,515,200,'message');return false},profile:function(){win(this.href,600,650,'profile','yes');return false},overview:function(){win(this.href,515,600,'overview','yes');return false},jdots:function(){win(this.href,890,600,'jdots','yes');return false},editFav:function(){win(this.href,515,400,'editFav','yes');return false},editLinks:function(){win(this.href,600,500,'editLinks','yes');return false},show_all:function(){win(this.href,450,600,'show_all','yes');return false}},search:function(){if(this.q.value=="search..."||this.q.value=="search user..."){alert("You must enter a search term into the box!");return false}var search=win('../search/index.php?u='+this.u.value+'&q='+this.q.value,550,515);return false},scriptSearch:function(){var searchMe=$('#searchMe');searchMe.q.onfocus=function(){if(this.value=='search user...'){this.value=''}this.select()};searchMe.onsubmit=sj.search},userInfoLinks:function(){if($('#messageMe')){$('#messageMe').onclick=sj.openWindow.post_it}$('#show_all').onclick=sj.openWindow.show_all;$('#profile').onclick=sj.openWindow.profile;$('#overview').onclick=sj.openWindow.overview;$('#jdots').onclick=sj.openWindow.jdots;if($('#editFav')){$('#editFav').onclick=sj.openWindow.editFav;$('#editLinks').onclick=sj.openWindow.editLinks}},setLinks:function(){if($('#user_data')){$('#user_data a').forEach(function(v){if(v.className=='cat_link'){var size=(v.title>17)?17:v.title;size=(size<9)?9:size;v.title=v.title+' entries for this category';v.style.fontSize=size+'px'}});sb.events.add('#user_data','click',function(e){var target=e.target;if(target.nodeName.match(/^img$/i)){switch(target.className){case"send_data":sj.openWindow.send_data.call(target);e.preventDefault();break}}})}sb.events.add('body','click',function(e){var target=e.target;if(target.nodeName=='IMG'&&typeof target.parentNode!='undefined'){target=target.parentNode;switch(target.className){case"blank":sj.openWindow.blank.call(target);sb.events.stopAndPrevent(e);break}}else if(target.nodeName=='A'){switch(target.className){case"e_link":case"blank":sj.openWindow.blank.call(target);sb.events.stopAndPrevent(e);break;case"cat_link":sj.openWindow.cat_link.call(target);sb.events.stopAndPrevent(e);break;case"addComment":sj.openWindow.comment_link.call(target);sb.events.stopAndPrevent(e);break}}})},nextPrevLinks:function(){var entries=$('#journals div');var entries_id=[];entries.forEach(function(v){if(v.title!==''&&v.className=='entry'){entries_id.push(v.title)}});entries_id.sort();var prev10=new sb.element({tag:'img',src:'../cache/'+theme+'/prev_10.png',onclick:function(){window.location='index.php?u='+u+'&n=prev&id='+entries_id.shift()}});prev10.style.cursor='pointer';sb.ie6.pngFix(prev10);prev10.appendToTop('#journal_text');var next10=new sb.element({tag:'img',src:'../cache/'+theme+'/next_10.png',onclick:function(){window.location='index.php?u='+u+'&n=next&id='+entries_id.pop()}});next10.style.cursor='pointer';sb.ie6.pngFix(next10);next10.appendAfter(prev10);$('#journal_text').appendChild(prev10.cloneNode(false)).onclick=prev10.onclick;$('#journal_text').appendChild(next10.cloneNode(false)).onclick=next10.onclick;prev10=next10=sm=null},journalIcons:function(){sb.events.add('#journals','click',function(e){e.preventDefault();var target=e.target;if(target.nodeName.match(/img/i)){switch(target.alt){case"pmobl":sj.openWindow.pmobl.call(target);break;case"print":sj.openWindow.print.call(target);break;case"deleteMe":if(confirm('Permanently delete this journal?')){window.location='../update/blog_delete.php?'+target.parentNode.title}break;case"undraft":window.location='../update/show_hide.php?pub=y&'+target.parentNode.title;break;case"draft":window.location='../update/show_hide.php?pub=n&'+target.parentNode.title;break;case"update":window.location='../journals/index.php?c=tu&'+target.parentNode.title;break;case"addComment":sj.openWindow.comment_link.call(target);break;case"link":sj.openWindow.blank.call(target.parentNode);break}e.preventDefault()}});var jimages=$('#journals img');jimages.forEach(function(v){switch(v.alt){case"pmobl":v.style.cursor='pointer';v.title='This mobile journal was published with pmobl.  Learn More!';break;case"print":v.style.cursor='pointer';v.title='print version of this journal!';break;case"deleteMe":v.style.cursor='pointer';v.title='Permanently delete this journal!';break;case"undraft":v.style.cursor='pointer';v.title='Take this journal out of draft mode!';break;case"draft":v.style.cursor='pointer';v.title='Put this journal in draft mode!';break;case"update":v.style.cursor='pointer';v.title='Update this journal entry!';break;case"addComment":v.style.cursor='pointer';v.title='comment on this journal!';break}})},addSoundToggle:function(){function switch_sound(){if(sound_enable=='n'){sound_enable='y';sb.sound.muted=0;sb.cookies.set('sound_enable','y');this.checked=false}else{sound_enable='n';sb.sound.muted=1;sb.sound.muteAll();sb.cookies.set('sound_enable','n');this.checked=true}}var sound_toggle=$('#sound_toggle');sound_toggle.style.cursor="pointer";if(sb.cookies.get('sound_enable')=='n'||sound_enable=="n"){sound_enable='n';sb.sound.muted=1;$('#sound_toggle').checked=true}else{sound_enable='y';sb.sound.muted=0;$('#sound_toggle').checked=false;sb.cookies.set('sound_enable','y')}$('#sound_toggle').onclick=switch_sound},jumpMenu:function(){var who=$('#who');who.jump.onkeyup=function(){var jump=this.value;if(jump.length>3){sj.ajax.searchName.data="name="+jump.substr(0,jump.length-1);sj.ajax.searchName.fetch()}};who.jump.onfocus=function(){if(this.value=='username'){this.value='';this.select()}};who.onsubmit=function(){var jump=this.jump.value;if(jump=="username"||jump===''){alert("Please enter a username");return false}jump=jump.split(",");var location='index.php?u='+jump[0];if(jump.length>1){jump_date=jump[1].split("/");if(jump_date.length==2){location=location+'&m='+jump_date[0]+'&y='+jump_date[1]}else if(jump_date.length==3){location=location+'&m='+jump_date[0]+'&d='+jump_date[1]+'&y='+jump_date[2]}else{location=location+'&id='+jump[1]}}window.location.href=location;return false}},createMiniPic:function(user){if(!$('#mp_'+user)){var im=new sb.element({tag:'img',id:'mp_'+user,src:'../data/userpic.php?u='+user,title:user,alt:user,onclick:function(){window.location='../journals/index.php?u='+user}});im.styles({border:'1px solid black',cursor:'pointer'});im.appendTo('#upics_online');im=null}return},addCommentPics:function(){$('#parent .comments_pic').nodes.forEach(function(v){v.style.margin='0 0 5px 5px';v.style.cursor='pointer';v.title='visit '+v.alt+"'s journal";v.onclick=function(){window.location='../journals/index.php?u='+v.alt}})},addUserSound:function(){try{if(user_sound!=''){var usound_lnk=new sb.element({tag:'button',innerHTML:'load user sound',onclick:function(){this.remove();var myMp3=new sb.swf({src:"../flash/usoundPlayer.swf?file="+user_sound,width:125,height:45,bgColor:"#607913"});myMp3.embed('#usersound_player')}});usound_lnk.styles({marginTop:'5px'});usound_lnk.appendTo('#usersound_player')}}catch(e){}},displayNotifications:function(){if(notify!==''&&!sb.cookies.get('notified')){var noteBox=new sb.element({tag:'div',id:'notify'});noteBox.appendTo('#parent');noteBox.mv(100,100,999);var noteClose=new sb.element({tag:'span',innerHTML:'(close)',onclick:function(){sb.cookies.set('notified','n');this.parentNode.remove()}});noteClose.style.cursor='pointer';noteBox.appendChild(noteClose);var noteP=new sb.element({tag:'p'});noteP.innerHTML=notify;noteBox.appendChild(noteP)}},installed_themes:[],onload:[],init:function(){this.setLinks();this.addSoundToggle();this.jumpMenu();if($('#show_more')){$('#show_more').onclick=sj.showMoreEntries}if($('#reset_latest')){$('#reset_latest').onclick=sj.resetLatestEntries}this.getUsersOnline();this.addCommentPics();if($('#journals')){this.addUserSound();if($_GET['s']){this.hiliteText()}this.journalIcons();this.nextPrevLinks();this.userInfoLinks();this.scriptSearch();if($_GET['co']==1){sb.dom.toggle($('#comments_'+$_GET['id']))}if(sb.browser.agent=='ie'&&sb.browser.version==6){sb.ie6.pngFix('#journal')}if($('#parent').offsetHeight<$('#journal_text').offsetHeight){$('#parent').style.height=($('#journal_text').offsetHeight+100)+'px'}if($('#parent').offsetHeight<$('#user_data').offsetHeight){$('#parent').style.height=($('#user_data').offsetHeight+100)+'px'}}this.onload.forEach(function(v){if(typeof v=='function'){v()}});this.displayNotifications()}};function unix_time(){return Date.parse(new Date())/1000}if(typeof win=='undefined'){win=sb.browser.win}var talkbox={match_url:new RegExp("(\s|\n|)([a-z]+?):\/\/([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)","i"),map:new RegExp("map (\\d{1,5}) (\\w{1,100}) (\\w{1,100})?","ig"),ymap:new RegExp("ymap (\\d{1,5}) (\\w{1,100}) (\\w{1,100})?","ig"),setDomReferences:function(){this.chatterbox=$('#talkbox_chatterbox');this.chatForm=$('#talkbox_chat_box');this.chatter=$('#talkbox_chatter');this.refresher=''},refreshChat:function(refr){talkbox.ajax.getChatter.data='cid='+latest_cid;talkbox.ajax.getChatter.fetch();if(refr=='y'){this.refresher=setInterval(function(){talkbox.refreshChat()},TALKBOX_REFRESH);return this.refresher}},checkSounds:function(nl){if(nl.match('estrip')){s='../sounds/estrip.mp3'}else if(nl.match('bush')){s='../sounds/warInIraq.mp3'}else if(nl.match('vomit')){s='../sounds/vomit.mp3'}else if(nl.match('omg')){s='../sounds/gasp.mp3'}else if(nl.match('sick')){s='../sounds/sick.mp3'}else if(nl.match('sad')){s='../sounds/cry.mp3'}else if(nl.match('kiss')){s='../sounds/kiss.mp3'}else if(nl.match('doorbell')){s='../sounds/doorbell.mp3'}else if(nl.match('children')){s='../sounds/children.mp3'}else if(nl.match('stuck')){s='../sounds/stuck.mp3'}else if(nl.match('drugs')){s='../sounds/drugs.mp3'}else if(nl.match('alert')){s='../sounds/alert.mp3'}else{s='../sounds/boing.mp3'}try{var play=new sb.sound({url:s}).play()}catch(e){}},ajax:{postChat:new sb.ajax({debug:0,url:'../data/chat_post.php',method:'post',handler:function(result){talkbox.chatter.value='';talkbox.loading.remove();if(result!='n'){var line=document.createElement("li");line.innerHTML=result;talkbox.chatterbox.insertBefore(line,talkbox.chatterbox.firstChild)}clearTimeout(talkbox.refresher);talkbox.refreshChat('y')}}),getChatter:new sb.ajax({debug:0,url:'../data/chat_get.php',method:'get',handler:function(r){eval(r);if(typeof(lines)!='undefined'){var num_lines=lines.l.length;if(num_lines!==0){latest_cid=lines.l[0].c;for(var x=num_lines-1;x>-1;x--){var new_line=document.createElement('li');var chat_name=document.createElement('b');var chat_name_txt=document.createTextNode(lines.l[x].u+' '+lines.l[x].t.replace(/\\/,'\\')+': ');chat_name.appendChild(chat_name_txt);new_line.appendChild(chat_name);if(lines.l[x].src!==undefined){new_line.appendChild(document.createElement('br'));var new_line_img_link=document.createElement('a');new_line_img_link.href=lines.l[x].orig;new_line_img_link.onclick=function(){win(this.href,750,500,'image','yes');return false};var new_line_img=document.createElement('img');new_line_img.src=lines.l[x].src;new_line_img_link.appendChild(new_line_img);new_line.appendChild(new_line_img_link)}var new_line_txt=document.createTextNode(lines.l[x].m);new_line.appendChild(new_line_txt);talkbox.chatterbox.insertBefore(new_line,talkbox.chatterbox.firstChild);if(PARSE_CHAT===true&&lines.l[x].src===undefined){new_line.innerHTML=talkbox.parseChat(new_line)}if(TALKBOX_SOUND=='y'){try{talkbox.checkSounds(lines.l[x].m)}catch(e){}}}}}}})},loading:new sb.element({tag:'span',innerHTML:'loading...'}),setSubmit:function(){this.chatForm.onsubmit=function(){talkbox.loading.appendAfter('#talkbox_chat_box');talkbox.ajax.postChat.data={chatter:this.chatter.value};talkbox.ajax.postChat.fetch();return false}},parsePreloadedChat:function(){var old_lines=talkbox.chatterbox.getElementsByTagName("li");for(var l=0;l<old_lines.length;l++){old_lines[l].innerHTML=talkbox.parseChat(old_lines[l])}},parseChat:function(line){var lineData=line.innerHTML;var orig_txt=lineData;var nam=lineData.match(/(\<b\>(.*?)<\/b\>)/i);if(!lineData.match(/\.gif|\.jpg|\.png/i)&&lineData.match(talkbox.match_url)){lineData=lineData.replace("AMP","&");lineData=lineData.replace(talkbox.match_url,"<a href=\"$2://$3\" target=\"_blank\">::link::</a>")}else if(lineData.match(/\.gif|\.jpg|\.png/i)){var titleDat=lineData.match(/alt=\"(.*?)\"/);var source=lineData.match(/src="(.*?)"/i);nam=lineData.match(/(\<b\>(.*?)<\/b\>)/i);if(titleDat===null){titleDat=lineData.match(/alt=(.*?) /)}if(titleDat!==null){lineData='<br />'+nam[1]+'<br /><a href="'+titleDat[1]+'" target="_blank" ><img src="'+source[1]+'" alt="thumb" /></a>'}}else if(lineData.match(talkbox.ymap)){var mymap=lineData.match(talkbox.ymap);mymap=mymap.join("\+");mymap=mymap.replace(/ymap /,"");lineData='<a style="font-size:1.5em;" href="http://maps.yahoo.com/beta/#maxp=search&q1='+mymap+'+'+'buffalo,+ny" target="_blank">::VIEW A YMAP '+mymap+'::</a>'}else if(lineData.match(talkbox.map)){var mymap=lineData.match(talkbox.map);mymap=mymap.join("\+");mymap=mymap.replace(/map /,"");lineData='<a style="font-size:1.5em;" href="http://www.google.com/maps?f=q&t=h&q='+mymap+'+'+'buffalo,+ny" target="_blank">::VIEW A MAP '+mymap+'::</a>'}else{lineData=lineData.replace(/lol/,"hahaha");lineData=lineData.replace("AMP","&");if(typeof sj.word_filter!='undefined'){lineData=sj.word_filter(lineData)}}if(orig_txt!=lineData){return'<br />'+lineData}else{return lineData}},playStartSound:function(){if(typeof startSnd!='undefined'){if(startSnd!==''){try{var snd=new sb.sound({url:startSnd});snd.play()}catch(e){}}}},init:function(){this.setDomReferences();this.setSubmit();this.parsePreloadedChat();this.refresher=talkbox.refreshChat();this.playStartSound()}};