var jsCheckTimeout = 0;
var jsCheckTimer = 0;
var jsCurrentUser;
var jsCurrentUserID;
var titleHolder = document.title;
var syncThresholdTimer;
var previewPaneDelay;
var lastClickedQQ;

var windowIsActive = true;
      
function lostFocus()
{
	windowIsActive = false;
}
    
function gainedFocus()
{
	windowIsActive = true;
	
}

function blinkTitle(state, count)
{
		if (windowIsActive != true)
		{
			if (state == 1)
			{
				document.title = "[new!] - " + titleHolder;
				state = 2;			
			}
			else
			{
				document.title = "" + titleHolder;
				state = 1;
			}

			count = count + 1;

			setTimeout("blinkTitle(" + state + ", " + count + ")", 1600);
			
		}
		else
		{
			document.title = titleHolder;
		}
	
}

var clientTimezone = new Date();
if (clientTimezone)
{
	SetCookie("mf_timezone",clientTimezone.getTimezoneOffset()/60,300);	
}

function quickQuote(poster,postID,pCount) {

	qqTag = 'qq' + postID + '.' + pCount;
	

	
	if (lastClickedQQ == qqTag)
	{
		window.location = String(window.location).replace(/\#.*$/, "") + "#reply";
	}
	else
	{
		if (document.getElementById)
		{
			s = new String(document.getElementById(qqTag).innerHTML);
			s = s.replace(/\n/g, "");
			s = s.replace(/\r/g, "");
			s = s.replace(/\t/g, "");
			document.replyForm.message.value += "[qq." + postID + "." + pCount +".][i]" + poster + " said:[/i][br]" + s + "[/qq]\n\n";
		}
	}
	
	lastClickedQQ = qqTag;
}

function addSmily(smily)
{
	if (document.getElementById)
	{
		document.replyForm.message.value += smily + " ";
	}
}

function qqHover(elementID)
{
	if (document.getElementById)
	{
		passage = document.getElementById(elementID);
		passage.className = 'qqContainerHover';
	}
}

function qqHoverOff(elementID)
{
	if (document.getElementById)
	{
		passage = document.getElementById(elementID);
		passage.className = 'qqContainer';
	}
}


function debug(message)
{
	if (document.getElementById)
	{
		var debugPane = document.getElementById('debug');
		debugPane.innerHTML = debugPane.innerHTML + "<br />" + message;
	}
}

function threadUpdate(user)
{	
	var dataLine = new String();
	var timeStamp = document.getElementById('timestamp');
	dataLine = timeStamp.className + "::" + user + "::" + 0;
	
	x_ajax_threadUpdate(dataLine, resetThreads);
		
	setTimeout("threadUpdate(\'" + user + "\')", 10000);
}

function runOnce(user)
{
	//toggleDisplay('thresholdContainer');
	setTimeout("threadUpdate(\'" + user + "\')", 1000);
	setTimeout("updateLastPostMinutes()", 60000);
	if (document.getElementById)
	{
		blinger = document.getElementById('speaker');
		
		if (GetCookie('mf_speaker') != "")
			blinger.className = GetCookie('mf_speaker');
	}
		
}

function runThreadWatcherOnce(threadID)
{
	//toggleDisplay('thresholdContainer');
	//applyThreshold();
	setTimeout("postUpdate(" + threadID + ")", 1000);
	initAllowNextPostTimer();
	if (document.getElementById)
	{
		blinger = document.getElementById('speaker');
		
		if (GetCookie('mf_speaker') != "")
			blinger.className = GetCookie('mf_speaker');
			
		var anchor = location.href;
		anchor = anchor.split("#");
		anchor = anchor[1];			
		
		var anchorElement;
		
		if (anchorElement = document.getElementById(anchor))
		{
			anchorElement.scrollIntoView();
		}
	}	
	

	
	
	
}

function postUpdate(threadID)
{	
		var timeStamp = document.getElementById('lastPostTimeStamp');
		var dataLine = new String();
		dataLine = timeStamp.className + "::" + threadID;
		x_ajax_postUpdate(dataLine, appendPosts);
		setTimeout("postUpdate("+ threadID + ")", 10000);
}

function appendPosts(dataLine)
{	
	if (dataLine != "false")
	{
		
		if (windowIsActive != true)
		{
			if (document.getElementById('speaker').className == "speakerOn")
				so.write("flashcontent"); 
				
			blinkTitle(1, 1);
		}		
		
		var dataLineArray = dataLine.split('__timeDlm__');
		var timeStamp = document.getElementById('lastPostTimeStamp');
		var postCounter = document.getElementById('newPostPlaceHolder');
		timeStamp.className=dataLineArray[0];
		
		
		var postArray = dataLineArray[1].split('__postDlm__');
		
		for (i=0;i<postArray.length;i++)
		{
			if (postArray[i] != "")
			{	
				
				var postContentArray = postArray[i].split('__postIDDlm__');
				
				postToAppend = document.createElement("div");
				postToAppend.id = 'postCounter' + postCounter.className;
				
				if (!(document.getElementById('postContent' + postContentArray[1])))
				{				
					postToAppend.innerHTML = postContentArray[0];
					postToAppend.style.opacity = .00;
					postCount = postCounter.className * 1;
					postCounter.className = postCount + 1;
					postCounter.appendChild(postToAppend);
					fadeIn(postToAppend.id);
				}
				
			}
		}
		
	}
	
	document.getElementById('newPostIndicator').style.display='none';
	
	
}



function fadeIn(element)
{
	var elementToFade = document.getElementById(element);
	
	if (elementToFade.style.opacity < 1)
	{		
		elementOpac = elementToFade.style.opacity;
		elementOpac = elementOpac * 1;
		elementOpac = (elementOpac + .1);
		
		elementToFade.style.opacity = elementOpac;
		setTimeout("fadeIn(\'" + element + "\')", 20);
	}
}

function submitPost(channelTag, threadID)
{
	var textArea = document.getElementById('replyWindow');
	
	if (textArea.value != '')
	{		
		document.getElementById('newPostIndicator').style.opacity = .00;
		document.getElementById('newPostIndicator').style.display = "block";
		fadeIn('newPostIndicator');
		var dataLine = textArea.value + '__lineDlm__' + channelTag + '__lineDlm__' + threadID;
		x_ajax_submitPost(dataLine, postUpdateRunOnce);
		var replyForm = document.replyForm;
		replyForm.replySubmit.disabled=true;
	}	
	
	return false;
}

function submitQuickPost(threadID)
{
	toggleIndicator();
	var textArea = document.getElementById('replyWindow');
		
	if (textArea.value != '')
	{	
		var dataLine = textArea.value + '__lineDlm__0__lineDlm__' + threadID;
		nd();
		x_ajax_submitPost(dataLine, threadUpdateRunOnce);
			
		return false;
	}	
	
	
	
	return false;
}

function threadUpdateRunOnce()
{
	toggleIndicator();
	nd();
	//var dataLine = new String();
	//var timeStamp = document.getElementById('timestamp');
	//dataLine = timeStamp.className + "::" + jsCurrentUser + "::" + 0;

	//x_ajax_threadUpdate(dataLine, resetThreads);	
}
	

function postUpdateRunOnce(threadID)
{
	
	//overlib('<div id=\'indicator\'></div>', WIDTH, 50, RELY,0,RELX, -1,CSSCLASS,TEXTFONTCLASS,'OLfontClass',FGCLASS,'OLfgClass', BGCLASS,'OLbgClass',CAPTIONFONTCLASS,'OLcapfontClass', CLOSEFONTCLASS, 'OLcapfontClass');
	
	var timeStamp = document.getElementById('lastPostTimeStamp');
	
	var dataLine = new String();
	dataLine = timeStamp.className + "::" + threadID;
	x_ajax_postUpdate(dataLine, appendPosts);
	
	var textArea = document.getElementById('replyWindow');
	textArea.value='';
	textArea.focus();
	startAllowNextPostTimer();

}

function startAllowNextPostTimer()
{	
	var lastPost = new Date();
	lastPost = lastPost.getTime();
	SetCookie("mf_lastPostTime",lastPost,300);
	initAllowNextPostTimer();		
}

function initAllowNextPostTimer()
{
	var lastPost = GetCookie("mf_lastPostTime");
	var replyForm = document.replyForm;
	if (replyForm.replyWindow)
	{
		replyForm.replyWindow.disabled=true;
		replyForm.replySubmit.disabled=true;	
		runAllowNextPostTimer(lastPost);

	}
}

function runAllowNextPostTimer(lastPost)
{	
	var replyForm = document.replyForm;
	if (replyForm.replyWindow)
	{
		var difference = new Date();
		difference = difference.getTime();
		difference = difference - lastPost*1;
		difference = difference / 1000;
		var textArea = document.getElementById('replyWindow');

		var timeLeft = 2 - difference;

		if (timeLeft > 0)
		{		
			textArea.value="You may post again in " + Math.ceil(timeLeft) + " seconds.";
			setTimeout("runAllowNextPostTimer(" + lastPost + ")", 1000);
		}
		else
		{
			textArea.value='';
			replyForm.replyWindow.disabled=false;
			replyForm.replySubmit.disabled=false;		
		}
	}
}

function resetThreads(dataLine)
{
	
	if (document.getElementById)
	{
		
		//var cs = document.getElementById('connectionStatus');
		//cs.innerHTML = jsCheckTimer;
		//jsCheckTimer = (jsCheckTimer * 1) + 1;
		
		var dataLineArray = dataLine.split('!@timeDlm@!');
		var timeStamp = document.getElementById('timestamp');
		timeStamp.className = dataLineArray[0];
		var parent = document.getElementById('parentC');
		var topNode = parent.firstChild;
		
		if (dataLineArray[1] != "false")
		{
			if (windowIsActive != true)
			{
				if (document.getElementById('speaker').className == "speakerOn")
					so.write("flashcontent"); 
					
				blinkTitle(1, 1);
			}
			
			var threadArray = dataLineArray[1].split('!@rcrdDlm@!');
			threadArray.pop();

			for (i=0; i < threadArray.length; i++)
			{
				var recordArray = threadArray[i].split('::!::');
				if (document.getElementById)
				{
					var cNode = document.getElementById('post' + recordArray[0]);
					
					if (cNode != null)
					{
						totalDistance = cNode.offsetTop - topNode.offsetTop;
						moveElement('post'+recordArray[0], escape(recordArray[1]), cNode.offsetTop, 40, totalDistance);
					}
					else
					{
						var parent = document.getElementById('parentC');
						parent.innerHTML = recordArray[1] + parent.innerHTML;
					}
				}
			}
		}
		else
		{		
			//debug('No changes');
		}
		
		

	
	}
	
}

function moveElement(elementName, elementContents, distance, v, totalDistance)
{
	elementContents = unescape(elementContents);
	var parent = document.getElementById('parentC');
	var topNode = parent.firstChild;
	var element = document.getElementById(elementName);
	element.style.position='absolute';
	element.style.width=parent.clientWidth + 'px';
		
				
	if (distance > topNode.offsetTop)
	{		
		element.style.top = distance + 'px';
		
		distanceToGo = distance - topNode.offsetTop;
		var distanceToMove = ((distanceToGo / totalDistance) * v);
		if (distanceToMove < 1)
		{
			distanceToMove = 1;
		}
		
		distance = distance -  distanceToMove;		
		
		setTimeout("moveElement(\'" + elementName + "\', \'" + escape(elementContents) + "\', " + distance + ", " + v + ", " + totalDistance + ")", 10);
	}
	else
	{		
		parent.removeChild(element);		
		parent.innerHTML = elementContents + parent.innerHTML;
	}
}


function changeModLineInitialCall(dataLine)
{

	var modLineArray = dataLine.split('::');	
	
	postTag = new String();
	postTag = "postRating" + modLineArray[0];	
	
	if (document.getElementById)
	{
		var x = document.getElementById(postTag);	
		x.innerHTML="<div class='moderateLine'><b>Processing...</b></div>";
	}
	
	if (modLineArray[3] == "positive")
	{
		sign = '+';
	}
	else
	{
		sign = '-';
	}
	
	overlib('<form name=commentForm action=index.php onSubmit=\"return submitRatingComment(\'' + dataLine + '\');\">  <small style=\'float: left;\'>0.0000</small><small style=\'float: right;\'>' + modLineArray[2] + '</small><br/><div class=\'slider\' id=\'slider-2\' tabIndex=\'1\'><input class=\'slider-input\' id=\'slider-input-2\' name=\'slider-input-2\'/></div>Mod ' + sign + '<input size=5 id=ratingValue name=\'ratingValue\'> points to this post<br/>Reason:<br/><select name=ratingComment><option>Informative<option>Intelligent<option>Funny<option>Well Written<option SELECTED>None<option>Poorly Composed<option>Stupid<option>Off Topic<option>Flame / Troll</select><br/><br/><input type=submit name=ratingSubmit value=Go!></form>', STICKY, LEFT, OFFSETY, 15, WIDTH, 150, BELOW, FGCOLOR, '#f8f8f8', BGCOLOR, '#959596', CELLPAD, 4);


	var s2 = new Slider(document.getElementById("slider-2"),document.getElementById("slider-input-2"));
	
	s2.setMaximum(modLineArray[2] * 1000);
	s2.setMinimum(0);
	s2.setUnitIncrement(1);
												
	s2.onchange = function () {
		document.getElementById('ratingValue').value = s2.getValue() / 1000;

	}												
												
	s2.setValue(modLineArray[2] * 1000);
	
	if (document.getElementById)
	{
		var commentForm = document.commentForm.slider-input-2;
		commentForm.focus();
	}
	
	
	
	
}

function submitRatingComment(dataLine)
{

	
	if (document.getElementById)
	{
		var ratingComment = document.commentForm.ratingComment.value;
		var ratingValue = document.commentForm.ratingValue.value;
	}
		
	
	
	nd(1);
	
	/*if (!(ratingComment == ''))
	{
		dataLine = dataLine + "::" + ratingComment;
		x_ajax_UpdatePostRatingComment(dataLine, updateComment);
	}*/
	
	
	
	return false;
}

function updateComment(result)
{
	//alert(result);
	commentLineArray = result.split('::');
	postTag = new String();
	postTag = "comment" + commentLineArray[0];
	//alert(postTag);
	
	if (document.getElementById)
	{
		var x = document.getElementsByTagName('div');
		
		for (var i=0;i<x.length;i++)
		{
			
			if (x[i].className == postTag)
			{	
				x[i].style.display='block';
				x[i].innerHTML=commentLineArray[1];
				
			}
		}
	}
}

function callAjaxShowEditWindow(rowID)
{
	overlib('<div id=\'indicator\'></div>', WIDTH, 50, RELY,0,RELX, -1,CSSCLASS,TEXTFONTCLASS,'OLfontClass',FGCLASS,'OLfgClass', BGCLASS,'OLbgClass',CAPTIONFONTCLASS,'OLcapfontClass', CLOSEFONTCLASS, 'OLcapfontClass');
	postTag = new String();
	postTag = "postContent" + rowID;
	ratingTag = "postRating"+ rowID;
	if (document.getElementById)
	{
		var x = document.getElementById(postTag);
		x.innerHTML="<b>Processing edit request, please wait...</b>";
		
		var ratingLine;
		
		if (ratingLine = document.getElementById(ratingTag))
		{
			ratingLine.style.display="none";
		}
		
		
	}
	x_ajax_showEditWindow(rowID, updateEditWindow);
	
}

function updateEditWindow(result)
{
	nd();
	resultArray = result.split(':!@:');
	postTag = new String();
	postTag = "postContent" + resultArray[0];
	
	if (document.getElementById)
	{
		var x = document.getElementById(postTag);
		x.innerHTML=resultArray[1];

	}
}

function callAjaxSubmitEdit(rowID)
{
	overlib('<div id=\'indicator\'></div>', WIDTH, 50, RELY,0,RELX, -1,CSSCLASS,TEXTFONTCLASS,'OLfontClass',FGCLASS,'OLfgClass', BGCLASS,'OLbgClass',CAPTIONFONTCLASS,'OLcapfontClass', CLOSEFONTCLASS, 'OLcapfontClass');
	var textAreas = document.getElementsByTagName("textarea");
	textAreaName = new String();
	textAreaName = "editText" + rowID;
	submitVal = new String();
	
	for (var i=0;i<textAreas.length;i++)
	{
		if (textAreas[i].name==textAreaName)
		{
			submitVal = rowID + ":!@:" + textAreas[i].value;
			x_ajax_submitEdit(submitVal, resetEditWindow);
		}
	}
	
	return false;
}

function callAjaxSubmitDelete(rowID)
{	
	overlib('<div id=\'indicator\'></div>', WIDTH, 50, RELY,0,RELX, -1,CSSCLASS,TEXTFONTCLASS,'OLfontClass',FGCLASS,'OLfgClass', BGCLASS,'OLbgClass',CAPTIONFONTCLASS,'OLcapfontClass', CLOSEFONTCLASS, 'OLcapfontClass');
	x_ajax_submitDelete(rowID, resetEditWindow);
	return false;
}

function resetEditWindow(result)
{
	nd();
	resultArray = result.split(':!@:');
	postTag = new String();
	ratingTag = new String();
	postTag = "postContent" + resultArray[0];
	ratingTag = "postRating"+ resultArray[0];
	
	
	if (document.getElementById)
	{
		var x = document.getElementById(postTag);
		x.innerHTML=resultArray[1];
				

		var postRating = document.getElementById(ratingTag);	
		postRating.style.display="block";
	}	
	
}

function callAjaxShowLastPost(rowID, onlyOneNew)
{
	if (document.getElementById)
	{
		//overlib('<div id=\'indicator\'></div>', STICKY, WIDTH, 50, RELY,0,RELX, -1,CSSCLASS,TEXTFONTCLASS,'OLfontClass',FGCLASS,'OLfgClass', BGCLASS,'OLbgClass',CAPTIONFONTCLASS,'OLcapfontClass', CLOSEFONTCLASS, 'OLcapfontClass');
		toggleIndicator();
		
		var dataLine = rowID + ':!@:' + onlyOneNew;
				
		x_ajax_returnLastPost(dataLine, displayLastPost);
		
		if (onlyOneNew == 'true')
		{
			var newNotifier = document.getElementById(rowID + 'newPosts');
			var thread = document.getElementById(rowID + 'newPostsToggle');
			
			newNotifier.innerHTML = '0';
			thread.className = 'noNewPosts';
		}
		
	}
}

function displayLastPost(dataLine)
{
	if (document.getElementById)
	{
		toggleIndicator();
		dataLine = dataLine + '<div onClick=\'javascript: nd();\' class=\'closeButton\'></div>';
		overlib(dataLine, STICKY, WIDTH, 500, ABOVE, LEFT, CSSCLASS,TEXTFONTCLASS,'OLfontClass',FGCLASS,'OLfgClass', BGCLASS,'OLbgClass',CAPTIONFONTCLASS,'OLcapfontClass', CLOSEFONTCLASS, 'OLcapfontClass');
	}
		
}

function SetCookie(cookieName,cookieValue,nDays) {
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+cookieValue
                 + ";expires="+expire.toGMTString();
}

function GetCookie(cookiename) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(cookiename);
 if (index1==-1 || cookiename=="") return ""; 
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length; 
 return cookiestring.substring(index1+cookiename.length+1,index2);
}
	

