/*
Generic style elements
Hadrian Forum

Version 1.1  10/14/2004 23:46
	* changed resize behaviour, for better script-execution and make it compatible with mozilla
	* make fullscreen url load always
*/

var resized_images_width = new Array();
var resized_images_height = new Array();

function URLEncode( txt )
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = txt;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	//document.URLForm.F2.value = encoded;
	return encoded;
};

function fullSize(){
	scrollbars = 0;
	var oSource = this.src;
	width = resized_images_width[oSource];
	height = resized_images_height[oSource];

	url = fRoot + "/image.php?src="+URLEncode(oSource)+"&width="+width+"&height="+height;

	if(width > screen.availWidth){
		width = screen.availWidth;
		scrollbars = 1;
	}

	if(height > screen.availHeight){
		height = screen.availHeight;
		scrollbars = 1;
	}

	fullscr = window.open(url, "_blank","toolbar=no,location=no,menubar=no,fullscreen="+scrollbars+",channelmode="+scrollbars+",scrollbars="+scrollbars+",status=no,left=0,top=0,width="+width+",height="+height);
}

threshold = 580;

function resize(img){
	width = img.width;
	height = img.height;

	var url = img.src;

	if(width>threshold){
		resized_images_width[url] = width;
		resized_images_height[url] = height;
		img.width = threshold;
		img.alt = 'Afbeelding';
		img.title = 'Klik voor originele grootte ('+width+'x'+height+')';
		img.style.border = "dotted 1px black";
		img.style.cursor = "pointer";
		img.onclick = fullSize;
		img.height = Math.floor(height/(width/threshold));
	}
}

function check_images(hostName){

	if (typeof(SymWinOpen)=='function'){
		//alert("Je hebt Norton Firewall of Virus Scan geïnstalleerd.\nZet het vinkje 'Reclame onderdrukken' uit!");
		}


	count = document.images.length;
	i = 0;
	while(count>i){
		url = document.images[i].src;
		if(!url.match(hostName)){
			if(document.images[i].className != 'userImage' && document.images[i].width>threshold){
				resize(document.images[i]);
				document.images[i].onload = resize;
				document.images[i].className = 'userImage';
			}
		}
		i++;
	}
}