/* Replacement for German characters in javascript
	Chr	Replacement
	ä	\344
	ö	\366
	ü	\374
	Ä	\304
	Ö	\326
	Ü	\334
	ß	\337
*/

// function for UBB code
if (navigator.appName.indexOf("Microsoft")!=-1 && navigator.userAgent.indexOf("Opera") ==-1)
	ie=true;
else
	ie=false;
var isSelected=false;
var toinsertObj='';

function TagButtons(){
	outputtxt='&nbsp;<input class="wmfc" type="button" tabindex="-1" value="[B]" onclick="insertTag(\'[B]\',\'[/B]\')"> ';
	outputtxt+='<input class="wmfc" type="button" tabindex="-1" value="[I]" onclick="insertTag(\'[I]\',\'[/I]\')"> ';
	outputtxt+='<input class="wmfc" type="button" tabindex="-1" value="[IMG]" onclick="insertTag(\'[IMG]\',\'[/IMG]\')"> ';
	outputtxt+='<input class="wmfc" type="button" tabindex="-1" value="[URL]" onclick="insertTag(\'[URL]\',\'[/URL]\')"> ';
	outputtxt+='<input class="wmfc" type="button" tabindex="-1" value="[LIST]" onclick="insertTag(\'[LIST]\',\'[/LIST]\')"> ';
	outputtxt+='<input class="wmfc" type="button" tabindex="-1" value="[*]" onclick="insertTag(\'[*]\',\'\')"> ';
	outputtxt+='<input class="wmfc" type="button" tabindex="-1" value="[QUOTE]" onclick="insertTag(\'[QUOTE]\',\'[/QUOTE]\')"> ';
	outputtxt+='<input class="wmfc" type="button" tabindex="-1" value="[CODE]" onclick="insertTag(\'[CODE]\',\'[/CODE]\')"><br />';
	document.write(outputtxt);
	outputtxt='';
}

function write_emoticon(e) {
	output='<tr><td class="wmbg1 wmalright">Post Icons:</td><td class="wmbg1"><table border="0" cellspacing="0" cellpadding="3"><tr>';
	alt=new Array("Laugh","Disappoint","Anger","Evil","Important","Haehhh??","Winking","Thanks!","Info!","Idea!");
	for (i=1;i<=10;i++){
		output=output+'<td class="wmbg1 wmalcent"><input type="radio" name="em" value="'+i+'"';
		if (e==i)
			output=output+' checked="checked"';
		output=output+' /><br /><img src="'+imgsrc+i+'.gif" hspace="2" title="'+alt[i-1]+'" /></td>';
	}
	output=output+'<td class="wmbg1 wmalcent"><input type="radio" name="em" value="0"';
	if (e==0)
		output=output+' checked="checked"';
	output=output+' /><br />&nbsp;K.A.</td></tr></table></td></tr>';	
	document.write(output);
}

// smilies in message writting
function write_smilies(id,smilie,code,ispaid){
output='<table class="wmtbl"><tr><td class="wmalright"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /></td></tr>';
	if(smilie && code){
		output=output+'<tr><td class="wmalright"><a href="javascript: DoSmilie(\' :) \');"><img src="'+imgsrc+'1.gif" hspace="5" vspace="3" title="Laugh" /></a><a href="javascript: DoSmilie(\' :( \');"><img src="'+imgsrc+'2.gif" hspace="5" vspace="3" title="Disappoint" /></a><a href="javascript: DoSmilie(\' :mad: \');"><img src="'+imgsrc+'4.gif" hspace="5" vspace="3" title="Evil" /></a><br /><a href="javascript: DoSmilie(\' ;) \');"><img src="'+imgsrc+'7.gif" hspace="5" vspace="3" title="Winking" /></a><a href="javascript: DoSmilie(\' :D \');"><img src="'+imgsrc+'11.gif" hspace="5" vspace="3" title="Cheeeese" /></a><a href="javascript: DoSmilie(\' :o \');"><img src="'+imgsrc+'12.gif" hspace="5" vspace="3" title="Surprise" /></a></td></tr><tr><td class="wmsmall wmalright"><a href="javascript: wp(\'_moresmilies.cfm?id='+id+'\',650,250,1);">More Smilies</td></tr>';
	}
	else
		output=output+'<tr><td><br /><br /><br /><br /><br /><br /></td></tr>';
	output=output+'<tr><td class="wmsmall wmalright">';
	if (code){	
		output=output+'<a href="http://s3-01.webmart.de/i/forumcode.htm" target="_blank" class="wmsmall">Forum-Code</a><br />'
	}
	output=output+'<a href="javascript:chk_len();">Post&nbsp;Length</a></td></tr></table>';
	document.write(output);
}

function markSelection(thistextObj){
	if (toinsertObj!=thistextObj)
		toinsertObj=thistextObj
	if(typeof document.selection != 'undefined')
		thisSelection=document.selection.createRange();
}

function checkURL(url){
	var c=url.search(/^http|ftp/);//  :\/\/[-\w\.]{2,}\.[A-Za-z]{2,}
	if(c==-1)url="http://"+url;
	c=url.search(/^(http|https|ftp):\/\/[-\w\.]{2,}\.[A-Za-z]{2,}/);
	document.getElementById("UrlWinPath").value=url;
	return c;
	}
