var jsCheckTimeout = 0;
var jsCheckTimer = 0;
var jsCurrentUser;
var jsloc;

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

			count = count + 1;

			setTimeout("blinkTitle(" + state + ", \'" + msg + "\', " + count + ")", 600);


		}
		else
		{
			document.title = msg;
		}
	
}

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

function quickQuote(poster,postID,pCount) {

	qqTag = 'qq' + postID + '.' + pCount;
	
	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";
	}
}

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;
	
	x_ajax_threadUpdate(dataLine, resetThreads);
		
	setTimeout("threadUpdate(\'" + user + "\')", 10000);
}

function runOnce(user)
{
	applyThreadThreshold();
	setTimeout("threadUpdate(\'" + user + "\')", 1000);
	//startTimeoutCheck();
}

function runThreadWatcherOnce(threadID)
{
	applyThreshold();
	setTimeout("postUpdate(" + threadID + ")", 1000);
	initAllowNextPostTimer();
}

function pt_runThreadWatcherOnce(threadID)
{
	setTimeout("postUpdate(" + threadID + ")", 1000);
	initAllowNextPostTimer();
	
}

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")
	{
		blinkTitle(1, document.title, 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);
				}
				
			}
		}
		
	}
	
	nd();
	
	
}



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

function submitPost(channelTag, threadID)
{
	
	var textArea = document.getElementById('replyWindow');
	
	
	
	if (textArea.value != '')
	{		
		overlib('<div id=\'indicator\'></div>', WIDTH, 50, RELY,0,RELX, -1,CSSCLASS,TEXTFONTCLASS,'OLfontClass',FGCLASS,'OLfgClass', BGCLASS,'OLbgClass',CAPTIONFONTCLASS,'OLcapfontClass', CLOSEFONTCLASS, 'OLcapfontClass');
		var dataLine = textArea.value + '__lineDlm__' + channelTag + '__lineDlm__' + threadID;
		
		
		
		x_ajax_submitPost(dataLine, postUpdateRunOnce);
		
		
		
		var replyForm = document.replyForm;
		replyForm.replyWindow.disabled=true;
		replyForm.replySubmit.disabled=true;
		
		
		
		
	}	
	
	return false;
}

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;
	replyForm.replyWindow.disabled=true;
	replyForm.replySubmit.disabled=true;	
	runAllowNextPostTimer(lastPost);
}

function runAllowNextPostTimer(lastPost)
{	
	var replyForm = document.replyForm;
	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")
		{
			blinkTitle(1, document.title, 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 = 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 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');
		
		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 = '';
			thread.className = 'noNewPosts';
		}
		
	}
}

function displayLastPost(dataLine)
{
	if (document.getElementById)
	{
		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 modifyChannelFilter(ID)
{
	if (document.getElementById)
	
	{
		var selectedChannel = document.getElementById('channel' + ID);
		
		if (selectedChannel.checked == true)
		{
			// Channel was just checked to be filtered, toggle that ho
			selectedChannel.parentNode.parentNode.parentNode.parentNode.className = 'channelListingFiltered';
		}
		else
		{
			// Channel was just unchecked, to be not-filtered, toggle that ho
			selectedChannel.parentNode.parentNode.parentNode.parentNode.className = 'channelListing';
		}

		form = document.forms["channelFilter"];
		channelNodes = form.elements;


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



		SetCookie('metaChannelFilter', retStr, 60);
	}
	
	return true;
}

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+"="+escape(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 unescape(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";
	}
	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 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 = currentPost.lastChild.firstChild.id;
			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;
				}
				
				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;
				}
				
				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';		
	}
}

function applyThreadThreshold()
{
		
	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 validateForm(formName)
{
	
	returnStr = true;
	if (document.getElementById)
	{
	
		formElement = document.getElementById(formName);
		
		inputArray = formElement.elements;
		
		for ( i=0; i<inputArray.length; i++)
		{			
			if (inputArray[i].value == "")
			{
				displayError('Please complete all form fields before proceeding.');
				i = 50;
				returnStr = false;
			}
		}
		

	}
	
	return returnStr;
	
}

function displayError(errorStr)
{
	
	if (document.getElementById)
	{
		errorPane = document.getElementById('errorPane');		
		errorPane.innerHTML = "<div id='errorImage'></div>" + errorStr;		
		errorPane.style.display = "block";
		errorPane.style.zIndex = 1;
		
		
		setTimeout("closeError()", 3000);
	}
}

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



function showPosOptions (ID, currentuser, nriDiv, loc)
{
	if (document.getElementById)
	{
		jsCurrentUser = currentuser;
		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)
{
	if (document.getElementById)
	{
		jsCurrentUser = currentuser;
		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 + "::" + jsloc;
		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');
}


		
		
		

