function unSML(oldMsg){
	var post="post";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		} 
	var url='templates/new/unSML.php';
	var adata=document.getElementById(post+oldMsg).innerHTML;
	xmlHttp.onreadystatechange=stateRepliesChanged
	xmlHttp.open("POST",url,true)
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.send(adata)
}

function stateRepliesChanged() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("message").innerHTML+=xmlHttp.responseText 
	} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 


function addslashes(str) {
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\0/g,'\\0');
return str;
}
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"');
str=str.replace(/\\\\/g,'\\');
str=str.replace(/\\0/g,'\0');
return str;
}


Array.prototype.inArray = function (value)
// Returns true if the passed value is found in the
// array.  Returns false if it is not.
{
    var ix;
    for (ix=0; ix < this.length; ix++) {
        // Matches identical (===), not just similar (==).
        if (this[ix] === value) {
            return true;
        }
    }
    return false;
};


function doBg(clrs)
	{
	document.body.style.backgroundImage='none';
	document.body.style.backgroundColor=clrs;
	}

function SelectCurrent() {
	document.getElementById('current').checked=true;
	var InputElements = document.getElementsByTagName("input");
	for(var i=0;i<InputElements.length;i++) {
		if(InputElements[i].getAttribute("type") == "checkbox" && InputElements[i].getAttribute("id") != "current") {
			InputElements[i].checked = false;
		}
	}
}

function SelectAll() {
	document.getElementById('current').checked=true;
	var InputElements = document.getElementsByTagName("input");
	for(var i=0;i<InputElements.length;i++) {
		if(InputElements[i].getAttribute("type") == "checkbox") {
			InputElements[i].checked = true;
		}
	}
}

function SelectInverse() {
		document.getElementById('current').checked=false;
		var InputElements = document.getElementsByTagName("input");
		for(var i=0;i<InputElements.length;i++) {
			if(InputElements[i].getAttribute("type") == "checkbox" && InputElements[i].getAttribute("id") != "current") {
				InputElements[i].checked = true;
			}
		}
	} 

function JQtoggle(elid) {
	try{
	if(document.getElementById('cc'+elid).style.display=='none')
	{
	$("#c"+elid).html('<span style="cursor:pointer" title="uitklappen" align="center" onClick="JQtoggle('+elid+');"><img src="http://i.fokzine.net/templates/new/i/minb.gif"></span>');
	setCookie(elid,'1',365,'/',host, false);
	}
	else
	{
	$("#c"+elid).html('<span style="cursor:pointer" title="inklappen" align="center" onClick="JQtoggle('+elid+');"><img src="http://i.fokzine.net/templates/new/i/plusb.gif"></span>');
	setCookie(elid,'0',365,'/',host, false);
	}
	$("#cc"+elid).toggle('fast', function() {
 if ($.browser.msie)
       this.style.removeAttribute('filter');
 });
}catch(e){}
}

function sfhide(elid) {
	document.getElementById('subf'+elid).style.display='none';
	document.getElementById('sf'+elid).innerHTML='<span style="cursor:pointer" title="subforums uitklappen" align="center" onClick="sfshow('+elid+');"><img src="http://i.fokzine.net/templates/new/i/plus.gif"> <b>subforums uitklappen</b></span>';
	setCookie('subf'+elid,'0',365,'/',host, false);
	}

function sfshow(elid) {
	document.getElementById('subf'+elid).style.display='block';
	document.getElementById('sf'+elid).innerHTML='<span style="cursor:pointer" title="subforums inklappen" align="center" onClick="sfhide('+elid+');"><img src="http://i.fokzine.net/templates/new/i/min.gif"> <b>subforums inklappen</b></span>';
	setCookie('subf'+elid,'1',365,'/',host, false);
	}


function tthide(elid,tt) {
	var atts="table #"+tt;
	document.getElementById(tt).style.display='none';
	document.getElementById('t'+tt).innerHTML='<img src="http://i.fokzine.net/templates/new/i/plus.gif" alt="" title="uitklappen"  style="cursor:pointer;" onClick="ttshow('+elid+',\'closedtopic\');">';
	setCookie(tt+elid,'0',365,'/',host, false);
	}

function ttshow(elid,tt) {
	document.getElementById(tt).style.display='';
	document.getElementById('t'+tt).innerHTML='<img src="http://i.fokzine.net/templates/new/i/min.gif" alt="" title="inklappen"  style="cursor:pointer;" onClick="tthide('+elid+',\'closedtopic\');">';
	setCookie(tt+elid,'1',365,'/',host, false);
	}

function cookieCheck() {
	setCookie('Enabled', 'true',1,'/',host, false);
	if (getCookie('Enabled') == null) {
		document.write('<div id="jsError">Dit forum werkt met cookies. Je browser ondersteunt geen cookies of je weigert cookies. Klik <a href="http://wiki.fok.nl/index.php/GeenCookies" title="Wat is dit voor een melding en waarom krijg ik hem?">hier<\/a> voor meer informatie.<\/div>');
	}else{
		document.write('<div id="jsError" style="display:none;"></div>');
	}
}		

function delnote(id) {if (confirm("Note verwijderen?")){location=basehref+"fok/delete_usernote/"+id+"";}}
function hopforum(s) {self.location=basehref+s;}
function quickhop(s) {self.location=s;}
function deltopicnote(id) {if (confirm("Note verwijderen?")){location=basehref+"fok/delete_topicnote/"+id+"";}}
function del_usericon(name){location=basehref+"fok/use_usericon/"+name;}

