// KB: modified messageRPC() and tellMeAgain() to use try/catch to prevent irregular HTTP errors
var offsetYToAdd=15;

/*------------------Message Checking Functions--------------------------*/
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}

var messageCheckRate=10*1000;

function messageRPC(){
	var url="pages/actions/act_forumCheckForPrivateMessages.cfm?"+(new Date()).getTime();
	try {
 	xmlhttp.open("GET", url,true);
 	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			parseReceivedMessages(xmlhttp.responseText)
		}
 	}
 	xmlhttp.send(null);
	} catch(e) {}
}

function tellMeAgain() {
	var url="pages/actions/act_forumMessagesTellMeAgain.cfm?"+(new Date()).getTime();
	try {
		xmlhttp.open("GET", url,true);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				parseReceivedMessages(xmlhttp.responseText)
			}
		}
		xmlhttp.send(null);
	} catch(e) {}
}

function pollForPrivateMessages() {
		try {
			messageRPC();
		} catch(e) {}
		setTimeout('pollForPrivateMessages()', messageCheckRate);
}

//function pollForPrivateMessages() {
//
//}

function parseReceivedMessages(responseText) {
	var myMessages=document.getElementById("myMessages");
	if(responseText.trim()!="") {
		myMessages.style.fontWeight="bold";
		writeBalloonText(responseText);
		showBalloon();
	} else {	
		myMessages.style.fontWeight="normal";
		document.getElementById("balloon").style.display="none";
	}
}

function ackMessage(obj) {
	var ackImg = new Image();
	ackImg.src="pages/actions/act_ackMessages.cfm?" + (new Date()).getTime();
	var myMessages=document.getElementById("myMessages");
	myMessages.style.fontWeight="normal";
	hideBalloon(obj);
}
/*----------------------------------------------------------------------*/

String.prototype.trim = function()
{  
  return( this.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );   // example: str=str.trim();
}

function showBalloon() {
	var balloon=document.getElementById("balloon");
	var myMessages=document.getElementById("myMessages");
	balloon.style.display="block";
	var x=findPosX(myMessages);
	var y=findPosY(myMessages);
	var balloonWidth=balloon.offsetWidth;
	var balloonHeight=balloon.offsetHeight;
	balloon.style.top=y-balloonHeight;
	balloon.style.left=(x-balloonWidth)+Math.round((myMessages.offsetWidth)/2)+10;
		
}

function writeBalloonText(theText) {
	document.getElementById("balloonText").innerHTML=theText;
}

function hideBalloon(obj) {
	obj.style.display="none";
}

function getScreenWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function userOptions(e) {
	var isPopDownMenu=document.all? event.srcElement.getAttribute("popDownMenu") : e.target.getAttribute("popDownMenu");
	var itemId=document.all? event.srcElement.getAttribute("itemId") : e.target.getAttribute("itemId");
	var item2Id=document.all? event.srcElement.getAttribute("item2Id") : e.target.getAttribute("item2Id");
	var item3Id=document.all? event.srcElement.getAttribute("item3Id") : e.target.getAttribute("item3Id");
	var menu=document.getElementById("menuDiv");
	if(isPopDownMenu!=null) {
		var underMenuObj=document.all? event.srcElement : e.target;
		var x=findPosX(underMenuObj);
		var y=findPosY(underMenuObj)+offsetYToAdd;
		menu.style.left=x;
		menu.style.top=y;
		switch(isPopDownMenu) {
			case "controlPanel":
				populateControlMenu();
				menu.style.display="block";
				break;
			case "rateTopic":
				populateRateTopicMenu(itemId);
				menu.style.display="block";
				break;
			case "topicOptions":
				populateTopicOptionsMenu(itemId,item2Id,item3Id);
				menu.style.display="block";
				break;
			case "categoryOptions":
				populateCategoryOptionsMenu(itemId,item2Id);
				menu.style.display="block";
				break;
			case "subscriptionOptions":
				populateSubscriptionOptionsMenu(itemId);
				menu.style.display="block";
				break;
			case "categorySubscriptionOptions":
				populateCategorySubscriptionOptionsMenu(itemId);
				menu.style.display="block";
				break;
			case "memberProfile":
				populateMenu(itemId);
				menu.style.display="block";
				break;
			case "buddyProfile":
				populateBuddyProfile(itemId);
				menu.style.display="block";
				break;
			case "pmUserProfile":
				populatePmUserProfile(itemId);
				menu.style.display="block";
				break;
			case "ignoredUser":
				populateIgnoredUser(itemId);
				menu.style.display="block";
			break;
			case "sortForum":
				sortForum(itemId);
				menu.style.display="block";
			break
			case "sortCategory":
				sortCategory(itemId);
				menu.style.display="block";
			break;
			case "myMessages":
				populateMyMessages();
				menu.style.display="block";
			break;
			case "favouritesMenu":
				populateMyFavouritesMenu(itemId);
				menu.style.display="block";
			break;
			case "moderatorCategoryOptions":
				populateModeratorCategoryOptions(itemId,item2Id);
				menu.style.display="block";
			break;
			case "pmInbox":
				populatePMInboxOptions(itemId,item2Id);
				menu.style.display="block";
			break;
			case "pmSentItems":
				populatePMSentItemsOptions(itemId);
				menu.style.display="block";
			break;
			case "quickSearch":
				populateQuickSearchMenu();
				menu.style.display="block";
				document.getElementById("quickSearchTerm").focus();
			break;
			case "searchInForum":
				populateSearchInForumMenu(itemId);
				menu.style.display="block";
				document.getElementById("forumSearchTerm").focus();
			break;
			case "searchInCategory":
				populateSearchInCategoryMenu(itemId);
				menu.style.display="block";
				document.getElementById("categorySearchTerm").focus(); 
			break;
			case "recentTopics":
				populateRecentTopicsMenu();
				menu.style.display="block";
			break;
		}
		var menuWidth=menu.offsetWidth;
		var menuSize=parseInt(menu.style.left) + menuWidth;
		var screenWidth=getScreenWidth();
		if(menuSize > screenWidth) {
			menu.style.left=screenWidth-menuWidth;
		}
	} else {
		try {
			var underMenuObj=document.all? event.srcElement : e.target;
			if(underMenuObj.getAttribute("pinned")!="Y") {
				menu.style.display="none";
			}
		} catch(e) {
			menu.style.display="none";
		}
	}
}

function forumJump() {
	var obj=document.getElementById("forumJump");
	
	if(obj.options[obj.selectedIndex].value!="-1") {
		
	} else {	
		var forumId=obj.options[obj.selectedIndex].getAttribute("forumId");
		var categoryId=obj.options[obj.selectedIndex].getAttribute("categoryId");
		if(forumId!=null) {
			document.location="index.cfm?page=viewForum&forumId="+forumId;
		} else if(categoryId!=null) {
			document.location="index.cfm?page=viewForumCategory&categoryId="+categoryId;
		} else {
			obj.selectedIndex=0;
		}
	}
}

function checkQSEnter(e){ 
	var characterCode;
	if(e && e.which) {
		e=e;
		characterCode=e.which;
	} else {
		e=event;
		characterCode=e.keyCode;
	}
	if(characterCode == 13) { 
		validateQuickSearch();
		return false;
	} else{
		return true ;
	}
}

function checkFSEnter(e,forumId){ 
	var characterCode;
	if(e && e.which) {
		e=e;
		characterCode=e.which;
	} else {
		e=event;
		characterCode=e.keyCode;
	}
	if(characterCode == 13) { 
		validateForumSearch(forumId);
		return false;
	} else{
		return true ;
	}
}

function checkCSEnter(e,categoryId){ 
	var characterCode;
	if(e && e.which) {
		e=e;
		characterCode=e.which;
	} else {
		e=event;
		characterCode=e.keyCode;
	}
	if(characterCode == 13) { 
		validateCategorySearch(categoryId);
		return false;
	} else{
		return true ;
	}
}

//KB: Email syntax check added
//function checkEmail(field) {
	
//}

//KB: Function to show remaining characters in form test field
function checkTextArea(TextArea, counter, maxChar)
{
	if(TextArea.value.length > maxChar)
		{	TextArea.value = TextArea.value.substring(0,maxChar);	}
	else
		{	counter.value = maxChar - TextArea.value.length;	}
}

