
// bbCode control by
// subBlue design
// www.subBlue.com

// Startup variables
var imageTag = false;
var theSelection = false;
var postQuoteHtml = new Array();

// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version

var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_moz = 0;

var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);

// Define the bbCode tags
bbcode = new Array();
bbtags = new Array('[b]','[/b]','[i]','[/i]','[u]','[/u]','[s]','[/s]','[link=http://]','[/link]','[img]','[/img]','[color=','[/color]', '[spoiler]', '[/spoiler]');
imageTag = false;
bbtagsTemp = bbtags[12];

// Replacement for arrayname.length property
function getarraysize(thearray) {
	for (i = 0; i < thearray.length; i++) {
		if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
			return i;
		}
	return thearray.length;
}

// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
	thearray[ getarraysize(thearray) ] = value;
}

// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
	thearraysize = getarraysize(thearray);
	retval = thearray[thearraysize - 1];
	delete thearray[thearraysize - 1];
	return retval;
}

/*
function checkForm() {

	formErrors = false;

	if (document.post.message.value.length < 2) {
		formErrors = "You must enter a message when posting.";
	}

	if (formErrors) {
		alert(formErrors);
		return false;
	} else {
		bbstyle(-1);
		//formObj.preview.disabled = true;
		//formObj.submit.disabled = true;
		return true;
	}
}*/

function emoticon(text, theArea) {
	if (theArea) {
		var txtarea = theArea;
	} else {
		var txtarea = document.post.body;
	}
	text = '[' + text + ']';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} else if (!is_mac && !is_ie) {
		mozWrap(txtarea, text, '');
		txtarea.focus();
	} else {
		txtarea.value += text;
	}
}

/*
function bbfontstyle(bbopen, bbclose) {
	var txtarea = document.post.message;

	if ((clientVer >= 4) && is_ie && is_win) {
		theSelection = document.selection.createRange().text;
		if (!theSelection) {
			txtarea.value += bbopen + bbclose;
			txtarea.focus();
			return;
		}
		document.selection.createRange().text = bbopen + theSelection + bbclose;
		txtarea.focus();
		return;
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbopen, bbclose);
		return;
	}
	else
	{
		txtarea.value += bbopen + bbclose;
		txtarea.focus();
	}
	storeCaret(txtarea);
}
*/

function bbstyle(bbnumber, col, elem, pid) {
	// Color.
	if (col) {
		bbtags[bbnumber] = bbtagsTemp + col + ']';
	} else if (bbnumber == 12) {
		bbtags[bbnumber] = bbtagsTemp + ']';
	}
	if (!bbcode[pid]) {
		bbcode[pid] = new Array();
	}
	
	var txtarea = elem ? elem : document.post.body;

	txtarea.focus();
	donotinsert = false;
	theSelection = false;
	bblast = 0;

	if (bbnumber == -1) { // Close all open tags & default button names
		while (bbcode[pid][0]) {
			butnumber = arraypop(bbcode[pid]) - 1;
			txtarea.value += bbtags[butnumber + 1];
			buttext = eval('document.post' + pid + '.addbbcode' + butnumber + pid + '.value');
			eval('document.post' + pid + '.addbbcode' + butnumber + pid + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
		}
		imageTag = false; // All tags are closed including image tags :D
		txtarea.focus();
		return;
	}

	if ((clientVer >= 4) && is_ie && is_win)
	{
		theSelection = document.selection.createRange().text; // Get text selection
		if (theSelection) {
			// Add tags around selection
			document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
			txtarea.focus();
			theSelection = '';
			if (col) {
				bbcolorReturn();
			}
			return;
		}
	}
	else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0))
	{
		mozWrap(txtarea, bbtags[bbnumber], bbtags[bbnumber+1]);
		if (col) {
			bbcolorReturn();
		}
		return;
	}

	// Find last occurance of an open tag the same as the one just clicked
	for (i = 0; i < bbcode[pid].length; i++) {
		if (bbcode[pid][i] == bbnumber+1) {
			bblast = i;
			donotinsert = true;
		}
	}

	if (donotinsert) {		// Close all open tags up to the one just clicked & default button names
		while (bbcode[pid][bblast]) {
				butnumber = arraypop(bbcode[pid]) - 1;
				txtarea.value += bbtags[butnumber + 1];
				buttext = eval('document.post' + pid + '.addbbcode' + butnumber + pid + '.value');
				eval('document.post' + pid + '.addbbcode' + butnumber + pid + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
				imageTag = false;
			}
			txtarea.focus();
			return;
	} else { // Open tags

		if (imageTag && (bbnumber != 10)) {		// Close image tag before adding another
			txtarea.value += bbtags[11];
			lastValue = arraypop(bbcode[pid]) - 1;	// Remove the close image tag from the list
			eval('document.post' + pid + '.addbbcode10'+pid+'.value = "img"');	// Return button back to normal state
			imageTag = false;
		}

		// Open tag
		txtarea.value += bbtags[bbnumber];
		if ((bbnumber == 10) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
		arraypush(bbcode[pid],bbnumber+1);
		eval('document.post' + pid + '.addbbcode'+bbnumber+pid+'.value += "*"');
		txtarea.focus();
		return;
	}
	storeCaret(txtarea);
}

function bbcolor(bbnumber) {
	var col = document.post['addbbcode' + bbnumber].value;
	colorSelect = document.getElementById('bbcolor').innerHTML;
	document.getElementById('bbcolor').innerHTML = "<input class='button' type='button' name='addbbcode12' value='color' style='width:80px;' onClick='bbstyle(12);bbcolorReturn()' />";
	bbstyle(bbnumber, col);
}

function bbcolorReturn() {
	document.getElementById('bbcolor').innerHTML = colorSelect;
}

// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2)
		selEnd = selLength;

	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}

// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function replyTo(un, pid) {
	var txtarea = document.post.body;
	txtarea.focus();
	if (pid > 0) {
		txtarea.value+="[i]In reply to "+un+", #"+pid+":[/i]\n\n";
	}
	return false;
}

function setReply(id, uid, user) {
	var txtarea = document.post.body;
	txtarea.focus();
	document.post.replyId.value = id;
	document.post.replyUid.value = uid;
	document.getElementById('replyPreview').innerHTML = '<span style=\'cursor:default;\'>...</span><a style=\'font-size:inherit;\' href=\'/forum/viewPost.php?id=' + id + '\' onclick=\'forumPostLightbox("' + id + '");return false;\' class=\'light\'>in reply to <b>' + user + '</b></a><span style=\'cursor:default;\'> &nbsp;</span><a href=\'javascript:;\' onclick=\'document.post.replyId.value="";document.post.replyUid.value="";document.getElementById("replyPreview").innerHTML="";\' class=\'user\' style=\'font-size:11px;\'>x</a>';

	$("a.doLightbox").fancybox({
		"overlayColor" : "#000",
		"width" : 640,
		"speedOut" : 100 
	});

	return false;
}

function forumPostLightbox(id) {
	if ($.fancybox) {
		$.fancybox.close();
	}
	$.fancybox({"href" : "/forum/postLightbox.php?id=" + id, "overlayColor" : "#000","width" : 640,"speedOut" : 100});
}

function quotePost(un, pid, num) {
	var txtarea = document.post.body;
	txtarea.focus();
	if (pid > 0) {
		txtarea.value+="[i]In reply to "+un+", #"+pid+":[/i]\n\n";
	}
	txtarea.value += "[quote]" + postQuoteHtml[num] + "[/quote]\n";
	return false;
}

k=document;
pansOn=2;
countdownOn=0;
countdownIntervalId=0;
chatMax=0;
if (!topNavPos) {
	topNavPos = 120;
}
chatShown=new Array();
function lim(tf, m) {
	if (tf.value.length + 1 >= m) {
		tf.value = tf.value.substring(0, m);
	}
}
boxes = new Array();
function changeState(id) {
	q = k.getElementById(id);
	if (!boxes[id]) {
		boxes[id] = q.innerHTML;
		q.innerHTML = '';
		k['img_' + id].src = '/assets/images/smallBullet.gif';
	}
	else {
		q.innerHTML = boxes[id];
		boxes[id] = false;
		k['img_' + id].src = '/assets/images/smallBulletDown.gif';
	}	
}
var z = new Array();
function addImage(id, img) {
	var tmp = new Image();
	tmp.src = img;
	tmp.onLoad = setTimeout("_addImage('" + id + "', '" + img + "', '" + tmp +"')", 25);
}
function _addImage(id, img, tmp) {
	var len = z.length;
	z[len] = new Array(id,img,tmp);
	var string = z[len][1];
	var name = string.substring(string.lastIndexOf('/')+1, string.length);
	z[len][3] = destSize(len);
	z[len][4] = name;
	hideImage(len);
}
function destSize(i) {
	var w = 540;
	var h = 600;
	var dRatio = w/h;
	var destSize = new Array();	
	if (z[i][2].width < w && z[i][2].height < h) {
		destSize[0] = z[i][2].width;
		destSize[1] = z[i][2].height;
	}
	else {
		srcRatio = z[i][2].width / z[i][2].height;
		if (dRatio > srcRatio) {
			destSize[1] = h;
			destSize[0] = h * srcRatio;
		} 
		else {
			destSize[0] = w;
			destSize[1] = w / srcRatio;
		}
	}
	return destSize;
}
function viewImage(i) {
	var q = k.getElementById(z[i][0]);
	q.innerHTML = "<div onClick='javascript:hideImage(" + i + ")' style='cursor:pointer;width:" + (Math.round(z[i][3][0])+2) + ";background:#fff;border:1px solid #000;border-bottom:0;height:16px;padding-left:2px;'><img src='/assets/images/close.gif' /> " + z[i][4] + "</div>";
	q.innerHTML += "<div style='width:" + (Math.round(z[i][3][0])+2) + ";height:" + (Math.round(z[i][3][1])+2) + ";background:#fff;border:1px solid #000;border-top:0;padding-left:2px;'><a target='_blank' href='" + z[i][1] + "'><img width='" + Math.round(z[i][3][0]) + "' height='" + Math.round(z[i][3][1]) + "' src='" + z[i][1] + "' border='0' /></a></div>";
}
function hideImage(i) {
	var q = k.getElementById(z[i][0]);
	q.innerHTML = "<div onClick='javascript:viewImage(" + i + ")' style='cursor:pointer;width:" + (Math.round(z[i][3][0])+2) + ";background:#fff;border:1px solid #000;height:16px;padding-left:2px;'><img src='/assets/images/expand.gif' /> " + z[i][4] + "</div>";
}

function imageMouseover(i) {
	var q = k.getElementById(['over_'+i]).style;
	q.display = "block";
}

function imageMouseout(i) {
	var q = k.getElementById(['over_'+i]).style;
	q.display = "none";
}

// Hilite messaging.
function liteOver(pid, def, v) {
	k.getElementById("td" + pid).style.backgroundColor = v ? '#d9e1ec' : '#' + def;
}
function liteClick(pid) {
	k.modify[pid].checked = !k.modify[pid].checked;
}

// New stuff by the totally cool and sexy Ben

