function forumHome(){
	$get("fAction").value = "HOME"
	$get("px").value = "1"
	$get("pgTp").value = "1"
	$get("frId").value = "0"
	$get("thId").value = "0"
	$get("mwEvent").value = "HOME";
	__doPostBack('forumHome', 'Go Forum Home')
}

function forumSearch() {
    $get("frId").value = "0"
    $get("thId").value = "0"
    $get("fAction").value = "SEARCH"
    $get("mwEvent").value = "FORUMSEARCH";
    __doPostBack('forumSearch', 'Go Forum Search')
}

function forumNewUser() {
    $get("frId").value = "0"
    $get("thId").value = "0"
    $get("fAction").value = "NEWUSER"
    $get("mwEvent").value = "NEWUSER";
    __doPostBack('forumNewUser', 'Forum New User')
}

function forumCreateNewUser() {

	if (!checkStandard($get("sDName"), "Display Name", 11)){
		return;
	}

	if ($get("sFName").value != ""){
		if (!checkKeyboardCharacters($get("sFName"), 'Full Name')){
			return;
		}
	}

	if ($get("sAvatar").value != ""){
	    if (!checkSpecificChars($get("sAvatar"), "Avatar URL", "-:+=?&#./", 0)) {
			return;
		}
	}

	if ($get("sEmail").value != ""){
		if (!checkEmail($get("sEmail"))){
			return;
		}
	}
	else{
		alert("E-mail may not be blank.");
		$get("sEmail").focus();
		$get("sEmail").select();
		return;
	}

	if (!checkStandard($get("sPass"), 'Password',11)){
		return;
	}

	if ($get("sOcc").value != ""){
		if (!checkKeyboardCharacters($get("sOcc"), 'Occupation')){
			return;
		}
	}

	if ($get("sLoc").value != ""){
		if (!checkKeyboardCharacters($get("sLoc"), 'Location')){
			return;
		}
	}

	if ($get("sBio").value != ""){
		if (!checkAllCharacters($get("sBio"), 'Bio')){
			return;
		}
	}

	if ($get("sSig").value != ""){
		if (!checkAllCharacters($get("sSig"), 'Signature')){
			return;
		}
	}

	$get("fAction").value = "SAVENEWUSER"
	$get("mwEvent").value = "SAVENEWUSER";
	__doPostBack('forumSaveNewUser', 'Forum Save New User')

}

function forumLostPassword() {
    $get("frId").value = "0"
    $get("thId").value = "0"
    $get("fAction").value = "LOST"
    $get("mwEvent").value = "LOST";
    __doPostBack('forumLostPassword', 'Forum Lost Password')
}

function forumSignIn(){

	if (!checkStandard($get("fUser"), 'User Name', 11)){
		return;
	}

	if (!checkStandard($get("fPass"), 'Password', 11)){
		return;
    }
    $get("fAction").value = "SIGN"
    $get("mwEvent").value = "SIGN";
    __doPostBack('forumSignIn', 'Forum Sign In')
}

function forumAccount() {
    $get("frId").value = "0"
    $get("thId").value = "0"
    $get("fAction").value = "ACCOUNT"
    $get("mwEvent").value = "ACCOUNT";
    __doPostBack('forumAccount', 'Forum Account')
}

function forumQuickSearch(){
    $get("thId").value = "0"
    $get("frId").value = "0"
	$get("searchStr").value = "0||1||1|" + $get("fSearch").value + "|MSG|"
	$get("fAction").value = "QUICKSEARCH"
	$get("mwEvent").value = "QUICKSEARCH";
	__doPostBack('forumQuickSearch', 'Forum Quick Search')
}

function forumJump() {
    $get("frId").value = "0"
	$get("thId").value = "0"
	$get("tpId").value = $get("fTopic").options[$get("fTopic").selectedIndex].value
	$get("fAction").value = "JUMPTOPIC"
	$get("mwEvent").value = "JUMPTOPIC";
	__doPostBack('forumJumpTopic', 'Forum Jump Topic')
}

function showThread(threadId){
	$get("thId").value = threadId
	$get("fAction").value = "VIEWTHREAD"
	$get("mwEvent").value = "VIEWTHREAD";
	__doPostBack('forumViewThread', 'Forum View Thread')
}

function showTopic(topicId) {
    $get("frId").value = "0"
	$get("thId").value = "0"
	$get("px").value = "1"
	$get("pgTp").value = "1"
	$get("tpId").value = topicId
	$get("searchStr").value = "0||1||1||MSG|"
	$get("fAction").value = "JUMPTOPIC"
	$get("mwEvent").value = "JUMPTOPIC";
	__doPostBack('forumJumpTopic', 'Forum Jump Topic')
}

function forumSignOut() {
    $get("thId").value = "0"
    $get("frId").value = "0"
	$get("fAction").value = "OUT"
	$get("mwEvent").value = "OUT";
	__doPostBack('forumSignOut', 'Forum Sign Out')
}