function validateQuickSearch() {
	var searchTerm=document.getElementById("quickSearchTerm").value;
	if(searchTerm.length!=0) {
		document.location="index.cfm?page=forumQuickSearch&searchTerm="+searchTerm;
	} else {
		alert("Please enter a quick search term");
	}
}

function validateForumSearch(forumId) {
	var searchTerm=document.getElementById("forumSearchTerm").value;
	if(searchTerm.length!=0) {
		document.location="index.cfm?page=forumSearchThisForum&searchTerm="+searchTerm+"&forumId="+forumId;
	} else {
		alert("Please enter a search term");
	}
}

function validateCategorySearch(categoryId) {
	var searchTerm=document.getElementById("categorySearchTerm").value;
	if(searchTerm.length!=0) {
		document.location="index.cfm?page=forumSearchThisCategory&searchTerm="+searchTerm+"&categoryId="+categoryId;
	} else {
		alert("Please enter a search term");
	}
}

function sortForum(forumId) {
	var html="";
	html+="<table width=\"100%\">";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForum&forumId="+forumId+"&sortBy=cna\">By Category Name Ascending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForum&forumId="+forumId+"&sortBy=cnd\">By Category Name Descending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForum&forumId="+forumId+"&sortBy=nota\">By Number Of Topics Ascending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForum&forumId="+forumId+"&sortBy=notd\">By Number Of Topics Descending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForum&forumId="+forumId+"&sortBy=lpda\">By Last Post Date Ascending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForum&forumId="+forumId+"&sortBy=lpdd\">By Last Post Date Descending</a></td></tr>";
	html+="</table>"
	
	document.getElementById("menuDiv").style.width="210px";
	document.getElementById("menuDiv").innerHTML=html;
}

