<!--

// Function confirmLink() is copied from PhpMyAdmin (phpmyadmin.net)

function confirmLink(theLink, text) {
 if (typeof(window.opera) != 'undefined') {
  return true;
 }

 var is_confirmed = confirm(text);
 if (is_confirmed) {
  if ( typeof(theLink.href) != 'undefined' ) {
   theLink.href += '';
  }else if ( typeof(theLink.form) != 'undefined' ) {
   theLink.form.action += '';
  }
 }
 return is_confirmed;
}


// For settings the real URL
if (window != top) {
 top.location.href = location.href
}


// Function for popups
function popUp(URL) {
 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=600,height=500');");
}

function chat() {
 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open('chat/index.php', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=1,width=805,height=460');");
}

// Function for photos, almost same as popup(), except manual width and height settings
function foto(URL,WIDTH,HEIGHT) {
 day = new Date();
 id = day.getTime();
 eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=" + WIDTH + ",height=" + HEIGHT + "');");
}

function fotoview(url) {
	document.getElementById('fotoview').innerHTML = '<img src=\"'+url+'\" />';
	document.getElementById('fotoview').style.display = 'block';
}

// resize images (for too big images in forum etc/ubb)

var maxImageWidth = 500;
function unscaleImage()
{
	if(maxImageWidth > 0)
		this.width = this.width == maxImageWidth? this.orgwidth:maxImageWidth;
}

function scaleImage(im)
{
	if (maxImageWidth > 0 && im.width > maxImageWidth)
	{
		im.orgwidth = im.width;
		im.width = maxImageWidth;
		im.onclick = unscaleImage;
	}
}

// Voor gebruiker opties, de tabs
 function tabMouseOver(obj) {
	if(obj.className == "tab") {
		obj.style.cursor = "pointer";
		obj.className = "tab_over";
	}
 }
 function tabMouseOut(obj) {
	if(obj.className == "tab_over") {
		obj.style.cursor = "default";
		obj.className = "tab";
	}
 }
 function tabSet(divName) {
	document.getElementById('forum').style.display = 'none';
	document.getElementById('standaard').style.display = 'none';
	document.getElementById('wachtwoord').style.display = 'none';
	document.getElementById('cookies').style.display = 'none';
	
	document.getElementById('forum_tab').className = 'tab';
	document.getElementById('standaard_tab').className = 'tab';
	document.getElementById('wachtwoord_tab').className = 'tab';
	document.getElementById('cookies_tab').className = 'tab';
	
	document.getElementById(divName).style.display = 'block';
	document.getElementById(divName+'_tab').className = 'tab_act';
	if(divName == "cookies") {
		document.getElementById("submit").style.display = "none";
	}else{
		document.getElementById("submit").style.display = "block";
	}
 }
 
// Van allerlei sites geplukt, kwait nait meer woar.
function Prompt() {

	/*** Private properties ***/
	var _msie = (navigator.appVersion.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Opera') == -1);
	var _simulate = navigator.appVersion.match(/\bMSIE (\d+)/) && (RegExp.$1 >= 7) && window.showModalDialog;
	var _script_uri_path = 'includes/html/';


	/*** Private methods ***/

	// Returns the estimated dimensions of the given string when rendered as text (not html).
	// Functionally similar to the Windows API function GetTextExtent(h,txt).
	// 'opts' is an optional object in which you may pass styles such as 'fontFamily' or 'fontSize'.
	// EXPERIMENTAL:
	//   Requires more testing.
	//   Perhaps the 1st argument should be a DOM element to be cloned instead of using opts.
	var _getTextExtent = function(txt, opts) {
		var div = document.createElement('div');
		if (opts) {
			if (opts['fontFamily']) {
				div.style.fontFamily = 'font-family: ' + opts['fontFamily'];
			}
			if (opts['fontSize']) {
				div.style.fontSize = opts['fontSize'];
			}
		}
		div.style.position = 'absolute';
		div.style.top = 0;
		div.style.left = 0;
		div.style.whiteSpace = 'nowrap';
		div.style.overflow = 'hidden';
		div.zIndex = 6322;
		var lines;
		// MSIE bug (tested with MSIE 7) String.split() doesn't keep empty matches, so this hack is required:
		if (_msie) {
			lines = [];
			while (txt.length && txt.match(/^([^\r\n]*)(\r\n|\n\r|\r|\n)?/)) {
				lines.push(RegExp.$1);
				txt = txt.substr(RegExp.$2 ? RegExp.$1.length + RegExp.$2.length : RegExp.$1.length);
			}
		}
		else {
			lines = txt.split(/\r\n|\n\r|\r|\n/);
		}
		for (var i = 0; i < lines.length; i++) {
			div.appendChild(document.createTextNode(lines[i] == ' ' ? '' : lines[i]));
			if (i < lines.length - 1) {
				div.appendChild(document.createElement('br'));
			}
		}
		div.style.visibility = 'hidden';
		//div.style.backgroundColor = 'green';
		var container = document.body;
		if (container.firstChild) {
			container.insertBefore(div, container.firstChild);
		}
		else {
			container.appendChild(div);
		}
		var dims = [div.offsetWidth, div.offsetHeight];
		container.removeChild(div);
		div = null;
		return dims;
	};


	/*** Public methods ***/
	// Either calls or simulates the javascript prompt function.
	// The first 2 arguments are the same as for the javascript prompt function.
	// An optional 3rd argument can be passed which is the caption to be used
	// in the title bar, but this only applies to MSIE 7+.
	this.show = function(msg) {
		var argv = arguments;
		if (msg && (typeof(msg) == 'string')) {
			msg = msg.replace(/^\s+|\s+$/g,'');
		}
		var input = argv.length <= 1 ? '' : argv[1];
		var caption = argv.length <= 2 ? '' : argv[2];
		var result;
		if (_simulate) {
			var dims = _getTextExtent(msg, {fontFamily: 'Arial, sans-serif', fontSize: '10pt'});
			var w = dims[0] + 60;
			if (w < 250) {
				w = 250;
			}
			var h = dims[1] + 115;
			result = window.showModalDialog(
				_script_uri_path + 'Prompt.html',
				{ msg: msg, input: input, caption: caption },
				'dialogWidth: ' + w + 'px; dialogHeight: ' + h + 'px');
		}
		else {
			result = prompt(msg, input);
		}
		return result;
	};
}
Prompt.show = function(msg) {
	var argv = arguments;
	var input = argv.length <= 1 ? '' : argv[1];
	var caption = argv.length <= 2 ? '' : argv[2];
	var p = new Prompt();
	return p.show(msg, input, caption);
};

function getSelectedNothing(which) {
	myField = document.getElementById("msg");
	
	//IE support
	if (document.selection) {
	    sel = document.selection.createRange();
		if (sel.text.length > 0) {
			return false;
		}
		else {
			return true;
		}
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		if (startPos != endPos) {
			return false;
		}
		else {
			return true;
		}
	}
	else {
		return false;
	}
}
function wrapSelection(which, start,end) {
    myField = document.getElementById("msg");
	
	//IE support
	if (document.selection) {
		myField.focus();
	    sel = document.selection.createRange();
		if (sel.text.length > 0) {
			sel.text = start + sel.text + end;
		}
		else {
			sel.text = start + end;
		}
		myField.focus();
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		var cursorPos = endPos;
		var scrollTop = myField.scrollTop;
		if (startPos != endPos) {
			myField.value = myField.value.substring(0, startPos)
			              + start
			              + myField.value.substring(startPos, endPos) 
			              + end
			              + myField.value.substring(endPos, myField.value.length);
			cursorPos += start.length + end.length;
		}
		else {
			putStr(start+end);
		}
		myField.focus();
		myField.selectionStart = cursorPos;
		myField.selectionEnd = cursorPos;
		myField.scrollTop = scrollTop;
	}
	else {
		if (end == '') {
			myField.value += start;
		}
		else {
			myField.value += end;
		}
		myField.focus();
	}
}

function putStr(myValue) {
    myField = document.getElementById("msg");
	//IE support
	if (document.selection) {
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
		myField.focus();
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		var scrollTop = myField.scrollTop;
		myField.value = myField.value.substring(0, startPos)
		              + myValue 
                      + myField.value.substring(endPos, myField.value.length);
		myField.focus();
		myField.selectionStart = startPos + myValue.length;
		myField.selectionEnd = startPos + myValue.length;
		myField.scrollTop = scrollTop;
	} else {
		myField.value += myValue;
		myField.focus();
	}
}

function placeImage(txtarea) {
 if(!getSelectedNothing(txtarea)) {
  wrapSelection(txtarea, '[img]', '[/img]');
  return;
 }
 var my_link = Prompt.show("Link naar afbeelding");
 if (my_link != false && my_link != null && my_link !='http://') {
  lft="[img]" + my_link;
  rgt="[/img]";
  wrapSelection(txtarea, lft, rgt);
 }
 return;
}

function placeLink(txtarea) {
 if(!getSelectedNothing(txtarea)) {
  var my_link = Prompt.show("Website adres (leeg indien dit het adres is)");
  if (my_link != false && my_link != null && my_link !='http://') {
   wrapSelection(txtarea, '[url='+my_link+']', '[/url]');
  }else{
   wrapSelection(txtarea, '[url]', '[/url]');
  }
  return;
 }
 var _simulate = navigator.appVersion.match(/\bMSIE (\d+)/) && (RegExp.$1 >= 7) && window.showModalDialog;
 var my_link = Prompt.show("Website adres");
 if (my_link != false && my_link != null && my_link !='http://') {
  if(!_simulate) {
	  var my_linkname = prompt("Naam van link (leeg voor websiteadres)");
	  if (my_linkname != false && my_linkname != null && my_link != my_linkname && my_linkname != '') {
	   lft="[url=" + my_link + "]" + my_linkname;
	   rgt="[/url]";
	  }else{
	   lft="[url]" + my_link;
	   rgt="[/url]";
	  }
  }else{
   lft="[url]" + my_link;
   rgt="[/url]";
  }
  wrapSelection(txtarea, lft, rgt);
 }
 return;
}

function placeQuote(txtarea) {
 var quote_source = Prompt.show("Wie quote je (of bron)? (leeg voor niemand)")
 if(quote_source != false && quote_source != null && quote_source != '') {
  var quote1 = "[quote=" + quote_source + "]";
  wrapSelection(txtarea, quote1, '[/quote]');
  return;
 }else{
  wrapSelection(txtarea, '[quote]', '[/quote]');
  return;
 }
}

//-->