function setURL(sec_start,sec_end,tvs,tve){
	sec_insText=document.getElementById("UrlWinTitle").value;
	sec_url=document.getElementById("UrlWinPath").value;
	
	if(sec_url!="" ){
		if(checkURL(sec_url)==-1){alert("Invalid URL"); return}
		else sec_url=document.getElementById("UrlWinPath").value;
		if(sec_insText!="" && tvs=="[URL]"){
			tvs=tvs.substr(0,tvs.length-1)+"="+sec_url+"]";
		}
		else{
			sec_insText=sec_url;
		} 
		if(typeof document.selection != 'undefined'){
			thisSelection.text = tvs+sec_insText+tve;
		}else if(typeof toinsertObj.selectionStart != 'undefined'){
			toinsertObj.value = toinsertObj.value.substr(0, sec_start) + tvs + sec_insText + tve + toinsertObj.value.substr(sec_end);
			var new_pos=0;
			new_pos = sec_start+tvs.length+sec_insText.length+tve.length;
			toinsertObj.selectionStart=new_pos;
			toinsertObj.selectionEnd=new_pos;
		}
		closeUrlWin();
	}
	else alert("Please enter an URL");
	}
	
function closeUrlWin(){
	var d=document.getElementById("messageWin");
	toinsertObj.parentNode.removeChild(d);
	}
function checkKey(Event){
	if(!Event)Event=window.event;
	if(Event.keyCode==13)document.getElementById("URLSendBtn").focus();
	};
function showUrlWin(sec_start,sec_end,tvs,tve){
	var mW=document.getElementById("messageWin");
	if(!mW){
		var d=document.createElement("div");
		d.setAttribute("id","messageWin");
		d.setAttribute("style","position: absolute;  width: 0px; height: 0px;");
		var t='<div  style="position: relative;  top: 100px; left: 100px;"><div style="background-color:#333333; height:120px; width:300px; position: absolute; z-index:1000; float:left">'
				  +'<table style="background-color:#FFFFFF; border:1px solid black; height:100%; width:100%;">'
				  +'<tr><td height="20%">&nbsp;</td><td align="right"><input tabIndex=1004 align="right" type="button" id="UrlWinCloseBtn" name="closeBtn" onclick="closeUrlWin()" value="x" /></td></tr>'
				  +'<tr><td height="20%">URL</td><td><input type="text" tabIndex=1001 id="UrlWinPath"  style="width:220px;" name="path" value="http://" /></td></tr>'
				  +'<tr><td height="20%">'; if(tvs=="[URL]") t+='Text';t+='</td><td><input tabIndex=1002 style="width:220px;" id="UrlWinTitle" name="title"'; if(tvs=="[URL]") t+='type="text"'; else t+='type="hidden"';  t+=' />&nbsp;</td><td></td></tr>'
				  +'<tr><td height="20%">&nbsp;</td><td><input type="button" id="URLSendBtn" value="'; if(tvs=="[URL]")t+='Insert URL'; else t+='Insert image'; t+='" tabIndex=1003 onclick="setURL('+sec_start+','+sec_end+",'"+tvs+"','"+tve+"'"+')"/></td></tr>'
				  +'</table>'
				+'</div></div>';
			toinsertObj.parentNode.insertBefore(d,toinsertObj.previousSibling);
			document.getElementById("messageWin").innerHTML=t;
			uwp=document.getElementById("UrlWinPath");
			uwt=document.getElementById("UrlWinTitle");
			uwp.focus();
			uwp.select();
			uwt.onkeydown=checkKey;
			uwp.onkeydown=checkKey;
		}
	}
	
function insertTag(tvs,tve){
	if (toinsertObj=='')
		return
	toinsertObj.focus();
	if(typeof document.selection != 'undefined'){
		range_text_length = thisSelection.text.length;
		if (range_text_length==0 && (tvs=="[URL]" ||  tvs=="[IMG]")){
			showUrlWin(0,0,tvs,tve);
		}
		else{
			thisSelection.text = tvs+thisSelection.text+tve;
			if (range_text_length==0)
				thisSelection.move('character', -tve.length);
			thisSelection.select();
		}
	}
	else if(typeof toinsertObj.selectionStart != 'undefined'){
		sec_start = toinsertObj.selectionStart;
		sec_end = toinsertObj.selectionEnd;
		sec_insText = toinsertObj.value.substring(sec_start,sec_end);
		if (sec_insText.length==0 && (tvs=="[URL]" ||  tvs=="[IMG]")){
			showUrlWin(sec_start,sec_end,tvs,tve);
		}
		else{
			toinsertObj.value = toinsertObj.value.substr(0, sec_start) + tvs + sec_insText + tve + toinsertObj.value.substr(sec_end);
			new_pos=0;
			if (sec_insText.length==0)
				new_pos = sec_start + tvs.length;
			else
			new_pos = sec_start+tvs.length+sec_insText.length+tve.length;
			toinsertObj.selectionStart=new_pos;
			toinsertObj.selectionEnd=new_pos;
		}
	}
	else{
		toinsertObj.value+=tvs + tve;
	}
}

// win popup function for all pop up
function wp(u,h,w,r){
	attr='';
	attr=attr+'width='+w+',height='+h+',left='+Math.ceil(screen.width/2-w/2)+',top='+Math.ceil((screen.height-h)/2);
	if(r==1)
		attr=attr+',resizable,scrollbars';
	wn=window.open(u,'_blank',attr);
	if (wn==null || typeof(wn)=="undefined") 
		return false;
	else
		wn.focus();
}
	
//_header.cfm forumwechseln menu
function ChangeForum(obj){
	// replace old id, l and t
	qstr = qstr.replace(/id=\d+/gi,"");
	qstr = qstr.replace(/&sr=\d+/gi,"");
	qstr = qstr.replace(/l=\d+/gi,"");
	qstr = qstr.replace(/t=\d+/gi,"");
	qstr = qstr.replace(/&+/gi,"&");
	qstr = qstr.replace(/\?&+/gi,"?");
	val=obj.id[obj.id.selectedIndex].value;
	sendto=val.substring(0,1);
	id=val.substring(1,val.length);
		if (sendto=='F'){
			if (qstr.charAt(qstr.length-1) =='&')
				url=qstr+'id='+id
			else
				url=qstr+'&id='+id
			if(typeof lang!="undefined")
				url=url+'&l='+lang
		}
		else
			url='boardlist.cfm?listid='+id
		self.location.href=url
}