function toggleLayer(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display=(style2.display=='block')?'none':'block';
		
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function toggleElement(element)
{
	element.style.display=(element.style.display=='block')?'none':'block';
}

function toggleClass(whichLayer)
{
	if (document.getElementById)
	{
		var x = document.getElementsByTagName('div');
		
		for (var i=0;i<x.length;i++)
		{
			
			if (x[i].className == whichLayer)
			{	
				
				x[i].style.display=(x[i].style.display=='block')?'none':'block';
				
			}
		}
	}

	else if (document.all)
	{
		var x = document.getElementsByTagName('div');
		
		for (var i=0;i<x.length;i++)
		{
			
			if (x[i].className == whichLayer)
			{				
				x[i].style.display=(x[i].style.display=='block')?'none':'block';
			}
		}
	}
	else if (document.layers)
	{
		var x = document.getElementsByTagName('div');
		
		for (var i=0;i<x.length;i++)
		{
			
			if (x[i].className == whichLayer)
			{				
				x[i].style.display=(x[i].style.display=='block')?'none':'block';
			}
		}
	}
}



function applyThreshold()
{
	if (document.getElementById)
	{
		var thresholdElement = document.getElementById('thresholdValue');
		var thresholdValue = thresholdElement.value;
		thresholdValue = thresholdValue * 1;
		
		var postListBeginPlaceHolder = document.getElementById('postListBeginPlaceHolder');
		var currentPost = postListBeginPlaceHolder.nextSibling;
		
		while (currentPost.id != 'newPostPlaceHolder')
		{
			//alert(currentPost.id);
			
			var currentPostThresholdValue = document.getElementById(currentPost.id + 'currentNRIvalue');
			currentPostThresholdValue = currentPostThresholdValue.innerHTML;
			currentPostThresholdValue = currentPostThresholdValue * 1;
			
			var thresholdCounter = document.getElementById('thresholdCounter');
			
			if (currentPostThresholdValue < thresholdValue)
			{ 
				if ((currentPost.lastChild.style.display == 'block') || (currentPost.lastChild.style.display == ''))
				{
					thresholdCounter.innerHTML = (thresholdCounter.innerHTML * 1) + 1;
				}
				
				document.getElementById('post' + currentPost.id).style.display='none';
				document.getElementById(currentPost.id + 'hidden').style.display='block';
				document.getElementById(currentPost.id + 'normal').style.display='none';
				
				//currentPost.lastChild.style.display = 'none';
				//currentPost.firstChild.nextSibling.firstChild.style.display = 'block';
				//currentPost.firstChild.nextSibling.firstChild.nextSibling.style.display = 'none';
				
				
			}
			else
			{
				if (currentPost.lastChild.style.display == 'none')
				{
					thresholdCounter.innerHTML = (thresholdCounter.innerHTML * 1) - 1;
				}
				
				document.getElementById('post' + currentPost.id).style.display='block';
				document.getElementById(currentPost.id + 'hidden').style.display='none';
				document.getElementById(currentPost.id + 'normal').style.display='block';				
				
				//currentPost.lastChild.style.display = 'block';
				//currentPost.firstChild.nextSibling.firstChild.style.display = 'none';
				//currentPost.firstChild.nextSibling.firstChild.nextSibling.style.display = 'block';
				
							
			}
			
			currentPost = currentPost.nextSibling;
			
		}
		
	}
	return true;
	
}

function showPost(postID)
{
	if (document.getElementById)
	{
		var thresholdCounter = document.getElementById('thresholdCounter');
		var postToShow = document.getElementById('post' + postID);
		
		if (postToShow.style.display == 'none')
		{
			thresholdCounter.innerHTML = (thresholdCounter.innerHTML * 1) - 1;
		}
		else
		{
			thresholdCounter.innerHTML = (thresholdCounter.innerHTML * 1) + 1;
		}
			
		postToShow.style.display=(postToShow.style.display=='block')?'none':'block';
		document.getElementById(postID + 'hidden').style.display = (document.getElementById(postID + 'hidden').style.display=='none')?'block':'none';
		document.getElementById(postID + 'normal').style.display = (document.getElementById(postID + 'normal').style.display=='block')?'none':'block';
	}
}

function applyThreadThreshold()
{
	startSyncThresholdValue();
	
	if (document.getElementById)
	{		
		var thresholdElement = document.getElementById('thresholdValue');
		var thresholdValue = thresholdElement.value;
		thresholdValue = thresholdValue * 1;
		
		var threadListParent = document.getElementById('parentC');
		
		var currentPost = threadListParent.firstChild;
	
		while (currentPost)
		{
			
			var currentPostThresholdValue = currentPost.firstChild.innerHTML;
			currentPostThresholdValue = currentPostThresholdValue * 1;
			var thresholdCounter = document.getElementById('thresholdCounter');
			
			
			if (currentPostThresholdValue < thresholdValue)
			{
				if ((currentPost.style.display == 'block') || (currentPost.style.display == ''))
				{
					thresholdCounter.innerHTML = (thresholdCounter.innerHTML * 1) + 1;
				}				
				currentPost.style.display = 'none';
				
				
			}
			else
			{
				if (currentPost.style.display == 'none')
				{
					thresholdCounter.innerHTML = (thresholdCounter.innerHTML * 1) - 1;
				}
				currentPost.style.display = 'block';
				
											
			}
			
			currentPost = currentPost.nextSibling;
			
		}
		
	}
	return true;
	
}

function startSyncThresholdValue()
{
	if (document.getElementById)
	{
		var i = document.getElementById('indicator');
		i.style.display='block';
	}
	
	clearTimeout(syncThresholdTimer);
	syncThresholdTimer = setTimeout("execSyncThresholdValue()", 1500);	
}

function execSyncThresholdValue()
{
	if (document.getElementById)
	{
		var thresholdElement = document.getElementById('thresholdValue');
		var thresholdValue = thresholdElement.value;
		thresholdValue = thresholdValue * 1;
		thresholdValue = thresholdValue.toString();
		
		x_ajax_resetThreshold(thresholdValue, displayResetThreads);
	}
}



function validateForm(formName)
{
	
	var returnStr = true;
	if (document.getElementById)
	{
	
		formElement = document.getElementById(formName);
		
		inputArray = formElement.elements;
		
		for ( i=0; i<inputArray.length; i++)
		{
			if (((inputArray[i].value==null) || (inputArray[i].value.length==0) || (inputArray[i].value == "")) && (inputArray[i].id != "toList") && (inputArray[i].id.search('poll') == -1))
			{
				//displayError('Please complete all form fields before proceeding.', formElement.lastChild.id);
				var anchor = document.getElementById(formElement.lastChild.id);
				var errorPane = document.getElementById('errorPane');
				var errorPaneText = document.getElementById('errorPaneText');
				errorPaneText.innerHTML = "<div id='errorImage'></div>Please complete all form fields before proceeding.";
				errorPane.style.opacity = .00
				errorPane.style.display = "block";
				errorPane.style.top = anchor.offsetTop - (errorPane.clientHeight / 2) + "px";
				errorPane.style.left = anchor.offsetLeft + "px";		
				errorPane.style.zIndex = 1;		
				fadeIn('errorPane');
				
				i = 50;
				returnStr = false;
			}
		}
		

	}
	return returnStr;
	
}

function displayError(errorStr, anchorElement)
{
	
	if (document.getElementById)
	{
		anchor = document.getElementById(anchorElement);
		errorPane = document.getElementById('errorPane');
		errorPaneText = document.getElementById('errorPaneText');
		errorPaneText.innerHTML = "<div id='errorImage'></div>" + errorStr;
		alert(document.getElementById('errorPaneText').innerHTML);
		errorPane.style.opacity = .00
		errorPane.style.display = "block";
		errorPane.style.top = anchor.offsetTop - (errorPane.clientHeight / 2) + "px";
		errorPane.style.left = anchor.offsetLeft + "px";		
		errorPane.style.zIndex = 1;		
		fadeIn('errorPane');
	}
}

function closeError()
{
	if (document.getElementById)
	{
	
		var errorPane = document.getElementById('errorPane');
		var errorPaneText = document.getElementById('errorPaneText');
		errorPane.style.display = "none";
		errorPaneText.innerHTML = "";		
					
			
	}
}



function showPosOptions (ID, currentuser, nriDiv, loc, currentuserID)
{
	if (document.getElementById)
	{
		jsCurrentUser = currentuser;
		jsCurrentUserID = currentuserID;
		jsloc = loc;
		var posListArray = posModOptionList.split(':.:');
		
		var dataLine = "<div class='slider' id='slider-" + nriDiv + "' tabIndex='1'><small style='float: left;'>0.0001</small><input class='slider-input' id='slider-input-" + nriDiv + "' name='slider-input-" + nriDiv + "'/><small style='float: right;'>" + document.getElementById(nriDiv + 'value').innerHTML + " </small></div><select style='float:right;'><option>Reason:</option>";
		
		for (var i=0; i < posListArray.length; i++)
		{
			posLineArray = posListArray[i].split('::');
			if (posLineArray[0] != "")
			{
				dataLine = dataLine + "<option onClick=\'javascript: submitModeration(" + posLineArray[0] + ", 1, " + ID + "); return nd();\'>" + posLineArray[1] + "</option>";
			}
		}
		
		dataLine = dataLine + "</select>";
		
		overlib(dataLine, STICKY, CAPTION, 'Positively Moderate:', CLOSECLICK, WIDTH, 350, CENTER, ABOVE, CSSCLASS,TEXTFONTCLASS,'OLfontClass',FGCLASS,'OLfgClass', BGCLASS,'OLbgClass',CAPTIONFONTCLASS,'OLcapfontClass', CLOSEFONTCLASS, 'OLcapfontClass');	
		
		var postSlider = new Slider(document.getElementById("slider-" + nriDiv),document.getElementById("slider-input-" + nriDiv));
		
		var maxNRI = document.getElementById(nriDiv + 'value').innerHTML * 10000;
		
		postSlider.setMaximum(maxNRI);
		postSlider.setMinimum(1);
		postSlider.setUnitIncrement(1);	
		
		postSlider.onchange = function () { document.getElementById(nriDiv).innerHTML = (postSlider.getValue() / 10000); };
		postSlider.setValue(maxNRI);		
		
	}
	
}

function showNegOptions (ID, currentuser, nriDiv, loc, currentuserID)
{
	if (document.getElementById)
	{
		jsCurrentUser = currentuser;
		jsCurrentUserID = currentuserID;
		jsloc = loc;
		var posListArray = negModOptionList.split(':.:');
		var dataLine = "<div class='slider' id='slider-" + nriDiv + "' tabIndex='1'><small style='float: left;'>0.0001</small><input class='slider-input' id='slider-input-" + nriDiv + "' name='slider-input-" + nriDiv + "'/><small style='float: right;'>" + document.getElementById(nriDiv + 'value').innerHTML + " </small></div><select style='float: right;'><option>Reason:</option>";
		
		for (var i=0; i < posListArray.length; i++)
		{
			posLineArray = posListArray[i].split('::');
			if (posLineArray[0] != "")
			{
				dataLine = dataLine + "<option onClick=\'javascript: submitModeration(" + posLineArray[0] + ", 2, " + ID + "); return nd();\'>" + posLineArray[1] + "</option>";
			}
		}
		
		dataLine = dataLine + "</select>";		
		
		overlib(dataLine, STICKY, CAPTION, 'Negatively Moderate:', CLOSECLICK, WIDTH, 350, CENTER, ABOVE, CSSCLASS,TEXTFONTCLASS,'OLfontClass',FGCLASS,'OLfgClass', BGCLASS,'OLbgClass',CAPTIONFONTCLASS,'OLcapfontClass', CLOSEFONTCLASS, 'OLcapfontClass');	
		
		var postSlider = new Slider(document.getElementById("slider-" + nriDiv),document.getElementById("slider-input-" + nriDiv));
		
		var maxNRI = document.getElementById(nriDiv + 'value').innerHTML * 10000;
		
		postSlider.setMaximum(maxNRI);
		postSlider.setMinimum(1);
		postSlider.setUnitIncrement(1);	
		
		postSlider.onchange = function () { document.getElementById(nriDiv).innerHTML = (postSlider.getValue() / 10000); };
		postSlider.setValue(maxNRI);		
	}	
}

function submitModeration(reason, posNeg, ID)
{
	nd();
	if (document.getElementById)
	{
		var amountToMod = document.getElementById(ID + 'currentNRI').innerHTML;
		var dataLine = amountToMod + "::" + reason + "::" + posNeg + "::" + ID + "::" + jsCurrentUser + "::" + jsCurrentUserID;
		x_ajax_ChangePostRating(dataLine, changeModLine);
	}	
}


function changeModLine(result)
{
	
	var modLineArray = result.split('::');
		
	postTag = new String();
	postTag = "postRating" + modLineArray[0];
	
	if (document.getElementById)
	{
		var x = document.getElementById(postTag);
		x.innerHTML="<div class='moderateLine'>" + modLineArray[1] + "</div>";
		x.parentNode.parentNode.parentNode.parentNode.previousSibling.id = modLineArray[2];
		applyThreshold();
		
		
		dataLine = modLineArray[0] + "::NaN";
		x_ajax_UpdatePostRatingComment(dataLine, updateComment);		
	}	
}


function addOption(posNeg)
{
	
	if (document.getElementById)
	{
		var posInputElement = document.getElementById('addNewPosOption');
		
		if (posNeg == 1)
		{
			posInputElement = document.getElementById('addNewNegOption');
		}
		
		var dataline = posNeg + "::" + posInputElement.value;
		x_ajax_addNewModOption(dataline, updateOptionsList);
		posInputElement.value = "";
	}
}

function updateOptionsList(dataline)
{	
	if (document.getElementById)
	{
		var datalineArray = dataline.split('::');
		var optionsList;
		if (datalineArray[0] == "0")
		{
			optionsList = document.getElementById('posOptionsHolder');
		}
		else
		{
			optionsList = document.getElementById('negOptionsHolder');
		}
		
		optionsList.innerHTML = datalineArray[1];
		
	}
}

function chooseGraft(newGraft)
{
	
	x_ajax_changeGraft(newGraft, reloadPage);	
	
}

function reloadPage(retVal)
{
	window.location.reload();
}

function askIfOkay(promptQuestion)
{
	var answer = confirm ( promptQuestion );
	if (answer)
		return true;
	else
		return false;
		
}

function startTimeoutCheck()
{
	if (document.getElementById)
	{
		var cs = document.getElementById('connectionStatus');
		cs.innerHTML = jsCheckTimeout;
		
		jsCheckTimeout = (jsCheckTimeout*1) + 1;
	}
	
	setTimeout("startTimeoutCheck()", 10000);
}

function showSmiles()
{
	//var load = window.open('index.php?shard=smile&action=show','','scrollbars=yes,menubar=no,height=600,width=400,resizable=no,toolbar=no,location=no,status=no');
	x_ajax_show_smiles(1, displayLoadedSmiles);
}

function displayLoadedSmiles(data)
{
	if (document.getElementById)
	{
		document.getElementById('moreSmiliesPane').innerHTML = data;
	}
}


function toggleRatingArrow(location, ID, upDown, amount)
{
	if (document.getElementById)
	{

		
		var ratingHolder = document.getElementById(ID + 'ratingDisplay' + location);		
				
		if (upDown == 'uparrow') // What did they click, uparrow or down arrow?
		{						
			// They clicked the up arrow
			arrow = document.getElementById(ID + 'uparrow' + location);
			otherArrow = document.getElementById(ID + 'downarrow' + location);
			
			if (arrow.className == 'uparrowoff' && otherArrow.className == 'downarrowoff')
			{
				arrow.className = 'uparrowon';
				newRating = (ratingHolder.innerHTML * 1) + amount;
				
				ratingHolder.style.opacity = 0;
				ratingHolder.innerHTML = newRating.toFixed(2);
				ratingHolder.className = gradientSelector(newRating.toFixed(2));
				fadeIn(ID + 'ratingDisplay' + location);
				
				updateModCookie(ID, location, upDown);
				
				if (location == "post")
				{
					
					var options = document.getElementById('posmodoptions' + ID);
					options.style.display='block';					
					var ratingReasonControl = document.getElementById('ratingReasonControl' + ID);
					ratingReasonControl.style.opacity = 0;
					ratingReasonControl.style.display = 'block';
					fadeIn(ratingReasonControl.id);
					
					
				}
			}
			else if (arrow.className =='uparrowoff' && otherArrow.className == 'downarrowon')
			{
				arrow.className = 'uparrowon';
				otherArrow.classname = 'downarrowoff';
				
				newRating = (ratingHolder.innerHTML * 1) + amount * 2;			
				
				ratingHolder.style.opacity = 0;
				ratingHolder.innerHTML = newRating.toFixed(2);
				ratingHolder.className = gradientSelector(newRating.toFixed(2));
				fadeIn(ID + 'ratingDisplay' + location);
				
				updateModCookie(ID, location, 'uparrow');
				updateModCookie(ID, location, 'downarrow');
				
				if (location == "post")
				{
					var options = document.getElementById('posmodoptions' + ID);
					options.style.display='block';		
					var options = document.getElementById('negmodoptions' + ID);
					options.style.display='none';					
					var ratingReasonControl = document.getElementById('ratingReasonControl' + ID);
					ratingReasonControl.style.opacity = 0;
					ratingReasonControl.style.display = 'block';
					fadeIn(ratingReasonControl.id);
				}
			}
			else if (arrow.className == 'uparrowon' && otherArrow.className =='downarrowoff')
			{
				arrow.className = 'uparrowoff';
				newRating = (ratingHolder.innerHTML * 1) - amount;
				ratingHolder.style.opacity = 0;
				ratingHolder.innerHTML = newRating.toFixed(2);
				ratingHolder.className = gradientSelector(newRating.toFixed(2));
				
				fadeIn(ID + 'ratingDisplay' + location);
				
				updateModCookie(ID, location, upDown);
				
				if (location == "post")
				{
					var options = document.getElementById('posmodoptions' + ID);
					options.style.display='none';						
					var ratingReasonControl = document.getElementById('ratingReasonControl' + ID);
					ratingReasonControl.style.display = 'none';
				}
			}
			
			otherArrow.className='downarrowoff';
			
				
			
		}
		else if (upDown == 'downarrow')
		{
			// They clicked the down arrow
			arrow = document.getElementById(ID + 'downarrow' + location);
			otherArrow = document.getElementById(ID + 'uparrow' + location);
			
			if (arrow.className == 'downarrowoff' & otherArrow.className == 'uparrowoff')
			{
				arrow.className = 'downarrowon';
				newRating = (ratingHolder.innerHTML * 1) - amount;
				ratingHolder.style.opacity = 0;
				ratingHolder.innerHTML = newRating.toFixed(2);
				ratingHolder.className = gradientSelector(newRating.toFixed(2));
				fadeIn(ID + 'ratingDisplay' + location);	
				
				updateModCookie(ID, location, upDown);
				
				if (location == "post")
				{
					var options = document.getElementById('negmodoptions' + ID);
					options.style.display='block';						
					var ratingReasonControl = document.getElementById('ratingReasonControl' + ID);
					ratingReasonControl.style.opacity = 0;
					ratingReasonControl.style.display = 'block';
					fadeIn(ratingReasonControl.id);		
				}
			}
			else if (arrow.className =='downarrowoff' && otherArrow.className == 'uparrowon')
			{
				arrow.className = 'downarrowon';
				otherArrow.classname = 'upwnarrowoff';
				
				newRating = (ratingHolder.innerHTML * 1) - amount * 2;				
				
				ratingHolder.style.opacity = 0;
				ratingHolder.innerHTML = newRating.toFixed(2);
				ratingHolder.className = gradientSelector(newRating.toFixed(2));
				fadeIn(ID + 'ratingDisplay' + location);
				
				updateModCookie(ID, location, 'downarrow');
				updateModCookie(ID, location, 'uparrow');
				
				if (location == "post")
				{
					var options = document.getElementById('negmodoptions' + ID);
					options.style.display='block';	
					var options = document.getElementById('posmodoptions' + ID);
					options.style.display='none';					
					var ratingReasonControl = document.getElementById('ratingReasonControl' + ID);
					ratingReasonControl.style.opacity = 0;
					ratingReasonControl.style.display = 'block';
					fadeIn(ratingReasonControl.id);
				}
			}			
			else if (arrow.className == 'downarrowon')
			{
				arrow.className = 'downarrowoff';
				newRating = (ratingHolder.innerHTML * 1) + amount;
				ratingHolder.style.opacity = 0;
				ratingHolder.innerHTML = newRating.toFixed(2);
				ratingHolder.className = gradientSelector(newRating.toFixed(2));
				fadeIn(ID + 'ratingDisplay' + location);
				
				updateModCookie(ID, location, upDown);
				
				if (location == "post")
				{
					var options = document.getElementById('negmodoptions' + ID);
					options.style.display='none';						
					var ratingReasonControl = document.getElementById('ratingReasonControl' + ID);
					ratingReasonControl.style.display = 'none';	
				}
			}
			
			otherArrow.className='uparrowoff';
			
		}
		
		x_ajax_updateMod(ID + ':' + location + ':' + upDown, finishUpdateMod);
		
	}
}

function gradientSelector(value)
{
	if (value < 0) {
		return "postRatingColorGradient3";
	}
	else if (value > 0) {
		return "postRatingColorGradient2";
	}
	else if (value == 0) {
		return "postRatingColorGradient1";
	}
}

function updateModCookie(ID, location, upDown)
{	
	var modList = GetCookie('mf_mod_list');
	var modToAdd = ID + location + upDown + ':';
	
	inthere = false;
	while (modList.indexOf(modToAdd) > 0){
		modList = modList.replace(modToAdd, "");
		inthere = true;
	}
	
	if (!inthere) {
		modList = modList + modToAdd;
	}
	
	SetCookie('mf_mod_list', modList, 300);
}

function submitPostRatingComment(commentID, postID)
{
	if (document.getElementById)
	{
		var ratingReasonControl = document.getElementById('ratingReasonControl' + postID);
		ratingReasonControl.style.display = 'none;';
		
		x_ajax_submitPostRatingComment(commentID + ":::" + postID, updatePostRatingComment);
	}
}

function updatePostRatingComment(data)
{
	if (document.getElementById)
	{
		var arr = data.split(':::');
		var pane = document.getElementById('topcomment' + arr[0]);
		pane.innerHTML = arr[1];
	}
}

function explainRated(ID)
{
	x_ajax_explainRated(ID, showExplainRated);
}

function showExplainRated(data)
{
	if (document.getElementById)
	{
		var arr = data.split(':::');
		var ratedPane = document.getElementById('explainRated' + arr[0]);
		ratedPane.innerHTML = arr[1];
	}
}

function finishUpdateMod(dataline)
{
	
}

function callNewThreadForm()
{
	if (document.getElementById)
	{
		var ph = document.getElementById('newThreadFormPlaceholder');
		if (ph.style.display == "block")
		{
			ph.style.display = "none";
		}
		else if (ph.style.display == "none")
		{
			ph.style.display = "block";
		}
		else
		{
			x_ajax_callNewThreadForm('', showNewThreadForm);
		}
	}
}

function showNewThreadForm(formData)
{
	if (document.getElementById)
	{
		var ph = document.getElementById('newThreadFormPlaceholder');
		ph.innerHTML = formData;
		ph.style.opacity=.00;
		ph.style.display='block';
		fadeIn(ph.id);
	}
}

function toggleDisplay(elementName)
{
	if (document.getElementById)
	{
		var element = document.getElementById(elementName);
		
		if (element.style.display == "none")
		{
			element.style.opacity = .00;
			element.style.display = "block";
			fadeIn(elementName);			
		}
		else if (element.style.display == "block")
		{
			element.style.display="none";
		}
		else
		{
			element.style.opacity = .00;
			element.style.display = "block";
			element.style.position = "relative";
			element.style.visibility = "visible";
			fadeIn(elementName);
		}
	}
}

function updateLastPostMinutes()
{
	if (document.getElementById)
	{
		var elementsToUpdate = document.getElementsByTagName('span');
		
		for (i=0; i<elementsToUpdate.length; i++)
		{
			if (elementsToUpdate[i].className == "updateMinute")
			{
				elementsToUpdate[i].innerHTML = (elementsToUpdate[i].innerHTML * 1) + 1;
			}
		}
		
		setTimeout("updateLastPostMinutes()", 60000);
		
	}
}

function addUserToPthread()
{
	//alert(document.getElementById('add_username').value);
	if (document.getElementById)
	{
		x_ajax_add_new_pthread_user(document.getElementById('add_username').value, updatePthreadUsers);
		document.getElementById('add_username').value = "";
	}
}

function updatePthreadUsers(data)
{
	var dataArray = data.split("::arrdlm::");
	
	if (dataArray[0] == "false")
	{
		displayError(dataArray[1], 'add_username_button');
	}
	else
	{
		if (document.getElementById)
		{
			document.getElementById('listpThreadUsers').innerHTML = dataArray[1];
		}
	}
}

function deletePthreadUser(ID)
{
	x_ajax_delete_pthread_user(ID, updatePthreadUsers);
}


function submitPollVote(ID)
{
	pollChoice = document.forms[ID + "pollChoice"];
	pollChoices = pollChoice.elements;
	
	selected = 'false';
	for (counter = 0; counter < pollChoices.length; counter++)
	{
		if (pollChoices[counter].checked == true)
		{
			selected = pollChoices[counter].value;
		}
	}		
	
	
	document.getElementById('submittingVoteIndicator').style.display = "block";
	
	x_ajax_submit_poll_vote(ID + ":arrdlm:" + selected, updatePoll);
}

function updatePoll(selection)
{
	selection = selection.split(':arrdlm:');
	if (IsNumeric(selection[1]))
	{
		if (document.getElementById)
		{
			document.getElementById('submittingVoteIndicator').style.display='none';
			pollHolder = document.getElementById('pollHolder');
			pollHolder.style.opacity = 0.0;
			pollHolder.innerHTML = selection[2];
			fadeIn('pollHolder');
		}
	}
	else
	{
		document.getElementById('submittingVoteIndicator').style.display='none';
		displayError(selection[1], selection[0] + 'submit');
	}
}
		
		
function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

function showPreview(text, delay, offsetH, offsetV, reference)
{
	if (closePreview())
	{
		if (delay == 0)
		{
			if (document.getElementById)
			{
				preview = document.getElementById('previewPane');
				preview.innerHTML = text;	
				previewPaneDelay = setTimeout("showPreview('blank', 1, " + offsetH + ", " + offsetV + ", '" + reference + "')", 700);
			}
		}
		else
		{
			if (document.getElementById)
			{

				ref = document.getElementById(reference);
				preview = document.getElementById('previewPane');
				offTop = ref.offsetTop + offsetV;
				offLeft = ref.offsetLeft + offsetH;

				if (text != 'blank')
				{
					preview.innerHTML = text;
				}

				preview.style.top = offTop + 'px';
				preview.style.left = offLeft + 'px';
				preview.style.zindex = '1001';
				preview.style.opacity = 0;
				preview.style.display='block';
				fadeIn('previewPane');

			}
		}
	}
}

function closePreview()
{
	if (document.getElementById)
	{
		clearTimeout(previewPaneDelay);
		preview = document.getElementById('previewPane');
		if (preview.style.display == 'block')
		{
			preview.style.display = 'none';
			return false;
		}
		else 
		{
			preview.style.display = 'none';
			return true;
		}
	}
}

function toggleSound()
{
	if (document.getElementById)
	{
		blinger = document.getElementById('speaker');
		blinger.className=(blinger.className=='speakerOn')?'speakerOff':'speakerOn';
		SetCookie('mf_speaker', blinger.className, 300);
	}
}

function subscribe(ID)
{
	if (document.getElementById)
	{
		x_ajax_subscribe(ID, updateSubscribed);
	}
}

function unsubscribe(ID)
{
	if (document.getElementById)
	{
		x_ajax_unsubscribe(ID, updateSubscribed);
	}
}

function updateSubscribed(data)
{
	if (document.getElementById)
	{
		var line = document.getElementById('subscriptionNotification');
		
		line.innerHTML = data;
	}
}

function showChannels()
{
	if (document.getElementById)
	{		
		ref = document.getElementById('channelsAnchor');
		preview = document.getElementById('channelsWindow');
		if (preview.style.display == 'block') {
			preview.style.display = 'none';
		}
		else {
			offTop = ref.offsetTop + 25;
			offLeft = ref.offsetLeft + 0;
			preview.style.top = offTop + 'px';
			preview.style.left = offLeft + 'px';
			preview.style.zindex = '1001';
			preview.style.opacity = 0;
			preview.style.display='block';
			fadeIn('channelsWindow');
		}
	}
}

function modifyChannelFilter(ID)
{
	if (document.getElementById)
	
	{
		var selectedChannel = document.getElementById('channel' + ID);
		
		if (selectedChannel.checked == false)
		{
			// Channel was just unchecked to be filtered, toggle that ho
			selectedChannel.parentNode.parentNode.parentNode.parentNode.className = 'channelListingFiltered';
		}
		else
		{
			// Channel was just checked, to be not-filtered, toggle that ho
			selectedChannel.parentNode.parentNode.parentNode.parentNode.className = 'channelListing';
		}

	}
	
	return true;
}

function modifyChannelFilterExclusive(ID)
{
	if(document.getElementById)
	{
		form=document.forms["channelFilter"];
		channelNodes = form.elements;
		
		for(i=0;i<channelNodes.length;i++)
		{
			if (channelNodes[i].name != ID)
			{
				channelNodes[i].checked = false;
				modifyChannelFilter(channelNodes[i].name);
			}
			else
			{
				channelNodes[i].checked = true;
				modifyChannelFilter(channelNodes[i].name);
			}
		}
	}
}

function applyChannelFilter()
{
	if(document.getElementById)
	{
		form = document.forms["channelFilter"];
		channelNodes = form.elements;


		retStr = '';
		for (i=0;i<channelNodes.length;i++)
		{
			if (channelNodes[i].checked == false)
			{
				retStr += channelNodes[i].name + ',';
			}
		}



		SetCookie('metaChannelFilter', retStr, 60);
	}
	
	showChannels();
	toggleIndicator();	
	
	x_ajax_resetThreadList(1, displayResetThreads);
}

function displayResetThreads(dataline)
{	
	if (document.getElementById)
	{
		dlarray = dataline.split('::arrdlm::');
		
		var parent = document.getElementById('parentC');
		
		parent.innerHTML = dlarray[0];
		
		var pls = document.getElementById('pagesListStr');
		pls.innerHTML = dlarray[2];
		
		toggleIndicator();
	}
}

function resetChannels()
{
	if(document.getElementById)
	{
		form=document.forms["channelFilter"];
		channelNodes = form.elements;
		
		for(i=0;i<channelNodes.length;i++)
		{
			channelNodes[i].checked = true;
			modifyChannelFilter(channelNodes[i].name);
		}
	}
}

function showQQButton(element, buttonID)
{
	if(document.getElementById)
	{
		button = document.getElementById(buttonID);
		if (button.style.visibility == 'hidden')
		{
			button.style.visibility = 'visible';		
			fadeIn(buttonID);
		}
		

	}
	
	
}

function hideQQButton(buttonID)
{
	if(document.getElementById)
	{
		button = document.getElementById(buttonID);
		button.style.visibility='hidden';
		
	}
}

function toggleIndicator()
{
	//if(document.getElementById)
	//{
		//var i = document.getElementById('indicator');
		//if (i.style.display == 'none' || i.style.display == '')
			//i.style.display = 'block';
		//else
			//i.style.display = 'none';
	//}
}