function onMs(usrId) {//open member
	window.location.href='index.cfm?pg='+pg+'&fp=member&mID='+usrId;
}
function fEm(ftId,msgId,fp,cr) {//forum edit message
	window.location.href='index.cfm?pg='+pg+'&fp=messageEdit&ftID='+ftId+'&editMessageID='+msgId+'&'+forumPageType+'='+fp+'&scrollToRow=row'+cr;
}
function rFv(tpcId) {//remove favourite
	window.location.href='index.cfm?pg='+pg+'&fp=topic&fscID=0&remUtf='+tpcId;
}
function sPM(usrId) {//send PM
	window.location.href='index.cfm?pg='+pg+'&fp=PrivateMessage&writePm=true&intToMemberID='+usrId;
}
function dEm(email) {
	window.location.href='mailto:'+email;
}
function oSr(fscID,tpcId,forumPage,searchFor,searchObject,searchinfscid) {
	window.location.href='index.cfm?pg='+pg+'&fp=message&fscID='+fscID+'&ftID='+tpcId+'&ftp='+forumPage+'&searchFor='+searchFor+'&searchObject='+searchObject+'&searchinfscid='+searchinfscid;
}
function oTp(fscID,tpcId,forumPage) {//open topic
	var url='index.cfm?pg='+pg+'&fp=message&fscID='+fscID+'&ftID='+tpcId+'&ftp='+forumPage;
	if (oTp.arguments[3])
		url+='&fmp='+oTp.arguments[3];
	window.location.href=url;
}
function oLt(tpcId,fmp) {//open latest post
	window.location.href='index.cfm?pg='+pg+'&fp=message&ftID='+tpcId+'&fmp='+fmp+'&autoScroll=true';
}
function f_showSearch() {
	var o=get_object('forumSearchFormHolder');
	o.style.display=(o.style.display == 'block')?'none':'block';
}
function doMainCheckbox(o) {
	var cbForm=o.form;
	var cbName=o.name.split('_')[0];
	var cbTarget=eval('cbForm.'+cbName);
	if (cbTarget[1]) {
		for (var i=0;i<cbTarget.length;i++) {
			cbTarget[i].checked=o.checked;
		}
	} else {
		cbTarget.checked=o.checked;
	}
}
function doQuote(theUser,msg_id) {
	//var theMessage=get_object('div_msg_'+msg_id).innerHTML.replace(/<br>/g,'\n');
	var theMessage=get_object('div_msg_'+msg_id).innerHTML;
	theFormField=document.message.strText;
	var theQuote='[quoter]'+theUser+' '+txtWrote+':[/quoter][quote]'+theMessage+'[/quote]\n';
	if (theFormField.value.length != 0)
		theQuote='\n'+theQuote;
	theFormField.value+=theQuote;
	doScroll('anchor_bottom');
}
var activeFloater=null;
function sFl(idOrO) {//start topic floater
	activeFloater=(isNaN(idOrO))?get_object(idOrO):get_object('tf_'+idOrO);
	activeFloater.style.visibility='visible';
	activeFloater.style.display='block';
}
function spF() {//stop topic floater
	if (activeFloater != null) {
		activeFloater.style.visibility='hidden';
		activeFloater.style.display='none';
		activeFloater=null;
	}
}
function doFloater(evt) {
	if (window.activeFloater && activeFloater != null) {
		//o.style.top=(parseInt(mouseY(evt))+offY-Math.ceil(o.offsetHeight/2))+'px';
		activeFloater.style.top=(parseInt(mouseY(evt))+offY)+'px';
		activeFloater.style.left=(parseInt(mouseX(evt))+offX)+'px';
	}
}
document.onmousemove=doFloater;
var offX=10;
var offY=20;
function mouseX(evt) {
	if (!evt)
		evt=window.event;
	if (evt.pageX)
		return evt.pageX;
	else if (evt.clientX)
		return evt.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
	else
		return 0;
}
function mouseY(evt) {
	if (!evt)
		evt=window.event;
	if (evt.pageY)
		return evt.pageY;
	else if (evt.clientY)
		return evt.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
	else
		return 0;
}
function replaceBadMSWordCharacter(theField) {
	theField.value=theField.value.replace(/\u201A/g,"'");//baseline single quote
	theField.value=theField.value.replace(/\u0192/g,'<i>f</i>');//florin (small letter f with hook)
	theField.value=theField.value.replace(/\u201E/g,'"');//baseline double quote
	theField.value=theField.value.replace(/\u2026/g,'...');//ellipsis (3 horisontal ellipsis)
	theField.value=theField.value.replace(/\u2020/g,'&sup1');//dagger (cross)
	theField.value=theField.value.replace(/\u2021/g,'&sup2');//double dagger (cross with two horisontal lines)
	theField.value=theField.value.replace(/\u02C6/g,'^');//circumflex accent
	theField.value=theField.value.replace(/\u2030/g,'o/oo');//permile (as procent sign, but with double zeros)
	theField.value=theField.value.replace(/\u0160/g,'Sh');//S Hacek
	theField.value=theField.value.replace(/\u2039/g,'"');//left single guillemet (single left-pointing angle quotation mark)
	theField.value=theField.value.replace(/\u0152/g,'OE');//OE ligature
	theField.value=theField.value.replace(/\u2018/g,"'");//left single quote
	theField.value=theField.value.replace(/\u2019/g,"'");//right single quote
	theField.value=theField.value.replace(/\u201C/g,'"');//left double quotation mark
	theField.value=theField.value.replace(/\u201D/g,'"');//right double quotation mark
	theField.value=theField.value.replace(/\u2022/g,"*");//bullet
	theField.value=theField.value.replace(/\u2013/g,"-");//endash
	theField.value=theField.value.replace(/\u2014/g,"--");//emdash
	theField.value=theField.value.replace(/\u02DC/g,'~');//tilde accent
	theField.value=theField.value.replace(/\u2122/g,'<sup>TM</sup>');//trademark ligature
	theField.value=theField.value.replace(/\u0161/g,'sh');//s Hacek
	theField.value=theField.value.replace(/\u203A/g,'"');//right single guillement  (single right-pointing angle quotation mark)
	theField.value=theField.value.replace(/\u0153/g,'oe');//oe ligature
	theField.value=theField.value.replace(/\u0178/g,'Y');//Y Dieresis
}
function getCheckedRadioValue(theRadio) {
	for (i=0;i<theRadio.length;i++) {
		if (theRadio[i].checked)
			return theRadio[i].value;
	}
	return '';
}
function getCheckedValues(theCheckbox,theReturnType) {
	switch (theReturnType) {
		case 'list':
			var theList='';
			if (theCheckbox[0])
				for (i=0;i<theCheckbox.length;i++) {
					if (theCheckbox[i].checked) {
						if (theList.length > 0)
							theList=theList+',';
						theList=theList+theCheckbox[i].value;
					}
				}
			else if (theCheckbox.checked)
				theList=theCheckbox.value;
			return theList;
		break;
		case 'count':
			var checkedCount=0;
			if (theCheckbox[0])
				for (i=0;i<theCheckbox.length;i++) {
					if (theCheckbox[i].checked)
						checkedCount++;
				}
			else if (theCheckbox.checked)
				checkedCount++;
			return checkedCount;
		break;
		case 'boolean':
			if (theCheckbox[0])
				for (i=0;i<theCheckbox.length;i++) {
					if (theCheckbox[i].checked) {
						return true;
						break;
					}
				}
			else if (theCheckbox.checked)
				return true;
		break;
	}
	return false;
}
// Removes leading whitespaces
function LTrim(value) {
	var re=/\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim(value) {
	var re=/((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim(value) {
	return LTrim(RTrim(value));
}
var brd={
	lk: function(o) {
		this.doLike(o,'like');
	},
	dl: function(o) {
		this.doLike(o,'dislike');
	},
	rs: function(o) {
		this.doLike(o,'reset');
	},
	doLike: function(o,act) {
		var msgId=o.id.split('_')[1];
		url='forum_mlk.cfm?act='+act+'&msgId='+msgId;
		km_loadAjax('mlk',url,'text');
	}
}
function km_popAjax_mlk(response) {
	var response=trim(response);
	var ar=response.split(';');
	//return string looks like this
	//boardAccess;act;msgId;likeCount;dislikeCount
	var boardAccess=ar[0];
//	alert(ar);
	if (boardAccess == "true") {
		var act=ar[1];
		var msgId=ar[2];
		var aTag_like=get_object('like_'+msgId);
		var aTag_dislike=get_object('dlike_'+msgId);
		var like_reset=(act == "like");
		var dislike_reset=(act == "dislike");
		//set like link
		if (like_reset) {
			aTag_like.innerHTML=txtMlk_ar[2];
			aTag_like.onclick=function() {
				brd.rs(this);
			}
		} else {
			aTag_like.innerHTML=txtMlk_ar[0];
			aTag_like.onclick=function() {
				brd.lk(this);
			}
		}
		//set dislike link
		if (dislike_reset) {
			aTag_dislike.innerHTML=txtMlk_ar[3];
			aTag_dislike.onclick=function() {
				brd.rs(this);
			}
		} else {
			aTag_dislike.innerHTML=txtMlk_ar[1];
			aTag_dislike.onclick=function() {
				brd.dl(this);
			}
		}
		//SET DIAGRAM
		var likeCount=parseInt(ar[3]);
		var dislikeCount=parseInt(ar[4]);
		var totalCount=likeCount+dislikeCount;
		var likeBarWidth=0;
		if (likeCount != 0)
			likeBarWidth=parseInt((likeCount/totalCount)*likeDiagramWidth);
//		alert('totalCount:'+totalCount+' likeBarLength:'+likeBarWidth);
		get_object('lkbr_'+msgId).style.width=likeBarWidth+'px';
		get_object('likeC_'+msgId).innerHTML=(likeCount == 0)?txtMlk_ar[6]+' '+txtMlk_ar[4]:likeCount+' '+txtMlk_ar[4];
		get_object('dlikeC_'+msgId).innerHTML=(dislikeCount == 0)?txtMlk_ar[6]+' '+txtMlk_ar[5]:dislikeCount+' '+txtMlk_ar[5];
		get_object('lkdgh_'+msgId).style.display=(totalCount == 0)?'none':'block';
	}
}