function addaPoll() {
	var el = k.getElementById("addapoll");
	var e2 = k.getElementById("addpolllink");
	if (el.style.display != 'none') {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
	return false;
}

function addPollAnswer() {
	pansOn++;
	var el = k.getElementById("an"+pansOn);
	if(el) {
	el.style.display='';
	}
	if(pansOn == 10) {
	k.getElementById('addAnswer').style.display='none';
	}
	return false;
}

function showFiltered(id) {
	var p=k.getElementById('tdcom'+id);
	var d=k.getElementById('divid'+id);
	var p2=k.getElementById('filnote'+id);
	var d2=k.getElementById('fildiv'+id);

	p.style.display='table-cell';
	d.style.display='block';
	p2.style.display='none';
	d2.style.display='none';
		
	return false;
}

function videoEmbed(ob, width, height, file, episodeNum, episode, clicktext, more, store, autoplay, epsid, epid) {
	var so = new SWFObject("/archive/RT_player_int.swf", ob, width, height, "9.0.115");
	var flashMajor = deconcept.SWFObjectUtil.getPlayerVersion().major;
	if(!flashMajor) {
		k.getElementById(ob).innerHTML='<embed src="'+file+'" width="'+width+'" height="'+height+'" pluginspage="http://www.apple.com/quicktime/"></embed>';
		return;	
	}
	if(autoplay) {
		so.addVariable("autostart", true);
	}
	so.addVariable("file", file);
	so.addVariable("width", width);
	so.addVariable("height", height);
	so.addVariable("episodeNum", episodeNum);
	so.addVariable("episode", episode);
	so.addVariable("clicktext", clicktext);
	so.addVariable("more", more);
	so.addVariable("store", store);
	so.addVariable("showfsbutton", "true");
	so.addVariable("showdigits", "false");
	so.addVariable("linkfromdisplay", "true");
	so.addVariable("repeat", "list");
	so.addVariable("backcolor","0x333333");
	so.addVariable("frontcolor","0xEEEEEE");
	so.addVariable("lightcolor","0xFFFFFF");
	so.addVariable("showdownload","true");
	so.addVariable("stretching","fill");
	so.addVariable("callback","/archive/callback.php?info="+epsid+"-"+epid);
	so.addParam("allowfullscreen", "true");
	so.addParam("wmode", "transparent");
	so.useExpressInstall("/expressinstall.swf");
	so.write(ob);
}

function jumpPost(n, p) {
	var newPage=Math.ceil(n / 30);
	if(newPage == p) {
		window.location.hash='#t'+n;
		return false;
	} else {
		return true;
	}
}

// PHP helper functions
function rawurlencode(str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Brett Zamir (http://brettz9.blogspot.com)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brettz9.blogspot.com)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Michael Grier
    // +   bugfixed by: Brett Zamir (http://brettz9.blogspot.com)
    // *     example 1: rawurlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin%20van%20Zonneveld%21'
    // *     example 2: rawurlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: rawurlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
 
    var histogram = {}, tmp_arr = [];
    var ret = str.toString();
 
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
 
    // The histogram is identical to the one in urldecode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A'; 
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['\u20AC'] = '%80';
    histogram['\u0081'] = '%81';
    histogram['\u201A'] = '%82';
    histogram['\u0192'] = '%83';
    histogram['\u201E'] = '%84';
    histogram['\u2026'] = '%85';
    histogram['\u2020'] = '%86';
    histogram['\u2021'] = '%87';
    histogram['\u02C6'] = '%88';
    histogram['\u2030'] = '%89';
    histogram['\u0160'] = '%8A';
    histogram['\u2039'] = '%8B';
    histogram['\u0152'] = '%8C';
    histogram['\u008D'] = '%8D';
    histogram['\u017D'] = '%8E';
    histogram['\u008F'] = '%8F';
    histogram['\u0090'] = '%90';
    histogram['\u2018'] = '%91';
    histogram['\u2019'] = '%92';
    histogram['\u201C'] = '%93';
    histogram['\u201D'] = '%94';
    histogram['\u2022'] = '%95';
    histogram['\u2013'] = '%96';
    histogram['\u2014'] = '%97';
    histogram['\u02DC'] = '%98';
    histogram['\u2122'] = '%99';
    histogram['\u0161'] = '%9A';
    histogram['\u203A'] = '%9B';
    histogram['\u0153'] = '%9C';
    histogram['\u009D'] = '%9D';
    histogram['\u017E'] = '%9E';
    histogram['\u0178'] = '%9F';
 
 
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
 
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }
 
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
 
    return ret;
}

// Ajax, bitches.
function loadXMLDoc(url) {
	document.body.className = 'waiting';
	if (window.XMLHttpRequest) {
		//alert('window.XMLHttpRequest');
		req = new XMLHttpRequest();
		//alert('object made');
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		//alert('object opened');
		req.send(null);
		//alert('sent');
	}
	else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChange;
			req.open("GET", url);
			req.send();
		}
	}
}
function loadQuickSearch() {
	document.body.className = 'waiting';
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = retrieveQuickSearch;
		req.open("GET", "/_getQuickSearch.php", true);
		req.send(null);
	}
	else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = retrieveQuickSearch;
			req.open("GET", "/_getQuickSearch.php");
			req.send();
		}
	}
}
function loadPage(url, changeHash) {
	document.body.className = 'waiting';
	if (url.indexOf('?')) {
		newUrl = url + '&ajaxRequest=1';
	} else {
		newUrl = url + '?ajaxRequest=1';
	}
	if (changeHash) {
		window.location.hash = url;
	}
	if (window.XMLHttpRequest) {
		//alert('window.XMLHttpRequest');
		req = new XMLHttpRequest();
		//alert('object made');
		req.onreadystatechange = processPageReqChange;
		req.open("GET", newUrl, true);
		//alert('object opened');
		req.send(null);
		//alert('sent');
		//document.getElementById('loadPageWait').style.display = 'block';
	}
	else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processPageReqChange;
			req.open("GET", newUrl);
			req.send();
			//document.getElementById('loadPageWait').style.display = 'block';
		}
	}
	return false;
}
function processReqChange() {
	if (req.readyState == 4) {
		document.body.className = '';
		if (req.status == 200) {
			//alert('processReqChange finished');
			var tarr = req.responseText.split('&');
			var rarr = new Array();
			for (var i = 0; i < tarr.length; i++) {
				var t = tarr[i].split('=');
				rarr[t[0]] = unescape(t[1]);
			}
			if (rarr['method']) {
				eval(rarr['method'] + '(rarr)');
			}
		}
	}
}
function processPageReqChange() {
	if (req.readyState == 4) {
		document.body.className = '';
		if (req.status == 200) {
			//alert('processReqChange finished');
			if (k.getElementById('sidebar')) {
				var side = k.getElementById('sidebar').innerHTML;
			}
			var tarr = req.responseText;
			k.getElementById('pageContent').innerHTML = tarr;
			if (side) {
				k.getElementById('sidebar').innerHTML = side;
			}
			//document.getElementById('loadPageWait').style.display = 'none';
			//window.scrollTo(0, 0);
		}
		else {
			alert('Error: ' + req.statusText + ' / ' + req.status);
		}
	}
}
// Functions using Ajax.
function retrieveQuickSearch() {
	if (req.readyState == 4) {
		document.body.className = '';
		if (req.status == 200) {
			//alert('processReqChange finished');
			var tarr = req.responseText;
			if (!searchAuto) {
				eval(tarr);
			}
		}
	}
}