function sortCategory(categoryId) {
	var html="";
	html+="<table width=\"100%\">";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumCategory&categoryId="+categoryId+"&sortBy=tna\">By Topic Name Ascending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumCategory&categoryId="+categoryId+"&sortBy=tnd\">By Topic Name Descending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumCategory&categoryId="+categoryId+"&sortBy=oa\">By Originator Ascending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumCategory&categoryId="+categoryId+"&sortBy=od\">By Originator Descending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumCategory&categoryId="+categoryId+"&sortBy=va\">By Views Ascending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumCategory&categoryId="+categoryId+"&sortBy=vd\">By Views Descending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumCategory&categoryId="+categoryId+"&sortBy=lpda\">By Last Post Date Ascending</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumCategory&categoryId="+categoryId+"&sortBy=lpdd\">By Last Post Date Descending</a></td></tr>";
	html+="</table>"
	
	document.getElementById("menuDiv").style.width="210px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateSearchInForumMenu(forumId) {
	var html="";
	html+="<table width=\"100%\" cellspacing=0 cellpadding=0>"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupTitleInner\">Search This Forum</td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\" style=\"padding:10px\">";
	html+="<input onkeypress=\"checkFSEnter(event,"+forumId+")\" class=\"quickSearchTextBox\" name=\"forumSearchTerm\" id=\"forumSearchTerm\" pinned=\"Y\" type=\"text\">&nbsp;<a class=\"forumLinkNested\" href=\"javascript:validateForumSearch("+forumId+")\">Find!</a>";
	html+="</td></tr>";
	html+="</table>"
	
	document.getElementById("menuDiv").style.width="200px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateSearchInCategoryMenu(categoryId) {
	var html="";
	html+="<table width=\"100%\" cellspacing=0 cellpadding=0>"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupTitleInner\">Search This Category</td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\" style=\"padding:10px\">";
	html+="<input onkeypress=\"checkCSEnter(event,"+categoryId+")\" class=\"quickSearchTextBox\" name=\"categorySearchTerm\" id=\"categorySearchTerm\" pinned=\"Y\" type=\"text\">&nbsp;<a class=\"forumLinkNested\" href=\"javascript:validateCategorySearch("+categoryId+")\">Find!</a>";
	html+="</td></tr>";
	html+="</table>"
	
	document.getElementById("menuDiv").style.width="200px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateQuickSearchMenu() {
	var html="";
	html+="<table width=\"100%\" cellspacing=0 cellpadding=0>"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupTitleInner\">Quick Search</td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\" style=\"padding:10px\">";
	html+="<input onkeypress=\"checkQSEnter(event)\" class=\"quickSearchTextBox\" name=\"quickSearchTerm\" tabindex=\"1\" id=\"quickSearchTerm\" pinned=\"Y\" type=\"text\">&nbsp;<a class=\"forumLinkNested\" href=\"javascript:validateQuickSearch()\">Find!</a>";
	//html+="<br><a href=\"index.cfm?page=forumAdvancedSearch\" class=\"forumLink\">Advanced Search...</a>";
	html+="</td></tr>";
	html+="</table>"
	
	document.getElementById("menuDiv").style.width="200px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateMyMessages() {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:tellMeAgain()\">Tell Me Again</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumPrivateMessagesInbox\">View Inbox</a></td></tr>";
	html+="</table>"
	document.getElementById("menuDiv").style.width="100px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populatePMInboxOptions(privateMessageId,isRead) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:readPrivateMessage('"+privateMessageId+"')\">Read Message</a></td></tr>";
	if(isRead=="N") {	
		html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:markPMMessageRead('"+privateMessageId+"')\">Mark As Read</a></td></tr>";
	} else {
		html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:markPMMessageUnRead('"+privateMessageId+"')\">Mark As Unread</a></td></tr>";
	}
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:replyToPrivateMessage('"+privateMessageId+"')\">Reply To Message</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:deletePMMessage('"+privateMessageId+"')\">Delete Message</a></td></tr>";
	html+="</table>"
	document.getElementById("menuDiv").style.width="130px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populatePMSentItemsOptions(privateMessageId) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:viewPrivateSentMessage('"+privateMessageId+"')\">View Message</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:deletePMSentMessage('"+privateMessageId+"')\">Delete Message</a></td></tr>";
	html+="</table>"
	document.getElementById("menuDiv").style.width="130px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populatePmUserProfile(userId) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumMemberProfile&userId="+userId+"\">View Member Profile</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumAddBuddy&userId="+userId+"\">Add To buddy List</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumAddIgnore&userId="+userId+"\">Add To ignore List</a></td></tr>";
	if(forumOptions.allowuserpm) html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:sendPM("+userId+")\">Send Private Message</a></td></tr>";
	if(forumOptions.allowuseremail) html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:sendEmail("+userId+")\">Send Email To Member</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewAllUserPosts&userId="+userId+"\">Find All Members Posts</a></td></tr>";
	html+="</table>"
	document.getElementById("menuDiv").style.width="160px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateIgnoredUser(userId) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumMemberProfile&userId="+userId+"\">View Member Profile</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumRemoveIgnore&userId="+userId+"\">Remove From Ignore List</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumAddBuddy&userId="+userId+"\">Add To buddy List</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:sendPM("+userId+")\">Send Private Message</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:sendEmail("+userId+")\">Send Email To Member</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewAllUserPosts&userId="+userId+"\">Find All Members Posts</a></td></tr>";
	html+="</table>"
	document.getElementById("menuDiv").style.width="160px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateMenu(userId) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumMemberProfile&userId="+userId+"\">View Member Profile</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumAddBuddy&userId="+userId+"\">Add To buddy List</a></td></tr>";
	if(forumOptions.allowuserpm)html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:sendPM("+userId+")\">Send Private Message</a></td></tr>";
	if(forumOptions.allowuseremail)html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:sendEmail("+userId+")\">Send Email To Member</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewAllUserPosts&userId="+userId+"\">Find All Members Posts</a></td></tr>";
	html+="</table>"
	document.getElementById("menuDiv").style.width="160px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateBuddyProfile(userId) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumMemberProfile&userId="+userId+"\">View Buddy Profile</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumRemoveBuddy&userId="+userId+"\">Remove Buddy</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:sendPM("+userId+")\">Send Private Message</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:sendEmail("+userId+")\">Send Email To Buddy</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewAllUserPosts&userId="+userId+"\">Find All Buddys Posts</a></td></tr>";
	html+="</table>"
	document.getElementById("menuDiv").style.width="160px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateRecentTopicsMenu() {
	var html="";
	html+="<table pinned=\"Y\" width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupTitleInner\">Select View...</td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumAllTodaysPosts\">All Todays Posts</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumAllYesterdaysPosts\">All Yesterdays Posts</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumRecentTopics&topicSort=lv\">Posts Since My Last Visit</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumRecentTopics&topicSort=12\">Posts from last 12 hours</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumRecentTopics&topicSort=24\">Posts from last 24 hours</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumRecentTopics&topicSort=48\">Posts from last 48 hours</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumDynamicRange\">Posts between date range</a></td></tr>";
	html+="</table>"
	document.getElementById("menuDiv").style.width="180px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateControlMenu() {
	var html="";
	html+="<table pinned=\"Y\" width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupTitleInner\">Control Panel</td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumEditMemberContact\">Contact</a> / <a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumEditPersonalInformation\">Personal Info</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumEditMessageSignature\">Message Signature</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumEditAvatar\">Avatar</a> / <a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumEditPersonalPhoto\">Photo Image</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumEditRegistrationDetails\">Registration Details</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitle\">Your Controls</td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumEditSettings\">Forum Settings</a></td></tr>";
	if( forumOptions.usekeywords )
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumEditKeywordAlerts\">My Keyword Alerts</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumMyCategorySubscriptions\">Category Subscriptions</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumMyTopicSubscriptions\">Subscriptions</a> / <a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumMyFavourites\">Favourites</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumPrivateMessagesInbox\">PM Inbox</a> / <a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumPrivateMessagesSentItems\">PM SentItems</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumMyBuddyList\">Buddies</a> / <a class=\"smallForumLinkNested\" href=\"index.cfm?page=forumMyIgnoreList\">Ignore List</a></td></tr>";
	html+="</table>"
	document.getElementById("menuDiv").style.width="180px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateTopicOptionsMenu(topicId,threadId,subscribed) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumTopic&topicId="+topicId+"&threadId="+threadId+"&forumaction=reply\">Post Reply To Topic</a></td></tr>";
	if(subscribed!=0) {
		html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumUnSubscribeToTopic&topicId="+topicId+"\">Unsubscribe From Topic</a></td></tr>";
	} else {
		html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumSubscribeToTopic&topicId="+topicId+"\">Subscribe To Topic</a></td></tr>";
	}
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumAddToFavourites&topicId="+topicId+"\">Add To Favourites</a></td></tr>";
	if(hasAttachments) html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:viewTopicAttachments('"+topicId+"')\">Attachments...</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:emailTopic('"+topicId+"')\">Email This Topic</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:printTopic('"+topicId+"')\">Print This Topic</a></td></tr>";
	html+="</table>";
	document.getElementById("menuDiv").style.width="150px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateCategoryOptionsMenu(categoryId,subscribed) {
	var html="";
	html+="<table width=\"100%\">"
	if(subscribed!=0) {
		html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumUnSubscribeToCategory&categoryId="+categoryId+"\">Unsubscribe From Category</a></td></tr>";
		document.getElementById("menuDiv").style.width="180px";
	} else {
		html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumSubscribeToCategory&categoryId="+categoryId+"\">Subscribe To Category</a></td></tr>";
		document.getElementById("menuDiv").style.width="150px";
	}
	html+="</table>";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateModeratorCategoryOptions(forumId,categoryId) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForum&forumAction=renameCategory&categoryId="+categoryId+"&forumId="+forumId+"\">Rename Category</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:moderatorDeleteCategory('"+forumId+"','"+categoryId+"')\">Delete Category</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForum&forumAction=moveCategory&categoryId="+categoryId+"&forumId="+forumId+"\">Move Category</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForum&forumAction=categoryProperties&categoryId="+categoryId+"&forumId="+forumId+"\">Change Properties</a></td></tr>";
	html+="</table>";
	document.getElementById("menuDiv").style.width="150px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateSubscriptionOptionsMenu(topicId) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumTopic&topicId="+topicId+"\">View Topic</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumUnSubscribeToTopic&pRef=forumMyTopicSubscriptions&topicId="+topicId+"\">Unsubscribe From Topic</a></td></tr>";
	html+="</table>";
	document.getElementById("menuDiv").style.width="150px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateCategorySubscriptionOptionsMenu(categoryId) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumCategory&categoryId="+categoryId+"\">View Category</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumUnSubscribeToCategory&pRef=forumMyCategorySubscriptions&categoryId="+categoryId+"\">Unsubscribe From Category</a></td></tr>";
	html+="</table>";
	document.getElementById("menuDiv").style.width="180px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateMyFavouritesMenu(topicId) {
	var html="";
	html+="<table width=\"100%\">"
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?page=viewForumTopic&topicId="+topicId+"\">View Topic</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:emailTopic('"+topicId+"')\">Email This Topic</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"javascript:printTopic('"+topicId+"')\">Print This Topic</a></td></tr>";
	html+="<tr pinned=\"Y\"><td pinned=\"Y\" class=\"forumGroupSubTitleInner\"><a class=\"smallForumLinkNested\" href=\"index.cfm?action=forumRemoveFavourite&topicId="+topicId+"\">Remove From Favourites</a></td></tr>";
	html+="</table>";
	document.getElementById("menuDiv").style.width="170px";
	document.getElementById("menuDiv").innerHTML=html;
}