/*
De onderstaande Javascript is geschreven door Crisp, van Tweakers.net en is
gebruikt met toestemming. De code is hier en daar een tikkeltje aangepast voor gebruik en extra features op FOK!

De originele code, en de schrijver, zijn beide te bewonderen op het forum van
onze buren; Gathering of Tweakers.

http://gathering.tweakers.net
*/
var incompetent_browser = document.all && navigator.userAgent.indexOf('MSIE') > -1 && navigator.userAgent.indexOf('Opera') == -1;
var atarget = null;
function initMessageBox(isqr)
{
	atarget = $$('message');
	if (atarget !== null)
	{
		if (isqr != '1') { atarget.focus(); }
		if (typeof atarget.createTextRange != 'undefined')
		{
			atarget.onkeydown = shortkey;
			atarget.onkeyup = storeCursor;
			atarget.onclick = storeCursor;
			atarget.onselect = storeCursor;
			atarget.onselect();
		}
		else
		{
			atarget.onkeypress = shortkey;
		}
	}
}
function storeCursor()
{
	this.cursorPos = document.selection.createRange().duplicate();
}

function det_replace(type, text)
{
	var aval = '';
	switch (type)
	{
		case 'plain':
			break;
		case 'bold':
			text = '[b]'+text+'[/b]';
			break;
		case 'italic':
			text = '[i]'+text+'[/i]';
			break;
		case 'underline':
			text = '[u]'+text+'[/u]';
			break;
		case 'strike':
			text = '[s]'+text+'[/s]';
			break;
		case 'sub':
			text = '[sub]'+text+'[/sub]';
			break;
		case 'sup':
			text = '[sup]'+text+'[/sup]';
			break;
		case 'spoiler':
			text = '[spoiler]'+text+'[/spoiler]';
			break;
		case 'code':
			text = '[code]'+text+'[/code]';
			break;
		case 'php':
			text = '[php]'+text+'[/php]';
			break;
		case 'quote':
			text = '[quote]'+text+'[/quote]';
			break;
		case 'me':
			text = '[me='+thisuser+']'+text+'[/me]';
			break;
		case 'listbullet':
			//text = '\r\n[*]'+(text.split(/\r?\n/).join('\r\n[*]'))+'\r\n';
			text = '\r\n[*]'+(text.split(/\r?\n/).join('\r\n[*]'));
			break;
		case 'url':
			if (/^(http:\/\/|www\.)/i.test(text))
			{
				aval = prompt('Voer omschrijving in:', text);
				if (aval !== null && aval !== '') {text = '[url='+text+']'+aval+'[/url]';}
			}
			else
			{
				aval = prompt('Voer de URL in:','http:\/\/');
				if (aval !== null && aval != 'http:\/\/')
				{
					if (text === '') {text = '[url]'+aval+'[/url]';}
					else {text = '[url='+aval+']'+text+'[/url]';}
				}
			}
			break;
		case 'img':
			if (text === '')
			{
				aval = prompt('Voer de URL in:','http:\/\/');
				if (aval !== null && aval != 'http:\/\/') {text = '[img]'+aval+'[/img]';}
			}
			else
			{
				text = '[img]'+text+'[/img]';
			}
			break;
		case 'quotesplits':
			text += '[/quote]\r\n[quote]';
			break;
	}

	return text;
}

function putStr(text)
{
	putExt('plain', text);
}

function AddSmile(text)
{
	putExt('plain', text);
}
function putExt(type, text)
{
	if (atarget !== null)
	{
		if (typeof atarget.cursorPos != 'undefined')
		{
			var cursorPos = atarget.cursorPos;
			if (type != 'plain') {text = cursorPos.text;}
			cursorPos.text = det_replace(type, text);
		}
		else if (typeof atarget.selectionStart != 'undefined')
		{
			// remember scrollposition
			var scrollTop = atarget.scrollTop;

			var sStart = atarget.selectionStart;
			var sEnd = atarget.selectionEnd;
			if (type != 'plain') {text = atarget.value.substring(sStart, sEnd);}
			text = det_replace(type, text);
			atarget.value = atarget.value.substr(0, sStart) + text + atarget.value.substr(sEnd);
			var nStart = sStart == sEnd ? sStart + text.length : sStart;
			var nEnd = sStart + text.length;
			atarget.setSelectionRange(nStart, nEnd);

			// reset scrollposition
			atarget.scrollTop = scrollTop;
		}
		else
		{
			if (type != 'plain') {text = '';}
			atarget.value += det_replace(type, text);
		}

		atarget.focus();
		if (typeof atarget.cursorPos != 'undefined') {atarget.onselect();}
	}
}

function shortkey(e)
{
	if (!e) {e = event;}

	var akey = 0;
	if (e.KeyCode) {key = e.KeyCode;}
	else if (e.which) {akey = e.which - 32;}

	if (e.ctrlKey && !e.shiftKey)
	{
		switch (akey)
		{
			case 66:
				putExt('bold');
				return cancelEvent(e);
			case 73:
				putExt('italic');
				return cancelEvent(e);
			case 83:
				putExt('strike');
				return cancelEvent(e);
			case 85:
				putExt('underline');
				return cancelEvent(e);
		}
	}

	return true;
}
function is_ignorable(nod) {
   return (nod.nodeType == 8 || (nod.nodeType == 3 && !/[^\t\n\r ]/.test(nod.data)));
}
function node_after( sib ) {
	if (sib) {
		while ((sib = sib.nextSibling) !== null) {
			if (!is_ignorable(sib)) {return sib;}
		}
	}
	return null;
}
function winopen(url, winname, width, height, extra)
{
	if (!extra) {extra = '';} else {extra = ',' + extra;}
	var popup = window.open(url,winname,'toolbar=no,location=no,menubar=no,width='+width+',height='+height+',resizable=yes,status=no'+extra);
	try { popup.focus(); } catch(e) {}
}

