// CHECKALL
function checkall(formname) {
	for (var i = 0; i < formname.elements.length; i++)
	{
		var element = formname.elements[i];
		if ((element.name != "allbox") && (element.type == "checkbox"))
		{
			element.checked = formname.allbox.checked;
		}
	}
}


// CHECKBOX
function checkbox(name) {
	var checked = window.document.form.elements[name].checked;
	if (checked == true) {
		window.document.form.elements[name].checked=false;
	} else {
		window.document.form.elements[name].checked=true;
	}
}


// ADDTEXT
function addtext(veld,text) {
	text = ''+text+' ';
  	if (document.form.elements[veld].createTextRange) {
  		document.form.elements[veld].focus();
  		document.selection.createRange().duplicate().text = text;
   	} else {
		document.form.elements[veld].focus();
  		document.form.elements[veld].value += text;
   	}
}

// CHANGE TAG
function veranderKeuze(t) { 
	document.getElementById('titel').value = t.options[t.selectedIndex].value + document.getElementById('titel').value; 
}

// SHOWAVATAR
function showavatar(filename)
{
	if(document.layers) {
		document.images.avatar.src='images/avatars/' + filename
		document.images.avatar.alt=filename
	} else {
		document.getElementById('avatar').src='images/avatars/' + filename
		document.getElementById('avatar').alt=filename
	}
}

// WRITESPAN
function writespan(naam, html) {
	if(document.layers) {
		document.elements[naam].writespan.document.write(html);
		document.elements[naam].writespan.document.close();
	} else {
		document.getElementById(naam).innerHTML = html;
	}
}

// REACTIEPOP
function reactiepop(url) {
	window.open(url,'reacties','height=500,width=700,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes');
}

// POPUP
function popup(url, naam, width, height) {
	window.open(url,naam,'width='+width+',height='+height+',location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes');
}

// VAARDIGHEDEN
function vaardigheden(x) {
	if(x=="5") { alert("Weet je het zeker?"); }
}

// ADMINTOOLS
function admintools(eventObject) {
	var admintools = document.getElementById("admintools").style;
	if(admintools.visibility == "hidden") {
		admintools.top = eventObject.clientY+document.body.scrollTop-65;
		admintools.left = eventObject.clientX+document.body.scrollLeft-100;
		admintools.visibility="visible";
	} else {
		admintools.visibility="hidden";
	}
}

// SHOW/HIDE CODE
function show_hide(id) {
	var object = document.getElementById(id).style;
	if(object.display == "none") {
		object.display="";
	} else {
		object.display="none";
	}
}

// COUNT SIGNATURE CHARACTERS
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}

// IMAGE RESIZE
var vorig_width = new Array();
var vorig_height = new Array();
	
function resize()
{
	image = document.images;
   
	for(i = 0; i < image.length; i++)
	{
		id_tag = image[i].getAttribute('id')
        
		if(id_tag == 'topic')
		{
			if(image[i].width > 300)
			{
			   vorig_width[image[i].src] = image[i].width;
			   vorig_height[image[i].src] = image[i].height;

			   image[i].width = 300;
			   image[i].style.border = "#000000 1px dashed";
			   image[i].style.cursor = "hand";
			   image[i].height = Math.floor(image[i].height/(image[i].width/300));
			   image[i].alt = 'Originele grootte: ' + vorig_width[image[i].src] + ' x ' + vorig_height[image[i].src];
			}
		}
	}
}

function image_fullscreen(image)
{
	width = vorig_width[image.src];
	height = vorig_height[image.src];

	if(width > 300)
	{
		scrollbar = 0;
		target = url + "image.php?src=" + escape(image.src) + "&width=" + width + "&height=" + height;

		if(width > screen.availWidth)
		{
			scrollbar = 1;
			width = screen.availWidth;
		}

		if(height > screen.availHeight)	
		{
			scrollbar = 1;
			height = screen.availHeight;
    	}

		full = window.open(target, "_blank", "toolbar=no,location=no,menubar=no,fullscreen=" + scrollbar + ",channelmode=" + scrollbar + ",scrollbars=" + scrollbar + ",status=no,left=0,top=0,width=" + width + ",height=" + height);
	}
}

//SIDEBAR
function addSidebar() { 
	if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) 
	{ 
		window.sidebar.addPanel ("WebmasterCity Sidebar", "http://www.wmcity.nl/sidebar_feed.php",""); 
	}
	else
	{
		alert("Je browser ondersteunt deze functie niet! Deze functie is alleen beschikbaar in Mozilla-gebaseerde browsers.");
	}
} 

// Advertenties
function ad1() {
var id=671; var jar=new Date();var s=jar.getSeconds();var m=jar.getMinutes();
var flash=s*m+id;var cgi='http://www4.bannertjes.nl/cgi-bin/bannertjes';
var p='<iframe src=\"'+cgi+'/adcycle.cgi?gid=43&layout=multi&t=_blank&id='+flash+'&type=iframe\" ';
p+='height=60 width=120 border=0 marginwidth=0 marginheight=0 hspace=0 ';
p+='vspace=0 frameborder=0 scrolling=no>';
p+='<a href=\"'+cgi+'/adclick.cgi?gid=43&layout=multi&id='+flash+'\" target=\"_blank\">';
p+='<img src=\"'+cgi+'/adcycle.cgi?gid=43&layout=multi&id='+flash+'\" width=120 height=60 ';
p+='border=1 alt=\"Click to Visit\"></a></iframe>'; document.write(p);
}

function ad2() {
var id=210; var jar=new Date();var s=jar.getSeconds();var m=jar.getMinutes();
var flash=s*m+id;var cgi='http://www4.bannertjes.nl/cgi-bin/bannertjes';
var p='<iframe src=\"'+cgi+'/adcycle.cgi?gid=44&layout=multi&t=_blank&id='+flash+'&type=iframe\" ';
p+='height=60 width=120 border=0 marginwidth=0 marginheight=0 hspace=0 ';
p+='vspace=0 frameborder=0 scrolling=no>';
p+='<a href=\"'+cgi+'/adclick.cgi?gid=44&layout=multi&id='+flash+'\" target=\"_blank\">';
p+='<img src=\"'+cgi+'/adcycle.cgi?gid=44&layout=multi&id='+flash+'\" width=120 height=60 ';
p+='border=1 alt=\"Click to Visit\"></a></iframe>'; document.write(p);
}