
function organize(that,id){if(that.innerHTML.match(/this$/i)){$(that).set('oldhtml',that.innerHTML).set('html','Hide filer');$('o'+id).setStyle('display','');}else{$('o'+id).setStyle('display','none');$(that).set('html',that.get('oldhtml'));}
return false;}
function check_submit(){var x,m;if(x=$('new-label')){if(m=x.value.match(new RegExp(x.getProperty('reserved'),'gi'))){alert('Sorry, '+m+' is a reserved word and may not be used as a label.');return false;}}
return true;}
function toggleAbout(that){if(that.innerHTML=='Read more'){$('moreabout').setStyle('display','');$('hellip').setStyle('display','none');that.innerHTML='Collapse';}else{$('moreabout').setStyle('display','none');$('hellip').setStyle('display','');that.innerHTML='Read more';}
return false;}
function ajaxsearch(that){if($type(that)=='element'){$('currenttab').set('id','');that.id='currenttab';var url=that.href;}else
var url=that;new Request({url:url,onComplete:function(txt){$('items').set('html',txt);}}).post({action:'getlabel'});return false;}
function renameFolder(){var oldname=$('currenttab').firstChild.nodeValue.replace(/ \([\d]+\)$/,'');var newname=prompt('Rename "'+oldname+'" folder to:','').trim();if(newname==''||newname==oldname)
return false;return doFolder(oldname,newname);}
function deleteFolder(){if(confirm("Are you sure you want to delete this folder?")){var oldname=$('currenttab').firstChild.nodeValue.replace(/ \([\d]+\)$/,'');return doFolder(oldname,'');}
return false;}
function doFolder(oldname,newname){new Request({url:window.location.toString().split('#')[0],onComplete:function(){window.location.reload(true);}}).post({action:'doFolder',oldname:oldname,newname:newname});return false;}
function newFolder(){var newname=prompt('Name of your new folder:','');if(!newname)
return false;newname=newname.trim();if(newname=='')
return false;return doFolder('',newname);}
function seeFavorites(that){var fv=$('favoritesbar');if(that.innerHTML.match(/^See all/)){fv.set('oldwidth',fv.offsetWidth-10);fv.set('oldheight',fv.offsetHeight-10);fv.setStyle('width','');fv.setStyle('height','auto');that.innerHTML='Collapse favorites';}else{fv.setStyle('width',fv.get('oldwidth')+'px');fv.setStyle('height',fv.get('oldheight')+'px');that.innerHTML='See all my favorites &raquo;';}
return false;}
function mailThisCollector(that,username){var your_name='';var your_email='';var form_html="\
 <h5><label for='yourname'>Your name:</label> <input type='text' id='yourname' value=\""+your_name+"\" /><br /></h5>\
 <h5><label for='youremail'>Your email:</label> <input type='text' id='youremail' value=\""+your_email+"\" /><br /></h5>\
 <h5><label for='themessage'>Message:</label> <textarea rows='4' cols='30' id='themessage'></textarea></h5>\
 ";var form_buttons="\
 <input type='submit' id='sendButton' value='Send' /> <input type='submit' id='tellFriendCancel' onclick='return closeBox()' value='Cancel' />\
 ";var html="\
 <h3>Email this collector ("+username+")</h3>\
 "+form_html+"\
 <p>*Collectors Weekly will send your email to this collector. We won&rsquo;t use your email address for any other purpose.<br /><br /></p>\
 "+form_buttons;return buildForm(html,that,sendMail.bind(username));}
function tellAFriend(that){var your_name=(x=Cookie.read('your_name'))?x:'';var your_email=(x=Cookie.read('your_email'))?x:'';var form_html="\
 <h5><label for='yourname'>Your name:</label> <input type='text' id='yourname' value=\""+your_name+"\" /><br /></h5>\
 <h5><label for='youremail'>Your email:</label> <input type='text' id='youremail' value=\""+your_email+"\" /><br /></h5>\
 <h5><label for='theiremail'>Your friend's email:</label> <input type='text' id='theiremail' /><br /></h5>\
 <h5><label for='themessage'>Message: (optional)</label> <textarea rows='4' cols='30' id='themessage'></textarea></h5>\
 ";var form_buttons="\
 <input type='submit' id='sendButton' value='Send' /> <input type='submit' id='tellFriendCancel' onclick='return closeBox()' value='Cancel' />\
 ";var html="\
 <h3>Forward this page to a friend*</h3>\
 "+form_html+"\
 <p>*Collectors Weekly will send a short email to your friend with a link to this page. We won&rsquo;t use your email (or your friend&rsquo;s) for any other purpose.<br /><br /></p>\
 "+form_buttons;return buildForm(html,that,sendToFriend);}
function buildForm(html,that,fn){var fb;if(fb=$('friendBox'))
fb.destroy();fb=new Element('form').setProperty('id','friendBox').setStyle('top','-1000px').set('html',html).inject(document.body).addEvent('submit',fn);(function(){$('yourname').focus();}).delay(400);var pos=$(that).getPosition();if(pos.x>575){pos.x=160;pos.y=140;}
new Fx.Morph(fb).start({'top':[pos.y+10,pos.y+30],'left':[pos.x,pos.x+20],'opacity':[0,0.9999]});return false;}
function closeBox(){var fb=$('friendBox');var _top=fb.getStyle('top').replace(/px/,'').toInt();var _left=fb.getStyle('left').replace(/px/,'').toInt();new Fx.Morph(fb).start({'top':[_top,_top+20],'left':[_left,_left+20],'opacity':[0.9999,0]});return false;}
function sendToFriend(e){var y_name=$('yourname').value;var y_email=$('youremail').value;var t_email=$('theiremail').value;var message=$('themessage').value;Cookie.write('your_name',y_name,{path:'/'});Cookie.write('your_email',y_email,{path:'/'});var data={action:'sendToFriend',y_name:y_name,y_email:y_email,t_email:t_email,message:message};data.page=window.location.toString();var title=$('page-title');if(title)
data.page_title=(title.getFirst()||title).innerHTML;else
data.page_title=document.title.split(' | ')[0];new Request({url:'/ajax/tellafriend.php',onComplete:function(html){var fb=$('friendBox').set('html',html);closeBox.delay(1700);}}).post(data);new Event(e).stop();return false;}
function sendMail(e){var y_name=$('yourname').value;var y_email=$('youremail').value;var message=$('themessage').value;var to_username=this;Cookie.write('your_name',y_name,{path:'/'});Cookie.write('your_email',y_email,{path:'/'});var data={action:'mailThisCollector',y_name:y_name,y_email:y_email,message:message,to:to_username};data.page=window.location.toString();var title=$('page-title');if(title)
data.page_title=(title.getFirst()||title).innerHTML;else
data.page_title=document.title.split(' | ')[0];new Request({url:'/ajax/tellafriend.php',onComplete:function(html){var fb=$('friendBox').set('html',html);closeBox.delay(1700);}}).post(data);new Event(e).stop();return false;}