function openImage()
{
	var winwidth = (this.naturalWidth < screen.availWidth ? this.naturalWidth : screen.availWidth);
	var winheight = (this.naturalHeight < screen.availHeight ? this.naturalHeight : screen.availHeight);
	winopen(basehref+'templates/new/showimage.html?'+escape(this.src),'',winwidth,winheight,'scrollbars=no,left=0,top=0');
}

function openGalleryImage(imagelocation,wt,ht)
{
	var winwidth = (wt < screen.availWidth ? wt : screen.availWidth);
	var winheight = (ht < screen.availHeight ? ht : screen.availHeight);
	winopen(basehref+'templates/new/showimage.html?'+escape(imagelocation),'',winwidth,winheight,'scrollbars=no,left=0,top=0');
}

function cancelEvent(e)
{
	if (typeof e.preventDefault != 'undefined')
	{
		e.preventDefault();
	}
	else if (typeof e.cancelBubble != 'undefined')
	{
		if (e.keyCode) {e.keyCode = 0;}
		e.returnValue = 0;
		e.cancelBubble = true;
	}

	return false;
}


/*
DOM functies
*/
function add_bookmark(form) {
	var name = form['titel'].value;
	if (name.length<1) 
		{
		alert("Bookmark is niet toegevoegd.");
		return false;
		}
	if (name.length>0) 
		{
		alert("Bookmark wordt toegevoegd");
		form['titel'].value=name;
		return true;
		//alert("Bookmark met titel: '"+titel+"' toegevoegd. Via de bookmarks-pagina kun je een omschrijving toevoegen.");
		}
	}

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (il = 0, j = 0; il < elsLen; il++) {
		if ( pattern.test(els[il].className) ) {
			classElements[j] = els[il];
			j++;
		}
	}
	return classElements;
}
function $$() {
	var elements = new Array();
	for (var il = 0; il < arguments.length; il++) {
		var element = arguments[il];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}

function dce(name) {
	return document.createElement(name);
}

function ctn(content) {
	return document.createTextNode(content);
}

function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent) {
		var ar = elm.attachEvent('on' + evType, fn);
		return ar;
	}
	else {
		elm['on' + evType] = fn;
		return true;
	}
}
function removeEvent( obj, type, fn ) {
		if ( obj.detachEvent ) {
			obj.detachEvent( 'on'+type, obj[type+fn] );
			obj[type+fn] = null;
		} else
			obj.removeEventListener( type, fn, false );
}
function input(type,name,value,theClass) {
	try {
		var il = dce('<input type="'+type+'" name="'+name+'" id="'+name+'" value="'+value+'" class="'+theClass+'" />');
	} catch (e) {
		il = dce('input');
		il.setAttribute('id',name);
		il.setAttribute('type',type);
		il.setAttribute('name',name);
		il.setAttribute('value',value);
		il.className = theClass;
	}
	return il;
}

function loadWindow() {
	if (cNewPage == 1) {
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var il=0; il<anchors.length; il++) {
			var anchor = anchors[il];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
				anchor.target = "_blank";
			}
		}
	}
	//if(typeof(document.getElementById('jsError')) != 'undefined') {
		//document.getElementById('jsError').style.display = 'none;';
	//}
}
window.onload = loadWindow;
function toggleStr(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}
function toggleSub(e) {
	if (!e) var e = window.event;
	//(selectcategory,warningdiv,category_count)
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) {// defeat Safari bug
		targ = targ.parentNode;
	}
	var theID = targ.getAttribute('id');
	if(theID.indexOf('subarrow') == -1) {
		targ = targ.parentNode;
	}
	theID = targ.getAttribute('id');
	var splitID = theID.split("_");
	var realID = parseInt(splitID[1]);
	//alert();
	var el = document.getElementById('content' + realID);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
	var img = document.getElementById('content' + realID + 'img');
	if (img.alt == 'Uitklappen') {
		img.setAttribute('src','/templates/foksilver/i/uitklap_min.gif');
		img.setAttribute('alt','Inklappen');
	} else {
		img.setAttribute('src','/templates/foksilver/i/uitklap_plus.gif');
		img.setAttribute('alt','Uitklappen');
	}
	var span = document.getElementById('content' + realID + 'expl');
	if(span.innerHTML == '(Subfora uitklappen)') {
		span.innerHTML = '(Subfora inklappen)';
		//Hier ook ff een cookie zetten:
		setCookie(theID + 'status','on',24,'/',host, false);
	} else {
		span.innerHTML = '(Subfora uitklappen)';
		setCookie(theID + 'status','off',31,'/',host,false);
	}
}
function toggle(el) {
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}

function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60*60*24; // dagen
	}
	var expires_date = new Date( today.getTime() + expires );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}

function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

function countDelMessages() {
   var theForm = document.delmsgs;
   var selectedMessages = 0;
   for (var il=0;il<theForm.elements.length;il++) {
   	   if ((theForm.elements[il].type.indexOf('checkbox') > -1) && theForm.elements[il].checked == true) {
         selectedMessages++;
      }
   }
   if(selectedMessages==0) {
      alert('Selecteer eerst berichten.' );
   } else {
      theForm.submit();
   }
} 

