function forumCheckForm() {

	p1 = document.getElementById('p_title')
	p2 = document.getElementById('p_author')
	p3 = document.getElementById('p_content')
		
	moveOn = true;

	if(p3.value.length<10) {
		p3.select();
		p3.focus();
		window.status = 'Error: Content must be at least 10 characters';
		moveOn = false;
	}
	if(p2.value.length<1) {
		p2.select();
		p2.focus();
		window.status = 'Error: Author must be specified';
		moveOn = false;
	}
	if(p1.value.length<1) {
		p1.select();
		p1.focus();	
		window.status = 'Error: Title must be specified';
		moveOn = false;
	}

	if(moveOn) {
		window.status = 'Form filled succesfully - Posting data now...';
	} else {
		return false;
	}
}


function newTopic() {

	theDiv = document.getElementById('newtopic_div')
	theAct = document.getElementById('forumAction')
	p1     = document.getElementById('p_title')
	p2     = document.getElementById('p_author')
	p3     = document.getElementById('p_content')


	theDiv.style.display = '';
	theAct.value         = 'topic';
	p1.value	         = '';
	p2.value	         = '';
	p3.value	         = '';
	
    if(advPwd_XavioUserName.length>0) {
        p2.value = advPwd_XavioName
    }	
	
	window.setTimeout("p1.focus()",250)

	return true;

}


function replyPost() {

	theDiv = document.getElementById('newtopic_div')
	theAct = document.getElementById('forumAction')
	p1     = document.getElementById('p_title')
	p2     = document.getElementById('p_author')
	p3     = document.getElementById('p_content')

	replyTitle = document.getElementById('forumReplyTitle');
	if(replyTitle!=null) { replyTitle = replyTitle.innerHTML; }


	theDiv.style.display = '';
	theAct.value         = 'reply';
	p1.value	     = 'RE: '+replyTitle;
	p2.value	     = '';
	p3.value	     = '';
	
    if(advPwd_XavioUserName.length>0) {
        p2.value = advPwd_XavioName
        window.setTimeout("p3.focus()",250)
    } else {
	    window.setTimeout("p2.focus()",250)
    }

	return true;
}


function hideForumForm() {
	theDiv = document.getElementById('newtopic_div')
	theDiv.style.display = 'none';
}



function showSmileyWin() {
	window.open('includes/smiley_table.html','xaviosmileylist','width=300,height=260,toolbar=no,status=yes,menubar=no,scrolling=no,resizable=no')
}



function storeCaret(elm) {
    if (elm.createTextRange) 
    elm.caretPos = document.selection.createRange().duplicate();
}

function insAtCaret(id, str) {
    var caretPos, elm = document.getElementById(id);
    if (elm.createTextRange && elm.caretPos) {
        caretPos = elm.caretPos;
        caretPos.text = (caretPos.text.charAt(caretPos.text.length - 1)==" ")? str+" " : str;
    }
    else elm.value = str;
    if (caretPos) caretPos.select();
}