function updateMod(table, id, mod) {
	if (mod == -1) {
		return;
	}
	loadXMLDoc('/modPostAjax.php?table=' + table + '&id=' + id + '&mod=' + mod);
}
function refreshChat() {
	if (req.readyState == 4 || req.readyState == 0) {
		var start = chatMax;
		if (!start) {
			start = '0';
		}
		loadXMLDoc('/live/chatAjax.php?start=' + start);
	}
}
function refreshChatSlow() {
	if (req.readyState == 4 || req.readyState == 0) {
		var start = chatMax;
		if (!start) {
			start = '0';
		}
		loadXMLDoc('/live/chatAjax.php?slow=1&start=' + start);
	}
}
function loadChat() {
	loadXMLDoc('/live/chatAjax.php?jumpDown=1&start=0');
	var f = k.getElementById('liveChat');
	f.scrollTop = f.scrollHeight;
}
function postChat(body) {
	loadXMLDoc('/live/chatPost.php?body=' + rawurlencode(body));
}
function chatPostEnable() {
	k.getElementById('chatPostBody').disabled = false;
	k.getElementById('chatPostBody').style.backgroundColor = '#fff';
	document.forms[1].chatPostBody.value = '';
}
function chatPostDisable() {
	k.getElementById('chatPostBody').disabled = true;
	k.getElementById('chatPostBody').style.backgroundColor = '#f4f4f4';
	document.forms[1].chatPostBody.value = 'Please wait...';
	window.setTimeout('chatPostEnable()', 4000);
}
function refreshLiveSchedule() {
	loadXMLDoc('/live/index.php?ajaxSchedule=1');
}
function refreshMeWatchingLive() {
	loadXMLDoc('/live/updateWatching.php');
}
function refreshLiveCount() {
	loadXMLDoc('/live/liveCount.php');
}
function updateCheckTitle(fid, title) {
	if (!title) {
		k.getElementById('titleCheckField').innerHTML = '';
		return;
	}
	loadXMLDoc('/checkTitleAjax.php?fid=' + fid + '&title=' + title);
}
function updateLiveSchedule(result) {
	k.getElementById('scheduleData').innerHTML = unescape(result['data']);
}
function updateChat(result) {
	if (result['max'] > 0) {
		chatMax = result['max'];
	}
	delete result['method'];
	delete result['max'];
	var f = k.getElementById('liveChat');
	if (f.innerHeight) {
		var height = f.innerHeight;
	} else {
		var height = f.scrollHeight;
	}
	var scrollPos = ((parseInt(height) - parseInt(f.offsetHeight)) - 60);
	if (scrollPos < f.scrollTop || result['jumpDown']) {
		var jumpDown = true;
	} else {
		var jumpDown = false;
	}
	delete result['jumpDown'];
	
	for (var x in result) {
		if (!chatShown[x]) {
			chatShown[x] = 1;
			var post = result[x].split('>');
			post[3] = unescape(post[3]);
			var newDiv = document.createElement('div');
			if (post[2] > 0) {
				classMain = ' class="colorAccent"';
				sponsStar = ' <img src=\'http://s3.roosterteeth.com/assets/style/web2/newStar.png\' width=\'11\' height=\'9\' style=\'float:none;\'>';
			} else {
				classMain = '';
				sponsStar = '';
			}
			if (post[4] > 2) {
				classPost = ' class="chatMod"';
				newDiv.className = 'chatModDiv';
			} else {
				classPost = ' class="chatNormal"';
			}
			newDiv.innerHTML = '<a target=\'_blank\' href=\'/' + post[1].toLowerCase() + '\'' + classMain + '><b>' + post[1] + '</b></a>' + sponsStar + ' &nbsp;<span style=\'font-weight:bold;font-size:11px;color:#ccc;\'>&#8212;</span>&nbsp; <span' + classPost + '>' + post[3] + '</span>';
			f.appendChild(newDiv);
			if (f.innerHeight) {
				var height = f.innerHeight;
			} else {
				var height = f.scrollHeight;
			}
			if (jumpDown) {
				f.scrollTop = height;
			}
		}
	}
}