function addSpaces()
	{
	invoer=$("textarea#message").attr("value");
	tempValue = invoer.replace(/\[img\](https?|ftp|file)(:\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$])\[\/img\]/img, '<img src="$1$2">');
	$("#images").html(tempValue); iaantal=$("#images").find("img").length;

	try{
	// voegt automatisch spaties toe voor elke \n en [/spoiler en [/quote tag
	invoer=$("textarea#message").attr("value");
	invoerNew=invoer.replace(/\b(https?|ftp|file)(:\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$])(\n|\r|\r\n)/ig, "$1$2 $3");
	invoerNew=invoer.replace(/(\[spoiler\]|\[quote\]|\[q\]|\[kwoot\])(\w*?:\/\/.*?)(\[\/)(spoiler\]|quote\]|kwoot\]|q\])/ig, "$1 $2 $3$4");
	
	// img=x,x verkleining onmogelijk maken
	invoerNew = invoerNew.replace(/(\[img=\d,\d\]|\[img=\d\d,\d\]|\[img=\d,\d\d\])(.*?)(\[\/img\])/img, "[img=51,51]$2?&isspam=1$3");


	// maakt youtube links van [url=youtube] omzeiling
	//invoerNew=invoerNew.replace(/\[url=(http:\/\/)(.*?)(youtube\.com\/watch\?v=)(\w*?)\](.*?)\[\/url\]/gi, "[youtube=$1$2$3$4]$5[/youtube]");
	//invoerNew=invoerNew.replace(/\[url=(http:\/\/)(.*?)(youtube\.com\/)(.*?)(v)(=|\/)(.*?)\](.*?)\[\/url\]/gi, "[youtube=http://www.youtube.com/watch?v=$7]$8[/youtube]");
	invoerNew=invoerNew.replace(/(\[url=)(http:\/\/)(.*?)(www\.|\.)(youtube\.)(co\.uk|co\.kr|co\.jp|\D{2,4}\/?\/)(\/|)(.*?)(v\/|v=)(.*?)\](.*)\[\/url\]/img, "[youtube=http://www.youtube.com/watch?v=$10]$11[/youtube]");
	invoerNew=invoerNew.replace(/(http:\/\/)(.*?)(www\.|\.)(youtube\.co\.kr\/|youtube\.co\.jp\/)(.*?)(v\/|v=)(\S*)/img, "[youtube=http://www.youtube.com/watch?v=$7]http://www.youtube.com/watch?v=$7[/youtube]");
	// voer aangepaste input in in textarea
	$("textarea#message").attr("value",invoerNew);
	youtubenewwindow(); spoiler();
	}catch(e){alert("error: "+e);}
	if(iaantal>30 && op!=1){alert("Je post bevat "+iaantal+" afbeeldingen. Om te voorkomen dat pagina's erg traag worden verzoeken we je niet meer dan 30 afbeeldingen per post te plaatsen. En dat is al aan de hoge kant."); return false;}
}



function spoiler()
	{
	try{	
	var spcount=0;
	// we selecteren alle blockquote elementen op de pagina die een spoiler zijn
	$("div[class=spoiler]").each(function() {
			// unieke divid genereren voor de div a la <div class='spoiler' id='spoiler1.. spoiler2.. etc'>
			spcount++;
			if($(this).attr("id")!="spoiler"+spcount){
			$(this).attr("id","spoiler"+spcount);
			$(this).css("display","none");
			$(this).closest("blockquote").prepend("<img id=\"spimg"+spcount+"\" src=\"http://i.fokzine.net/templates/new/i/plus.gif\" alt=\"\" title=\"spoiler weergeven\" border=\"0\" style=\"margin-left:3px;\">&nbsp;");
			$(this).closest("blockquote").wrap("&nbsp;<span style=\"width:424px;overflow:none;color:#000000;\" onclick=\"toggleSpoiler("+spcount+")\" class=\"spoilertoggle\"></span>");
			$(this).closest("blockquote").css("background-color","#a0a0a0");
			$(this).closest("blockquote").css("width","424px");
			$(this).closest("blockquote").css("border","1px dashed #808080");
			$(this).closest("blockquote").css("padding","0");
		}
		})
	}
	catch(e){}
}

function toggleSpoiler(nummer)
	{
	try{
	if(document.getElementById('spoiler'+nummer).style.display=='none')
		{
		$("#spoiler"+nummer).closest("blockquote").css("border-bottom","0");
		$("#spoiler"+nummer).closest("blockquote").css("padding","1");
		$("#spimg"+nummer).attr("src","http://i.fokzine.net/templates/new/i/min.gif");
		}
	else
		{
		$("#spoiler"+nummer).closest("blockquote").css("border-bottom","1px dashed #808080");
		$("#spoiler"+nummer).closest("blockquote").css("padding","0");
		$("#spimg"+nummer).attr("src","http://i.fokzine.net/templates/new/i/plus.gif");
		}
	$("#spoiler"+nummer).toggle();
	}
catch(e){}
}

function hideshow()
	{
	var thisx=document.getElementById('cDropDownMenu').value;
	if(thisx=='1')
		{
		document.getElementById('cmenu').style.display='inline';
		}
	else
		{
		document.getElementById('cmenu').style.display='none';
		}
	}
	

function canviewdel(canviewdelvalue){
	setCookie('canviewdel',canviewdelvalue,365,'/',host, false); 
}

function fhover(el){
	el.style.backgroundColor='#E4EDF8';
}
function funhover(el){	
	el.style.backgroundColor='#f8f8f8';
}