function populateRateTopicMenu(topicId) {
	var html="";
	html+="<table width=\"180\">"
	html+="<tr><td class=\"forumGroupSubTitleInnerRating\"><img src=\"styles/"+forumStyle+"/images/ratings/misc_rating5.gif\" width=\"64\" height=\"15\" alt=\"\" border=\"0\"></td><td class=\"forumGroupSubTitleInnerRating\" align=right>Great Topic <input onclick=\"rateTopic("+topicId+",5)\" type=\"radio\"></td></tr>";
	html+="<tr><td class=\"forumGroupSubTitleInnerRating\"><img src=\"styles/"+forumStyle+"/images/ratings/misc_rating4.gif\" width=\"64\" height=\"15\" alt=\"\" border=\"0\"></td><td class=\"forumGroupSubTitleInnerRating\" align=right>Good Topic <input onclick=\"rateTopic("+topicId+",4)\" type=\"radio\"></td></tr>";
	html+="<tr><td class=\"forumGroupSubTitleInnerRating\"><img src=\"styles/"+forumStyle+"/images/ratings/misc_rating3.gif\" width=\"64\" height=\"15\" alt=\"\" border=\"0\"></td><td class=\"forumGroupSubTitleInnerRating\" align=right>Average <input onclick=\"rateTopic("+topicId+",3)\" type=\"radio\"></td></tr>";
	html+="<tr><td class=\"forumGroupSubTitleInnerRating\"><img src=\"styles/"+forumStyle+"/images/ratings/misc_rating2.gif\" width=\"64\" height=\"15\" alt=\"\" border=\"0\"></td><td class=\"forumGroupSubTitleInnerRating\" align=right>Bad Topic <input onclick=\"rateTopic("+topicId+",2)\" type=\"radio\"></td></tr>";
	html+="<tr><td class=\"forumGroupSubTitleInnerRating\"><img src=\"styles/"+forumStyle+"/images/ratings/misc_rating1.gif\" width=\"64\" height=\"15\" alt=\"\" border=\"0\"></td><td class=\"forumGroupSubTitleInnerRating\" align=right>Terrible <input onclick=\"rateTopic("+topicId+",1)\" type=\"radio\"></td></tr>";
	html+="</table>";
	document.getElementById("menuDiv").style.width="200px";
	document.getElementById("menuDiv").innerHTML=html;
}