function forumRequestLost(){
	if (($get("fDUser").value == "")&&($get("fEmail").value == "")){
		alert("Both User Name and E-mail may not be blank.")
		return;
	}

	if ($get("fDUser").value != ""){
		if (!checkStandard($get("fDUser"), 'User Name', 11)){
			return;
		}
	}

	if ($get("fEmail").value != ""){
		if (!checkEmail($get("fEmail"))){
			return;
		}
	}

	$get("fAction").value = "SENDLOST"
	$get("mwEvent").value = "SENDLOST";
	__doPostBack('forumLostPassword', 'Forum Send Lost Password')
}

function addUrl(fRef){
	var mStr = prompt("Enter the URL for the link that you would like add.","http://")
	if (mStr){
		if (fRef == 1){
			$get("sBio").value = $get("sBio").value + '<a href="' + mStr +  '" target="forum">' + mStr + '</a>'
		}
		else{
			$get("sSig").value = $get("sSig").value + '<a href="' + mStr +  '" target="forum">' + mStr + '</a>'
		}
	}

}

function forumDeleteFriend(fId){
	$get("frId").value = fId
	$get("fAction").value = "REMOVEUSER"
	$get("mwEvent").value = "REMOVEUSER";
	__doPostBack('forumDeleteFriend', 'Forum Delete Friend')
}

function showUser(fId){
	$get("frId").value = fId
	$get("fAction").value = "VIEWUSER"
	$get("mwEvent").value = "VIEWUSER";
	__doPostBack('forumShowUser', 'Forum Show User')
}

function forumDeleteFav(thId){
	$get("thId").value = thId
	$get("fAction").value = "REMOVEFAV"
	$get("mwEvent").value = "REMOVEFAV";
	__doPostBack('forumDeleteFav', 'Forum Delete Favorite')
}

function forumViewPM(pmId){
	$get("pmId").value = pmId
	$get("fAction").value = "VIEWPM"
	$get("mwEvent").value = "VIEWPM";
	__doPostBack('forumViewPm', 'Forum View PM')
}

function forumSendPM(){
	$get("pmId").value = "0"
	$get("fAction").value = "NEWPM"
	$get("mwEvent").value = "NEWPM";
	__doPostBack('forumSendPm', 'Forum Send PM')
}

function forumViewPosts(displayName){
	$get("thId").value = "0"
	$get("frId").value = $get("frId").value
	$get("fAction").value = "VIEWUSERPOSTS"
	$get("mwEvent").value = "VIEWUSERPOSTS";
	__doPostBack('forumViewPosts', 'Forum View Posts')
}

function forumBackUserPosts(){
	$get("thId").value = "0"
	$get("frId").value = $get("frId").value
	$get("fAction").value = "VIEWUSERPOSTS"
	$get("mwEvent").value = "VIEWUSERPOSTS";
	__doPostBack('forumViewUserPosts', 'Forum View User Posts')
}

function forumAddFriend(){
	$get("fAction").value = "ADDFRIEND"
	$get("mwEvent").value = "ADDFRIEND";
	__doPostBack('forumAddFriend', 'Forum Add Friend')
}

function forumIgUser(){
	$get("fAction").value = "IGNORE"
	$get("mwEvent").value = "IGNORE";
	__doPostBack('forumIgnore', 'Forum Ignore User')
}

function postNewThread(tpId){
	$get("tpId").value = tpId
	$get("fAction").value = "NEW"
	$get("mwEvent").value = "NEW";
	__doPostBack('forumNewThread', 'Forum New Thread')
}

function forumNextPage(){
	obj = document.foFrm
	$get("pgTp").value = parseInt($get("pgTp").value) + 1
	$get("px").value = parseInt($get("px").value) + 1
	__doPostBack('forumNext Page', 'Forum Next Page')
}

function forumPrevPage(){
	obj = document.foFrm
	$get("pgTp").value = parseInt($get("pgTp").value) - 1
	$get("px").value = parseInt($get("px").value) - 1
	__doPostBack('forumPrevousPage', 'Forum Previous Page')
}

function goToForumPage(){
	obj = document.foFrm
	$get("pgTp").value = $get("pSel").options[$get("pSel").selectedIndex].value
	$get("px").value = $get("pSel").options[$get("pSel").selectedIndex].value
	__doPostBack('forumGoToPage', 'Forum Go To Page')
}

function upDatePage(pNo){
	if ($get("thId").value == "0"){
		$get("pgTp").value = pNo
	}
	else{
		$get("px").value = pNo
	}
	__doPostBack('forumUpdatePage', 'Forum Update Page')
}

function addFavorite(thId){
	$get("thId").value = thId
	$get("fAction").value = "ADDFAV"
	$get("mwEvent").value = "NEW";
	__doPostBack('forumAddFav', 'Forum Add Favorite')
}

