function quoten(naam, id, ts_vs_reply)
{		
    //text selectie
    var quote;
    if(window.getSelection)
    {
        quote = window.getSelection().toString();
    }
    else if(document.getSelection)
    {
        quote = document.getSelection();
    }
    else if(document.selection)
    {
        quote = document.selection.createRange().text;
    }

    //de textuele inhoud van de reactie die we willen quoten (opgeschoont)
    var tequoten = $("#"+id).text().replace(/[\n\r\t\s\(\)]/g, "");
    //de quote 'opschonen'
    pat = quote.replace(/[\n\r\t\s\(\)]/g, "");
    //als de geselecteerde text niet matched met de 'te quoten' reactie (er is meer text geselecteerd OF een), dan een ajax request om de gehele ge-ubb-de reactie op te halen
//alert("tequoten\n"+tequoten)
//alert("pat\n"+pat);
	if(tequoten.indexOf(pat) == -1 || pat == "")
    { 
        if(ts_vs_reply != 'ts')
	    {
            ts_vs_reply = 0
	    }
		$.ajax({ url: "/forum_quotes.php?id="+id+"&ts_vs_reply="+ts_vs_reply+"&anticache="+Math.random()*999, success: function(data)
            {
                var inhoud = $("#inhoud").val();
                var nl = inhoud != "" ? "\r\n" : '';
                $("#inhoud").val(inhoud + nl+"[quote="+naam+"]"+data+"[/quote]")
            }
        });
    }
    else
    //er was alleen een gedeelte uit de reactie geselecteerd
    { 
        var inhoud = $("#inhoud").val();
        var nl = inhoud != "" ? "\r\n" : '';
        $("#inhoud").val(inhoud + nl+"[quote="+naam+"]"+quote+"[/quote]")
    }
	$('html,body').animate({scrollTop: $('#reply').offset().top}, 1000);
} 

<!--Thx to FangorN again (see index source) -->
function popup(page, width, height)
{
	var ls = Math.round(screen.width/2 - width/2);
	var ts = Math.round(screen.height/2 - height/2);
	//var raam = null;

	raam = window.open("/toonplaatje.php?image="+page,"raam","width="+width+",height="+height+",top="+ts+",left="+ls+",scrollbars=no,status=no,resizable=yes,menubar=no");
	raam.focus();
}

/* deze werkt perfect, maar met popup die overal geblokked word :(
function flashchat(tegenIP,hoe)
{
	if(hoe != 'vraag'){
		chatraam = window.open("/chat.php?tegenIP="+tegenIP,"chatraam","width=550, height=325,top=100,left=100,scrollbars=no,status=no,resizable=no,menubar=no");
		chatraam.focus();
	} else {
		chatraam = window.open("/chat.php?hoe=vraag&tegenIP="+tegenIP,"chatraam","width=550, height=325,top=100,left=100,scrollbars=no,status=no,resizable=yes,menubar=no");
		chatraam.focus();
	}
}
*/
//ie vs gecko meuk 
ie5  = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
//style.opacity = 0.8 <=opera

trans = 0;

function maakSWF(url1, url2, mijnNaam, zijnNaam, hoe){
  if(hoe != 'vraag'){
	
	var so = new SWFObject('/flashChatBeta2.swf?mijnIP='+url1+'&tegenIP='+url2+'&mijnNaam='+mijnNaam+'&zijnNaam='+zijnNaam, 'chat', '550', '325', '8');
      so.addParam('allowScriptAccess', 'sameDomain');
      so.addParam('quality', 'high');
      so.addParam('scale', 'noscale');
      so.addParam('loop', 'false');
			so.addParam("wmode", "transparent");
	    so.write('chatInhoud');
  } else {

	var so = new SWFObject('/flashChatBeta2.swf?mijnIP='+url1+'&tegenIP='+url2+'&mijnNaam='+mijnNaam+'&zijnNaam='+zijnNaam+'&hoe=vraag', 'chat', '550', '325', '8');
      so.addParam('allowScriptAccess', 'sameDomain');
      so.addParam('quality', 'high');
      so.addParam('scale', 'noscale');
      so.addParam('loop', 'false');
			so.addParam("wmode", "transparent");
	    so.write('chatInhoud');
	}
}
  