function rateTopic(topicId,rating) {
	document.location="index.cfm?action=forumRateTopic&topicId="+topicId+"&rating="+rating;
}

function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function deletePMMessage(privateMessageId) {
	var confirmation=confirm("Are you sure you wish to delete this private message?");
	if(confirmation) {
		document.location="index.cfm?action=forumDeletePrivateMessage&privateMessageId="+privateMessageId;
	}
}

function deletePMSentMessage(privateMessageId) {
	var confirmation=confirm("Are you sure you wish to delete this sent private message?");
	if(confirmation) {
		document.location="index.cfm?action=forumDeleteSentPrivateMessage&privateMessageId="+privateMessageId;
	}
}


function markPMMessageRead(privateMessageId) {
	document.location="index.cfm?action=forumMarkPrivateMessageRead&privateMessageId="+privateMessageId;
}

function markPMMessageUnRead(privateMessageId) {
	document.location="index.cfm?action=forumMarkPrivateMessageUnread&privateMessageId="+privateMessageId;
}

function selectAllPMMessages(obj) {
	var ooo=false;
	if(obj.checked) {
		ooo=true;
	}
	var cbs=document.getElementsByTagName("INPUT");
	var idList="";
	for(i=0;i<cbs.length;i++) {	
		if(cbs[i].name=="privateMessageId") {
			cbs[i].checked=ooo;
		}
	}
}

