
function RefreshImage(valImageId) {
    var objImage = document.images[valImageId];
    if (objImage == undefined) {
        return;
    }
    var now = new Date();
    objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

function forumCheckForm() {

	p1 = document.getElementById('p_title')
	p2 = document.getElementById('p_author')
	p3 = document.getElementById('p_content')
	p4 = document.getElementById('captchacode')

	moveOn = true;

	if (p4.value.length < 6) {
	    p4.select();
	    p4.focus();
	    window.status = 'Error: CAPTCHA length must be 6 characters';
	    moveOn = false;
	}

	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 showForumForm() {
    theDiv = document.getElementById('newtopic_div')
    theDiv.style.display = '';
}

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(elem) {
  if(elem.isTextEdit) elem.caretPos = document.selection.createRange();
}

function insAtCaret(elem,wordInsert) {
  elem = document.getElementById(elem);

  if(elem.isTextEdit && elem.caretPos) {
    elem.caretPos.text += wordInsert;
  } else if(elem.selectionStart || (elem.selectionStart == '0')) {
    var before = elem.value.substring(0,elem.selectionStart);
    var after = elem.value.substring(elem.selectionEnd,elem.value.length);
    var selText = elem.value.substring(elem.selectionStart,elem.selectionEnd);
    elem.value = before+selText+wordInsert+after;
  }
}