function threadResponse(thId){
	$get("rType").value = "R"
	$get("thId").value = thId
	$get("rpId").value = "0"
	$get("fAction").value = "REPLY"
	$get("mwEvent").value = "REPLY";
	__doPostBack('forumReply', 'Forum Reply')
}

function threadQuickResponse(thId){
	$get("rType").value = "R"
	$get("thId").value = thId
	document.location = "#QR"
}

function postQteResponse(pType, thId, replyId){
	$get("rType").value = "R"
	$get("thId").value = thId
	$get("rpId").value = replyId
	$get("fAction").value = "QUOTE"
	$get("mwEvent").value = "QUOTE";
	__doPostBack('forumQuoteResponse', 'Forum Quote Response')
}

function postQuickResponse(pType, pId){
	$get("rType").value = "R"
	$get("thId").value = pId
	document.location = "#QR"
}

function postResponse(pType, pId, replyId){
	$get("rType").value = "R"
	$get("thId").value = pId
	$get("rpId").value = replyId
	$get("fAction").value = "REPLY"
	$get("mwEvent").value = "REPLY";
	__doPostBack('forumReply', 'Forum Reply')
}

function forumQuick(pRef){
	if (pRef == 0){
		if (!checkKeyboardCharacters($get("rTitle"), 'Subject')){
			return;
		}

		cCount = 0
		for(i=0;i<$get("rMsg").value.length;i++){
			var c = $get("rMsg").value.charAt(i);
			if (c == "'"){
				cCount = cCount + 1
			}
		}
		cCount = ((cCount * 5) - cCount) + $get("rMsg").value.length

		if (cCount > 8000){
			alert("The message can only contain a maxiumum of 8000 characters.")
			return;
		}

		if ($get("rPreview").checked == true){
			$get("fAction").value = "PREVIEW"
	        $get("mwEvent").value = "PREVIEW";
		}
		else{
			$get("fAction").value  = "SAVEPOST"
	        $get("mwEvent").value = "SAVEPOST";
		}
	}
	else{
		$get("fAction").value  = "SAVEPOST"
	    $get("mwEvent").value = "SAVEPOST";
	}
	__doPostBack('forumQuick', 'Forum Quick')
}

function upDateCounter(){
	$get("rCount").value = 7500 - parseInt($get("rMsg").value.length)
}

function editResponse(){
	$get("fAction").value = "TREPLY"
	$get("mwEvent").value = "TREPLY";
	__doPostBack('forumEditResponse', 'Forum Edit Response')
}

function forumSendUserPM(){
	if (!checkKeyboardCharacters($get("rTitle"), 'Subject')){
		return;
	}

	cCount = 0
	for(i=0;i<$get("rMsg").value.length;i++){
		var c = $get("rMsg").value.charAt(i);
		if (c == "'"){
			cCount = cCount + 1
		}
	}
	cCount = ((cCount * 5) - cCount) + $get("rMsg").value.length

	if (cCount > 8000){
		alert("The message can only contain a maxiumum of 8000 characters.")
		return;
	}

	$get("fAction").value = "SENDPM"
	$get("mwEvent").value = "SENDPM";
	__doPostBack('forumSendPm', 'Forum Send PM')
}

function forumNoRPM(pmId){
	$get("pmId").value = pmId
	$get("fAction").value = "DELETEPM"
	$get("mwEvent").value = "DELETEPM";
	__doPostBack('forumDeletePm', 'Forum Delete PM')
}

function forumAdvSearch(refId){

	if ($get("sVal").value != ""){
		if (!checkStandard($get("sVal"), 'Newer Than', 5)){
			return;
		}
	}

	if ($get("sVal2").value != ""){
		if (!checkStandard($get("sVal2"), 'Older Than', 5)){
			return;
		}
	}
	$get("searchStr").value = "";
	if (refId == "1"){
		//KEYWORD
		$get("fAction").value = "KEYSEARCH"
	    $get("mwEvent").value = "KEYSEARCH";
	}
	else{
		//USERNAME
		$get("fAction").value = "NAMESEARCH"
	    $get("mwEvent").value = "NAMESEARCH";
	}
	__doPostBack('forumAdvancedSearch', 'Forum Advanced Search')
}

function forumBackSearchPosts(){
	$get("thId").value = "0"
	if ($get("searchStr").value == "0||1||1||MSG|"){
		$get("fAction").value = "JUMPTOPIC"
	    $get("mwEvent").value = "JUMPTOPIC";
	}
	else{
		$get("fAction").value = "QUICKSEARCH"
	    $get("mwEvent").value = "QUICKSEARCH";
	}
	__doPostBack('forumBackToResults', 'Forum Back To Results')
}

function forumPmReply(userId, pmId) {
    $get("pmId").value = pmId
    $get("pmUId").value = userId
    $get("fAction").value = "NEWPM"
    $get("mwEvent").value = "NEWPM";
    __doPostBack('forumSendPm', 'Forum Send PM')
}