// _moderate.cfm Beiträge freischalten
function checkall(chk){
	df=document.f1;
	for (var i=0;i < df.elements.length;i++){
		var e=df.elements[i];
		if (e.type=="checkbox")
			e.checked=chk.checked;
	}
}

// updprofile.cfm (subscription)
function check_subs(chk){
	for (var i=0;i < document.f1.tids.length;i++)	{
		var e=document.f1.tids[i];
		if (e.type=="checkbox")
			e.checked=chk.checked;
	}
}

function search_action(act,id,s){
	df=document.f1;
	if(act=='user_search')
		df.action=df.formaction.value+'&r='+act;
	else
		df.action=df.formaction.value+'&r=user_edit&uid='+id+'&start='+s;	
	document.f1.submit();
}

// moderation function
function inbox_sub(sr,w,o){
	df=document.f1;
	ischecked=0
	action=df.r[df.r.selectedIndex].value
	for(i=0;i<df.m.length;i++){
		if (df.m[i].checked==true){
			ischecked=1
			break;
		}
	}
	if (ischecked==0)
		alert('Please select a message!');
	else{
		if(action=='delete'){
			ok=confirm('Do you really want to delete selected Messages?');
			if (ok==true){
				df.action=df.action+'&r=inboxdel&sr='+sr+'&w='+w+'&o='+o;
				df.submit();
			}
		}	
		else if (action=='unread'){
			df.action=df.action+'&r=inboxunread&sr='+sr+'&w='+w+'&o='+o;
			df.submit();
		}
		else if  (action=='ignore'){
			df.action=df.action+'&r=inboxignore&sr='+sr+'&w='+w+'&o='+o;
			df.submit();		
		}		
	}
}

// message edit
function msg_edit(id,m){
	url='fa.cfm?r=editmsg&id='+id+'&t='+tid+'&m='+m
	if (typeof lang !='undefined')
		url+='&l='+lang	
	wp(url,550,820,1);
}

// submit function used in 1_user.cfm
function check_submit(s){
	df=document.f1;
	urlact=df.act[df.act.selectedIndex].value;
	if(urlact=='deleteuser' || urlact=='resend'){
		ischecked=0
		for(i=0;i<df.itemid.length;i++){
			if (df.itemid[i].checked==true){
				ischecked=1
				break;
			}
		}
		if (ischecked==0)
			alert('Please select a User.');
		else{
				if (urlact=='deleteuser'){
				ok=confirm('Do you really want to delete all selected Users?');
				if (ok==true){
					df.action=df.action+'&r='+urlact+'&'+s;
					df.submit();
				}
			}
			else if (urlact=='resend'){
				df.action=df.action+'&r='+urlact+'&'+s;
				df.submit();
			}			
		}
	}
	else if (urlact=='editall'){
		df.action=df.action+'&r='+urlact+'&'+s;
		df.submit();
	}
}


// for smilies
function DoSmilie(addSmile){
	var revisedMessage;
	var currentMessage=document.f1.body.value;
	revisedMessage=currentMessage+addSmile;
	document.f1.body.value=revisedMessage;
	document.f1.body.focus();
}

// function relocating opener location
function openerurl(url){
	opener.location.href=url;
	opener.focus();
}

// for cancel button
function cancel(url){
	document.location.href=url;
}
// checks email(optional)
function email_chk(req){
	email=document.f1.email.value;
	msg='';
	if (email.length <6 && req==1)
		msg=msg+'Please give a email address (min. 5 characters).\n';
	else if(email.length >0){
		if(email.indexOf("@")==-1)
			msg=msg+'   Your email address contains no "@".\n';
		if(email.indexOf("@")==0)
			msg=msg+'   A "@" sign can not be at start position of email address.\n';
		if(email.indexOf("@")==email.length-1)
			msg=msg+'   A "@" sign can not be at end position of email address.\n';
		if(email.indexOf("@")!= email.lastIndexOf("@"))
			msg=msg+'   Your email address can have only one "@" sign.\n';
		if(email.indexOf(".")==-1)
			msg=msg+'   Your email address do not contains any period.\n';
		if(email.indexOf(".")==0)
			msg=msg+'   A period can not be at start position of email address.\n';
		if(email.indexOf(".")==email.length-1)
			msg=msg+'   A period can not be at end position of email address.\n';
		wrong=new Array(',','>','<',' ','*',':',';','(',')','"');
		for(i=0;i<wrong.length;i++){
			if (email.indexOf(wrong[i])>-1)
				msg=msg+'   Your email address can not contains "'+wrong[i]+'" character.\n';
		}
		for(i=0;i<email.length;i++){
			if(email.charCodeAt(i)>128)
				msg=msg+'   Your email address can not contains "'+email.charAt(i)+'" character.\n';
		}
	}
	if (msg.length){
		alert('Failure in email address "'+email+'":\n'+msg);
		return false;
	}
}
// removes white spaces
function trim(str){
	return str.replace(/^\s+/g,'').replace(/\s+$/g,'');
}
// check blank of form fields
function chk_some(){
	msg='';
	chka=chk.split(',');
	sha=sh.split(',');
	df=document.f1;
	focused=0
	for (i=0;i<chka.length; i++){
		if (eval('df.'+chka[i]+'.type')!='select-one' && trim(eval('df.'+chka[i]+'.value'))==''){
			msg+=sha[i]+' can not be blank!\n';
			if(!focused){
				eval('df.'+chka[i]+'.focus();')
				focused=1
			}
		}
		else if (eval('df.'+chka[i]+'.type')=='select-one' && eval('df.'+chka[i]+'[df.'+chka[i]+'.selectedIndex].value')==''){
			msg+='Please select a '+sha[i]+' \n';
			if(!focused){
				eval('df.'+chka[i]+'.focus();')
				focused=1
			}
		}
	}
	
	if (msg.length){
		msg='One Failure is occured:\n\n'+msg;
		alert(msg)
		return false;
	}
}
// checks for max characters
function chk_body(){
	if(document.f1.body.value.length>8000){
	alert('Your message is '+document.f1.body.value.length+' characters long.\nMaximum 8000 characters are allowed.\nPlease shorten your message and try again!');
return false;
	}
}
// moderation function
function chk_submit(){
	df=document.f1;
	ischecked=0
	for(i=0;i<df.itemid.length;i++){
		if (df.itemid[i].checked==true){
			ischecked=1
			break;
		}
	}
	if (ischecked==0)
		alert('Please select a message!');
	else{
		action=df.act[df.act.selectedIndex].value;		
		if (action=='split'){
			itemid=chk_split();
			if (itemid==0)
				alert('Please select only one Message\nfrom which you want to separate this topic!')
			else {
				url=df.action+'&r='+action+'&t='+tid+'&itemid='+itemid;
				wp(url,450,625,1);
			}
		}
		else{
			df.action=df.action+'r='+action;
			df.submit();
		}
	}
}

