﻿function toggleThread(objLI) {
	$(objLI).toggleClass('open').toggleClass('closed');
	}

function joinWikiMall(clickedID) {
	displayBox("#confirmWikiMall", 193, 129, null);
	coords = $(clickedID).getPosition();
	$("newBox").setPosition({x:(coords.x + 5),y:(coords.y + 15)});
	}

function replyComment(mssgID, strTopic) {
	displayBox('#commentForm', 400, 300, true)
	if (document.forms['frmPostComment']) {
		document.forms['frmPostComment'].elements['hidReplyTo'].value = mssgID;
		document.forms['frmPostComment'].elements['txtTitle'].value = strTopic;
		document.forms['frmPostComment'].elements['txtTitle'].readOnly = true;
		}
	}

function addToTopic(strTopic) {
	displayBox('#commentForm', 400, 300, true)
	if (document.forms['frmPostComment']) {
		document.forms['frmPostComment'].elements['txtTitle'].value = strTopic;
		}
	}

function postComment() {
	if (document.forms['frmPostComment'].elements['txtComment'].value != "") {
		document.forms['frmPostComment'].submit();
		}
	}

function previewComment() {
	if ($('frmPostComment').getStyle('display') == 'none') {
		$('frmPostComment').setStyle('display', 'block');
		$('commentPreview').setStyle('display', 'none');
		$('btnPreview').set('html', 'Preview');
		}
	else {
		var strComment = document.frmPostComment.txtComment.value;
		new Request({
			 'url':'/_scripts/previewComment.asp'
			,'data':'txt=' + escape(strComment) + '&' + Math.random()
			,'headers':{'Content-Type':'application/x-www-form-urlencoded'}
			,'onSuccess':function(rT, rX){
				$("frmPostComment").setStyle('display','none');
				$("commentPreview").set('html',rT).setStyles({'display':'block','z-index':20,'width':422,'height':162});
				centerElement("commentPreview");
				$("btnPreview").set('html','Back');
				}
			}).send();
		}
	}

function slideContent(nDirection) {
	var tblFocus = $(wlTbl);
	var currLeft = tblFocus.offsetLeft;
	var minLeft = tblFocus.parentNode.offsetWidth - tblFocus.offsetWidth;
	var maxLeft = 20;
	if (nDirection == 1) {
		if (currLeft > minLeft) tblFocus.style.left = (currLeft - 3) + "px";
		else clearInterval(slideTimer);
		}
	if (nDirection == 2) {
		if (currLeft < maxLeft) tblFocus.style.left = (currLeft + 3) + "px";
		else clearInterval(slideTimer);
		}
	}
	
function swapIMGExpand(imgid) {
	if (imgid == 'togglefavs') var thisBox = $('all-favorites-box');
	else var thisBox = $('all-friends-box');
	var thisImage = $(imgid);
	if (thisImage.get('class','icon_expand')) {
		thisImage.set('class','icon_restore');
		thisBox.setStyle('visibility','visible');
		}
	else {
		thisImage.set('class','icon_expand');
		thisBox.setStyle('visibility','hidden');
		}
	}

var scrollTimer, slideTimer, wlTbl = document.body.id;
$('togglefavs').addEvent('click', function(e) {
	e = new Event(e);
	$$(".over9").toggleClass('hid');
	e.stop();
	});

var mySlide2 = new Fx.Slide('all-friends-content', {
	 mode:'vertical'
	,direction:'reverse'
	,onStart: function() { $('all-friends-content').setStyle('overflow','hidden'); }
	,onComplete: function() { $('all-friends-content').setStyle('overflow','auto'); }
	});
$('togglefriends').addEvent('click', function(e) {
	e = new Event(e);
	swapIMGExpand('togglefriends');
	mySlide2.toggle();
	e.stop();
	});
mySlide2.toggle();

if (location.search != '') {
	if (location.search.parseQueryString().frm == 'comment') {
		window.addEvent("load", function () { displayBox('#commentForm', 400, 300, true) });
		}
	}
