function sendCompliment(recipientId,assocObjId,assocRefType)
{var message=escape(trim(document.getElementById('compliment_message').value));if(message.length>=3)
{var complimentSelections=document.getElementsByName('compliment_type');var complimentType=-1;for(var j=0;j<complimentSelections.length;++j){if(complimentSelections[j].checked){complimentType=complimentSelections[j].value;break;}}
if(complimentType>-1){var url="/SendCompliment.do";var pars="recipientId="+recipientId;pars+="&complimentType="+complimentType+"&assocObjId="+assocObjId+"&assocRefType="+assocRefType+"&message="+message;ajaxUpdateDiv(url,pars,'get','compliment_status');hide('compliment_content');showInline('compliment_status');}}
else{alert('Please enter at least 3 characters in the compliment message.');}}
function showSelectedCompliments(complimentsToShow,complimentsToSelectDefault){var compliments=complimentsToShow.split(',');var complimentSelections=document.getElementsByName('compliment_type');for(var j=0;j<complimentSelections.length;++j){var bFound=false;for(var i=0;i<compliments.length;++i){if(complimentSelections[j].value==compliments[i]){bFound=true;break;}}
if(bFound){showBlock('compliment_selection_'+complimentSelections[j].value);if(complimentSelections[j].value==complimentsToSelectDefault){complimentSelections[j].checked=true;}}
else{document.getElementById('compliment_'+complimentSelections[j].value).disabled=true;hide('compliment_enabled_'+complimentSelections[j].value);showInline('compliment_disabled_'+complimentSelections[j].value);}}}
function showComplimentsPopup(recipientId,recipientNick,complimentsToShow,complimentsToSelectDefault,assocObjId,assocRefType){var win=new Window('compliments_win_'+Math.random(),{className:"askv_cube",title:"Send Compliment",width:430,height:300,minimizable:false,maximizable:false,resizable:true,url:"/SendCompliment.do?recipientId="+recipientId+"&recipientNick="+recipientNick+"&complimentsToShow="+complimentsToShow+"&complimentsToSelectDefault="+complimentsToSelectDefault+"&assocObjId="+assocObjId+"&assocRefType="+assocRefType,hideEffectOptions:{duration:0.5},showEffectOptions:{duration:0.5}});win.setDestroyOnClose();win.toFront();win.showCenter(true);}
function showComplimentSignInMessage(uniqueId){showBlock('compliment_signin_'+uniqueId);}
function showComplimentVerifyMessage(uniqueId){showBlock('compliment_verify_account_'+uniqueId);}
function setupTagWatchSection(){showInline('watch_status_button');}
function modifyTagWatchListTop(curUrl,filterTags,tagFilterId,watchStatus)
{if(isUserLoggedIn()){var url="/ajax/TagWatchList.do";var pars="action=modify&filterTags="+filterTags+"&tagFilterId="+tagFilterId+"&status="+watchStatus;ajaxLoad(url,pars,'post','watch_status_top','tagwatch_ajax_progress_div_top');}
else{signIn(curUrl,'tagwatch');}}
function showEditTopicsWindow(type,tagId){if(!isUserLoggedIn()){alert('Please sign in first');return;}
var windowTitle;if(type=='interest'){windowTitle='Edit Topics of Interest';}
else if(type=='linked'){windowTitle='Edit Included Topics';}
else{alert('unknown edit window type: '+type);}
var commentUrl='/EditTagLinksWindow.do?type='+type+'&tagId='+tagId;var win=new Window('edit_topic_win_'+Math.random(),{className:"askv_cube",title:windowTitle,width:560,height:400,minimizable:false,maximizable:false,resizable:true,url:commentUrl,hideEffectOptions:{duration:0.5},showEffectOptions:{duration:0.5}});win.setDestroyOnClose();win.showCenter(true);win.toFront();var myObserver={onDestroy:function(eventName,windo){if(windo==win){Windows.removeObserver(this);window.location.reload();}}}
Windows.addObserver(myObserver);}
function addTopic(type,sourceTagId,cost){if(document.getElementById('chargesLeft').innerHTML=="0"){alert('Sorry, but you are currently out of charges. Please wait for them to regenerate before trying again.');return;}
var targetTagName=document.getElementById('newTagName').value;if(!targetTagName||trim(targetTagName)==""){alert("Please type a valid topic name.");return;}
if(targetTagName.indexOf(',')!=-1){alert("Please enter only one topic at a time.");return;}
var result=confirm("Spend "+cost+" quest gold to include '"+targetTagName+"'?");if(!result){return;}
targetTagName=escape(targetTagName);var url='/EditTagLinksWindow.do';var pars='type='+type+'&action=add'+'&tagId='+sourceTagId+'&linkedTagName='+targetTagName+'&isAjax=true';ajaxLoad(url,pars,'get','links_div','links_div_progress');}
function removeTopic(type,sourceTagId,targetTagId,targetTagName,cost){if(document.getElementById('chargesLeft').innerHTML=="0"){alert('Sorry, but you are currently out of charges. Please wait for them to regenerate before trying again.');return;}
var result=confirm("Spend "+cost+" quest gold to remove '"+targetTagName+"'?");if(!result){return;}
var url='/EditTagLinksWindow.do';var pars='type='+type+'&action=remove'+'&tagId='+sourceTagId+'&linkedTagId='+targetTagId+'&linkedTagName='+escape(targetTagName)+'&isAjax=true';ajaxLoad(url,pars,'get','links_div','links_div_progress');}
function showPostBulletinWindow(tagId){if(!isUserLoggedIn()){alert('Please sign in first');return;}
var commentUrl='/EditTagBoardWindow.do?type=add&tagId='+tagId;var win=new Window('edit_topic_win_'+Math.random(),{className:"askv_cube",title:'Post Topic Bulletin',width:560,height:300,minimizable:false,maximizable:false,resizable:true,url:commentUrl,hideEffectOptions:{duration:0.5},showEffectOptions:{duration:0.5}});win.setDestroyOnClose();win.showCenter(true);win.toFront();var myObserver={onDestroy:function(eventName,windo){if(windo==win){Windows.removeObserver(this);showTagComment(tagId);}}}
Windows.addObserver(myObserver);}
function showRemoveBulletinWindow(tagId,messageId){if(!isUserLoggedIn()){alert('Please sign in first');return;}
var commentUrl='/EditTagBoardWindow.do?type=remove&tagId='+tagId+'&messageId='+messageId;var win=new Window('edit_topic_win_'+Math.random(),{className:"askv_cube",title:'Remove Bulletin Posting',width:560,height:300,minimizable:false,maximizable:false,resizable:true,url:commentUrl,hideEffectOptions:{duration:0.5},showEffectOptions:{duration:0.5}});win.setDestroyOnClose();win.showCenter(true);win.toFront();var myObserver={onDestroy:function(eventName,windo){if(windo==win){Windows.removeObserver(this);showTagComment(tagId);}}}
Windows.addObserver(myObserver);}
function showRestoreBulletinWindow(tagId,messageId){if(!isUserLoggedIn()){alert('Please sign in first');return;}
var commentUrl='/EditTagBoardWindow.do?type=restore&tagId='+tagId+'&messageId='+messageId;var win=new Window('edit_topic_win_'+Math.random(),{className:"askv_cube",title:'Restore Bulletin Posting',width:560,height:300,minimizable:false,maximizable:false,resizable:true,url:commentUrl,hideEffectOptions:{duration:0.5},showEffectOptions:{duration:0.5}});win.setDestroyOnClose();win.showCenter(false);win.toFront();var myObserver={onDestroy:function(eventName,windo){if(windo==win){Windows.removeObserver(this);window.location.reload();}}}
Windows.addObserver(myObserver);}
function postBulletin(tagId,cost){if(document.getElementById('chargesLeft').innerHTML=="0"){alert('Sorry, but you are currently out of charges. Please wait for them to regenerate before trying again.');return;}
var newBulletin=document.getElementById('new_bulletin').value;if(!newBulletin||trim(newBulletin)==""){alert("Please enter a valid bulletin.");return;}
var result=confirm("Spend "+cost+" quest gold to post this bulletin?");if(!result){return;}
newBulletin=escape(newBulletin);var url='/EditTagBoardWindow.do';var pars='type=add&action=add'+'&tagId='+tagId+'&message='+newBulletin+'&isAjax=true';ajaxLoad(url,pars,'get','board_div','board_div_progress');}
function removeBulletin(tagId,messageId,cost){if(document.getElementById('chargesLeft').innerHTML=="0"){alert('Sorry, but you are currently out of charges. Please wait for them to regenerate before trying again.');return;}
var result=confirm("Spend "+cost+" quest gold to remove this bulletin?");if(!result){return;}
var url='/EditTagBoardWindow.do';var pars='type=remove&action=remove'+'&tagId='+tagId+'&messageId='+messageId+'&isAjax=true';ajaxLoad(url,pars,'get','board_div','board_div_progress');}
function restoreBulletin(tagId,messageId,cost){if(document.getElementById('chargesLeft').innerHTML=="0"){alert('Sorry, but you are currently out of charges. Please wait for them to regenerate before trying again.');return;}
var result=confirm("Spend "+cost+" quest gold to restore this bulletin?");if(!result){return;}
var url='/EditTagBoardWindow.do';var pars='type=restore&action=restore'+'&tagId='+tagId+'&messageId='+messageId+'&isAjax=true';ajaxLoad(url,pars,'get','board_div','board_div_progress');}
function showFeatureAnswerers(startIndex,endIndex,tagId,tagName,paginateMode)
{var url="/ajax/TopicFeatureAnswerers.do";var pars="tagId="+tagId+"&tagName="+tagName+"&startIndex="+startIndex+"&endIndex="+endIndex;if(paginateMode){pars=pars+"&paginateMode="+paginateMode;}
ajaxLoad(url,pars,'get','featured_askvillers','featured_askvillers_progress');if(paginateMode!='SEE_MORE'){window.location.hash='#si='+startIndex+';ei='+endIndex;}}
function showTopicLeaders(startIndex,endIndex,tagId,tagName,paginateMode)
{var url="/ajax/TopicLeaders.do";var pars="tagId="+tagId+"&tagByName="+tagName+"&startIndex="+startIndex+"&endIndex="+endIndex;if(paginateMode){pars=pars+"&paginateMode="+paginateMode;}
ajaxLoad(url,pars,'get','topic_leaders_content','topic_leaders_progress_div');window.location.hash='#si='+startIndex+';ei='+endIndex;}
function checkTagUserSuperPowerStatus(){if(isUserLoggedIn()){var thisTagId=document.getElementById('thisTagId').innerHTML;var url="/ajax/SuperpowerCheckRender.do";var pars="tagId="+thisTagId;ajaxCheckTagUserSuperPowerStatus(url,pars,'get','tagUserSuperpowerStatus');}
else{var editLinks=document.getElementsByName('topic_edit');var curUrl='<nn:url_signin curURL="${__curUrl}" />'.replace(/\'/g,"\\\'");for(var i=0;i<editLinks.length;++i){editLinks[i].href=curUrl;}
editLinks=document.getElementsByName('topic_bulletin_post');curUrl='<nn:url_signin curURL="${curURL}" />'.replace(/\'/g,"\\\'");for(var i=0;i<editLinks.length;++i){editLinks[i].href=curUrl;}
editLinks=document.getElementsByName('topic_bulletin_delete');curUrl='<nn:url_signin curURL="${curURL}" />'.replace(/\'/g,"\\\'");for(var i=0;i<editLinks.length;++i){editLinks[i].href=curUrl;}}}
function ajaxCheckTagUserSuperPowerStatus(url,pars,method,contentDivId,progressDivId)
{pars=appendDateToParams(pars,method);var myAjax=new Ajax.ProgressableUpdater({success:contentDivId,progress:progressDivId},url,{asynchronous:true,method:method,parameters:pars,evalScripts:true,onFailure:reportAjaxUpdateError,onComplete:renderTagUserSuperpowerStatus});}
function renderTagUserSuperpowerStatus(){var tagUserSpStatus=document.getElementById('tagUserSuperpowerStatus');if(tagUserSpStatus==null)
{return;}
tagUserSpStatus=tagUserSpStatus.innerHTML;var spStatuses=tagUserSpStatus.split(",");var tagBulletinSpStatus=spStatuses[0];var tagEditSpStatus=spStatuses[1];var editLinks=document.getElementsByName('topic_edit');for(var i=0;i<editLinks.length;++i){if(tagEditSpStatus=='INSUFFICIENT_TAG_LEVEL'){editLinks[i].className='topic_edit_disabled';editLinks[i].href='javascript:alert("Sorry, you must be level 2 in this topic to use this feature.")';}else if(tagEditSpStatus=='INSUFFICIENT_COINS'){editLinks[i].className='topic_edit_disabled';editLinks[i].href='javascript:alert("Sorry, you do not have enough gold for this action.")';}else if(tagEditSpStatus=='SUPERPOWER_EXERCISE_LIMIT_REACHED'){editLinks[i].className='topic_edit_disabled';editLinks[i].href='javascript:alert("Sorry, you have reached your superpower exercise limit. Please try again later.")';}else if(tagEditSpStatus=='SUPERPOWER_PURCHASE_LIMIT_REACHED'){editLinks[i].className='topic_edit_disabled';editLinks[i].href='javascript:alert("Sorry, you do not have the necessary superpower to perform this action.")';}else{editLinks[i].className='topic_edit_enabled';}}
var bulletinDeleteLinks=document.getElementsByName('topic_bulletin_delete');for(var i=0;i<bulletinDeleteLinks.length;++i){if(tagBulletinSpStatus=='INSUFFICIENT_TAG_LEVEL'){bulletinDeleteLinks[i].className='bulletin_delete_disabled';bulletinDeleteLinks[i].href='javascript:alert("Sorry, you must be level 1 in this topic to use this feature.")';}else if(tagBulletinSpStatus=='INSUFFICIENT_COINS'){bulletinDeleteLinks[i].className='bulletin_delete_disabled';bulletinDeleteLinks[i].href='javascript:alert("Sorry, you do not have enough gold for this action.")';}else if(tagBulletinSpStatus=='SUPERPOWER_EXERCISE_LIMIT_REACHED'){bulletinDeleteLinks[i].className='bulletin_delete_disabled';bulletinDeleteLinks[i].href='javascript:alert("Sorry, you have reached your superpower exercise limit. Please try again later.")';}else if(tagBulletinSpStatus=='SUPERPOWER_PURCHASE_LIMIT_REACHED'){bulletinDeleteLinks[i].className='bulletin_delete_disabled';bulletinDeleteLinks[i].href='javascript:alert("Sorry, you do not have the necessary superpower to perform this action.")';}else{bulletinDeleteLinks[i].className='bulletin_delete_enabled';}}
var bulletinPostLinks=document.getElementsByName('topic_bulletin_post');for(var i=0;i<bulletinPostLinks.length;++i){if(tagBulletinSpStatus=='INSUFFICIENT_TAG_LEVEL'){bulletinPostLinks[i].className='bulletin_post_disabled';bulletinPostLinks[i].href='javascript:alert("Sorry, you must be level 1 in this topic to use this feature.")';}else if(tagBulletinSpStatus=='INSUFFICIENT_COINS'){bulletinPostLinks[i].className='bulletin_post_disabled';bulletinPostLinks[i].href='javascript:alert("Sorry, you do not have enough gold for this action.")';}else if(tagBulletinSpStatus=='SUPERPOWER_EXERCISE_LIMIT_REACHED'){bulletinPostLinks[i].className='bulletin_post_disabled';bulletinPostLinks[i].href='javascript:alert("Sorry, you have reached your superpower exercise limit. Please try again later.")';}else if(tagBulletinSpStatus=='SUPERPOWER_PURCHASE_LIMIT_REACHED'){bulletinPostLinks[i].className='bulletin_post_disabled';bulletinPostLinks[i].href='javascript:alert("Sorry, you do not have the necessary superpower to perform this action.")';}else{bulletinPostLinks[i].className='bulletin_post_enabled';}}}
function toggleTagBox(tagId,boxId){isShown=toggleHideShowWithCtlInlineReturnStatus(boxId+'_content',boxId+'_icon');if(isShown&&(boxShown[boxId]==false)){pars='tagId='+tagId+'&boxId='+boxId;ajaxFireAndForget('/ajax/TopicBox.do',pars,'get');boxShown[boxId]=true;}}
function modifyQuestionWatchList(requestId,watchStatus){url="/ajax/QuestionWatchList.do";pars="action=modify&outputStyle=minimal&requestId="+requestId+"&status="+watchStatus;ajaxLoad(url,pars,'post','watch_result_'+requestId,'watch_progress_'+requestId);}