function chk_split(){
	df=document.f1;
	itemselected=0;
	pos=0;	
	for(i=1;i<df.itemid.length;i++){
		if (df.itemid[i].checked==true){
			itemselected=itemselected+1
			pos=i
		}
	}
	if (itemselected==1)
		return df.itemid[pos].value
	else
		return 0;
}

// disabl=0 if button not to disable, just change text of button
function disableBtn(obj,disabl){
	obj.value='Loading..'
	if(typeof disabl == "undefined")
		obj.disabled=true;
}

function chk_move(){
	err=0
	if(document.f1.toboardid.selectedIndex==0){
		alert('Please select a destination Forum.')
		document.f1.toboardid.focus();
		err=1
	}
	return err;
}

function act_submit(w){
	if(w=='confirmdel'){
		error=0
	}
	else if (w=='confirmmove'){
		error=chk_move();
	}
	if(error==0){
		disableBtn(w);
		document.f1.submit();
    }
}

function chk_len(){
	alert('The message is '+document.f1.body.value.length+' characters long.');
}

// function for vote
function ques_submit(act){
	df=document.f1;
	msg='';
	if(df.expiryoption[0].checked){
		sd=df.thisdateday[df.thisdateday.selectedIndex].value;
		sm=df.thisdatemonth[df.thisdatemonth.selectedIndex].value-1;
		sy=df.thisdateyear[df.thisdateyear.selectedIndex].value;
		sh=df.thisdatehour[df.thisdatehour.selectedIndex].value;
		exptime = new Date(sy,sm,sd,sh);
		if(currtime >= exptime)
			msg='Please select date in future.';
	}	
	if (msg.length){
		alert(msg)
		return false;
	}
	else{
		df.action=df.action+'&r='+act;
		document.f1.submit();
	}
}

function del_ques(pos){
	ok=confirm('Do you really want to delete this Answer?');
	if (ok==true){
		document.f1.action=document.f1.action+'&r=del_voteques&qid='+pos;
		document.f1.submit();		
	}
}
function sort(s,e){
	df=document.f1;
	s=s+2
	merke=df.elements[s+e].value;
	df.elements[s+e].value=df.elements[s].value;
	df.elements[s].value=merke;
}

function write_select(wert,was,s,e,curr){
	var Monatsname = new Array ("January","February","March","April","May","Jun","July","August","September","October","November","December");
	textvar='<select name="'+wert+was+'" size="1"';
	if (was!="day" || was!="hr")
		textvar=textvar+' onchange="aendern(\''+wert+'\')"';
	textvar=textvar+'>';
	for (i=s; i<=e; i++){
		if (was=='month')
			otext=Monatsname[i-1]
		else
			otext=i
	textvar=textvar+'<option value="'+i+'"'
	if (curr==i)
		textvar=textvar+' selected="selected"';
	textvar=textvar+'>'+otext;
	}
	textvar=textvar+'</select>';
	return textvar
}

function aendern(was){
	Monat=eval('document.f1.'+was+'month.selectedIndex')+1;
	JO=eval('document.f1.'+was+'year.selectedIndex');
	Jahr=eval('document.f1.'+was+'year.options['+JO+'].value');
	TO=eval('document.f1.'+was+'day.selectedIndex');
	Tag=eval('document.f1.'+was+'day.options['+TO+'].value');
	var Monatsname = new Array ("Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember");
	var Stop = 31;
	if(Monat==4 || Monat==6 || Monat==9 || Monat==11 ) --Stop;
	if(Monat==2){
	 Stop=Stop-3;
	 if(Jahr%4==0) Stop++;
	 if(Jahr%100==0) Stop--;
	 if(Jahr%400==0) Stop++;
	}
	// loesche Select_Options
	for(t=eval('document.f1.'+was+'day.length'); t>=0 ;t--){
	  eval('document.f1.'+was+'day.options['+t+'] = null');
	}
	// schreibe Select_Options neu
	for(t=0; t<Stop ;t++){
	  	eval('document.f1.'+was+'day.options['+t+'] = new Option(document.f1.'+was+'day.value)');
	 	eval('document.f1.'+was+'day.options['+t+'].text = t+1');
		eval('document.f1.'+was+'day.options['+t+'].value = t+1');
	}
	if (Tag>Stop){
		eval('document.f1.'+was+'day.options['+eval(Stop-1)+'].selected=true');
		msg="Der "+Monatsname[Monat-1];
		if (Stop == 29)
			msg=msg+" im Schaltjahr ("+Jahr+")";
		msg=msg+" hat nur "+Stop+" Tage.\nDer Wert wurde auf "+Stop+" geändert.";
		alert(msg);
	}
	else
		eval('document.f1.'+was+'day.options['+TO+'].selected=true');
}
// separate thread 
function checksplit(){
	msg="";
	topic=document.f1.subject.value;
	topic=topic.replace(/^\s+/g,'').replace(/\s+$/g,'');
	if(topic=="")
		msg=msg+'Please select a Title for Topic!';
	if(msg.length>0){
		alert(msg);
	}
	else {
		disableBtn('split');
		document.f1.submit();
	}
	
}

