
function submit_form()   /* a function that submits the order form from forum.asp page */
{
	document.order.submit();
}

function post_message(msgId)
{
	document.post_message.msgId.value = msgId;
	document.post_message.submit();
}

function change_forum_output(Page,Order_By,RecordsInPage)
{
	document.change_forum_output.Page.value = Page;
	document.change_forum_output.Order_By.value = Order_By;
	document.change_forum_output.RecordsInPage.value = RecordsInPage;
	document.change_forum_output.submit();
}

function editMsg(Msg_num)
{
	document.post_message.editMsg.value = Msg_num;
	document.post_message.submit();
}

function displayMessage(id)
{
   var obj = document.getElementById(id);
   obj.style.display=(obj.style.display=="none"?"block":"none");
}

function del_message(msgId,subject)
{
	var result = confirm("האם אתה בטוח שברצונך למחוק את ההודעה");
	
	if( result == true )
	{
		document.del_message.msg_num.value = msgId;
		document.del_message.submit();
	}
}



/****************************************
 Function Name  : send_message
 Function Purpose : This function is used in the forums editory. It checks that 
 						the message chars are O.K (with the help of "Replace Quotes")
						as well its length and so on...
						As well the function calls replacing_bad_words to filter bad words
						from the message.
 ****************************************/
function send_message()   
{
	
	if(document.new_message.user_name.value.length<2)
	{
		alert("חובה להזין את שם הכותב");
		document.new_message.user_name.focus();
		return(false);	
	}
	
	/* Checking that the message length isn't to long :  */
	if(document.new_message.message_content.value.length>=55000)   // size of Data Base if 64K but still...
	{
		alert("ההודעה גדולה מדי");
		return(false);
	}
	
	if(document.new_message.subject.value.length==0)   // If the subject is empty
		if(document.new_message.message_content.value.length!=0)    // And the message body is not empty
			if(document.new_message.message_content.value.length>16)   // and the message body is longer than 16 chars
				document.new_message.subject.value = document.new_message.message_content.value.substring(0,16)+"...";
				/* Then put into the messages subject its begining */
			else   // If the message body length is less than 17 chars but not 0 then :
			    document.new_message.subject.value = document.new_message.message_content.value;
		else  //  meaning the subject and the body_message are empty
		{
			alert("לא ניתן לשלוח הודעה ללא כל טקסט");
			document.new_message.message_content.focus();
			return(false);
		}	
	
	return(true);
}

function check_add_manager_from()
{
	if(document.manager.private_name.value.length==0)
	{
		alert("חובה להזין שם פרטי");
		document.manager.private_name.focus();
		return false;
	}

	if(document.manager.family.value.length==0)
	{
		alert("חובה להזין שם משפחה");
		document.manager.family.focus();
		return false;
	}

	if(document.manager.user_name.value.length==0)
	{
		alert("חובה להזין שם משתשמש");
		document.manager.user_name.focus();
		return false;
	}

	if(document.manager.password.value.length==0)
	{
		alert("חובה להזין סיסמה");
		document.manager.password.focus();
		return false;
	}


	return true;
}

// a function to check the update admins table from 'forum_ManageAll' page
function check_manage_form()
{
	var tomer=new Array
	tomer[0]="private_name"
	tomer[1]="family"
	tomer[2]="user_name"
	tomer[3]="password"
	
	return ChkFrm('document.manage_list',tomer);

}

// a function to check the update forums table from 'forum_ManageAll' page
function update_forums_form()
{
	var forum_colums = new Array
	forum_colums[0] = "forumDesc"
	forum_colums[1] = "welcomeMessage"

	return ChkFrm('document.forums_manage',forum_colums);
}
	
	function ChkFrm(form_name,my_array)
	{
		FrmObj = eval(form_name)
		Flag=0
		if(isNaN(FrmObj.ids.length)) // there is only 1 value
		{
			for(j=0;j<my_array.length;j++)
			{
				InputObj=eval("FrmObj."+my_array[j]+"_"+FrmObj.ids.value)
				if(InputObj.value.length==0)
				{
					ColorInput(InputObj,"#ffffa0")
					Flag=1
				}	
				else{ColorInput(InputObj,"#ffffff")}
			}
		}

		if(Flag==1)
		{
			alert("חובה למלא את כל השדות")
			return false;
		}

		Len=document.manage_list.ids.length

		for(i=0;i<Len;i++)
		{
			for(j=0;j<my_array.length;j++)
			{
				InputObj=eval("FrmObj."+my_array[j]+"_"+FrmObj.ids[i].value)
				if(InputObj.value.length==0)
				{
					ColorInput(InputObj,"#ffffa0")
					InputObj.focus()
					Flag=1
				}
				else
				{
					ColorInput(InputObj,"#ffffff")			
				}
			}
		}
		
		if(Flag==1)
		{
			alert("חובה למלא את כל השדות")
			return false;
		}
		
		return true;
		
	}

	function ColorInput(Obj,CellColor)
	{
		Obj.style.backgroundColor=CellColor
	}

//Start added for upload file
var pop
function popup(url,p) { //opens a winow in pop up with param: p
	if(pop!=null && !pop.closed) pop.close()
	pop=window.open(url,"pop",p)
	pop.focus()
    }
 
 function upload_file(id){
	 popup('upload_forum_files.asp?forumId='+id,'width=540,height=190, scrollbars=yes');
 }


function emoticon(text) {
	text = ' ' + text + ' ';
	//alert(document.new_message.message_content.focus())
	
	document.new_message.message_content.value  += text;
	document.new_message.message_content.focus();

}

function ChkFrm_trivia(FrmObj)
{
	myOption = -1;
	for (i=document.f_trivia.ques1_answer_id.length-1; i > -1; i--) {
	if (document.f_trivia.ques1_answer_id[i].checked) {
	myOption = i; i = -1;
	}
	}
	if (myOption == -1) {
	alert("יש לבחור תשובה לשאלה");
	return false;
	}
		
	return true;
}