<!--
function ValidateForm(){
	error	= false;
	fields	= '';
	req		= new Array;
	desc	= new Array;
	req[0]	= 'gebruikersnaam';
	desc[0]	= 'Gebruikersnaam';
	req[1]	= 'pass_first';
	desc[1]	= 'Wachtwoord';
	req[2]	= 'pass_second';
	desc[2]	= 'Wachtwoord bevestiging';
	req[3]	= 'email';
	desc[3]	= 'E-mail adres';

	for (var i=0;i<req.length;i++){
		if (document.getElementById(req[i]).value==''){
			error = true;
			fields = fields + desc[i] +'\n';
		}
	}
	if (error==true){
		alert('Vul alle verplichte velden in!\n\n' + fields);
		return false;
	}
	else {
		return true;
	}
}

function votefor(id){
	document.location='/battle_vote/'+id;
}

function insubb(type, text, where){
	target = document.getElementById(where);
	if (target !== null)
	{
		if (typeof target.cursorPos != 'undefined')
		{
			var cursorPos = target.cursorPos;
			if (type != 'plain') {text = cursorPos.text;}
			cursorPos.text = det_replace(type, text);
		}
		else if (typeof target.selectionStart != 'undefined')
		{
			// remember scrollposition
			var scrollTop = target.scrollTop;

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

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

function det_replace(type, text){
	var val = '';
	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 'quote':
		text = '[quote]'+text+'[/quote]';
		break;
		case 'listbullet':
		text = '\r\n[*]'+(text.split(/\r?\n/).join('\r\n[*]'))+'\r\n';
		break;
		case 'left':
		text = '[left]'+text+'[/left]';
		break;
		case 'center':
		text = '[center]'+text+'[/center]';
		break;
		case 'justify':
		text = '[justify]'+text+'[/justify]';
		break;
		case 'right':
		text = '[right]'+text+'[/right]';
		break;
		case 'url':
		if (/^(http:\/\/|www\.)/i.test(text))
		{
			val = prompt('Omschrijving:', text);
			if (val !== null && val !== '') {text = '[url='+text+']'+val+'[/url]';}
		}
		else
		{
			val = prompt('Voer de URL in:','http:\/\/');
			if (val !== null && val != 'http:\/\/')
			{
				if (text === '') {text = '[url]'+val+'[/url]';}
				else {text = '[url='+val+']'+text+'[/url]';}
			}
		}
		break;
		case 'img':
		if (text === '')
		{
			val = prompt('Voer de URL in:','http:\/\/');
			if (val !== null && val != 'http:\/\/') {text = '[img]'+val+'[/img]';}
		}
		else
		{
			text = '[img]'+text+'[/img]';
		}
		break;
		case 'quotesplits':
		text += '[/quote]\r\n[quote]';
		break;
	}
	return text;
}

function addsmiley (what,where){
	target			= document.getElementById(where);
	target.value	= target.value + ' ' + what;
}

function selectAll(formObj, isInverse)
{
	for (var i=0;i < formObj.length;i++)
	{
		fldObj = formObj.elements[i];
		if (fldObj.type == 'checkbox')
		{
			if(isInverse)
			fldObj.checked = (fldObj.checked) ? false : true;
			else fldObj.checked = true;
		}
	}
}

function insertIntl(form) {
	inputPrefix2=form.intlPrefix.options[form.intlPrefix.selectedIndex].value;
	form.SMSTelefon.value=inputPrefix2;
	form.SMSTelefon.focus();
}
var supportsKeys = false;
var Signature = '';

function calcCharLeft(f,chars) {
	clipped = false;
	maxLength = chars;
	if (f.message.value.length > maxLength) {
		f.message.value = f.message.value.substring(0,maxLength);
		charleft = 0;
		clipped = true;
	} else {
		charleft = maxLength - f.message.value.length;
	}
	document.getElementById('keysleft').innerHTML = charleft;
	return clipped;
}
function textKey(f,chars) {
	supportsKeys = true;
	calcCharLeft(f,chars);
}
function validateForm() {
	f = document.smsBooster;
	if (calcCharLeft(f)) {
		alert("message too long!");
		f.message.focus();
		return false;
	}
	return true;
}

// Vote functie

function VoteForm() {
	fakevotes = document.getElementById('votes').getElementsByTagName('input');
	var votesCnt  = fakevotes.length;
	for (c = 0; c < votesCnt; c++) {
		if (fakevotes[c].name=='fakevote'){
			fakevotes[c].disabled = true;
		}
		if (fakevotes[c].checked==true){
			document.getElementById('vote').value=fakevotes[c].value;
		}
	}
	ajaxpage("/vote/"+document.getElementById('user').value+'/'+document.getElementById('vote').value,"ajaxcontainer","GET");
}

// Pincode Checken

function CheckPin() {
	ajaxpage("/pin/"+document.getElementById('pincode').value,"ajaxcontainer");
}

// Ajax Objecten

var loadedobjects=""
var rootdomain="http://"+window.location.hostname

function ajaxpage(url, containerid, type){
var page_request = false
if (window.XMLHttpRequest)
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return true
page_request.onreadystatechange=function(){
	loadpage(page_request, containerid)
}
page_request.open(type, url, true)
if (type=="POST"){
url=url.split("?");
vars=url[1];
url=url[0];
page_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
page_request.send(vars);
}
page_request.send(null)
}

function loadpage(page_request, containerid){
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
		document.getElementById(containerid).innerHTML=page_request.responseText
	}
}

function loadobjs(){
	if (!document.getElementById)
	return
	for (i=0; i<arguments.length; i++){
		var file=arguments[i]
		var fileref=""
		if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
			if (file.indexOf(".js")!=-1){ //If object is a js file
				fileref=document.createElement('script')
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", file);
			}
			else if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref=document.createElement("link")
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
			}
		}
		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			loadedobjects+=file+" " //Remember this object as being already added to page
		}
	}
}