function updateLiveCount(result) {
	k.getElementById('liveCount').innerHTML = result['str'];
}

function updateModReturn(result, itWasntMe) {
	if (!result) {
		alert('Refresh page please.  Currently debugging.');	
	}
	if (result['error']) {
		if(result['error'] == 'invalid:floodcontrol') {
			k.getElementById('mod' + result['id']).innerHTML = 'Flood Control';
		} else {
			k.getElementById('mod' + result['id']).innerHTML = 'Invalid';
		}
	}
	else {
		var fmod = k.getElementById('fontmod' + result['id']);
		if (fmod) {
			fmod.innerHTML = '<b>Mod Breakdown</b><br />' + result['modShowMouseOver'];
		}
		k.getElementById('mod' + result['id']).innerHTML = result['modShow'];
	}
	var sep = k.getElementById('mod' + result['id'] + 'Sep');
	if (sep) {
		sep.style.display = 'inline';
	}
	var formSep = k.getElementById('lightModFormText' + result['a'] + result['id']);

	if (formSep) {
		formSep.style.display = 'none';
	}

	if (!itWasntMe) {
		document.getElementById('select' + result['id']).blur();
		document.getElementById('select' + result['id']).disabled=true;
	}
}
function updateCheckTitleReturn(result) {
	if (!result || result['id'] == 0) {
		k.getElementById('titleCheckField').innerHTML = '';
		return;	
	}
	k.getElementById('titleCheckField').innerHTML = '<b>Warning!</b> This forum already has a topic with a similar title: <a href=\'/forum/viewTopic.php?id='+result['id']+'\' target=\'_blank\' class=\'small\'><b>'+unescape(result['title'])+'</b></a>';
}
var req;

function getHash() {
	var hash = window.location.hash;
	if (hash) {
		return hash.substring(1);
	}
	return false;
}
var thisPageHash = getHash();
if (thisPageHash) {
	if (thisPageHash.substring(0, 1) == '/') {
		window.location.href = thisPageHash;
	}
}
function toggleMoreSeasons() {
	var a = document.getElementById('moreSeasonsLink');
	var b = document.getElementById('moreSeasonsBox');
	if (b.style.display == 'none') {
		a.className = 'archiveMenu aMSel';
		b.style.display = 'table-cell';
	} else {
		a.className = 'archiveMenu';
		b.style.display = 'none';
	}
	return false;
}
function countdown(num, redirUrl, embedHtml, embedJs) {
	countdownOn = num;
	countdownRedir = redirUrl;
	countdownEmbedHtml = embedHtml;
	countdownEmbedJs = embedJs;
	updateCountdown();
	countdownIntervalId = setInterval('updateCountdown()', 1000);
}
function updateCountdown() {
	if (countdownOn < 0) {
		countdownOn = 0;
		if (countdownEmbedHtml) {
			clearInterval(countdownIntervalId);
			document.getElementById('countdownJs').innerHTML = '';
			document.getElementById('countdownInsert').innerHTML = countdownEmbedHtml;
			document.getElementById('countdownInsert').style.padding = 0;
			if (countdownEmbedJs) {
				var toDo = eval('(' + countdownEmbedJs + ')');
				eval(toDo);
			}
			return true;
		} else if (countdownRedir) {
			clearInterval(countdownIntervalId);
			window.location = countdownRedir;
			return true;
		}
	}
	var num = countdownOn;
	var days = Math.floor(num / 86400);
	var hrs = Math.floor((num - (days * 86400)) / 3600);
	var mins = Math.floor((num - (days * 86400) - (hrs * 3600)) / 60);
	var secs = Math.floor(num - (days * 86400) - (hrs * 3600) - (mins * 60));
	document.getElementById('countdownJs').innerHTML = (days ? '<span class=\'countdownNum\'>' + days + '</span> day' + (days == 1 ? '' : 's') + ' &nbsp;' : '') + (hrs || days ? '<span class=\'countdownNum\'>' + hrs + '</span> hour' + (hrs == 1 ? '' : 's') + ' &nbsp;' : '') + (mins || hrs || days ? '<span class=\'countdownNum\'>' + mins + '</span> minute' + (mins == 1 ? '' : 's') + ' &nbsp;' : '') + '<span class=\'countdownNum\'>' + secs + '</span> second' + (secs == 1 ? '' : 's');
	countdownOn--;
}

// New functions for quick search

var updatedNavPos, scrollFixed;

document.onkeydown = checkKeycode
function checkKeycode(e) {
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
if (keycode == 38 || keycode == 40 || keycode == 13) {
	var elem = document.getElementById('searchDrop');
	if (elem.style.visibility == 'visible') {
		searchKeyNav(keycode, e);
	}
}
}

function stopEvent(e) {
	if(!e) var e = window.event;
	
	//e.cancelBubble is supported by IE - this will kill the bubbling process.
	e.cancelBubble = true;
	e.returnValue = false;

	//e.stopPropagation works only in Firefox.
	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	}
	return false;
}