/* hier begint client.js */
	var request;
	var response;
	var callback;
	var theParams;
	var baseurl = basehref+"rde/server/";
	var getMessageField = '';

	if (typeof(basepath) == "undefined") {
	var	basepath = '/';
	}
	var baseurl = basepath+"rde/server/";
	var getMessageField = ''; 

function previewMessage(text) {
	text = document.getElementById('message').value;
	setCallback('updateText');
	var params = new Array();
	params[0] = text;
	postServer('parsesml',params);
	document.getElementById('message').focus();
}

function updateText(){
    document.getElementById('msgPreview').innerHTML=response;
    var tg=0; var tbx=0; var revgal=0;
	spoiler(); resizer(); youtubenewwindow();
}

function placeQuote(){
  	atarget = document.getElementById('message');
	putStr('');
	putStr(stripslashes(response));
}

function youtubenewwindow(){ 
	tel=0; thisdebug="";
	// maakt van normale linkjes die stiekem een youtube filmpje zijn een icoontje
	$("a[target=_blank][href*=youtube.com/]").each(function(){
		if($(this).closest("div").hasClass("spoiler") == true || $(this).closest("div").hasClass("quote") || $(this).closest("div").hasClass("forumpost") || $(this).closest("td").hasClass("forumpost") ) 
			{
			thistitle=$(this).text();
			thisitem=$(this).attr("href");
	        thisitem=thisitem.replace(/(http:\/\/)(www\.|)youtube\.(co\.uk|co\.kr|co\.jp|\w{2,4}).*?(v\/|&v=)(\w*\d*?)/img, "$5");
	        //thisitem=thisitem.replace(/(http:\/\/)(www\.|)youtube\.(co\.uk|co\.kr|co\.jp|\w{2,4}).*?(v\/|&v=)[^"]([\w_\-&#]*)/img, "$5");
			//thisitem=thisitem.replace(/(http:\/\/)(.*?)(.youtube.com\/)(watch\?)(.*?)(v=)(\w*\d*?)(.*)/img, "$7")
			//thisitem=thisitem.replace(/http:\/\/.*\.youtube\.com\/watch.*\?.*v=(.*)/ig, "$1");
			//thisitem=thisitem.replace(/(.*?)&.*/ig, "$1");
			//thisitem=escape(thisitem);
			//thistitle=thistitle.replace(/["]/img, '\\"');
			thistitle=thistitle.replace(/(["&%$])/img, "\\$1");
			thisitem=thisitem.replace(/["]/img, '');
			if(thisitem.length<18 && thisitem.length>3){
			$(this).wrap("<div class=\"youtube_video\"></div>");
			$(this).before("<a href=\"http://www.youtube.com/watch?v="+thisitem+"\" title=\""+thistitle+"\"><img alt=\""+thistitle+"\" src=\"http://i.ytimg.com/vi/"+thisitem+"/2.jpg\"></a><br />");
			thisdebug+=thistitle+"\n"+thisitem+"\n";
			}
			}
	})
	// maakt van metacafe linkjes soortgelijke youtube dingen (BETA!)
	$("a[target=_blank][href*=metacafe.com/watch]").each(function(){
		thisbasictitle=''; thistitle=''; thisitem='';
		if($(this).closest("div").hasClass("spoiler") == true || $(this).closest("div").hasClass("quote") || $(this).closest("div").hasClass("forumpost") || $(this).closest("td").hasClass("forumpost"))
			{
			thisbasictitle=$(this).attr("href");
			thistitle=thisbasictitle.replace(/(http:\/\/www.metacafe.com\/watch\/)([0-9]*?)(\/)(.*)/img, "$4");
			thistitle=thistitle.replace("/",""); 
			thisitem=$(this).attr("href").replace(/(http:\/\/www.metacafe.com\/watch\/)([0-9]*?)(\/)(.*)/img, "$2");
			$(this).text(thistitle);
			$(this).wrap("<div class=\"youtube_video\"></div>");
			$(this).before("<a href=\"http://www.metacafe.com/watch/"+thisitem+"/"+thistitle+"\" title=\""+thistitle+"\"><img alt=\""+thistitle+"\" src=\"http://www.metacafe.com/thumb/"+thisitem+".jpg\"></a><br />");
			}
		})
		
	// maakt van snotr linkjes soortgelijke youtube dingen (BETA!)
	$("a[target=_blank][href*=snotr.com/video]").each(function(){
		thisbasictitle=''; thistitle=''; thisitem='';
		if($(this).closest("div").hasClass("spoiler") == true || $(this).closest("div").hasClass("quote") || $(this).closest("div").hasClass("forumpost") || $(this).closest("td").hasClass("forumpost"))
			{
			thistitle=$(this).text();
			thisitem=$(this).attr("href").replace(/(http:\/\/www.snotr.com\/video\/)([0-9]*)/img, "$2");
			$(this).text(thistitle);
			$(this).wrap("<div class=\"youtube_video\"></div>");
			$(this).before("<a href=\"http://www.snotr.com/video/"+thisitem+"\" title=\""+thistitle+"\"><img alt=\""+thistitle+"\" src=\"http://videos.snotr.com/"+thisitem+"-large.gif\" width=\"140\"></a><br />");
			}
		})
		
	// koppelt viewer aan youtube icoontjes
	$(".youtube_video > a").attr("target","_blank");
	$(".youtube_video > a > img").each(function(){
		tel++; snotr=0;
		$(this).closest('a').attr("rel","youtube");
		bronURL=$(this).closest('a').attr('href');
		getURLYT=bronURL.replace("youtube.com");
		getURLMC=bronURL.replace("metacafe.com");
		getURLSN=bronURL.replace("snotr.com");
		if(bronURL!=getURLYT) { toURL='http://www.fok.nl/danny/yt.php'; }
		if(bronURL!=getURLMC) { toURL='http://www.fok.nl/danny/mc.php'; }
		if(bronURL!=getURLSN) { toURL='http://www.snotr.com/embed/'; snotr=1;} 
		bronURL=bronURL.replace("http://www.youtube.com/watch?v=","");
		bronURL=bronURL.replace("http://nl.youtube.com/watch?v=","");
		bronURL=bronURL.replace("http://www.metacafe.com/watch/","");
		bronURL=bronURL.replace("http://www.snotr.com/video/","");
		if(snotr==1){ bronURL=toURL+bronURL+"?autoplayiframe"; } else { bronURL=toURL+"?iframesrc="+bronURL; }
		$(this).closest('a').attr("href",bronURL);
	})
	jQuery(function($) {	
			$("a[rel='youtube']").fancybox({
			'frameWidth': 640,
			'frameHeight': 385,
			'zoomSpeedIn':		300, 
			'zoomSpeedOut':	300, 
			'overlayShow':		true,
			'overlayOpacity': 0.8,
			'hideOnContentClick': true,
			'callbackOnClose': 'emptydiv();'
			});
			})
}

function emptydiv() {
	alert("close!");
	$("div #fancy_content").empty();
	$("iframe #fancy_frame").src("");
	}
	
function setCheckboxesRange(the_form, do_check, basename, min, max){
    		for (var i = min; i <= max; i++) { 
					if (typeof(document.forms[the_form].elements[basename + i]) != 'undefined') {
						document.forms[the_form].elements[basename + i].checked = do_check;
					}
				}
			}
			
function toggleDiv(where)
	{
    if(document.getElementById(where).style.display=='none') 
    	{
        document.getElementById(where).style.display='block'
        if(where=="livescores")	{ var forekhid=0; setCookie('forekhid',forekhid,30,'/','fok.nl', false); }
    	} 
    else 
    	{
        document.getElementById(where).style.display='none'
        if(where=="livescores")	{ var forekhid=1; setCookie('forekhid',forekhid,30,'/','fok.nl', false); }
    	}
	}

function toggleInline(where)
	{
    if(document.getElementById(where).style.display=='none') 
    	{
        document.getElementById(where).style.display='inline'
        if(where=="livescores")	{ var forekhid=0; setCookie('forekhid',forekhid,30,'/','fok.nl', false); }
    	} 
    else 
    	{
        document.getElementById(where).style.display='none'
        if(where=="livescores")	{ var forekhid=1; setCookie('forekhid',forekhid,30,'/','fok.nl', false); }
    	}
	}	
	
function setSessionTemplate(templatename)
	{
	if(templatename=='remove') { setCookie('sessiontemplate','',-1,'/','fok.nl', false); }
	else { setCookie('sessiontemplate',templatename,999,'/','fok.nl', false); }
	window.location.reload();
    } 

function editGroupName(where, groepnaam){
	var inner=document.getElementById(where).innerHTML;
	document.getElementById(where).innerHTML='<input type=text name='+where+' size=30 maxlength=30 value=\''+groepnaam+'\'><input type=submit value=invoeren onclick=submitEditGroupName(where);>';
	}
	
function placeQuoteB(response,posticon){
       clientTarget = document.getElementById('message');
       putStr('');
       response=response.replace("[quote]", "[quote][img=12,12]http://i.fokzine.net/templates/new/i/p/"+posticon+".gif[/img] ");
       putStr(stripslashes(response));
}

function getQuoteMessageB(topicid,postid,posticon){
	setCallback('none('+posticon+');none');
	var params = new Array();
	params[0] = topicid.toString();
	params[1] = postid.toString();
	params[2] = path;
	
	postServer('quote',params);
	document.getElementById('message').focus();
}

function none(posticon) {
	if(posticon) { placeQuoteB(response,posticon); }
}

	
function brokenRemove() {
	try{
	$("img").eacherror(function(){
  $(this).hide();
});
	}catch(e){}
}

function resizer(max_width,thumber)
	{
	try{
	// by Danny Roodbol
	$(document).ready(function(){
	if(!max_width) { var max_width = 610; } 
	var selector = '.rde_img_default,.rde_img_leftalign,.rde_img_centeralign,.rde_img_rightalign'; 	// alleen images met ingevoerde classes worden geresized

	$(selector).each(function(){
		var width = $(this).width(); var height = $(this).height();
		$(this).attr("title", width+"*"+height+" pixels");
		if($(this).attr("src").indexOf("cosgan.de")>0) { $(this).css("display","none"); }
		if (width > max_width) 
			{
			var ratio = (height / width );
			var new_width = max_width;
			var new_height = Math.round(new_width * ratio);
			if(height<1 && width>=1) { height=Math.round(width*ratio); }
		if(width<1 && height>=1) { width=Math.round(height*(width/height)); }
			
			//plaatje verkleinen en link bakken indien geen topicgallery
			$(this).height(new_height).width(new_width);
			$(this).css("border","1px dashed #F00000");
			$(this).hover(function(){
				$(this).attr("title", "Dit plaatje is automatisch verkleind naar "+new_width+"*"+new_height+" pixels.  Klik hier om het plaatje in het oorspronkelijke formaat ("+width+"*"+height+") te bekijken.");
				$(this).css("cursor","pointer");
				});
			$(this).click(function(){
				urlsrc=$(this).attr("src");
				gotosrc="http://forum.fok.nl/templates/new/showimage.html?"+urlsrc;
				try{
				wt=width+15; ht=height+15;
				openGalleryImage(urlsrc,wt,ht);
				return false;
				//thewindow=gotosrc+","+urlsrc+",height="+(height+15)+",width="+(width+15)+",menubar=0,toolbar=0,scrollbars=0,status=0,resizable=1";
				//window.open(thewindow);
				}catch(e){ }
				});
			}
		});
	});
	initLightBox(1,1,1);

}catch(e){}
}

function getF() 
		{
		tel=0;
		$("img[src*='chrome://']").each(function()
			{
			$(this).unbind("click");
			papa=$(this).parent().attr("id");
			papaid="#"+papa;
			$(papaid).wrap("<div style=\"display:none !IMPORTANT\"></div>");
			});
		}


function blbl() 
	{
		/*
	var selector = "iframe[src*='google'],img[src*='google']";
	mld=0;
	$(selector).each(function(){
		if($(this).css("display")=="none"){
			if(mld!=1){
				alert("Schakel aub uw adblocker uit. FOK! is een gratis dienst en kan alleen bestaan op advertentie-inkomsten. Het blokkeren van advertenties is in strijd met onze algemene voorwaarden.\nWil je toch geen advertenties zien, ga dan naar shop.fok.nl en sluit een abonnement af.\nDiverse functies worden nu tijdelijk uitgeschakeld.");	
				$("#menuBottom").css("display","none");	
				$(".bottomMenu>a").css("display","none");
				$(".ar").hide();
				$("a").unbind("click");
				$("#topicOptions").css("display","none");
				//$("a").attr("href","http://shop.fok.nl"); 
				mld=1;}}});
		*/
	}
		
		
function thumber(max_width,thumber)
	{
		try{
	// by Danny Roodbol
	$(document).ready(function(){
	if(!max_width) { var max_width = 150; } 
	var selector = '.rde_img_default,.rde_img_leftalign,.rde_img_centeralign,.rde_img_rightalign'; 	// alleen images met class .rde_img_default worden geresized
	var imageCount;
	
	$(selector).each(function(){
		$(this).css=("width","auto !IMPORTANT");
		$(this).css=("height","auto !IMPORTANT");
		var width = $(this).width(); var height = $(this).height();
		
		imgsrc=$(this).attr("src");
		//var postId=$(this).closest("table").attr("mid"); // alle foto's in de huidige post
		var postId=$(this).closest("table").attr("mem"); // alle foto's geplaatst door deze user
		$(this).attr("title", width+"*"+height+" pixels");
		var ratio = (height / width);
		//if(width<1 && height>=1) { width=Math.round(height/ratio); }
		if(height<1 && width>=1) { height=Math.round(width*ratio); }
		if(width<1 && height>=1) { width=Math.round(height*(width/height)); }
		
		if (width > max_width || height<1 || width<1) 
			{	
			var new_width = max_width;
			var new_height = Math.round(new_width * ratio);
			
			//plaatje verkleinen en link bakken
			$(this).height(new_height).width(new_width);
			$(this).css("border","2px solid #000000");
			$(this).css("display","inline");
			$(this).attr("rel","done");
			
			// heeft het plaatje al een link?
			var parentTag = $(this).parent().get(0).tagName;
			linksrc=$(this).parent().attr("href");
						
			// plaatje heeft nog geen link, dus bak er een...
			if(parentTag!='A' && parentTag!='a')
				{
				var hastag=1;
				$(this).wrap("<a href=\""+imgsrc+"\" rel=\"lightbox-"+postId+"\" title=\"Gepost door "+postId+"\"></a>");
				$(this).css("marginBottom","2px");
				}			
			else
				{
				var hastag=0;
				}	
			// pas nu bestaande link van het plaatje aan...
			$(this).parent().attr("href",imgsrc);
			$(this).parent().attr("rel","lightbox-"+postId);
				
			// ...en plak er een nieuwe link achteraan als er al een link was...
			if(hastag==0)
				{
				$(this).parent().after("<a href=\""+linksrc+"\" target=\"_blank\"><div style=\"width:"+new_width+"px;overflow:none;background:#404040;border:2px solid #000000;color:#e0e0e0;display:block;font-size:10px;margin-bottom:2px;\" class=\"nodec\">&raquo volg hier de link...</div></a>");  
				}
			
			$(this).attr("title", "Dit plaatje is automatisch verkleind naar "+new_width+"*"+new_height+" pixels.  Klik hier om in te zoomen.");
			$(this).css("cursor","pointer");
						}
		});
	});
}catch(e){ }
}

function topicGallery(min_width,min_height,camefrom,revgal,boxtype){
	// by Danny Roodbol
	var tgstart="<div style=\"width:762px;max-width:762px;padding:4px;overflow:auto;overflow:-moz-scrollbars-horizontal;overflow:-web-scrollbars-horizontal;overflow-x:scroll;word-wrap:nowrap;background:#f4f4f4;\" class=\"btd\"><table><tr>";
	var tgallery="";
	$("#tgaantal").html('<span style="font-size:10px;"> reloading... </span>');
	$(document).ready(function(){

	// alleen images met class .rde_img_default worden meegenomen in de gallery
	var selector = '.rde_img_default,.rde_img_leftalign,.rde_img_centeralign,.rde_img_rightalign'; 	var galleryImages=0;
	var ingallery = new Array();
	
	// plaatjes verkleinen (phpth)
	//var maxw=screen.availWidth; var maxh=screen.availHeight;
	maxw=$(window).width(); 
	maxh=$(window).height(); 

	maxw=maxw-50;maxh=maxh-120;
	if(maxw<640){maxw=640;}	if(maxh<300){maxh=300;}
	// onderstaande uitvoeren op elke gevonden image
	$(selector).each(function(){
		var width = $(this).width(); var height = $(this).height();
		//alert(width+" > "+maxw+" -- "+height+" > "+maxh);
		var imgsrcsmall="";
		
	
		// is het plaatje niet kleiner dan de minimaal opgegeven grootte
		totalPixels=width*height;
		minTotalPixels=min_width*min_height;
		if(totalPixels>=minTotalPixels)
			{		
			imgsrc=$(this).attr("src");	
			if(!ingallery.inArray(imgsrc))
			{
			galleryImages++; 			
			ingallery[galleryImages]=imgsrc;
			$("#tgaantal").html("<span style=\"font-size:10px;\">"+galleryImages+" afbeeldingen gevonden...");
			$(this).before("<a name=\"pic"+galleryImages+"\"></a>");
			var postedBy=$(this).closest("table").attr("mem");			
			if(imgsrcsmall=="") { imgsrcsmall=imgsrc; }		
					
			if(revgal!=1)
				{ 
				// code per plaatje om te appenden - normale volgorde	
				tgallery+="<td><a href=\""+imgsrcsmall+"\" rel=\"topicgallery\"  title=\"gepost door "+postedBy+"\"><img class=\"galleryimg\" height=\"60\" border=\"0\" style=\"display: inline;\" onmouseout=\"this.className='galleryimg'\" onmouseover=\"this.className='galleryimgv'\" alt=\"gepost door "+postedBy+"\" src=\""+imgsrc+"\"></a><br /><a class=\"px12\" title=\"geplaatst door "+postedBy+"\" href=\""+camefrom+"#pic"+galleryImages+"\">&raquo;</a></td>";
				}
				else
				{
				// code per plaatje om te appenden - omgekeerde volgorde
				tgallery="<td><a href=\""+imgsrcsmall+"\" rel=\"topicgallery\" title=\"gepost door "+postedBy+"\"><img class=\"galleryimg\" height=\"60\" border=\"0\" style=\"display: inline;\" onmouseout=\"this.className='galleryimg'\" onmouseover=\"this.className='galleryimgv'\" alt=\"gepost door "+postedBy+"\" src=\""+imgsrc+"\"></a><br /><a class=\"px12\" title=\"geplaatst door "+postedBy+"\" href=\""+camefrom+"#pic"+galleryImages+"\">&raquo;</a></td>"+tgallery;
				}
			}
		}

		});
		tgstart+=tgallery+"</tr></table></div>";
		$("#gallery").html(tgstart);
		$("#tgaantal").html("<span style=\"font-size:10px;\">"+galleryImages+" afbeeldingen gevonden... </span>");
	if(boxtype!=0){	
	initLightBox(1,1,boxtype);
	}
		});
	}

function init_page(tg,pg,tbx){
	if(pg<1) { setTimeout("resizer();","400"); } else { thumber(); }
	}


		
function initLightBox(tg,pg,boxtype) {
	if(tg==1 && boxtype!=0){
		if(boxtype=='fancybox'){
			jQuery(function($) {	
			$("a[rel='topicgallery']").fancybox({
			'zoomSpeedIn':		300, 
			'zoomSpeedOut':	300, 
			'overlayShow':		true,
			'overlayOpacity': 0.8
			});
			})
			}
		else
			{
			jQuery(function($) {	
			$("a[rel='topicgallery']").slimbox({overlayOpacity: 0.7, overlayFadeDuration: 90, resizeDuration: 120,  imageFadeDuration: 90, captionAnimationDuration: 200, counterText: "Afbeelding {x} / {y}"}, null, function(el) {
			return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));})
			});
		}
	}
	if(pg==1){	
		if(boxtype=='fancybox'){
			jQuery(function($) {
			$("a[rel^='lightbox']").fancybox({
			'zoomSpeedIn':		300, 
			'zoomSpeedOut':	300, 
			'overlayShow':		true,
			'overlayOpacity': 0.8
			});	
			})
			}
		else
			{
	jQuery(function($) {	
		$("a[rel^='lightbox']").slimbox({overlayOpacity: 0.7, overlayFadeDuration: 50, resizeDuration: 50,  imageFadeDuration: 50, captionAnimationDuration: 50, counterText: "Afbeelding {x} / {y}"}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));})
		});
		}
	}
}

function toggleTopicTypes(topicType) {
	$("tr[rel="+topicType+"]").each(function(){
		$(this).toggle();
		})
	}
	
function toggleTD(tag) {
	current=$("#views").css("display");
	$("td[rel="+tag+"]").each(function(){
		$(this).toggle();
		})
	if(current=='none')
		{
		// is nu verborgen
		setCookie("tdhide"+tag,'1',365,'/',host, false); // unhide
		$('#explainTD').attr('colspan','5');
		$('#explain3TD').attr('colspan','5');
		$('#explain4TD').attr('colspan','5');
		//$('#s1').attr('colspan','5');
		}
	else
		{
		// is nu niet verborgen
		setCookie("tdhide"+tag,'0',365,'/',host, false); // hide
		$('#explainTD').attr('colspan','4');
		$('#explain3TD').attr('colspan','4');
		$('#explain4TD').attr('colspan','4');
		//$('#s1').attr('colspan','4');
		}
	}