function fadeIn(url1,url2,mijnNaam,zijnNaam, hoe) {
	 document.getElementById('bgZwart').style.height = parseInt(document.documentElement.scrollHeight) + "px";
	 document.getElementById('bgZwart').style.display="block";
   document.getElementById('chatInhoud').style.display="block";
	 
	 var y;
   if (self.pageYOffset) y = self.pageYOffset;
   else if (document.documentElement && document.documentElement.scrollTop) y = document.documentElement.scrollTop;
   else if (document.body) y = document.body.scrollTop;  
	 document.getElementById('chatInhoud').style.top = y+50 + "px";
	 
	 var x = (document.documentElement.clientWidth / 2) - (document.getElementById('chatInhoud').offsetWidth / 2);
	 document.getElementById('chatInhoud').style.left = x + "px";
		
   if(trans <= 70){
      trans+=5;
      if(ie5) document.getElementById('bgZwart').filters.alpha.opacity = trans;
      if(ns6) document.getElementById('bgZwart').style.MozOpacity = trans/100;
      if(ie5) document.getElementById('chatInhoud').filters.alpha.opacity = trans+30;
      if(ns6) document.getElementById('chatInhoud').style.MozOpacity = trans/100+30;      
			document.getElementById('logo').style.display="none";
      
			inTimer = setTimeout("fadeIn('"+ url1 +"','"+ url2 +"','"+ mijnNaam +"','"+ zijnNaam +"','"+ hoe +"')", 50);
      
      if(trans >=70){
				 clearTimeout(inTimer)
         maakSWF(url1, url2, mijnNaam, zijnNaam, hoe);
      }
   }
}

function fadeOut() {
    if(trans > 0){
      trans-=5;
      if(ie5) document.getElementById('bgZwart').filters.alpha.opacity = trans;
      if(ns6) document.getElementById('bgZwart').style.MozOpacity = trans/100;

      outTimer = setTimeout('fadeOut()', 50);
      if(trans <=0){
        document.getElementById('bgZwart').style.display="none";
        document.getElementById('chatInhoud').style.display="none";
        clearTimeout(outTimer);
				document.getElementById('logo').style.display="block";
        document.getElementById('chatInhoud').innerHTML = "";		
      }
   }
}

function antiie6()
{
    var bName = navigator.appName;
    var bVer = navigator.userAgent;
    var bNum;
     
    if(bName == 'Microsoft Internet Explorer')
    {
        var bVerId = bVer.indexOf('MSIE');
        bNum = bVer.substr(bVerId+5,1);
         
        if(bNum <= 6)
        {
            var now = new Date();
            var time = now.getTime();
            var div = document.createElement('a');
            var id = 'saynotoie6_div_' + time;
            div.setAttribute('id',id);
            div.setAttribute('href','http://www.savethedevelopers.org/');
            div.setAttribute('target','_blank');
            div.style.display = 'block';
            div.style.color = '#1D1D1D';
            div.style.textAlign = 'left';
            div.style.fontFamily = 'Arial';
            div.style.fontSize = '11px';
            div.style.background = 'url(/afbeeldingen/antiie6.gif)';
            div.style.padding = '0';
            div.style.position = 'absolute';
            div.style.top = '0';
            div.style.right = '40px';
            div.style.zIndex = '999999';
            div.style.width = '330px';
            div.style.height = '63px';
            div.style.marginTop = '-80px';
            div.style.filter = 'alpha(opacity=95)';
            document.body.appendChild(div);
             
            var animate = function()
            {
                var myDiv = document.getElementById(id);
                var value = parseInt(myDiv.style.marginTop)
                myDiv.style.marginTop = value + 1 + 'px';
                if(parseInt(myDiv.style.marginTop) < -1)
                {
                    var timer = setTimeout(animate,30 * 80/Math.abs(value) * .27);
                }
                else
                {
                    var timer = setTimeout(hide,5000);
                }
            }
             
            var hide = function()
            {
                var myDiv = document.getElementById(id);
                var value = parseInt(myDiv.style.marginTop)
                myDiv.style.marginTop = value - 1 + 'px';
                if(parseInt(myDiv.style.marginTop) > -80)
                {
                    var timer = setTimeout(hide,1.4 * 80/Math.abs(value) * 3.70);
                }
            }
             
            setTimeout(animate,1);
        }
    }
} 