function enumeratePMMessages() {
	var cbs=document.getElementsByTagName("INPUT");
	var idList="";
	var count=0;
	for(i=0;i<cbs.length;i++) {	
		if(cbs[i].name=="privateMessageId" && cbs[i].checked) {
			idList+=cbs[i].value + ",";
			count++;
		}
	}
	if(idList.length!=0) {
		var confirmation=confirm("Are you sure you wish to delete these " + count + " private messages?");
		if(confirmation) {
			document.location="index.cfm?action=forumDeleteBatchPrivateMessages&idList="+idList;
		}
	} else {
		alert("Please select one or more private messages to delete");
	}
}

function enumerateSentPMMessages() {
	var cbs=document.getElementsByTagName("INPUT");
	var idList="";
	var count=0;
	for(i=0;i<cbs.length;i++) {	
		if(cbs[i].name=="privateMessageId" && cbs[i].checked) {
			idList+=cbs[i].value + ",";
			count++;
		}
	}
	if(idList.length!=0) {
		var confirmation=confirm("Are you sure you wish to delete these " + count + " sent private messages?");
		if(confirmation) {
			document.location="index.cfm?action=forumDeleteBatchSentPrivateMessages&idList="+idList;
		}
	} else {
		alert("Please select one or more sent private messages to delete");
	}
}

function viewPrivateSentMessage(privateMessageId) {
	var width=550;
	var height=450;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=no'");
	window.open("pages/popUp/popUp_viewPrivateSentMessage.cfm?privateMessageId="+privateMessageId, '', params);
}

function viewTopicAttachments(topicId) {
	var width=550;
	var height=380;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=no'");
	window.open("pages/popUp/popUp_viewTopicAttachments.cfm?topicId="+topicId, '', params);
}

function readPrivateMessage(privateMessageId) {
	var width=550;
	var height=450;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=no'");
	window.open("pages/popUp/popUp_readPrivateMessage.cfm?privateMessageId="+privateMessageId, '', params);
}

function replyToPrivateMessage(privateMessageId) {
	var width=550;
	var height=450;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=no'");
	window.open("pages/popUp/popUp_replyToPrivateMessage.cfm?privateMessageId="+privateMessageId, '', params);
}

function sendPM(userId) {
	var width=550;
	var height=450;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=no'");
	window.open("pages/popUp/popUp_sendPrivateMessage.cfm?userId="+userId, '', params);
}

function addAlertKeyword() {
	var width=450;
	var height=180;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=no'");
	window.open("pages/popUp/popUp_forumAddKeywordAlert.cfm", '', params);
}

function addNewTag() {
	var width=450;
	var height=180;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=no'");
	window.open("pages/popUp/popUp_forumAddNewTag.cfm", '', params);
}

function addNewTagAJAX() {
	var width=450;
	var height=180;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", status=yes,scrollbars=no'");
	window.open("pages/popUp/popUp_forumAddNewTagAJAX.cfm", '', params);
}

function ieAddToListHack(pText,pValue) {
	obj=document.getElementById("tagId");
	obj.options[obj.options.length] = new Option(pText, pValue);
}

function sendEmail(userId) {
	var width=550;
	var height=450;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=no'");
	window.open("pages/popUp/popUp_sendEmail.cfm?userId="+userId, '', params);
}