var dragobject={
	z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
	initialize:function(){
		document.onmousedown=this.drag
		document.onmouseup=function(){this.dragapproved=0}
	},
	drag:function(e){
		var evtobj=window.event? window.event : e
		this.targetobj=window.event? event.srcElement : e.target
		if (this.targetobj.className=="drag"){
			this.dragapproved=1
			if (isNaN(parseInt(this.targetobj.parentNode.parentNode.parentNode.parentNode.parentNode.style.left))){this.targetobj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.left=0}
			if (isNaN(parseInt(this.targetobj.parentNode.parentNode.parentNode.parentNode.parentNode.style.top))){this.targetobj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.top=0}
			this.offsetx=parseInt(this.targetobj.parentNode.parentNode.parentNode.parentNode.parentNode.style.left)
			this.offsety=parseInt(this.targetobj.parentNode.parentNode.parentNode.parentNode.parentNode.style.top)
			this.x=evtobj.clientX
			this.y=evtobj.clientY
			if (evtobj.preventDefault)
			evtobj.preventDefault()
			document.onmousemove=dragobject.moveit
		}
	},
	moveit:function(e){
		var evtobj=window.event? window.event : e
		if (this.dragapproved==1){
			this.targetobj.parentNode.parentNode.parentNode.parentNode.parentNode.style.left=this.offsetx+evtobj.clientX-this.x+"px"
			this.targetobj.parentNode.parentNode.parentNode.parentNode.parentNode.style.top=this.offsety+evtobj.clientY-this.y+"px"
			return false
		}
	}
}

dragobject.initialize()

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

//document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
//document.write('<img id="dhtmlpointer" src="/images/arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(userid, thewidth, thecolor){
	if (userid!=0){
		if (ns6||ie){
			tipobj.style.width="270px"
			if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
			ajaxpage("/riekelt/" + userid,"dhtmltooltip");
			enabletip=true
			return false
		}
	}
}

function positiontip(e){
	if (enabletip){
		var nondefaultpos=false
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
		var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

		var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
		var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

		var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

		if (rightedge<tipobj.offsetWidth){
			tipobj.style.left=curX-tipobj.offsetWidth+"px"
			nondefaultpos=true
		}
		else if (curX<leftedge)
		tipobj.style.left="5px"
		else{
			tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
			pointerobj.style.left=curX+offsetfromcursorX+"px"
		}

		if (bottomedge<tipobj.offsetHeight){
			tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
			nondefaultpos=true
		}
		else{
			tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
			pointerobj.style.top=curY+offsetfromcursorY+"px"
		}
		tipobj.style.visibility="visible"
		if (!nondefaultpos)
		pointerobj.style.visibility="visible"
		else
		pointerobj.style.visibility="hidden"
	}
}

function hideddrivetip(){
	if (ns6||ie){
		enabletip=false
		tipobj.style.visibility="hidden"
		pointerobj.style.visibility="hidden"
		tipobj.style.left="-1000px"
		tipobj.style.backgroundColor=''
		tipobj.style.width=''
	}
}

document.onmousemove=positiontip;

function jumpphoto(photo,width,height){
	document.images.mainpic.src=photo;
	document.images.mainpic.width=width;
	document.images.mainpic.height=height;
}
//-->