// function for sending private msg
function send_pm(btn){
	if($$('#touser_container input[type="hidden"]').length == 0){
		alert('Ooops...missing recipient(s).');
		return;
	}
	disableBtn(btn);
	document.f1.submit();
}

function createRecipientList(){
	$('touserdiv').innerHTML='';
	for(i=0;i<RecipientIDList.length;i++){
		$('touserdiv').insert('<li id="userid_'+RecipientIDList[i]+'">'+RecipientNameList[i]+' <img src="http://img.webmart.de/w/cross2.png" title="Remove recipient" onclick="removePNRecipient(\''+RecipientIDList[i]+'\');" /></li>');
	}
	$('recipientidlist').value=RecipientIDList.toString();
	if(RecipientIDList.length >= 10){
		$('touser').hide();
		document.f1.subject.focus();
	}
	else{
		$('touser').show();
		document.f1.touser.focus();
	}
}

function removePNRecipient(userid){
	for(i=0;i<RecipientIDList.length;i++){
		if(RecipientIDList[i] == userid){
			RecipientIDList.splice(i,1);
			RecipientNameList.splice(i,1);
			createRecipientList();
			break;
		}
	}			
}

// function to disable enter press in textbox.(avoiding submit)
function noenter(event){
	keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	return !(keyCode == 13);
}

// search options show hide
function show_hide(){
	if(document.getElementById('f_search').style.display=="none"){	
		document.getElementById('f_search').style.display='block';
		document.getElementById('f_option').innerHTML=hideoption;
	}	
	else{
		document.getElementById('f_search').style.display='none';
		document.getElementById('f_option').innerHTML=showoption;
	}	
}

// function used in forum moderation to kock and unlock message 
function msg_lock(bid,mid,lock){
	if (lock==0){ // if msg is already locked (text to unlock)
		text='Do you really want to lock this message?\n\n1. A locked message cannot be edited.\n2. A locked message can only be unlocked by administrators.\n3. A message or any topic containing a locked message cannot be deleted or moved.\n\n\n';
		r='lockmsg';
	}
	else if (lock==1){ // if msg is not locked (text to lock)
		text='Do you really want to unlock this message?';
		r='unlockmsg';
	}
	ok=confirm(text);
	if (ok==true){
		url='fa.cfm?r='+r+'&id='+bid+'&m='+mid+'&t='+tid+'&pg='+pg;
		document.location.href=url;
	}
}

function chk_draft(){
	qstr=qstr.replace(/r=/gi,"r_old=");
	qstr=qstr+'&r=getdraft';
	wp(qstr,'450','620',1);
	draft_hide();
}

// function used in writemsg.cfm to copy draft
function draftcopy(){
	opener.document.getElementById('body').value=document.getElementById('draft').value;
	opener.focus();
	self.close();
}

function draft_hide(){
	document.getElementById('draftcontent').style.display='none';
}

// function used to select users for private msg
function select_user(obj){
	si=document.getElementById('user').selectedIndex;
	if (si>=0){
		msg='';
		thisuser=document.getElementById('user')[si].text;
		if (document.getElementById('touser').value)
			if( check_exists('touser',thisuser)==true){
				msg+='This user is already entered as To-Recipient.\n';
			}
		if (document.getElementById('ccuser').value)
			if( check_exists('ccuser',thisuser)==true){
				msg+='This user is already entered as CC-Recipient.\n';
			}
		if (document.getElementById('bccuser').value)
			if( check_exists('bccuser',thisuser)==true){
				msg+='This user is already entered as BCC-Recipient.\n';
			}
		if (msg==''){
			if(document.getElementById(obj+'user').value=='')
				document.getElementById(obj+'user').value=thisuser;
			else 
				document.getElementById(obj+'user').value=document.getElementById(obj+'user').value+','+thisuser;
		}
		else{
			alert(msg);
		}
	}
}

function check_exists(obj,term){
	objval=trim(document.getElementById(obj).value);
	found=0;
	if (objval!=''){
		objval=objval.split(',');
		for(i=0;i<objval.length;i++){
			if (objval[i]==term){
				found=1;
				break;
			}
		}		
	}
	return found;
}

function google_ad_request_done(google_ads) {
	var i;
	var s;
	var j=0; // Count how many ads are served in a content block
	var k=0;

	if (google_ads.length == 0) {
		return;
	}	
	if (google_ads[0].type != "html") {
		if (AdType == 'normal'){
			adNote='<a href="' + google_info.feedback_url + '">by&nbsp;Google</a>';
			for(i = 0; i < google_ads.length; ++i) {
				s = '<div style="margin-bottom:8px;font-size:12px;cursor:pointer;" onclick="document.location.href=\'' +
				google_ads[i].url + '\';"><a style="font-size:16px;" href="' +
				google_ads[i].url + '"><b>' +
				google_ads[i].line1 + '</b></a><br />' +
				google_ads[i].line2 + ' ' +
				google_ads[i].line3 + '<br /><a href="' +
				google_ads[i].url + '">' +
				google_ads[i].visible_url + '</a></div>';
		
				if (j==0){
					adContent[k]=s;
				}
				else 
					adContent[k]+=s;
				if (j == 1){
					k++;	
					j=0;
				}
				else
					j++;	
			}
		}
		else{
			// qsearch Ads
			adContent[0]='';
			for(i = 0; i < google_ads.length; ++i) {
				adContent[0] += '<tr class="wmover"><td class="wmbg2" width="100%"><a href="' +
				google_ads[i].url + '"><b>' +
				google_ads[i].line1 + '</b></a><br />' +
				google_ads[i].line2 + ' ' +
				google_ads[i].line3 + '<br />Gesponsert von <a href="' +
				google_ads[i].url + '">' +
				google_ads[i].visible_url + '</a></td></tr>';	
			}
		}
	}
    return;
}

