function fEnter(){
	return !(window.event && window.event.keyCode == 13)
}


function fAddTag(sF, sL, fld){
	fld=fld||addForm.content
	fld.focus();

	if(document.all){
	    var oRange=document.selection.createRange();
	    if(oRange.parentElement()==fld) oRange.text=""+ sF+oRange.text+sL +"";
	}
	else
		fld.value+=""+ sF +""+ sL +"";
}

var first=0

function fAddCode(fld) {
	fld=fld||addForm.content
	fld.focus();
	if(fld.style.direction=="rtl"||!first){
		fld.style.direction="ltr"

		if(document.all){
			var oRange=document.selection.createRange();
			if (oRange.parentElement()==fld)oRange.text="\n|הקוד|\n"+oRange.text+"\n|סקוד|\n";
		}
		else
			fld.value+="\n|הקוד|\n\n|סקוד|\n"

		document.getElementById("oImg").src="/images/editor/align-right.gif"
		first++
	}
	else {
		fld.style.direction="rtl"
		document.getElementById("oImg").src="/images/editor/align-left.gif"
	}
}

var sCursorLocationObj=null; 

function fEmoWin(nPlace){
	window.open("/forums/emoticons.asp?place="+ nPlace, "winAddEmo", "width=450,height=550,scrollbars=no,resizable=no");
}

function fAddEmo(emo){
	var sPlace="", coll=document.frmEmo.nPlace;
	for(i=0; i<coll.length; i++){
		if(coll[i].checked) sPlace=(coll[i].value=="0" ? "Title" : "content");
	}

	obj=opener.document.getElementById(sPlace);

	opener.focus();
	obj.focus();

	if(sPlace=="Title"){
		if((obj.value.length + emo.length + 2)<=40) obj.value+=" "+ emo +" "
		else alert("אין מקום לאייקון נוסף")
	}
	else{
		if(document.all)
			opener.document.selection.createRange().text=" "+ emo +" "
		else
			obj.value+=" "+ emo +" ";
	}

	window.close();


/* TEMP FOR ADDING IN CURSOR LOCATION
	if(!sCursorLocationObj) return false;

	addForm[sCursorLocationObj].focus();
	if(sCursorLocationObj=="Title")
		addForm[sCursorLocationObj].value+=" "+ emo +" "
	else
		if(document.all)
			document.selection.createRange().text=" "+ emo +" "
		else
			addForm[sCursorLocationObj].value+=" "+ emo +" ";
*/
}

function fValidate(frm){
	if(document.getElementById("oGuestTxtTr") && document.getElementById("oGuestTxtTr").style.display!="none"){
		var sGuestName=fTrim(frm.sGuestName.value)
		if(!sGuestName){
			alert("עליך להזין שם משתמש")
			frm.sGuestName.focus()
			return false;
		}
		if(!fIsValidUserName(sGuestName)){
			alert("שם משתמש יכיל אותיות ומספרים בלבד")
			frm.sGuestName.focus()
			return false;
		}
	}

	if(frm.Title.value==""){
		alert("עליך להזין נושא להודעה")
		frm.Title.focus()
		return false;
	}
	if(frm.content.value.length>3000){
		alert("ההודעה לא תכיל יותר מ-3000 תווים\nאורך ההודעה כרגע הוא " + frm.content.value.length)
		frm.content.focus()
		return false;
	}
	try{
		for(var i=1;i<5;i++){
			if(frm["LinkURL"+i].value && !/^(?:http:\/\/|https:\/\/|ftp:\/\/)/.test(frm["LinkURL"+i].value)){
				alert("קישור לא חוקי")
				frm["LinkURL"+i].focus()
				frm["LinkURL"+i].select()
				return false;
			}
		}

		if(frm.att&&frm.att.value){
			if(!(/\.(?:jpg|gif|bmp|png|txt|htm|html|doc|rtf|pdf|xml|xls|pps|ppt)$/.test(frm.att.value.toLowerCase()))){
				alert("סוגי הקבצים המותרים הם: jpg gif bmp png txt htm html doc rtf pdf xml xls pps ppt")
				frm.att.focus()
				frm.att.select()
				return false;
			}
			if(frm.action!="EditMessageUPL.asp"){
				frm.action="InsertMessageUPL.asp"
				frm.encoding = "multipart/form-data"
			}
		}
	}catch(e){}

	try{
		document.getElementById("sendMsgBtn1").style.display="none";
		document.getElementById("sendMsgBtn2").style.display="none";
		document.getElementById("sendingMsg1").style.display="block";
		document.getElementById("sendingMsg2").style.display="block";
	}
	catch(e){}
	return true;
}
function fGuest(val){
	document.getElementById("oGuestMsgTr").style.display=(val?"none":"block")
	document.getElementById("oGuestTxtTr").style.display=(!val?"none":"block")
	document.getElementById("bIsGuest").value=(val?"1":"")
	if(val) alert("שים/י לב!\nההודעה תופיע בפורום רק לאחר אישור המנהל")
}