var searchKeyOn = 0;
function searchKeyNav(keycode, e) {
	var elem = document.getElementById('searchDrop');
	var si = document.getElementById('searchInput');
	if (keycode == 38) {
		if (searchKeyOn != 0) {
			si.blur();
			document.getElementById('searchA' + searchKeyOn).className = '';
			searchKeyOn = searchKeyOn - 1;
			if (document.getElementById('searchA' + searchKeyOn)) {
				document.getElementById('searchA' + searchKeyOn).className = 'hi';
			} else {
				searchKeyOn = 0;
			}
		}
		if (searchKeyOn == 0) {
			si.focus();
			setCaretTo(si, si.value.length);
			if (document.getElementById('searchA1')) {
				document.getElementById('searchA1').className = '';
			}			
		}
		stopEvent(e);
	} else if (keycode == 40) {
		si.blur();
		if (document.getElementById('searchA' + (searchKeyOn + 1))) {
			if (searchKeyOn != 0) {
				document.getElementById('searchA' + searchKeyOn).className = ''; 
			}
			searchKeyOn = searchKeyOn + 1;
			if (document.getElementById('searchA' + searchKeyOn)) {
				document.getElementById('searchA' + searchKeyOn).className = 'hi';
			} else {
				searchKeyOn = 1;
			}
		}
		stopEvent(e);
	} else if (keycode == 13) {
		if (searchKeyOn > 0 && document.getElementById('searchA' + searchKeyOn)) {
			si.blur();
			var goUrl = document.getElementById('searchA' + searchKeyOn).href;
			//document.getElementById('searchA' + searchKeyOn).className = 'searchClicked';
			var elem = document.getElementById('searchList');
			elem.innerHTML = '';
			document.getElementById('searchDrop').style.visibility = 'hidden';
			si.value = '';
			window.location = goUrl;
			stopEvent(e);
		}
	}
}

function setCaretTo(obj, pos) { 
    if(obj.createTextRange) { 
        /* Create a TextRange, set the internal pointer to
           a specified position and show the cursor at this
           position
        */ 
        var range = obj.createTextRange(); 
        range.move("character", pos); 
        range.select(); 
    } else if(obj.selectionStart) { 
        /* Gecko is a little bit shorter on that. Simply
           focus the element and set the selection to a
           specified position
        */ 
        obj.focus(); 
        obj.setSelectionRange(pos, pos); 
    } 
} 

function switchKeyNavHi(num) {
	document.getElementById('searchA' + searchKeyOn).className = '';

	searchKeyOn = num;
	document.getElementById('searchA' + searchKeyOn).className = 'hi';
	
}

function updateNavScroll() {
	var pos = window.scrollY;
	if (!topNavPos) {
		topNavPos = 120;
	}
	var st = document.getElementById('floatingNavDiv');
	if (st) {
	if (pos < topNavPos && updatedNavPos != 'absolute') {
		st.style.position = 'absolute';
		st.style.top = topNavPos + 'px';
		updatedNavPos = 'absolute';
		//alert('Switched to absolute');
	} else if (pos >= topNavPos && updatedNavPos != 'fixed') {
		st.style.position = 'fixed';
		st.style.top = '0';	
		updatedNavPos = 'fixed';
		//alert('Switched to fixed');
	}
	}
}
updateNavScroll();

function clearSearchAuto() {
	var elem = document.getElementById('searchList');
	elem.innerHTML = '';
	document.getElementById('searchDrop').style.visibility = 'hidden';
}
function navShow(k) {
	navHideAll();
	if (document.getElementById('searchDrop')) {
		document.getElementById('searchDrop').style.visibility = 'hidden';
	}
	if (document.getElementById('membersLive')) {
		document.getElementById('membersLive').style.visibility = 'hidden !important';
	}
	document.getElementById('navDiv' + k).style.visibility = 'visible';
	document.getElementById('navButton' + k).className = 'navbutton on';
	if(k == 'Sites') {
		document['barLogo'].src = 'http://s3.roosterteeth.com/assets/style/flashy/bits/barLogo2On.png';
	}
	navHovID = k;
}
function navHideAll() {
	if(navHovID) {
		document.getElementById('navDiv' + navHovID).style.visibility = 'hidden';
		if(navHovID != navOnID) {
			document.getElementById('navButton' + navHovID).className = 'navbutton';
		}
	}
	if(document['barLogo'].src.substring(document['barLogo'].src.length-14) == 'barLogo2On.png') {
		document['barLogo'].src = 'http://s3.roosterteeth.com/assets/style/flashy/bits/barLogo2.png';
	}
	if (document.getElementById('membersLive')) {
		document.getElementById('membersLive').style.visibility = 'visible !important';
	}
	navHovID = false;
}
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
function getBarColor(val) {
	return document.getElementById('barLight').style.background;
}
function updateBarColor(val) {
	document.getElementById('barLight').style.backgroundColor = val;
	var divs = getElementsByClass('navDiv');
	for (x = 0; x < divs.length; x++) {
		divs[x].style.backgroundColor = val;
	}
}

// Copyright 2006-2007 javascript-array.com