function spoolAds(p){
	if (AdType == 'normal'){
		var e=p;
		if ($('target_'+adSpot[p]) != undefined){
			if (adSpotAd[p] != undefined){
				if (adContent[(adSpotAd[p]+1)] != undefined){
					e=adSpotAd[p] +1;
				}
				else
					e=0;
			}
			else if(adContent[p] != undefined){
				$('note_'+adSpot[p]).innerHTML=adNote;
				$('more_'+adSpot[p]).innerHTML='<a href="#" onclick="spoolAds('+p+');return false;">&gt;&gt;<br /><br />&gt;&gt;<br /><br />&gt;&gt;</a>';
				$('more_'+adSpot[p]).show();
			}
			
			if(adContent[e] != undefined){
				$('target_'+adSpot[p]).hide().innerHTML=adContent[e];
				Effect.Appear($('target_'+adSpot[p]));
				adSpotAd[p]=e;
			}
		}
	}
	else{
		// qsearch Ads
		if ($('scontent') != undefined){
			$('scontent').insert({top:adContent[0]});
		}
	}
}

function spoolMsgs(a,p,m){
	for(i=0;i<a;i++){
		$('msg_'+i).insert(wmsoy.f.threadview({wmla:wmla,prop:p,msg:m[i]}))	
	}
}

function Picasa_SwitchImage(a,eid){
	var e=eid.split('_')[1];
	$(a+'_pic').hide();
	$(a+'_pic').innerHTML='<img src="'+window['PicasaContentSrc'+a][e-1]+'?size='+window['PicasaImageSize'+a]+'" />';
	$(a+'_pic').appear();
	$(a+'_summary').innerHTML=window['PicasaSummary'+a][e-1];
	window['Picasa_CurrentImage'+a]=e;
	Picasa_HighlightCurrentImage(a);
	if (window['PicasaSlideShowType'+a]){
		Picasa_PositionSlider(a);
	}
}

function Picasa_PositionSlider(a){
	var c=Math.ceil(window['Picasa_ImagesPerRow'+a]/2);
	var i=window['Picasa_CurrentImage'+a];
	var w=window['Picasa_Border'+a]+window['Picasa_ThumbnailSize'+a];
	var o=(i-c)*w;
	if (i <= c) 
		o=0;
	else if (i > (window['PicasaSummary'+a].length-c))
		o=(window['PicasaSummary'+a].length-window['Picasa_ImagesPerRow'+a])*w;
	new Effect.Move($(a+'_picasaslider'), {x:-o,mode:'absolute'});
}

function Picasa_HighlightCurrentImage(a){
	$$('#'+a+'_picasaimagebar img').each(function(s){
		$(s.id).removeClassName('picasathumbnailactive');
		$(s.id).addClassName('picasathumbnailinactive');
	});
	$$('#'+a+'_'+window['Picasa_CurrentImage'+a]+' img').each(function(s){
		$(s.id).addClassName('picasathumbnailactive');
		$(s.id).removeClassName('picasathumbnailinactive');		
	});
	$('picasacurrimage_'+a).innerHTML=window['Picasa_CurrentImage'+a]+' / '+window['PicasaSummary'+a].length;
}

function WMAjaxUpdater(u,t){
	$(t).innerHTML='&nbsp;Loading...';
	new Ajax.Updater({ success: t }, u, {method: 'get', evalScripts: true});
}

function addPicasaControls(e){
	$$('#'+e+' .picasatn').each(function(s){
		Event.observe($(s.id),'click', function(){		
			var a=s.id.split('_')[0];
			Picasa_SwitchImage(a,s.id);
		});
	});
	$$('#'+e+' .picasaleftclick').each(function(s){
		Event.observe($(s.id),'click', function(){	
			var a=s.id.split('_')[0];
			if (window['Picasa_CurrentImage'+a] > 1) {	
				window['Picasa_CurrentImage'+a]--;	
				Picasa_SwitchImage(a,a+'_'+window['Picasa_CurrentImage'+a]);
			}
		});
	});
	
	$$('#'+e+' .picasarightclick').each(function(s){
		Event.observe($(s.id),'click', function(){	
			var a=s.id.split('_')[0];
			if (window['Picasa_CurrentImage'+a] < window['PicasaSummary'+a].length) {	
				window['Picasa_CurrentImage'+a]++;	
				Picasa_SwitchImage(a,a+'_'+window['Picasa_CurrentImage'+a]);
			}
		});
	});	
}
function warn(url){
	if(url.hostname == ''){
		return false;
	}
	if(document.location.hostname != url.hostname){
		if(url.search.indexOf('interceptedURL') == 1){
			url.href = 'interceptoe.cfm' +  '?interceptedURL=' + url.search.substr(15);
		}else{
			url.href = 'interceptoe.cfm' +  '?interceptedURL=' + url.href;
		}
	}
	return true;
}

