function ajax(php,arr,functie) {
	q = php + '.php?randomnumber=' + Math.random();
	val = 0;
	for (var i in arr) {
	  if (val) {
	  	q = q + URLEncode(arr[i].toString());
	  	val = 0;
	  }
	  else {
	  	q = q + '&' + arr[i] + '=';
	  	val = 1;
	  }
	}
	$.get(q, functie);
}

function URLEncode(instring)
{
	var SAFECHARS = "0123456789" +					
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					
	var HEX = "0123456789ABCDEF";

	var plaintext = instring;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				
		} 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

	return encoded;
};

function rand(l,u) // lower bound and upper bound
 {
     return Math.floor((Math.random() * (u-l+1))+l);
 }

function animeer(id) {
	
	var x = parseInt($("#" + id).attr('oorspx'));
	var y = parseInt($("#" + id).attr('oorspy'));
	
	if (!x) x = parseInt($("#" + id).css('left'));
	if (!y) y = parseInt($("#" + id).css('top'));
	animeercont(id,x,y);
}
function stopanimeer(id) {
	$("#" + id).stop();
}

function animeercont(id,x,y) {
	
		var xnu = x + rand(-8,8);
		var ynu = y + rand(-12,12);



	  $('#' + id).animate({
	    left: xnu,
	    top: ynu
	  }, rand(1800,2200), function() {
	    animeercont(id,x,y);
	  });

}