var timeout	= 0;
var closetimer	= 0;
var ddmenuitem	= 0;
var ddmenuitemlink	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) {
		ddmenuitem.style.visibility = 'hidden';
		ddmenuitemlink.className = 'sddmlia';
	}

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitemlink = document.getElementById('link' + id);
	ddmenuitem.style.visibility = 'visible';
	ddmenuitemlink.className = 'tabCurrentHover';

}
// close showed layer
function mclose()
{
	if (ddmenuitem) {
		ddmenuitem.style.visibility = 'hidden';
		ddmenuitemlink.className = 'sddmlia';
	}
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
function MM_openBrWindow(url) {
	window.open(url);
}
function getCookie(name) {	

	var start = document.cookie.indexOf( name + "=" );

	var len = start + name.length + 1;

	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {

		return null;

	}

	if ( start == -1 ) return null;

	var end = document.cookie.indexOf( ';', len );

	if ( end == -1 ) end = document.cookie.length;

	return unescape( document.cookie.substring( len, end ) );

}
function setCookie(name, value) { // see dustin diaz for full code
	var expires_date = 'Thu, 2 Aug 2100 20:47:11 UTC';
	var path = '/';
	document.cookie = name+'='+escape( value ) +
		( ( expires_date ) ? ';expires='+expires_date : '' ) + 
		( ( path ) ? ';path=' + path : '' );
}
/*
 coded by Kae - kae@verens.com
 I'd appreciate any feedback.
 You have the right to include this in your sites.
 Please retain this notice.
*/

var isIE = window.attachEvent ? true : false;

/*function cartTrack(id, page) {
	loadXMLDoc('/store/cartTrack.php?id=' + id + '&page=' + rawurlencode(page));
}*/

function cartTrack(id, page){
	var url = '/store/cartTrack.php?id=' + id + '&page=' + rawurlencode(page);
	if (window.XMLHttpRequest) {
		var r = new XMLHttpRequest();
		r.open('GET', url, false);
		r.send(null);
	} else if (window.ActiveXObject) {
		var r = new ActiveXObject("Microsoft.XMLHTTP");
		if (r) {
			req.open("GET", url, false);
			req.send(null);
		}
	}
}

var searchAuto, searchImg, searchStartedLoading;
function updateSearchAuto(str) {	
		if (!searchAuto && !searchStartedLoading) {
			loadQuickSearch();	
			searchStartedLoading = true;
		}
	var elem = document.getElementById('searchList');
	elem.innerHTML = '';
	document.getElementById('searchDrop').style.visibility = 'hidden';
	
	var searchReplacements = new Array();
	searchReplacements["rt"] = new Array("rooster teeth");
	searchReplacements["rooster teeth"] = new Array("rt");
	searchReplacements["rvb"] = new Array("red vs blue", "red vs. blue");
	searchReplacements["red vs blue"] = new Array("rvb", "red vs. blue");
	searchReplacements["red vs. blue"] = new Array("rvb", "red vs blue");
	searchReplacements["strangerhood"] = new Array("the strangerhood");
	searchReplacements["the strangerhood"] = new Array("strangerhood");
	
	var doneVisible = false;
	if (str.length > 0) {
		var topnum = 1;
		for (i in searchAuto) {
			var num = 0;
			var doBreak = false;
			for (x in searchAuto[i]) {
				var hasChecked = false;
				for (checkX in searchReplacements) {
					for (checkY in searchReplacements[checkX]) {
						var testStr = str.replace(searchReplacements[checkX][checkY].substring(0, str.length), checkX);
						if (searchAuto[i][x][0].toLowerCase().indexOf(testStr.toLowerCase()) == 0) {
							var hasChecked = true;
						}
					}
				}
				if (searchAuto[i][x][0].toLowerCase().substring(0, 4) == 'the ') {
					if (searchAuto[i][x][0].toLowerCase().substring(4).indexOf(str.toLowerCase()) == 0) {
						var hasChecked = true;
					}
				}
				if (hasChecked || searchAuto[i][x][0].toLowerCase().indexOf(str.toLowerCase()) == 0 || i.toLowerCase().indexOf(str.toLowerCase()) == 0) {
					var div = document.createElement('div');
					div.className = 'searchItem';
					var a = document.createElement('a');
					a.setAttribute('id', 'searchA' + topnum);
					a.className = 'available';
					a.setAttribute('onmouseover', 'switchKeyNavHi(' + topnum + ');');
					a.setAttribute('onclick', 'document.getElementById(\'searchList\').innerHTML = \'\';document.getElementById(\'searchDrop\').style.visibility = \'hidden\';document.getElementById(\'searchInput\').value = \'\';');
					topnum++;
					var img = document.createElement('img');
					img.src = searchImg[searchAuto[i][x][2]];
					a.appendChild(img);
					var name = document.createElement('div');
					name.className = 'name';
					name.innerHTML = searchAuto[i][x][0];
					a.appendChild(name);
					var details = document.createElement('div');
					details.className = 'searchDetails';
					details.innerHTML = i;
					a.href = searchAuto[i][x][1];
					a.appendChild(details);
					div.appendChild(a);
					elem.appendChild(div);
					
					if (!doneVisible) {
						document.getElementById('searchDrop').style.visibility = 'visible';
					}
					doneVisible = true;
					if (num >= 4) {
						//var doBreak = true;
					}
					num++;
				}
				if (doBreak) {
					break;
				}				
				if (topnum >= 11) {
					break;
				}
			}
			if (topnum >= 11) {
				break;
			}
		}
	}
}

function tabbedPage(profileTabIsOn) {
	this.firstProfileTab = profileTabIsOn;
	
	this.setProfileTab = function(section) {
		oldProfileTab.className = '';
		oldProfileTab = document.getElementById('profileNav' + section);
		if (document.getElementById('profileNav' + section)) {
			document.getElementById('profileNav' + section).className = 'ptabOn';
		}
		profileTabIsOn = section;
	};
	
	this.loadProfilePage = function(url, displayUrl, commentsPos) {
		document.body.className = 'waiting';
		document.getElementById('profileAjaxContent').style.opacity = 0.2;
		$('#profileAjaxContent').load(url + (url.indexOf('?') != -1 ? "&" : "?") + "ajax=1", function() {
			var fromTab = profileTabIsOn;
			var toLink = (displayUrl ? displayUrl : url);
			document.getElementById('profileAjaxContent').style.opacity = 1;	
			var current = $(window).scrollTop();
			if (commentsPos) {
				var pos = $("#commentsArea").offset();
				if (pos) {
					var pos = pos.top - 75;
				}
			}
			if (!pos) {
				var pos = topNavPos;
			}
			if (current > pos) {
				window.scrollTo(0, pos);
			}
			$('.tip').tipsy({delayIn: 0, delayOut: 0, gravity: 's', html: true, live: true});

        	History.fromLoad = true;
			History.pushState({tabOn: fromTab}, null, toLink);
		});
		return false;
	};
	
	this.loadFromState = function(url, displayUrl) {
		document.body.className = 'waiting';
		document.getElementById('profileAjaxContent').style.opacity = 0.2;
		$('#profileAjaxContent').load(url + (url.indexOf('?') != -1 ? "&" : "?") + "ajax=1", function() {
			var fromTab = profileTabIsOn;
			var toLink = (displayUrl ? displayUrl : url);
			document.getElementById('profileAjaxContent').style.opacity = 1;
		});
		return false;
	};
}

function whenNaked(on, offset) {
	var foo = new Date; // Generic JS date object
	var unixtime_ms = foo.getTime(); // Returns milliseconds since the epoch
	var unixtime = parseInt(unixtime_ms / 1000);
	var dif = unixtime - on;
	if (offset) {
		var dif = dif - offset;
	}
		if (!on) {
			return false;
		}
		if (dif < 0) {
			dif = -dif;
			var future = true;
		}
		var suffix = 'ago';
		var arr = new Array();
		arr['second'] = 60;
		arr['minute'] = 60;
		arr['hour'] = 24;
		arr['day'] = 7;
		arr['week'] = 4.3482;
		arr['month'] = 12;
		arr['year'] = 169;
		for (i in arr) {
				var unit = i;
				var max = arr[i];
				if (dif > max) {
					 dif /= max;
				}
				else {
					if (future) {
					 dif = Math.ceil(dif);
					} else {
					 dif = Math.floor(dif);
					}
					 if (future && (unit == 'second')) {
					 	dif = 'just now';
					 } else {
					 	dif = (dif != 1) ? (future ? "in " : "") + dif + " " + unit + "s" + (future ? "" : " " + suffix) : (future ? "in " : "") + dif + " " + unit + (future ? "" : " " + suffix);
					 }
					 break;
				}
		}
	return dif;
}

function pollVote(id, answer, pid) {
	$("#pollHolder" + id).css("opacity", "0.5");
	$.get("/vote.php?id=" + id + "&a=" + answer + "&pid=" + pid + "&pollAjax=1", function(data) {
		$("#pollHolder" + id).html(data);
		$("#pollHolder" + id).css("opacity", "1");
	});
	return false;
}

			
			function sendReply(postUrl, pid) {
				$("#downloadButtonPreview" + pid).addClass("downloadButtonGray");
				$("#downloadButtonSubmit" + pid).addClass("downloadButtonGray");
				var serial = $("#post" + pid).serialize() + "&fastAjax=1&socket_id=" + pusher.socket_id + "&self=" + escape(window.location.pathname + window.location.search);
				$("#body" + pid).attr("disabled","disabled");
				$("#downloadButtonPreview" + pid).attr("disabled","disabled");
				$("#downloadButtonSubmit" + pid).attr("disabled","disabled");
				$.post(postUrl, serial, function(data) {

					if (data != "1") {
						$("#repliesArea" + pid).append(data);
					}
					$("#repliesTop" + pid).css("margin-top", "-10px");
					$("#repliesTop" + pid + " .replyArrow").show();

					$("#body" + pid).val(""); 
					$("#textCopy" + pid).html(""); 
					$("#textCopy" + pid).css("min-height", "46px");
					$("#body" + pid).css("min-height", "46px");
					document.getElementById("postButtons" + pid).style.display="none";
					if(document.getElementById("postFormatButtons" + pid)) {document.getElementById("postFormatButtons" + pid).style.display="none";}
					
					$("#body" + pid).removeAttr("disabled");
					window.setTimeout('$("#downloadButtonPreview' + pid + '").removeClass("downloadButtonGray");$("#downloadButtonSubmit' + pid + '").removeClass("downloadButtonGray");$("#downloadButtonPreview' + pid + '").removeAttr("disabled");$("#downloadButtonSubmit' + pid + '").removeAttr("disabled");', 12000);					
					
					 meTyping = false;
			
				 } );
				 
				 return false;			
			}


			function streamPreview(form) {
				form.action = '/preview.php';
				form.submit();
				return true;
			}



function markRead(a, id, uid, key) {
	document.getElementById('streamDivLevel' + a + key).style.display = 'none';
	$.ajax({url: '/members/markRead.php?a=' + a + '&id=' + id + '&uid=' + uid + '&ajax=1'});
}

function loadMoreReplies(a, id) {
	var shown = $("#repliesArea" + id + " .updateSingleReply").length;
	if ($("#repliesTop" + id + " .updateMoreReplies a").html() == "See Less") {
		shown = 0;
	}
	$("#repliesArea" + id).load("/_moreReplies.php?a=" + a + "&id=" + id + "&shown=" + shown, function() {
		var num = $("#repliesArea" + id + " .updateSingleReply:first").data("num");
		if (num == 1) {
			$("#repliesTop" + id + " .updateMoreReplies a").html("See Less");
		} else {
			$("#repliesTop" + id + " .updateMoreReplies a").html("See More");
		}
		$('.tip').tipsy({delayIn: 0, delayOut: 0, gravity: 's', html: true, live: true});
	});
}

function watchComments(el) {
	var toggle = $(el).data("toggle");
	$(el).html((toggle == 'on' ? 'Stop Watching' : 'Watch'));
	$.get($(el).attr("href") + "&ajax=1");
	if (toggle == 'on') {
		$(el).data("toggle", "off");
	} else {
		$(el).data("toggle", "on");
	}
	return false;
}