function createRecommenderContent(m){
	var u=m.u;
	var t=encodeURI(m.t);
	var o='<div style="display:block;width:300px;" id="recommender"><div id="recommenderbm"><ul>'+
	'<li class="fb"><a href="http://www.facebook.com/sharer.php?u='+u+'&amp;t='+t+'">Facebook</a></li>'+
	'<li class="tw"><a href="http://twitter.com/home?status='+ u +'">Twitter</a></li>'+
	'<li class="mw"><a href="http://www.mister-wong.de/index.php?bm_url='+u+'&amp;bm_description='+t+'&amp;bm_tags=&amp;action=addurl">Mister Wong</a></li>'+
	'<li class="ms"><a href="http://www.myspace.com/Modules/PostTo/Pages/?u='+u+'&amp;t='+t+'">Myspace</a></li>'+
	'<li class="dl"><a href="http://del.icio.us/post?v=2&amp;url'+u+'&amp;title='+t+'&amp;tags=">Delicious</a></li>'+
	'<li class="gg"><a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk='+u+'&amp;labels=&amp;title='+t+'">Google</a></li>'+
	'<li class="tr"><a href="http://technorati.com/faves?add='+u+'&amp;tag=">Technorati</a></li>'+
	'<li class="dg"><a href="http://digg.com/submit?phase=2&amp;url='+u+'&amp;title='+t+'">Digg</a></li>'+
	'</ul></div>'+
	'<br />Per Email:<br /><ul><li><a href="mailto:?subject='+t+'&amp;body='+u+'">Send topic via email</a></li></ul>'+
	'<br /><br />Link to this topic<br /><input type="text" style="margin:4px;width:285px;" onclick="this.select();" onfocus="this.select();" value="'+u+'">'+
	'</div>';
	return o;
}

function createRecommender(e,m){
	new Tip(e, createRecommenderContent(m), {
		title: 'Recommend this topic',
		closeButton: true,
		showOn: 'click',
		hideOn: { element: 'closeButton', event: 'click'},
		hideOn: 'click',
		hideOthers: true,
		stem: 'rightMiddle',
		hook: { target: 'leftMiddle', tip: 'rightMiddle' },
		offset: { x: 0, y: 0 },
		width: 'auto'
	});
}

