// JavaScript Document
var formName = "parm";
function validateLogin()
{
	var frm = document.getElementById(formName);
	if (isBlank(frm.username.value)) {
		alert('Please input your Username');
		frm.username.focus();
		return false;
	}
	
	if (isBlank(frm.password.value)) {
		alert('Please input your Password');
		frm.password.focus();
		return false;
	}
	//frm.module.value = "index.php";
	frm.submit();
}
function postMessage(topic, postId)
{
	var frm = document.getElementById(formName);

	topicUpdater('mainbody', 'topic.php', topic, 'Save', postId);
}
function postTopic()
{
	var frm = document.getElementById(formName);
	
	if (isBlank(frm.topic.value)) {
		alert('Please input Subject');
		frm.topic.focus();
		return false;
	}
	
	if (isBlank(frm.categories_id.value)) {
		alert('Please select Forum Section');
		frm.categories_id.focus();
		return false;
	}
	
	if (isBlank(frm.txtMessage.value)) {
		alert('Please input Message');
		frm.txtMessage.focus();
		return false;
	}
	var params = '&topic=' + frm.topic.value + '&categories_id=' + frm.categories_id.value + '&txtMessage=' + frm.txtMessage.value;
	topicUpdater('mainbody', 'posttopic.php', params, 'Save');
	
}
function popUpWin(page,winname, w, h) {
  OpenWin = this.open(page,winname,"toolbar='no',menubar='no',location='no',scrollbars='no',resizable='yes',width="+w+",height="+h);
	OpenWin.focus();  
}
function insertChatMessage(file)
{
	var frm = document.getElementById(formName);
	if (isBlank(frm.txtMessage.value)) {
		alert('Please input Message');
		frm.txtMessage.focus();
		return false;
	}
	dataUpdater("divChat",file,"insert",0);
}
function enterChat()
{
	var frm = document.getElementById(formName);
	if (isBlank(frm.txtName.value)) {
		alert('Please input Name');
		frm.txtName.focus();
		return false;
	}	

	dataUpdater("divTemp","load_chat.php","login",0);
}
function scrollDown(div)
{
	var divObject = document.getElementById(div);
	divObject.scrollTop = divObject.scrollHeight;
}
function validatePoll()
{
	var frm = document.getElementById(formName);
	if (isBlank(frm.question.value)) {
		alert("Please enter category");
		frm.question.focus();
		frm.question.select();
		return false;		
	}	
	frm.module.value = "poll.php";
	frm.actionCmd.value = "Save";
	frm.submit();
}
function validatePollChoices()
{
	var frm = document.getElementById(formName);
	if (isBlank(frm.poll_question_id.value)) {
		alert("Please select Question");
		frm.poll_question_id.focus();
		frm.poll_question_id.select();
		return false;		
	}
	if (isBlank(frm.choices.value)) {
		alert("Please input Choices");
		frm.choices.focus();
		frm.choices.select();
		return false;		
	}
	frm.module.value = "poll_choices.php";
	frm.actionCmd.value = "Save";
	frm.submit();		
}
function validateVote()
{
	var frm = document.getElementById(formName);
	/*if (isBlank(frm.choices.value)) {
		alert('Please select your answer');
		frm.choices.focus();
		return false;
	}*/	
	dataUpdater("divTemp","vote_user.php","vote",0);	
}
function voteResult()
{
	$('divAnswer').style.display = 'none';
	dataUpdater('divShowVote','vote_user.php','initial');	
}
function searchForum(catId)
{
	//$('divAnswer').style.display = 'none';
	//alert(catId);
	dataUpdater('divForum','forum_search.php','search',catId);	
}