function emailTopic(topicId) {
	var width=550;
	var height=450;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=no'");
	window.open("pages/popUp/popUp_emailTopic.cfm?topicId="+topicId, '', params);
}

function printTopic(topicId) {
	var width=750;
	var height=650;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=yes,toolbar=yes,resizable=yes'");
	window.open("pages/popUp/popUp_printTopic.cfm?topicId="+topicId, '', params);
}

function collapseExpand(section) {

	var obj=document.getElementById("table"+section);
	var img=document.getElementById("image"+section);
	var state=img.getAttribute("state");
	
	if(state=="e") {
		img.src="images/layout/forum/misc_expand.gif";
		for(i=1;i<obj.rows.length;i++) {	
			obj.rows[i].style.display="none";
		}
		writeCookie(section,"c",200);	
		img.setAttribute("state","c");
	} else {
		img.src="images/layout/forum/misc_collapse.gif";
		var colTyp="table-row";
		if(document.all) {
			colType="block";
		}
		for(i=1;i<obj.rows.length;i++) {	
			obj.rows[i].style.display=colType;
		}
		writeCookie(section,"e",200);
		img.setAttribute("state","e");
	}
	
}

function moderatorDeleteTopic(topicId) {
	var confirmation=confirm("Are you sure you wish to delete this topic and all its dependencies?");
	if(confirmation) {
		document.location="index.cfm?action=forumModeratorDeleteTopic&topicId="+topicId;
	}
}

function moderatorCloseTopic(topicId) {
	var confirmation=confirm("Are you sure you wish to close this topic and not allow any more replies?");
	if(confirmation) {
		document.location="index.cfm?action=forumModeratorCloseTopic&topicId="+topicId;
	}
}

function moderatorOpenTopic(topicId) {
	var confirmation=confirm("Are you sure you wish to open this topic and allow more replies?");
	if(confirmation) {
		document.location="index.cfm?action=forumModeratorOpenTopic&topicId="+topicId;
	}
}

function moderatorMoveTopic(topicId) {
	var width=550;
	var height=2300;
    var sLeft=(screen.width-width)/2;
	var sTop=(screen.height-height)/2;
	var params=eval("'height="+height+", width="+width+", top="+sTop+", left="+sLeft+", scrollbars=no'");
	window.open("pages/popUp/popUp_forumMoveTopic.cfm?topicId="+topicId, '', params);
}

function moderatorDeleteThread(topicId,threadId) {
	var confirmation=confirm("Are you sure you wish to delete this thread?");
	if(confirmation) {
		document.location="index.cfm?action=forumModeratorDeleteThread&threadId="+threadId+"&topicId="+topicId;
	}
}

function moderatorDeleteCategory(forumId,categoryId) {
	var confirmation=confirm("Are you sure you wish to delete this category?");
	if(confirmation) {
		document.location="index.cfm?action=forumModeratorDeleteCategory&forumId="+forumId+"&categoryId="+categoryId;
	}
}

function moderatorBanUser(topicId,userId) {
	var confirmation=confirm("Are you sure you wish to disable this users account?");
	if(confirmation) {
		document.location="index.cfm?action=forumModeratorBanUser&userId="+userId+"&topicId="+topicId;
	}
}

function moderatorUnBanUser(topicId,userId) {
	var confirmation=confirm("Are you sure you wish to enable this users account?");
	if(confirmation) {
		document.location="index.cfm?action=forumModeratorUnBanUser&userId="+userId+"&topicId="+topicId;
	}
}

function forumPollVote(topicId,pollResultId) {
	document.location="index.cfm?action=forumPollVote&topicId="+topicId+"&pollResultId="+pollResultId;
}

function forumClosePoll(topicId) {
	document.location="index.cfm?action=forumClosePoll&topicId="+topicId;
}

function forumOpenPoll(topicId) {
	document.location="index.cfm?action=forumOpenPoll&topicId="+topicId;
}

function forumAcceptAnswer(topicId,threadId) {
	document.location="index.cfm?action=forumAcceptAnswer&topicId="+topicId+"&threadId="+threadId;
}
			
function writeCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function deleteCookie(name) {
	writeCookie(name,"",-1);
}
			
			
document.onclick=userOptions;