// Soy (Google Closure)
var soy=soy||{};(function(){var a=navigator.userAgent,b=a.indexOf("Opera")==0;soy.IS_OPERA_=b;soy.IS_IE_=!b&&a.indexOf("MSIE")!=-1;soy.IS_WEBKIT_=!b&&a.indexOf("WebKit")!=-1})();soy.StringBuilder=function(a){this.buffer_=soy.IS_IE_?[]:"";a!=null&&this.append.apply(this,arguments)};soy.StringBuilder.prototype.bufferLength_=0; soy.StringBuilder.prototype.append=function(a,b){if(soy.IS_IE_)if(b==null)this.buffer_[this.bufferLength_++]=a;else{this.buffer_.push.apply(this.buffer_,arguments);this.bufferLength_=this.buffer_.length}else{this.buffer_+=a;if(b!=null)for(var c=1;c<arguments.length;c++)this.buffer_+=arguments[c]}return this};soy.StringBuilder.prototype.clear=function(){if(soy.IS_IE_)this.bufferLength_=this.buffer_.length=0;else this.buffer_=""}; soy.StringBuilder.prototype.toString=function(){if(soy.IS_IE_){var a=this.buffer_.join("");this.clear();a&&this.append(a);return a}else return this.buffer_};soy.renderElement=function(a,b,c){a.innerHTML=b(c)};soy.renderAsFragment=function(a,b){var c=document.createElement("div");c.innerHTML=a(b);if(c.childNodes.length==1)return c.firstChild;else{for(a=document.createDocumentFragment();c.firstChild;)a.appendChild(c.firstChild);return a}}; soy.$$augmentData=function(a,b){function c(){}c.prototype=a;a=new c;for(var d in b)a[d]=b[d];return a};soy.$$escapeHtml=function(a){a=String(a);if(!soy.$$EscapeHtmlRe_.ALL_SPECIAL_CHARS.test(a))return a;if(a.indexOf("&")!=-1)a=a.replace(soy.$$EscapeHtmlRe_.AMP,"&amp;");if(a.indexOf("<")!=-1)a=a.replace(soy.$$EscapeHtmlRe_.LT,"&lt;");if(a.indexOf(">")!=-1)a=a.replace(soy.$$EscapeHtmlRe_.GT,"&gt;");if(a.indexOf('"')!=-1)a=a.replace(soy.$$EscapeHtmlRe_.QUOT,"&quot;");return a}; soy.$$EscapeHtmlRe_={ALL_SPECIAL_CHARS:/[&<>\"]/,AMP:/&/g,LT:/</g,GT:/>/g,QUOT:/\"/g};soy.$$escapeJs=function(a){a=String(a);for(var b=[],c=0;c<a.length;c++)b[c]=soy.$$escapeChar(a.charAt(c));return b.join("")};soy.$$escapeChar=function(a){if(a in soy.$$escapeCharJs_)return soy.$$escapeCharJs_[a];var b=a,c=a.charCodeAt(0);if(c>31&&c<127)b=a;else{if(c<256){b="\\x";if(c<16||c>256)b+="0"}else{b="\\u";if(c<4096)b+="0"}b+=c.toString(16).toUpperCase()}return soy.$$escapeCharJs_[a]=b}; soy.$$escapeCharJs_={"\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\u000b":"\\x0B",'"':'\\"',"'":"\\'","\\":"\\\\"};soy.$$escapeUri=function(a){a=String(a);return soy.$$ENCODE_URI_REGEXP_.test(a)?a:encodeURIComponent(a)};soy.$$ENCODE_URI_REGEXP_=/^[a-zA-Z0-9\-_.!~*'()]*$/; soy.$$insertWordBreaks=function(a,b){a=String(a);for(var c=[],d=0,h=false,f=false,e=0,j=0,g=0,k=a.length;g<k;++g){var i=a.charCodeAt(g);if(e>=b&&i!=soy.$$CharCode_.SPACE){c[d++]=a.substring(j,g);j=g;c[d++]=soy.WORD_BREAK_;e=0}if(h){if(i==soy.$$CharCode_.GREATER_THAN)h=false}else if(f)switch(i){case soy.$$CharCode_.SEMI_COLON:f=false;++e;break;case soy.$$CharCode_.LESS_THAN:f=false;h=true;break;case soy.$$CharCode_.SPACE:f=false;e=0;break}else switch(i){case soy.$$CharCode_.LESS_THAN:h=true;break; case soy.$$CharCode_.AMPERSAND:f=true;break;case soy.$$CharCode_.SPACE:e=0;break;default:++e;break}}c[d++]=a.substring(j);return c.join("")};soy.$$CharCode_={SPACE:32,AMPERSAND:38,SEMI_COLON:59,LESS_THAN:60,GREATER_THAN:62};soy.WORD_BREAK_=soy.IS_WEBKIT_?"<wbr></wbr>":soy.IS_OPERA_?"&shy;":"<wbr>";soy.$$changeNewlineToBr=function(a){a=String(a);if(!soy.$$CHANGE_NEWLINE_TO_BR_RE_.test(a))return a;return a.replace(/(\r\n|\r|\n)/g,"<br>")};soy.$$CHANGE_NEWLINE_TO_BR_RE_=/[\r\n]/; soy.$$bidiTextDir=function(a,b){a=soy.$$bidiStripHtmlIfNecessary_(a,b);if(!a)return 0;return soy.$$bidiDetectRtlDirectionality_(a)?-1:1};soy.$$bidiDirAttr=function(a,b,c){b=soy.$$bidiTextDir(b,c);if(b!=a)return b<0?"dir=rtl":b>0?"dir=ltr":"";return""};soy.$$bidiMarkAfter=function(a,b,c){var d=soy.$$bidiTextDir(b,c);return soy.$$bidiMarkAfterKnownDir(a,d,b,c)}; soy.$$bidiMarkAfterKnownDir=function(a,b,c,d){return a>0&&(b<0||soy.$$bidiIsRtlExitText_(c,d))?"\u200e":a<0&&(b>0||soy.$$bidiIsLtrExitText_(c,d))?"\u200f":""};soy.$$bidiStripHtmlIfNecessary_=function(a,b){return b?a.replace(soy.$$BIDI_HTML_SKIP_RE_," "):a};soy.$$BIDI_HTML_SKIP_RE_=/<[^>]*>|&[^;]+;/g; soy.$$bidiSpanWrap=function(a,b){b=String(b);var c=soy.$$bidiTextDir(b,true),d=soy.$$bidiMarkAfterKnownDir(a,c,b,true);if(c>0&&a<=0)b="<span dir=ltr>"+b+"</span>";else if(c<0&&a>=0)b="<span dir=rtl>"+b+"</span>";return b+d};soy.$$bidiUnicodeWrap=function(a,b){b=String(b);var c=soy.$$bidiTextDir(b,true),d=soy.$$bidiMarkAfterKnownDir(a,c,b,true);if(c>0&&a<=0)b="\u202a"+b+"\u202c";else if(c<0&&a>=0)b="\u202b"+b+"\u202c";return b+d};soy.$$bidiLtrChars_="A-Za-z\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u0300-\u0590\u0800-\u1fff\u2c00-\ufb1c\ufdfe-\ufe6f\ufefd-\uffff"; soy.$$bidiNeutralChars_="\u0000- !-@[-`{-\u00bf\u00d7\u00f7\u02b9-\u02ff\u2000-\u2bff";soy.$$bidiRtlChars_="\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc";soy.$$bidiRtlDirCheckRe_=new RegExp("^[^"+soy.$$bidiLtrChars_+"]*["+soy.$$bidiRtlChars_+"]");soy.$$bidiNeutralDirCheckRe_=new RegExp("^["+soy.$$bidiNeutralChars_+"]*$|^http://");soy.$$bidiIsRtlText_=function(a){return soy.$$bidiRtlDirCheckRe_.test(a)};soy.$$bidiIsNeutralText_=function(a){return soy.$$bidiNeutralDirCheckRe_.test(a)}; soy.$$bidiRtlDetectionThreshold_=0.4;soy.$$bidiRtlWordRatio_=function(a){var b=0,c=0;a=a.split(" ");for(var d=0;d<a.length;d++)if(soy.$$bidiIsRtlText_(a[d])){b++;c++}else soy.$$bidiIsNeutralText_(a[d])||c++;return c==0?0:b/c};soy.$$bidiDetectRtlDirectionality_=function(a){return soy.$$bidiRtlWordRatio_(a)>soy.$$bidiRtlDetectionThreshold_};soy.$$bidiLtrExitDirCheckRe_=new RegExp("["+soy.$$bidiLtrChars_+"][^"+soy.$$bidiRtlChars_+"]*$"); soy.$$bidiRtlExitDirCheckRe_=new RegExp("["+soy.$$bidiRtlChars_+"][^"+soy.$$bidiLtrChars_+"]*$");soy.$$bidiIsLtrExitText_=function(a,b){a=soy.$$bidiStripHtmlIfNecessary_(a,b);return soy.$$bidiLtrExitDirCheckRe_.test(a)};soy.$$bidiIsRtlExitText_=function(a,b){a=soy.$$bidiStripHtmlIfNecessary_(a,b);return soy.$$bidiRtlExitDirCheckRe_.test(a)};