var curCrop= null;
var cropoHeight=0;
var cropoWidth=0;
var cropfilesize=0;
var glitter=0;
var size_Mb=1024*1024*5;
var orig_w=0;
var keeptekst='';
var keepfont='';
var keeplocatie='';
var keepcolor='';
var keepgroottetext='';

var keepgrootteglitter='';
var keephoek='';
var keepglitter='';
var keepschaduw='';
var keeprand='';
var keepranddikte='';
var cur_file_zise=0;

var el_id='';
var activeclass='Resize';
var scroll_x = 0;
var scroll_y = 0;

var gliterize_count=0;
var gliterize_images=new Array();

function myErrHandler()
{
	window.status ='';
 //здесь выполняем нужные нам действия

//Чтобы подавить стандартный диалог ошибки JavaScript, 
//функция должна возвратить true
return true;
}

//назначаем обработчик для события 
window.onerror = myErrHandler;

window.onscroll = function ()
{
 			if (typeof( window.pageYOffset ) == 'number') { // Netscape
  			scroll_y = window.pageYOffset; scroll_x = window.pageXOffset;
 			}
			 else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { // DOM
  			scroll_y = document.body.scrollTop; scroll_x = document.body.scrollLeft;
 			}
			 else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { // 				IE6
  		scroll_y = document.documentElement.scrollTop; scroll_x = document.documentElement.scrollLeft;
 		}

			if(scroll_x<100){scroll_x=0;}
			if(scroll_y<100){scroll_y=0;}
			
			document.getElementById('ImageProcess').style.left=scroll_x+'px';
			document.getElementById('ImageProcess').style.top=scroll_y+'px';

}
	function xmlhttpPost(strURL,fun)
	{
		shou_Loading();
		var xmlHttpReq = false;
		var self = this;
			// Mozilla/Safari
			if (window.XMLHttpRequest)
			{
			self.xmlHttpReq = new XMLHttpRequest();
			}
			// IE
			else if (window.ActiveXObject)
			{
			self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
			}
		self.xmlHttpReq.open('POST', strURL, true);
		self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		self.xmlHttpReq.onreadystatechange = function()
		{
			if (self.xmlHttpReq.readyState == 4)
			{
            	updatepage_resize(self.xmlHttpReq.responseText);
			}
		}
		
		if(fun=='crop'){ self.xmlHttpReq.send(getquerystring()); }
		if(fun=='resize'){ self.xmlHttpReq.send(getquerystring_resize()); }
		if(fun=='rotate' || fun=='flip' || fun=='specialfx'){ self.xmlHttpReq.send(getquerystring_rotate()); }
		if(fun=='addglitter'){ self.xmlHttpReq.send(getquerystring_addglitter()); }
		if(fun=='addtext'){ self.xmlHttpReq.send(getquerystring_addtext()); }
		if(fun=='gltran'){ self.xmlHttpReq.send(getquerystring_gltran()); }
		if(fun=='background'){ self.xmlHttpReq.send(getquerystring_background()); }
		if(fun=='set'){ self.xmlHttpReq.send(getquerystring_set()); }
		if(fun=='bubble'){ self.xmlHttpReq.send(getquerystring_bubble()); }
		if(fun=='fun_glitter'){ self.xmlHttpReq.send(getquerystring_fun_glitter()); }
		if(fun=='empty'){ self.xmlHttpReq.send(getquerystring_empty()); }
		if(fun=='glterize'){ self.xmlHttpReq.send(getquerystring_glterize()); }


	}

	function getCheckedValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}


	function getquerystring_empty()
	{
		qstr = 'width='+ document.getElementById('emp_w').value +'&height='+document.getElementById('emp_h').value +'&color='+ document.getElementById('colorfield').value;
		return qstr;
	}

		function getquerystring()
	{
		qstr = 'imageFileName='+ document.getElementById('imageFileName').value +'&cropWidth='+document.getElementById('cropWidth').value +'&cropHeight='+ document.getElementById('cropHeight').value +'&cropX='+ document.getElementById('cropX').value +'&cropY='+ document.getElementById('cropY').value +'';
		return qstr;
	}

	function getquerystring_glterize()
	{
		var elstyle1=chekbr().getElementById('image_line').style;
		qstr='imng='+chekbr().getElementById('image_line').src+'&glitt='+document.getElementById('gl_for_fuzz_value').value+'&fuz='+document.getElementById('fuszz_glit').value+'&flod='+document.getElementById('fill_repl').value;
		
		return qstr;
	}

	
	function getquerystring_rotate()
	{
		
		
		cur_file_zise=filesize(document.getElementById('save_img').value);
		if(cur_file_zise>size_Mb)
		{
		alert('De foto is groter dan 5 MB, je kunt nu geen wijzigingen meer doen.');
		hide_Loading();
		return false;
		}
		else
		{
		
		
		qstr = 'imageFileName='+document.getElementById('save_img').value +'';
		
		if(document.getElementById('effect_sped'))
		{
		qstr+='&speed='+document.getElementById('effect_sped').value+'';	
		}
		return qstr;
		}
	}

	function getquerystring_addglitter()
	{
				cur_file_zise=filesize(document.getElementById('imageFileName').value);
		if(cur_file_zise>size_Mb)
		{
		alert('De foto is groter dan 5 MB, je kunt nu geen wijzigingen meer doen.');
		hide_Loading();
		return false;
		}
		else
		{

		
		qstr = 'imageFileName='+ document.getElementById('imageFileName').value + '&t='+urlencode(document.getElementById('t').value) + '&loadFonth='+ urlencode(document.getElementById('loadFonth').value) + '&size='+document.getElementById('size').value + '&angle='+document.getElementById('angle').value + '&glitter='+document.getElementById('glitter').value + '&RadioGroup1='+getCheckedValue(document.forms['crop'].RadioGroup1) + '&RadioGroup2='+getCheckedValue(document.forms['crop'].RadioGroup2) + '&border='+document.getElementById('border').value + '';
		//alert (qstr);
		return qstr;
		}
	}

	function getquerystring_addtext()
	{
				cur_file_zise=filesize(document.getElementById('imageFileName').value);
		if(cur_file_zise>size_Mb)
		{
		alert('De foto is groter dan 5 MB, je kunt nu geen wijzigingen meer doen.');
		hide_Loading();
		return false;
		}
		else
		{

		qstr = 'imageFileName='+ document.getElementById('imageFileName').value + '&loadFonth='+ urlencode(document.getElementById('loadFonth').value) +'&font_size='+document.getElementById('font_size').value+'&location_text='+document.getElementById('location_text').value +'&color_text='+document.getElementById('colorfield').value +'&text_input='+urlencode(document.getElementById('text_input').value) + '';
		return qstr;
		}
	}

	function getquerystring_resize()
	{
		
		cur_file_zise=filesize(document.getElementById('imageFileName').value);
		if(cur_file_zise>size_Mb && document.getElementById('cropImage').width>orig_w)
		{
		alert('De foto is groter dan 5 MB, je kunt nu geen wijzigingen meer doen.');
		hide_Loading();
		return false;
		}
		else
		{

		qstr = 'imageFileName='+ document.getElementById('imageFileName').value +'&resizeWidth='+document.getElementById('IM_Width').value +'&resizeHeight='+document.getElementById('IM_Height').value +	'';
		return qstr;
		}
	}


	function getquerystring_gltran()
	{
				cur_file_zise=filesize(chekbr().getElementById('image_line').src);
		if(cur_file_zise>size_Mb)
		{
		alert('De foto is groter dan 5 MB, je kunt nu geen wijzigingen meer doen.');
		hide_Loading();
		return false;
		}
		else
		{

		var elstyle1=chekbr().getElementById('image_line').style;
		var elstyle2=chekbr().getElementById('first').style;
		qstr='mass='+chekbr().getElementById('image_line').src+'#'+parseInt(elstyle1.left)+'#'+parseInt(elstyle1.top)+'#'+parseInt(elstyle1.width)+'#'+parseInt(elstyle1.height)+'**'+chekbr().getElementById('first').src+'#'+parseInt(elstyle2.left)+'#'+parseInt(elstyle2.top)+'#'+parseInt(elstyle2.width)+'#'+parseInt(elstyle2.height);
		return qstr;
		}
	}



	function getquerystring_background()
	{
				cur_file_zise=filesize(chekbr().getElementById('image_line').src);
		if(cur_file_zise>size_Mb)
		{
		alert('De foto is groter dan 5 MB, je kunt nu geen wijzigingen meer doen.');
		hide_Loading();
		return false;
		}
		else
		{

		var elstyle1=chekbr().getElementById('image_line').style;
		var elstyle2=chekbr().getElementById('first').style;
		qstr='mass='+chekbr().getElementById('image_line').src+'#'+parseInt(elstyle1.left)+'#'+parseInt(elstyle1.top)+'#'+parseInt(elstyle1.width)+'#'+parseInt(elstyle1.height)+'**'+elstyle2.backgroundImage+'#'+parseInt(elstyle2.left)+'#'+parseInt(elstyle2.top)+'#'+parseInt(elstyle2.width)+'#'+parseInt(elstyle2.height);
		return qstr;
		}
	}

	function getquerystring_set()
	{

		qstr="&imageFileName="+document.getElementById('save_img').value;
		return qstr;
	}

	function getquerystring_bubble()
	{
				cur_file_zise=filesize(chekbr().getElementById('image_line').src);
		if(cur_file_zise>size_Mb)
		{
		alert('De foto is groter dan 5 MB, je kunt nu geen wijzigingen meer doen.');
		hide_Loading();
		return false;
		}
		else
		{

		var elstyle1=chekbr().getElementById('image_line').style;
		qstr='mass='+chekbr().getElementById('image_line').src+'#'+parseInt(elstyle1.left)+'#'+parseInt(elstyle1.top)+'#'+parseInt(elstyle1.width)+'#'+parseInt(elstyle1.height);
		
		
			for(var i=0;i<n;i++)
			{
				elstyle1=chekbr().getElementById(arr[i]);
				elstyle2=chekbr().getElementById(arr[i]+'_1');
				//elstyle3=chekbr().getElementById(arr[i]+'_1_1');
				//qstr+='**'+elstyle2.src+'#'+parseInt(elstyle1.style.left)+'#'+parseInt(elstyle1.style.top)+'#'+parseInt(elstyle2.width)+'#'+parseInt(elstyle2.height)+'#'+urlencode(str_replace("&nbsp;"," ",str_replace('<br>','\n',elstyle3.innerHTML)));
				
				qstr+='**'+escape(elstyle2.src)+'#'+parseInt(elstyle1.style.left)+'#'+parseInt(elstyle1.style.top)+'#'+parseInt(elstyle2.width)+'#'+parseInt(elstyle2.height);
			}
		
		//alert(qstr);
		return qstr;
		}
	}


	function getquerystring_fun_glitter()
	{
				cur_file_zise=filesize(chekbr().getElementById('image_line').src);
		if(cur_file_zise>size_Mb)
		{
		alert('De foto is groter dan 5 MB, je kunt nu geen wijzigingen meer doen.');
		hide_Loading();
		return false;
		}
		else
		{

		var elstyle1=chekbr().getElementById('image_line').style;
		qstr='mass='+chekbr().getElementById('image_line').src+'#'+parseInt(elstyle1.left)+'#'+parseInt(elstyle1.top)+'#'+parseInt(elstyle1.width)+'#'+parseInt(elstyle1.height);
		
		
			for(var i=0;i<n;i++)
			{
				elstyle1=chekbr().getElementById(arr[i]);
				elstyle2=chekbr().getElementById(arr[i]+'_1');
				qstr+='**'+elstyle2.src+'#'+parseInt(elstyle1.style.left)+'#'+parseInt(elstyle1.style.top)+'#'+parseInt(elstyle2.width)+'#'+parseInt(elstyle2.height);
			}
		
		qstr+='&speed='+document.getElementById('glitter_sped').value;
		return qstr;
		}
	}

////////////////////////////////////////////////////
//
//
//
//////////////////////////////////////////////////

	function updatepage_resize(str)
	{
		eval(str);
	}

	function update_lines(src1,w1,h1,src2,w2,h2)
	{
	document.getElementById("mov_glit").innerHTML='';
	chekbr().getElementById('image').innerHTML='<img  src="'+src1+'" id="image_line" style="LEFT: 0px;POSITION: absolute; TOP: 0px; width:'+w1+'px; height:'+h1+'px; visibility:; "><img  src="'+src2+'" id="first" style="LEFT: 0px;POSITION: absolute; TOP: 0px; width:'+w2+'px; height:'+h2+'px; visibility:; cursor:move; ">';


	var control='<br><h2>Glittertekst plaatsen</h2><p>Sleep de glittertekst naar de juiste plek op de foto en klik op <b>"Glittertekst plaatsen"</b></p>';
	
	control+='<a href="javascript:void(0);" onclick="xmlhttpPost(';
control+="'process.php?act=gltran','gltran');";
control+='" class="n-batton">Glittertekst plaatsen</a>';


	document.getElementById("mov_glit").innerHTML =control;
	hide_Loading();
	
	}

	function update_lines_pr(src1,w1,h1,src2,w2,h2)
	{
	document.getElementById("mov_glit").innerHTML='';
	chekbr().getElementById('image').innerHTML='<img  src="'+src1+'" id="image_line" style="LEFT: 0px;POSITION: absolute; TOP: 0px; width:'+w1+'px; height:'+h1+'px; visibility:; "><img  src="'+src2+'" id="first" style="LEFT: 0px;POSITION: absolute; TOP: 0px; width:'+w2+'px; height:'+h2+'px; visibility:; cursor:move; ">';


	var control='<br><h2>Tekst plaatsen</h2><p>Klik op de tekst en sleep die naar de juiste plek op de foto en klik dan op <b> "Tekst plaatsen" </b></p>';
	
	control+='<a href="javascript:void(0);" onclick="xmlhttpPost(';
	control+="'process.php?act=txttran','gltran');";
	control+='" class="n-batton">Tekst plaatsen</a>';

	
	document.getElementById("mov_glit").innerHTML =control;
	hide_Loading();
	
	}

	
	function Original()
	{
		
		if(curCrop!=null){curCrop.remove();}
		var control='<h2>Undo</h2>';
		control+='<div class="intro"><p>De originele foto is teruggezet.<p></div>';
		document.getElementById('control').innerHTML = control;
		document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('original_image').value+'" id="cropImage" />';
		document.getElementById('save_img').value=document.getElementById('original_image').value;
	}

	function Undo()
	{
		if(curCrop!=null){curCrop.remove();}
		var control='<h2>Undo</h2>';
		control+='<div class="intro"><p>De laatste wijziging is ongedaan gemaakt.<p></div>';
		document.getElementById('control').innerHTML = control;
		document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('undo').value+'" id="cropImage" />';
		var temp=document.getElementById('save_img').value;
		document.getElementById('save_img').value=document.getElementById('undo').value;
		document.getElementById('undo').value=temp;
	}


	function createCrop()
	{
		if(curCrop!=null){curCrop.remove();}
			document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';
			curCrop=new Cropper.Img('cropImage',{onEndCrop:onEndCrop});

			var filesize=gup('s',document.getElementById('cropImage').src);

			cropoHeight=document.getElementById('cropImage').height;
			cropoWidth=document.getElementById('cropImage').width;
			cropfilesize=filesize;

			var control=' <form name="crop" action="test.php" method="post" class="frmCrop">';
			control+='<input  type="hidden" class="hidden"  name="imageWidth" id="imageWidth" value="'+document.getElementById('cropImage').width +'" />';
			control+='<input type="hidden" class="hidden"  name="imageHeight" id="imageHeight" value="'+ document.getElementById('cropImage').height +'" />';
			control+='<input type="hidden"  class="hidden" name="imageFileName" id="imageFileName" value="'+ document.getElementById('save_img').value+'" />';
			control+='<input type="hidden" class="hidden"  name="cropX" id="cropX" value="0"  />';
			control+='<input type="hidden" class="hidden"  name="cropY" id="cropY" value="0" />';
			control+='</form>';

			
			
			control+='<h2>Uitsnede maken</h2><div class="nav-box"><p>Selecteer een gebied om een uitsnede van de foto te verkrijgen.</p></div>';
			control+='<div class="size-properties"><div class="size-wrap"><label>Breedte</label>';
			control+='<input type="text" class="text-input" name="cropWidth" id="cropWidth" value="0" readonly/></div>';
			control+='<div class="size-wrap"><label>Hoogte</label>';
			control+='<input type="text" class="text-input"  name="cropHeight" id="cropHeight" value="0" readonly/></div>';

			control+='<div class="size-wrap"><label>Bestand</label>';
			control+='<input type="text" class="size" readonly="readonly"  class="sol_input_text" name="IM_Size" id="IM_Size" value="'+KB(filesize)+'" /><span>KB schatting</span></div>';
			control+='<a href="javascript:void(0);" onclick="xmlhttpPost(';
			control+="'process.php?act=crop','crop');";							 
			control+='" class="n-batton">Toepassen</a>';
			
			document.getElementById('control').innerHTML = control;
	}
	function gup( name, url ){  
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
		var regexS = "[\\?&]"+name+"=([^&#]*)";  
		var regex = new RegExp( regexS );  
		var results = regex.exec( url ); 
		if( results == null )    
			return 0;  
		else    
			return results[1];
	}

	function KB(n){
		var kb= Math.round(n/1024*100)/100;
		return kb;
	}

	function createResize()
	{
			if(curCrop!=null){curCrop.remove();}
			document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';

			var owidth=document.getElementById('cropImage').width;
			var oheight=document.getElementById('cropImage').height;
			var filesize=gup('s',document.getElementById('cropImage').src);
			orig_w=document.getElementById('cropImage').width;

			var control ='<form action="last_step.php" method="post" class="frmResize">';
			control+='<input type="hidden" class="hidden" name="imageWidth" id="imageWidth" value="'+document.getElementById('cropImage').width+'" />';
			control+='<input type="hidden" class="hidden" name="imageHeight" id="imageHeight" value="'+ document.getElementById('cropImage').height +'" />';
			control+='<input type="hidden" class="hidden" name="imageFileName" id="imageFileName" value="'+ document.getElementById('save_img').value+'" />';
			control+='<input type="hidden" class="hidden" name="cropWidth" id="cropWidth" value="'+document.getElementById('cropImage').width+'" />';
			control+='<input type="hidden" class="hidden" name="cropHeight" id="cropHeight" value="'+ document.getElementById('cropImage').height +'" />';
			control+='<input type="hidden" class="hidden" name="resizeWidth" id="resizeWidth" value="'+document.getElementById('cropImage').width+'" />';
			control+='</form>';
			control+='<h2>Verkleinen</h2><div class="nav-box"><p>Bepaal met de slider hoe groot de foto moet worden of vul de exacte breedte of hoogte in.</p></div>';

			control+='<div id="resizeTrack">';
			control+='<div id="resizeHandle"></div>';
			control+='</div>';

control+='<div class="size-properties"><div class="size-wrap"><label>Breedte</label>';
control+='<input type="text" class="text-input" name="IM_Width" id="IM_Width" value="'+document.getElementById('cropImage').width+'" onblur="verklein(\'hoogte\', '+owidth+','+oheight+','+filesize+');" /></div>';
control+='<div class="size-wrap"><label>Hoogte</label><input type="text" class="text-input" name="IM_Height" id="IM_Height" value="'+document.getElementById('cropImage').height+'" onblur="verklein(\'breedte\', '+owidth+','+oheight+','+filesize+');"/></div>';
control+='<div class="size-wrap"><label>Bestand</label><input type="text" class="size"  readonly="readonly"  class="sol_input_text" name="IM_Size" id="IM_Size" value="'+KB(filesize)+'" /><span>KB schatting</span></div>';
control+='<div class="size-wrap ratio"><label>Ratio</label><input type="checkbox" checked="checked" class="checkbox" name="IM_Aspect" id="IM_Aspect" value="keep" CHECKED/></div></div>';
control+='<a href="javascript:void(0);" onclick="xmlhttpPost';
control+="('process.php?act=resize','resize');";
control+='" class="n-batton">Verkleinen</a>';

			document.getElementById('control').innerHTML = control;
			initSlider();
	}

	function verklein(zijde, owidth, oheight, filesize)
	{
		var ratio=document.getElementById('IM_Aspect').checked;
		//alleen doen als ratio is aangevinkt//
		if (ratio)
		{
			if (zijde=='hoogte' && document.getElementById('IM_Width').value!=0 && document.getElementById('IM_Width').value<=1200)
			{
				verhouding=owidth/parseInt(document.getElementById('IM_Width').value);
				document.getElementById('IM_Height').value=Math.round(oheight/verhouding);
				document.getElementById('IM_Size').value=KB(filesize/verhouding/verhouding);
				var scalePhoto = $('cropImage');
				scalePhoto.style.width = Math.round(parseInt(document.getElementById('IM_Width').value)) + 'px';
				scalePhoto.style.height = Math.round(parseInt(document.getElementById('IM_Height').value)) + 'px';
				slider.setValue(100/verhouding);
			}
			else if (zijde=='breedte' && document.getElementById('IM_Height').value!=0 && document.getElementById('IM_Height').value<=1200)
			{
				verhouding=oheight/parseInt(document.getElementById('IM_Height').value);
				document.getElementById('IM_Width').value=Math.round(owidth/verhouding);
				document.getElementById('IM_Size').value=KB(filesize/verhouding/verhouding);
				var scalePhoto = $('cropImage');
				scalePhoto.style.width = Math.round(parseInt(document.getElementById('IM_Width').value)) + 'px';
				scalePhoto.style.height = Math.round(parseInt(document.getElementById('IM_Height').value)) + 'px';
				slider.setValue(100/verhouding);
			}
			else {
				alert ("Onjuist invoer, getallen moeten groter dan 0 en kleiner dan 1200 zijn!");
				document.getElementById('IM_Height').value=oheight;
				document.getElementById('IM_Width').value=owidth;

			}
		}
		var scalePhoto = $('cropImage');
		scalePhoto.style.width = Math.round(parseInt(document.getElementById('IM_Width').value)) + 'px';
		scalePhoto.style.height = Math.round(parseInt(document.getElementById('IM_Height').value)) + 'px';
		verhouding1=oheight/parseInt(document.getElementById('IM_Height').value);
		verhouding2=owidth/parseInt(document.getElementById('IM_Width').value)
		document.getElementById('IM_Size').value=KB(filesize/verhouding1/verhouding2);
		document.getElementById('cropImage').height.value=Math.round(parseInt(document.getElementById('IM_Height').value));

	}

	function createRotate()
	{
			if(curCrop!=null){curCrop.remove();}
			document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';

			var  control='<form action="last_step.php" method="post" class="frmResize">';
			 control='<input type="hidden" class="hidden" name="imageFileName" id="imageFileName" value="'+ document.getElementById('save_img').value+'" />';
			control+='<h2>Roteren</h2><div class="rotate"><ul>';
			control+='<li><a href="javascript:void(0);" onclick="xmlhttpPost(';
			control+="'process.php?act=rotate_left','rotate');";
			control+='">Links</a></li>';
			control+='<li><a href="javascript:void(0);" onclick="xmlhttpPost(';
			control+="'process.php?act=rotate_right','rotate');";
			control+='"> Rechts</a></li></ul>';
			control+='<h2>Flip</h2><ul>';
			control+='<li><a href="javascript:void(0);" onclick="xmlhttpPost(';
			control+="'process.php?act=flip_vertical','flip');";
			control+='"> Vertikaal</a></li>';
			control+='<li><a href="javascript:void(0);" onclick="xmlhttpPost(';
			control+="'process.php?act=flip_horizontal','flip');";
			control+='">Horizontaal</a></li></ul></div></form>';

			document.getElementById('control').innerHTML = control;
	}


	
	function createUndo()
	{
		if(curCrop!=null){curCrop.remove();}
		document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';

		var  control='<form action="" method="post" class="frmResize">';

	    control+='<input type="hidden" class="hidden" name="imageFileName" id="imageFileName" value="'+ document.getElementById('save_img').value+'" />';

		control+='</form>';
		
			control+='<h2>Undo (Herstellen)</h2>';
			control+='<div class="resize undo-photo"><a href="javascript:void(0);" onclick="Undo();" class="n-batton">Ongedaan maken</a>';
			
		control+='<a href="javascript:void(0);" onclick="Original();" class="n-batton">Terug naar Origineel</a></div>';
		control+='<div id="email_resp"></div>';





		document.getElementById('control').innerHTML = control;
	}



	function Save(type)
	{
		document.location.href='specialfx.php?act='+type+'&imageFileName='+ document.getElementById('imageFileName').value +'';
	}

	function Print(width,height)
	{
		var windowname='print.php?imageFileName='+ document.getElementById('imageFileName').value +'';
		var w=width+20;
		var h=height+20;
		window.open(windowname,"Print_ ","width="+w+",height="+h+",location=no, toolbar=no");
	}


	function createSave()
	{
		if(curCrop!=null){curCrop.remove();}
		document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';

		var  control='<form action="" method="post" class="frmResize">';

	    control+='<input type="hidden" class="hidden" name="imageFileName" id="imageFileName" value="'+ document.getElementById('save_img').value+'" />';
		control+='<input type="hidden" class="hidden"  name="imageWidth" id="imageWidth" value="'+document.getElementById('cropImage').width+'" />';
		control+='<input type="hidden" class="hidden"  name="imageHeight" id="imageHeight" value="'+ document.getElementById('cropImage').height +'" />';
		control+='  </form>';
var im=''+strtok(document.getElementById('save_img').value,'?')+'';
setCookie("im",im);

var rand_no = Math.random();
rand_no = rand_no * 1000000;
rand_no = Math.ceil(rand_no);


			control+='<h2>Bewaar foto</h2>';
			control+='<div class="nav-box"><p>Sla hier je foto lokaal of online op. Klik op "Bewaren Online" om je foto direct op Hyves op te nemen.</p>';
			control+='<div class="resize undo-photo"><a href="javascript:void(0);" onclick="';
			control+="Save('GIF')";
			control+='"class="n-batton">Bewaren (harde schijf)</a>';
			control+='<a href="javascript:void(0);" onclick="';
			control+="iBox.showURL('email_picture.php','Email deze foto','width=500;height=280;');";
			control+='"class="n-batton">Email Foto</a>';
			control+='<a href="javascript:void(0);" onclick="';
			control+="iBox.showURL('code.php?r_n="+rand_no+"','Save Online','width=600;height=450;');";
			control+='"class="n-batton">Bewaren Online</a>';
			control+='<a href="javascript:void(0);" onclick="';
			control+="iBox.showURL('photobucket_login.php?r_n="+rand_no+"','Upload je foto naar je Photobucket account','width=600;height=550;');";
			control+='"class="n-batton">Bewaar op Photobucket</a></div></div>';
		
control+='<div id="email_resp"></div>';
		document.getElementById('control').innerHTML = control;
	}

	function createEmpty()
	{
		if(curCrop!=null){curCrop.remove();}
		document.getElementById('cropWrap').innerHTML ='<img src="'+document.getElementById('save_img').value+'" id="cropImage" />';
		el_id='1';
		ReadFile("empty.php");


	}

	function createFrame()
	{
		if(curCrop!=null){curCrop.remove();}
		document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';
		el_id='control';
		ReadFile("frame.php?act=first&table=fram")
	}
		
	function createEffects()
	{
	if(curCrop!=null){curCrop.remove();}
	document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';
	el_id='control';
	ReadFile("effects.php");
	}

	
	function createBackground()
	{
		if(curCrop!=null){curCrop.remove();}
		document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';
		el_id='control';
		ReadFile("frame.php?act=first&table=backgrounds")
	}
	
	function createTrim()
	{
		if(curCrop!=null){curCrop.remove();}
		document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';
		el_id='control';
		ReadFile("frame.php?act=first&table=trim")
	}

	
	function createBubble()
	{
		if(curCrop!=null){curCrop.remove();}
		document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';
		document.getElementById('control').style.display="none";
		tItemCounter=1000;
		el_id='control';
		ReadFile("bubble.php");
		
	window.setTimeout('el_id=1;ReadFile("set_bubble.php?imageFileName="+document.getElementById("save_img").value)',set_time_out);
		//el_id=1;
		

	}
	
	function createFun_Gliter()
	{
		if(curCrop!=null){curCrop.remove();}
		document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';
		document.getElementById('control').style.display="none";
		tItemCounter=1000;
		elmid=null;

		el_id='control';
		ReadFile("fun_glitter.php");
		
	window.setTimeout('el_id=1;ReadFile("set_glitter.php?imageFileName="+document.getElementById("save_img").value)',set_time_out);
		//el_id=1;
		

	}
		function createGlitter_fill()
	{
		if(curCrop!=null){curCrop.remove();}
		document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';
		document.getElementById('control').style.display="none";
		//tItemCounter=1000;
		//elmid=null;

		el_id='control';
		ReadFile("glitter_fill.php");
		//document.getElementById('control').style.display="";

	window.setTimeout('el_id=1;ReadFile("set_glitter_fill.php?imageFileName="+document.getElementById("save_img").value)',set_time_out);
		//el_id=1;
		

	}


	function Setframe(id)
	{
	document.getElementById("cropWrap").innerHTML='';
	shou_Loading();
	//el_id=1;
	//ReadFile("set_frame.php?id="+id+"&imageFileName="+document.getElementById('save_img').value);
	xmlhttpPost('set_frame.php?id='+id+'','set');

	}

	function Setbackground(id)
	{
	document.getElementById("cropWrap").innerHTML='';
	shou_Loading();
	//el_id=1;
	//ReadFile("set_background.php?id="+id+"&imageFileName="+document.getElementById('save_img').value);
	xmlhttpPost('set_background.php?id='+id+'','set');
	}

	function SetTrim(id)
	{
	document.getElementById("cropWrap").innerHTML='';
	shou_Loading();
	//el_id=1;
	//ReadFile("set_trim.php?id="+id+"&imageFileName="+document.getElementById('save_img').value);
	xmlhttpPost('set_trim.php?id='+id+'','set');

	}

	function update_frames(src1,w1,h1,src2,w2,h2)
	{
	initSliderframe();
	chekbr().getElementById('image').innerHTML='<img  src="'+src1+'" id="image_line" style="LEFT: 0px;POSITION: absolute; TOP: 0px; width:'+w1+'px; height:'+h1+'px; visibility:;cursor:move;"><img  src="'+src2+'" id="first" style="LEFT: 0px;POSITION: absolute; TOP: 0px; width:'+w2+'px; height:'+h2+'px; visibility:; cursor:move;">';


	hide_Loading();
	
	}
	
	function update_backgtound(src1,w1,h1,src2,w2,h2)
	{
		
	chekbr().getElementById('loadedImage').style.width=w1;
	chekbr().getElementById('loadedImage').style.height=h1;
	chekbr().getElementById('loadedImage').innerHTML='<img  src="'+src1+'" id="image_line" style="LEFT: 0px;POSITION: absolute; TOP: 0px; width:'+w1+'px; height:'+h1+'px; visibility:;"><div id="first" style="LEFT: 0px;POSITION: absolute; TOP: 0px; width:'+w2+'px; height:'+h2+'px; visibility:;background-image:url('+src2+');" >';

	hide_Loading();
	}
	
	function createText()
	{
		
			
			if (keeptekst==''){var showtekst='Type hier de tekst die je op de foto wilt zetten';}else {var showtekst=keeptekst;}
			if (keepfont==''){var showfont='Action Man';}else {var showfont=keepfont;}
			if (keeplocatie==''){var showlocatie='top';}else {var showlocatie=keeplocatie;}
			if (keepcolor==''){var showcolor='E60000';} else {var showcolor=keepcolor;}
			if (keepgroottetext==''){ var showgroottetext=16;} else {var showgroottetext=keepgroottetext;}
			
			//if(curCrop!=null){curCrop.remove();}
			document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';
			var control='<h2>Tekst toevoegen</h2><div class="lined-box">';
			control+=' <form name="crop" action="" method="post" class="frmCrop">';
			control+='<input type="hidden" class="hidden" name="imageFileName" id="imageFileName" value="'+ document.getElementById('save_img').value+'" />';
			control+='<div class="textarea"><textarea name="input_text" rows="3" cols="40" id="text_input" class="sol_input_textarea" onChange="keeptekst=document.getElementById(\'text_input\').value;"/>'+showtekst+'</textarea></div>';
			//glitter font//
			control+='<div class="select-wrap"><label>Font</label>';
			control+='<select name="loadFonth"  id="loadFonth" style="width:130px" onChange="keepfont=document.getElementById(\'loadFonth\').value;image(\'\'+this.value+\'\')">';
			control+="<option "; if (showfont=='Action Man'){ control+="selected "} control+="value='Action Man' > Action Man</option>";
			control+="<option "; if (showfont=='Aether Fox'){ control+="selected "} control+="value='Aether Fox' > Aether Fox</option>";
			control+="<option "; if (showfont=='Alexit'){ control+="selected "} control+="value='Alexis' > Alexis</option>";
			control+="<option "; if (showfont=='Antsy Pants'){ control+="selected "} control+="value='Antsy Pants' > Antsy Pants</option>";
			control+="<option "; if (showfont=='Architecture'){ control+="selected "} control+="value='Architecture' > Architecture</option>";
			control+="<option "; if (showfont=='Arial'){ control+="selected "} control+="value='Arial' > Arial</option>";
			control+="<option "; if (showfont=='Army'){ control+="selected "} control+="value='Army' > Army</option>";
			control+="<option "; if (showfont=='Astrolyte'){ control+="selected "} control+="value='Astrolyte' > Astrolyte</option>";
			control+="<option "; if (showfont=='Avquest'){ control+="selected "} control+="value='Avquest' > Avquest</option>";
			control+="<option "; if (showfont=='Bad Cargo'){ control+="selected "} control+="value='Bad Cargo' > Bad Cargo</option>";
			control+="<option "; if (showfont=='Balloon Bold BT'){ control+="selected "} control+="value='Balloon Bold BT' > Balloon Bold BT</option>";
			control+="<option "; if (showfont=='Bandwidth Bandmess BRK'){ control+="selected "} control+="value='Bandwidth Bandmess BRK' > Bandwidth Bandmess BRK</option>";
			control+="<option "; if (showfont=='Bardatrick'){ control+="selected "} control+="value='Bardatrick' > Bardatrick</option>";
			control+="<option "; if (showfont=='Base'){ control+="selected "} control+="value='Base' > Base</option>";
			control+="<option "; if (showfont=='Batman'){ control+="selected "} control+="value='Batman' > Batman</option>";
			control+="<option "; if (showfont=='BatmanForeverAlternate'){ control+="selected "} control+="value='BatmanForeverAlternate' > BatmanForeverAlternate</option>";
			control+="<option "; if (showfont=='Battlefield'){ control+="selected "} control+="value='Battlefield' > Battlefield</option>";
			control+="<option "; if (showfont=='Bauer'){ control+="selected "} control+="value='Bauer' > Bauer</option>";
			control+="<option "; if (showfont=='Beast Machines'){ control+="selected "} control+="value='Beast Machines' > Beast Machines</option>";
			control+="<option "; if (showfont=='Bergell LET'){ control+="selected "} control+="value='Bergell LET' > Bergell LET</option>";
			control+="<option "; if (showfont=='Beware'){ control+="selected "} control+="value='Beware' > Beware</option>";
			control+="<option "; if (showfont=='Billo'){ control+="selected "} control+="value='Billo' > Billo</option>";
			control+="<option "; if (showfont=='Borg'){ control+="selected "} control+="value='Borg' > Borg</option>";
			control+="<option "; if (showfont=='Bottix'){ control+="selected "} control+="value='Bottix' > Bottix</option>";
			control+="<option "; if (showfont=='Bremen Cameo 3D'){ control+="selected "} control+="value='Bremen Cameo 3D' > Bremen Cameo 3D</option>";
			control+="<option "; if (showfont=='Bring Tha Noize'){ control+="selected "} control+="value='Bring Tha Noize' > Bring Tha Noize</option>";
			control+="<option "; if (showfont=='Brush Script MT'){ control+="selected "} control+="value='Brush Script MT' > Brush Script MT</option>";
			control+="<option "; if (showfont=='Bubble'){ control+="selected "} control+="value='Bubble' > Bubble</option>";
			control+="<option "; if (showfont=='Captain Podd'){ control+="selected "} control+="value='Captain Podd' > Captain Podd</option>";
			control+="<option "; if (showfont=='Carbon Block'){ control+="selected "} control+="value='Carbon Block' > Carbon Block</option>";
			control+="<option "; if (showfont=='Celtic Garamond'){ control+="selected "} control+="value='Celtic Garamond' > Celtic Garamond</option>";
			control+="<option "; if (showfont=='Chemical Reaction'){ control+="selected "} control+="value='Chemical Reaction' > Chemical Reaction</option>";
			control+="<option "; if (showfont=='Chrome Yellow'){ control+="selected "} control+="value='Chrome Yellow' > Chrome Yellow</option>";
			control+="<option "; if (showfont=='Chromosome'){ control+="selected "} control+="value='Chromosome' > Chromosome</option>";
			control+="<option "; if (showfont=='Chronicles of a hero'){ control+="selected "} control+="value='Chronicles of a hero' > Chronicles of a hero</option>";
			control+="<option "; if (showfont=='College'){ control+="selected "} control+="value='College' > College</option>";
			control+="<option "; if (showfont=='Comic Sans'){ control+="selected "} control+="value='Comic Sans' > Comic Sans</option>";
			control+="<option "; if (showfont=='Corrida'){ control+="selected "} control+="value='Corrida' > Corrida</option>";
			control+="<option "; if (showfont=='Courier New'){ control+="selected "} control+="value='Courier New' > Courier New</option>";
			control+="<option "; if (showfont=='Cramps'){ control+="selected "} control+="value='Cramps' > Cramps</option>";
			control+="<option "; if (showfont=='Cream Puff'){ control+="selected "} control+="value='Cream Puff' > Cream Puff</option>";
			control+="<option "; if (showfont=='Creepy'){ control+="selected "} control+="value='Creepy' > Creepy</option>";
			control+="<option "; if (showfont=='Curlz'){ control+="selected "} control+="value='Curlz' > Curlz</option>";
			control+="<option "; if (showfont=='Dance Club'){ control+="selected "} control+="value='Dance Club' > Dance Club</option>";
			control+="<option "; if (showfont=='Deftone Stylus'){ control+="selected "} control+="value='Deftone Stylus' > Deftone Stylus</option>";
			control+="<option "; if (showfont=='Degrassi'){ control+="selected "} control+="value='Degrassi' > Degrassi</option>";
			control+="<option "; if (showfont=='Digital'){ control+="selected "} control+="value='Digital' > Digital</option>";
			control+="<option "; if (showfont=='Diploma'){ control+="selected "} control+="value='Diploma' > Diploma</option>";
			control+="<option "; if (showfont=='Dirty Ego'){ control+="selected "} control+="value='Dirty Ego' > Dirty Ego</option>";
			control+="<option "; if (showfont=='Disintigration'){ control+="selected "} control+="value='Disintigration' > Disintigration</option>";
			control+="<option "; if (showfont=='Distant Galaxy'){ control+="selected "} control+="value='Distant Galaxy' > Distant Galaxy</option>";
			control+="<option "; if (showfont=='Dodger'){ control+="selected "} control+="value='Dodger' > Dodger</option>";
			control+="<option "; if (showfont=='Dollar'){ control+="selected "} control+="value='Dollar' > Dollar</option>";
			control+="<option "; if (showfont=='Dope Jam'){ control+="selected "} control+="value='Dope Jam' > Dope Jam</option>";
			control+="<option "; if (showfont=='Dream Orphans'){ control+="selected "} control+="value='Dream Orphans' > Dream Orphans</option>";
			control+="<option "; if (showfont=='Earthquake'){ control+="selected "} control+="value='Earthquake' > Earthquake</option>";
			control+="<option "; if (showfont=='Edwardian Script'){ control+="selected "} control+="value='Edwardian Script' > Edwardian Script</option>";
			control+="<option "; if (showfont=='Embassy BT'){ control+="selected "} control+="value='Embassy BT' > Embassy BT</option>";
			control+="<option "; if (showfont=='Eraser Dust'){ control+="selected "} control+="value='Eraser Dust' > Eraser Dust</option>";
			control+="<option "; if (showfont=='Fat Boy Slim'){ control+="selected "} control+="value='Fat Boy Slim' > Fat Boy Slim</option>";
			control+="<option "; if (showfont=='Fiolex Girls'){ control+="selected "} control+="value='Fiolex Girls' > Fiolex Girls</option>";
			control+="<option "; if (showfont=='Fluoride'){ control+="selected "} control+="value='Fluoride' > Fluoride</option>";
			control+="<option "; if (showfont=='Gothic'){ control+="selected "} control+="value='Gothic' > Gothic</option>";
			control+="<option "; if (showfont=='Graffiti Treat'){ control+="selected "} control+="value='Graffiti Treat' > Graffiti Treat</option>";
			control+="<option "; if (showfont=='Grand Stylus'){ control+="selected "} control+="value='Grand Stylus' > Grand Stylus</option>";
			control+="<option "; if (showfont=='Gyparody'){ control+="selected "} control+="value='Gyparody' > Gyparody</option>";
			control+="<option "; if (showfont=='Hard Core'){ control+="selected "} control+="value='Hard Core' > Hard Core</option>";
			control+="<option "; if (showfont=='Heaven'){ control+="selected "} control+="value='Heaven' > Heaven</option>";
			control+="<option "; if (showfont=='Hursheys'){ control+="selected "} control+="value='Hursheys' > Hursheys</option>";
			control+="<option "; if (showfont=='Isuzu'){ control+="selected "} control+="value='Isuzu' > Isuzu</option>";
			control+="<option "; if (showfont=='Lucida Sans Unicode'){ control+="selected "} control+="value='Lucida Sans Unicode' > Lucida Sans Unicode</option>";
			control+="<option "; if (showfont=='Micro N55'){ control+="selected "} control+="value='Micro N55' > Micro N55</option>";
			control+="<option "; if (showfont=='Micro N56'){ control+="selected "} control+="value='Micro N56' > Micro N56</option>";
			control+="<option "; if (showfont=='Microgramma'){ control+="selected "} control+="value='Microgramma' > Microgramma</option>";
			control+="<option "; if (showfont=='Mini'){ control+="selected "} control+="value='Mini' > Mini</option>";
			control+="<option "; if (showfont=='Neuropol'){ control+="selected "} control+="value='Neuropol' > Neuropol</option>";
			control+="<option "; if (showfont=='Neuropol Medium'){ control+="selected "} control+="value='Neuropol Medium' > Neuropol Medium</option>";
			control+="<option "; if (showfont=='Never Say Die'){ control+="selected "} control+="value='Never Say Die' > Never Say Die</option>";
			control+="<option "; if (showfont=='Ogilvie'){ control+="selected "} control+="value='Ogilvie' > Ogilvie</option>";
			control+="<option "; if (showfont=='Plain O Matic'){ control+="selected "} control+="value='Plain O Matic' > Plain O Matic</option>";
			control+="<option "; if (showfont=='Plastique'){ control+="selected "} control+="value='Plastique' > Plastique</option>";
			control+="<option "; if (showfont=='Plump'){ control+="selected "} control+="value='Plump' > Plump</option>";
			control+="<option "; if (showfont=='Puma'){ control+="selected "} control+="value='Puma' > Puma</option>";
			control+="<option "; if (showfont=='Quill'){ control+="selected "} control+="value='Quill' > Quill</option>";
			control+="<option "; if (showfont=='Reska Graf'){ control+="selected "} control+="value='Reska Graf' > Reska Graf</option>";
			control+="<option "; if (showfont=='Serpentine Bold'){ control+="selected "} control+="value='Serpentine Bold' > Serpentine Bold</option>";
			control+="<option "; if (showfont=='Shopping List'){ control+="selected "} control+="value='Shopping List' > Shopping List</option>";
			control+="<option "; if (showfont=='Slammer Tag'){ control+="selected "} control+="value='Slammer Tag' > Slammer Tag</option>";
			control+="<option "; if (showfont=='Sofachrome Italic'){ control+="selected "} control+="value='Sofachrome Italic' > Sofachrome Italic</option>";
			control+="<option "; if (showfont=='Solo'){ control+="selected "} control+="value='Solo' > Solo</option>";
			control+="<option "; if (showfont=='Space Toaster'){ control+="selected "} control+="value='Space Toaster' > Space Toaster</option>";
			control+="<option "; if (showfont=='Stencil'){ control+="selected "} control+="value='Stencil' > Stencil</option>";
			control+="<option "; if (showfont=='Styrofoam Feelings'){ control+="selected "} control+="value='Styrofoam Feelings' > Styrofoam Feelings</option>";
			control+="<option "; if (showfont=='Super 911'){ control+="selected "} control+="value='Super 911' > Super 911</option>";
			control+="<option "; if (showfont=='Tags Extreme'){ control+="selected "} control+="value='Tags Extreme' > Tags Extreme</option>";
			control+="<option "; if (showfont=='Tech'){ control+="selected "} control+="value='Tech' > Tech</option>";
			control+="<option "; if (showfont=='The Battle'){ control+="selected "} control+="value='The Battle' > The Battle</option>";
			control+="<option "; if (showfont=='The Guru'){ control+="selected "} control+="value='The Guru' > The Guru</option>";
			control+="<option "; if (showfont=='Thug'){ control+="selected "} control+="value='Thug' > Thug</option>";
			control+="<option "; if (showfont=='Verdana'){ control+="selected "} control+="value='Verdana' > Verdana</option>";
			control+="<option "; if (showfont=='Weltron Urban'){ control+="selected "} control+="value='Weltron Urban' > Weltron Urban</option>";
			control+='</select></div>';
			//glitter font Preview/
			
			control+='<img  name="image_font" id="image_font" style="float:right;" src="font_image/'+urlencode(showfont)+'.gif" >';
			//lokatie
			
			control+='<div class="select-wrap"><label>Orientatie</label><select name="location_" id="location_text" onChange="keeplocatie=document.getElementById(\'location_text\').value;">';
			control+="<option selected value='horizontal'>Horizontale tekst</option>";
			control+="<option value='vertical'>Vertikale tekst</option>";
			control+='</select></div>';
			control+='<div class="select-wrap"><label>Tekst kleur </label><span>klik kleur</span>&nbsp;<input type="hidden" id="colorfield" value="'+showcolor+'" ><button style="width: 1.5em; height: 1.5em; border: 1px outset #666;" id="colorbox" class="colorbox"></button> </div>';
			
			control+='<div class="select-wrap"><label>Font grootte</label><select name="font_size" id="font_size" onChange="keepgroottetext=document.getElementById(\'font_size\').value;">';
			control+="<option "; if (showgroottetext=='12'){ control+="selected "} control+="value='12'>12</option>";
			control+="<option "; if (showgroottetext=='16'){ control+="selected "} control+="value='16'>16</option>";
			control+="<option "; if (showgroottetext=='20'){ control+="selected "} control+="value='20'>20</option>";
			control+="<option "; if (showgroottetext=='24'){ control+="selected "} control+="value='24'>24</option>";
			control+="<option "; if (showgroottetext=='32'){ control+="selected "} control+="value='32'>32</option>";
			control+="<option "; if (showgroottetext=='40'){ control+="selected "} control+="value='40'>40</option>";
			control+="<option "; if (showgroottetext=='48'){ control+="selected "} control+="value='48'>48</option>";
			control+='</select></div>';
			control+='<a href="javascript:void(0);" onclick="xmlhttpPost(';
			control+="'process.php?act=addtext','addtext');";
			control+='" class="n-batton">Preview</a>';
			control+='<div id="mov_glit"></div>';


			document.getElementById('control').innerHTML = control;
			new Control.ColorPicker("colorfield", { IMAGE_BASE : "img/", "swatch" : "colorbox" });
		
	}
	
	
	function createGlitter()
	{

			if (keeptekst==''){var showtekst='Type hier je glitter tekst die op de foto moet komen';}else {var showtekst=keeptekst;}
			if (keepfont==''){var showfont='Action Man';}else {var showfont=keepfont;}
			if (keeplocatie==''){var showlocatie='top';}else {var showlocatie=keeplocatie;}
			if (keepgrootteglitter==''){ var showgrootteglitter=40;} else {var showgrootteglitter=keepgrootteglitter;}
			if (keephoek==''){ var showhoek=0;} else {var showhoek=keephoek;}
			if (keepglitter==''){ var showglitter='img/DCglit32.gif';} else {var showglitter=keepglitter;}
			if (keepschaduw==''){ var showschaduw=1;} else {var showschaduw=keepschaduw;}
			if (keeprand==''){ var showrand=3;} else {var showrand=keeprand;}
			if (keepranddikte==''){ var showranddikte=1;} else {var showranddikte=keepranddikte;}

			if(curCrop!=null){curCrop.remove();}
			document.getElementById('cropWrap').innerHTML ='<img src="'+ document.getElementById('save_img').value+'" id="cropImage" />';
			
			var control=' <h2>Glitter tekst</h2><div class="lined-box">';
			control+=' <form name="crop" action="" method="post" class="frmCrop">';
			control+='<input type="hidden" class="hidden" name="imageFileName" id="imageFileName" value="'+ document.getElementById('save_img').value+'" />';

			control+='<div class="textarea"><textarea name="t" rows="3" cols="40" id="t" class="sol_input_textarea" onChange="keeptekst=document.getElementById(\'t\').value;"/>'+showtekst+'</textarea></div>';

			//glitter font//
			control+='<div class="select-wrap"><label>Font</label><select name="loadFonth"  id="loadFonth" style="width:130px;border:solid 1px #DEEEFf;" onChange="keepfont=document.getElementById(\'loadFonth\').value;image(\'\'+this.value+\'\')">';
			control+="<option "; if (showfont=='Action Man'){ control+="selected "} control+="value='Action Man' > Action Man</option>";
			control+="<option "; if (showfont=='Aether Fox'){ control+="selected "} control+="value='Aether Fox' > Aether Fox</option>";
			control+="<option "; if (showfont=='Alexit'){ control+="selected "} control+="value='Alexis' > Alexis</option>";
			control+="<option "; if (showfont=='Antsy Pants'){ control+="selected "} control+="value='Antsy Pants' > Antsy Pants</option>";
			control+="<option "; if (showfont=='Architecture'){ control+="selected "} control+="value='Architecture' > Architecture</option>";
			control+="<option "; if (showfont=='Arial'){ control+="selected "} control+="value='Arial' > Arial</option>";
			control+="<option "; if (showfont=='Army'){ control+="selected "} control+="value='Army' > Army</option>";
			control+="<option "; if (showfont=='Astrolyte'){ control+="selected "} control+="value='Astrolyte' > Astrolyte</option>";
			control+="<option "; if (showfont=='Avquest'){ control+="selected "} control+="value='Avquest' > Avquest</option>";
			control+="<option "; if (showfont=='Bad Cargo'){ control+="selected "} control+="value='Bad Cargo' > Bad Cargo</option>";
			control+="<option "; if (showfont=='Balloon Bold BT'){ control+="selected "} control+="value='Balloon Bold BT' > Balloon Bold BT</option>";
			control+="<option "; if (showfont=='Bandwidth Bandmess BRK'){ control+="selected "} control+="value='Bandwidth Bandmess BRK' > Bandwidth Bandmess BRK</option>";
			control+="<option "; if (showfont=='Bardatrick'){ control+="selected "} control+="value='Bardatrick' > Bardatrick</option>";
			control+="<option "; if (showfont=='Base'){ control+="selected "} control+="value='Base' > Base</option>";
			control+="<option "; if (showfont=='Batman'){ control+="selected "} control+="value='Batman' > Batman</option>";
			control+="<option "; if (showfont=='BatmanForeverAlternate'){ control+="selected "} control+="value='BatmanForeverAlternate' > BatmanForeverAlternate</option>";
			control+="<option "; if (showfont=='Battlefield'){ control+="selected "} control+="value='Battlefield' > Battlefield</option>";
			control+="<option "; if (showfont=='Bauer'){ control+="selected "} control+="value='Bauer' > Bauer</option>";
			control+="<option "; if (showfont=='Beast Machines'){ control+="selected "} control+="value='Beast Machines' > Beast Machines</option>";
			control+="<option "; if (showfont=='Bergell LET'){ control+="selected "} control+="value='Bergell LET' > Bergell LET</option>";
			control+="<option "; if (showfont=='Beware'){ control+="selected "} control+="value='Beware' > Beware</option>";
			control+="<option "; if (showfont=='Billo'){ control+="selected "} control+="value='Billo' > Billo</option>";
			control+="<option "; if (showfont=='Borg'){ control+="selected "} control+="value='Borg' > Borg</option>";
			control+="<option "; if (showfont=='Bottix'){ control+="selected "} control+="value='Bottix' > Bottix</option>";
			control+="<option "; if (showfont=='Bremen Cameo 3D'){ control+="selected "} control+="value='Bremen Cameo 3D' > Bremen Cameo 3D</option>";
			control+="<option "; if (showfont=='Bring Tha Noize'){ control+="selected "} control+="value='Bring Tha Noize' > Bring Tha Noize</option>";
			control+="<option "; if (showfont=='Brush Script MT'){ control+="selected "} control+="value='Brush Script MT' > Brush Script MT</option>";
			control+="<option "; if (showfont=='Bubble'){ control+="selected "} control+="value='Bubble' > Bubble</option>";
			control+="<option "; if (showfont=='Captain Podd'){ control+="selected "} control+="value='Captain Podd' > Captain Podd</option>";
			control+="<option "; if (showfont=='Carbon Block'){ control+="selected "} control+="value='Carbon Block' > Carbon Block</option>";
			control+="<option "; if (showfont=='Celtic Garamond'){ control+="selected "} control+="value='Celtic Garamond' > Celtic Garamond</option>";
			control+="<option "; if (showfont=='Chemical Reaction'){ control+="selected "} control+="value='Chemical Reaction' > Chemical Reaction</option>";
			control+="<option "; if (showfont=='Chrome Yellow'){ control+="selected "} control+="value='Chrome Yellow' > Chrome Yellow</option>";
			control+="<option "; if (showfont=='Chromosome'){ control+="selected "} control+="value='Chromosome' > Chromosome</option>";
			control+="<option "; if (showfont=='Chronicles of a hero'){ control+="selected "} control+="value='Chronicles of a hero' > Chronicles of a hero</option>";
			control+="<option "; if (showfont=='College'){ control+="selected "} control+="value='College' > College</option>";
			control+="<option "; if (showfont=='Comic Sans'){ control+="selected "} control+="value='Comic Sans' > Comic Sans</option>";
			control+="<option "; if (showfont=='Corrida'){ control+="selected "} control+="value='Corrida' > Corrida</option>";
			control+="<option "; if (showfont=='Courier New'){ control+="selected "} control+="value='Courier New' > Courier New</option>";
			control+="<option "; if (showfont=='Cramps'){ control+="selected "} control+="value='Cramps' > Cramps</option>";
			control+="<option "; if (showfont=='Cream Puff'){ control+="selected "} control+="value='Cream Puff' > Cream Puff</option>";
			control+="<option "; if (showfont=='Creepy'){ control+="selected "} control+="value='Creepy' > Creepy</option>";
			control+="<option "; if (showfont=='Curlz'){ control+="selected "} control+="value='Curlz' > Curlz</option>";
			control+="<option "; if (showfont=='Dance Club'){ control+="selected "} control+="value='Dance Club' > Dance Club</option>";
			control+="<option "; if (showfont=='Deftone Stylus'){ control+="selected "} control+="value='Deftone Stylus' > Deftone Stylus</option>";
			control+="<option "; if (showfont=='Degrassi'){ control+="selected "} control+="value='Degrassi' > Degrassi</option>";
			control+="<option "; if (showfont=='Digital'){ control+="selected "} control+="value='Digital' > Digital</option>";
			control+="<option "; if (showfont=='Diploma'){ control+="selected "} control+="value='Diploma' > Diploma</option>";
			control+="<option "; if (showfont=='Dirty Ego'){ control+="selected "} control+="value='Dirty Ego' > Dirty Ego</option>";
			control+="<option "; if (showfont=='Disintigration'){ control+="selected "} control+="value='Disintigration' > Disintigration</option>";
			control+="<option "; if (showfont=='Distant Galaxy'){ control+="selected "} control+="value='Distant Galaxy' > Distant Galaxy</option>";
			control+="<option "; if (showfont=='Dodger'){ control+="selected "} control+="value='Dodger' > Dodger</option>";
			control+="<option "; if (showfont=='Dollar'){ control+="selected "} control+="value='Dollar' > Dollar</option>";
			control+="<option "; if (showfont=='Dope Jam'){ control+="selected "} control+="value='Dope Jam' > Dope Jam</option>";
			control+="<option "; if (showfont=='Dream Orphans'){ control+="selected "} control+="value='Dream Orphans' > Dream Orphans</option>";
			control+="<option "; if (showfont=='Earthquake'){ control+="selected "} control+="value='Earthquake' > Earthquake</option>";
			control+="<option "; if (showfont=='Edwardian Script'){ control+="selected "} control+="value='Edwardian Script' > Edwardian Script</option>";
			control+="<option "; if (showfont=='Embassy BT'){ control+="selected "} control+="value='Embassy BT' > Embassy BT</option>";
			control+="<option "; if (showfont=='Eraser Dust'){ control+="selected "} control+="value='Eraser Dust' > Eraser Dust</option>";
			control+="<option "; if (showfont=='Fat Boy Slim'){ control+="selected "} control+="value='Fat Boy Slim' > Fat Boy Slim</option>";
			control+="<option "; if (showfont=='Fiolex Girls'){ control+="selected "} control+="value='Fiolex Girls' > Fiolex Girls</option>";
			control+="<option "; if (showfont=='Fluoride'){ control+="selected "} control+="value='Fluoride' > Fluoride</option>";
			control+="<option "; if (showfont=='Gothic'){ control+="selected "} control+="value='Gothic' > Gothic</option>";
			control+="<option "; if (showfont=='Graffiti Treat'){ control+="selected "} control+="value='Graffiti Treat' > Graffiti Treat</option>";
			control+="<option "; if (showfont=='Grand Stylus'){ control+="selected "} control+="value='Grand Stylus' > Grand Stylus</option>";
			control+="<option "; if (showfont=='Gyparody'){ control+="selected "} control+="value='Gyparody' > Gyparody</option>";
			control+="<option "; if (showfont=='Hard Core'){ control+="selected "} control+="value='Hard Core' > Hard Core</option>";
			control+="<option "; if (showfont=='Heaven'){ control+="selected "} control+="value='Heaven' > Heaven</option>";
			control+="<option "; if (showfont=='Hursheys'){ control+="selected "} control+="value='Hursheys' > Hursheys</option>";
			control+="<option "; if (showfont=='Isuzu'){ control+="selected "} control+="value='Isuzu' > Isuzu</option>";
			control+="<option "; if (showfont=='Lucida Sans Unicode'){ control+="selected "} control+="value='Lucida Sans Unicode' > Lucida Sans Unicode</option>";
			control+="<option "; if (showfont=='Micro N55'){ control+="selected "} control+="value='Micro N55' > Micro N55</option>";
			control+="<option "; if (showfont=='Micro N56'){ control+="selected "} control+="value='Micro N56' > Micro N56</option>";
			control+="<option "; if (showfont=='Microgramma'){ control+="selected "} control+="value='Microgramma' > Microgramma</option>";
			control+="<option "; if (showfont=='Mini'){ control+="selected "} control+="value='Mini' > Mini</option>";
			control+="<option "; if (showfont=='Neuropol'){ control+="selected "} control+="value='Neuropol' > Neuropol</option>";
			control+="<option "; if (showfont=='Neuropol Medium'){ control+="selected "} control+="value='Neuropol Medium' > Neuropol Medium</option>";
			control+="<option "; if (showfont=='Never Say Die'){ control+="selected "} control+="value='Never Say Die' > Never Say Die</option>";
			control+="<option "; if (showfont=='Ogilvie'){ control+="selected "} control+="value='Ogilvie' > Ogilvie</option>";
			control+="<option "; if (showfont=='Plain O Matic'){ control+="selected "} control+="value='Plain O Matic' > Plain O Matic</option>";
			control+="<option "; if (showfont=='Plastique'){ control+="selected "} control+="value='Plastique' > Plastique</option>";
			control+="<option "; if (showfont=='Plump'){ control+="selected "} control+="value='Plump' > Plump</option>";
			control+="<option "; if (showfont=='Puma'){ control+="selected "} control+="value='Puma' > Puma</option>";
			control+="<option "; if (showfont=='Quill'){ control+="selected "} control+="value='Quill' > Quill</option>";
			control+="<option "; if (showfont=='Reska Graf'){ control+="selected "} control+="value='Reska Graf' > Reska Graf</option>";
			control+="<option "; if (showfont=='Serpentine Bold'){ control+="selected "} control+="value='Serpentine Bold' > Serpentine Bold</option>";
			control+="<option "; if (showfont=='Shopping List'){ control+="selected "} control+="value='Shopping List' > Shopping List</option>";
			control+="<option "; if (showfont=='Slammer Tag'){ control+="selected "} control+="value='Slammer Tag' > Slammer Tag</option>";
			control+="<option "; if (showfont=='Sofachrome Italic'){ control+="selected "} control+="value='Sofachrome Italic' > Sofachrome Italic</option>";
			control+="<option "; if (showfont=='Solo'){ control+="selected "} control+="value='Solo' > Solo</option>";
			control+="<option "; if (showfont=='Space Toaster'){ control+="selected "} control+="value='Space Toaster' > Space Toaster</option>";
			control+="<option "; if (showfont=='Stencil'){ control+="selected "} control+="value='Stencil' > Stencil</option>";
			control+="<option "; if (showfont=='Styrofoam Feelings'){ control+="selected "} control+="value='Styrofoam Feelings' > Styrofoam Feelings</option>";
			control+="<option "; if (showfont=='Super 911'){ control+="selected "} control+="value='Super 911' > Super 911</option>";
			control+="<option "; if (showfont=='Tags Extreme'){ control+="selected "} control+="value='Tags Extreme' > Tags Extreme</option>";
			control+="<option "; if (showfont=='Tech'){ control+="selected "} control+="value='Tech' > Tech</option>";
			control+="<option "; if (showfont=='The Battle'){ control+="selected "} control+="value='The Battle' > The Battle</option>";
			control+="<option "; if (showfont=='The Guru'){ control+="selected "} control+="value='The Guru' > The Guru</option>";
			control+="<option "; if (showfont=='Thug'){ control+="selected "} control+="value='Thug' > Thug</option>";
			control+="<option "; if (showfont=='Verdana'){ control+="selected "} control+="value='Verdana' > Verdana</option>";
			control+="<option "; if (showfont=='Weltron Urban'){ control+="selected "} control+="value='Weltron Urban' > Weltron Urban</option>";
			control+='</select></div>';
			//glitter font Preview/
		   control+='<img  name="image_font" id="image_font" style="float:right;" src="font_image/'+urlencode(showfont)+'.gif">';
			

			//tekst grootte//
			control+='<div class="select-wrap"><label>Grootte</label><select name="size" id="size" style="border:solid 1px #DEEEFf;" onChange="keepgrootteglitter=document.getElementById(\'size\').value;"><option ';
			if (showgrootteglitter==16){ control+="selected "} control+='value="16" > XX-Klein </option>  <option '; if (showgrootteglitter==24){ control+="selected "} control+='value="24" > X-Klein </option> <option '; if (showgrootteglitter==32){ control+="selected "} control+='value="32" > Klein </option>  <option '; if (showgrootteglitter==40){ control+="selected "} control+='value="40" > Normaal </option>  <option '; if (showgrootteglitter==55){ control+="selected "} control+='value="55" > Groot </option>  <option '; if (showgrootteglitter==72){ control+="selected "} control+='value="72" > X-Groot </option>  <option '; if (showgrootteglitter==90){ control+="selected "} control+='value="90" >XX-Groot</option>  </select></div>';
			//tekst hoek//
			control+='<div class="select-wrap"><label>Texthoek</label><select name="angle" id="angle" style="border:solid 1px #DEEEFf;" onChange="keephoek=document.getElementById(\'angle\').value;">';
			for (var n = 0; n <= 360; n++) {
				control+='<option '; 
				if (showhoek==n){ control+='selected ';} 
				control+='value="'+n+'"> '+n+'</option>';
			}
			control+='</select></div>';			

			//glitter//
			control+='<div class="select-wrap"><label class="pattern-label">Glitter</label>';
			var onclick="iBox.showURL('glitters.php','Kies glitter','width=680;height=450;');";
			
			control+='<a href="javascript:void(0);" class="color pattern" rel="ibox"><img  name="color" id="color" src="'+showglitter+'" width="60" height="30" onClick="'+onclick+'"></a></div>';
			
			control+='<input type=hidden name=glitter id=glitter value="'+showglitter+'">';
			//schaduw//
			
			
			control+='<div class="select-wrap"><label>Schaduw</label><div class="radio-wrap"><div class="option-yes">';
			control+='<input type=radio name=RadioGroup1 value=1 '; if (showschaduw==1){ control+="checked "} control+=' onChange="keepschaduw=1;"><label for="yes">Ja</label></div>';
			
			control+='<div class="option-no"><input type=radio name=RadioGroup1 value=2 '; if (showschaduw==2){ control+="checked "} control+=' onChange="keepschaduw=2;"><label for="no">Nee</label></div>';
			control+='</div></div>';
			//rand//
			
			control+='<div class="select-wrap"><label>Rand</label>';
			control+='<div class="radio-wrap"><div class="option-yes"><input type=radio name=RadioGroup2 value=3 '; if (showrand==3){ control+="checked "} control+=' onChange="keeprand=3;"><label for="yes2">Ja</label></div>';
			
			control+='<div class="option-no"><input type=radio name=RadioGroup2 value=4 '; if (showrand==4){ control+="checked "} control+=' onChange="keeprand=4;"><label for="no2">Nee</label></div>';
			control+='</div></div>';
			//rand dikte//
			control+='<div class="select-wrap"><label>Rand dikte</label><select name="border" id="border" style="border:solid 1px #DEEEFf;" onChange="keepranddikte=document.getElementById(\'border\').value;">';
			for (var n = 0; n <= 20; n++) {
				control+='<option '; 
				if (showranddikte==n){ control+='selected ';} 
				control+='value="'+n+'"> '+n+'</option>';
			}
			control+='</select></div></div>';			
			//toepassen / uitvoeren//
			
			control+='<a href="javascript:void(0);" onclick="xmlhttpPost(';
			control+="'process.php?act=addglitter','addglitter');";
			control+='" class="n-batton">Preview</a></div>';
			
			control+='<div id="mov_glit"></div>';

			document.getElementById('control').innerHTML = control;
		
	}


	function urlencode(string){
	string = string.replace(/\r\n/g,"\n");
	var utftext = "";

	for (var n = 0; n < string.length; n++) {

		var c = string.charCodeAt(n);

		if (c < 128) {
			utftext += String.fromCharCode(c);
		}
		else if((c > 127) && (c < 2048)) {
			utftext += String.fromCharCode((c >> 6) | 192);
			utftext += String.fromCharCode((c & 63) | 128);
		}
		else {
			utftext += String.fromCharCode((c >> 12) | 224);
			utftext += String.fromCharCode(((c >> 6) & 63) | 128);
			utftext += String.fromCharCode((c & 63) | 128);
		}

	}
    return escape(utftext);
}

function image(img)
{
	document.forms['crop'].image_font.src = 'font_image/'+img+'.gif'
}


function setImage(p)
{
	
	document.forms['crop'].color.src = 'img/'+p;
	document.forms['crop'].glitter.value = 'img/'+p;
	keepglitter='img/'+p;
	iBox.hide();

}

function chekbr()
{
// get reference to form named 'ifrmTest' 

//document.getElementById("lines").contentDocument.getElementById('image_line').style;
var iframeEl = document.getElementById("lines");
	if ( iframeEl.contentDocument ) 
	{ // DOM
    	//var form = iframeEl.contentDocument.getElementById('ifrmTest');
		return (iframeEl.contentDocument);
	} 
	else if ( iframeEl.contentWindow ) 
	{ // IE win
    	//var form = iframeEl.contentWindow.document.getElementById('ifrmTest');
		return(self.lines.document)
	}
}


function grapics()
{
el_id=1;
}

function setBubbleImage(p)
{
	
	document.getElementById("bubble_image").src =p;
	document.getElementById("cur_bubble").value =p;
}

function setGlittereImage(im,w,h)
{
	document.getElementById("s_cur_gl").src=im;
	document.getElementById("cur_glitter").value =im;
	document.getElementById("image_width").value =w;
	document.getElementById("image_height").value =h;

}
function set_fun_name(name)
{
document.getElementById('fun_name').value=name;
}

function shou_Loading()
{
		/*	var scroll_x = 0, scroll_y = 0;
 			if (typeof( window.pageYOffset ) == 'number') { // Netscape
  			scroll_y = window.pageYOffset; scroll_x = window.pageXOffset;
 			}
			 else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { // DOM
  			scroll_y = document.body.scrollTop; scroll_x = document.body.scrollLeft;
 			}
			 else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) { // 				IE6
  		scroll_y = document.documentElement.scrollTop; scroll_x = document.documentElement.scrollLeft;
 		}*/
			
			
			new Effect.Opacity("ImageProcess", {duration: 1, transition: Effect.Transitions.linear, from: 0, to: 0.80 });
			document.getElementById('ImageProcess').style.display='block';
}

function hide_Loading()
{
	new Effect.Opacity("ImageProcess", {duration: 1, transition: Effect.Transitions.linear, from: 0.80, to: 0 });
	document.getElementById('ImageProcess').style.display='none';
}


function cancel_Loading() 
{
			conf = confirm("Weet je zeker dat je wilt afbreken?");
			if (conf == true)
			{
				hide_Loading();
			}
}

function checkform(form)
{
   var mes='';
	var re = new RegExp("^[^@]+@(\[?)([A-Za-z0-9\_\-]+\\.)+[A-Za-z0-9\_\-]+(\]?)$");
	if (!re.test(document.getElementById('js_te_email').value))
	{
		alert('Ongeldig emailadres naar');
		return false;
	}
	else if (!re.test(document.getElementById('js_fe_email').value))
	{
		alert('Ongeldig emailadres van');
		return false;
	}
	else if (document.getElementById('js_ta_subject').value=='')
	{
		alert('Geen Onderwerp');
		return false;
	}
	else if (document.getElementById('js_ta_text').value=='')
	{
		alert('Geen tekst');
		return false;
	}
	else
	{
	document.getElementById('att_im').value=document.getElementById('imageFileName').value;
	return true;	
	}
	
}

function str_replace(search, replace, subject) {
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
 
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
 
    return sa ? s : s[0];
}

function filesize (url) {
 
    var req = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
    if (!req) throw new Error('XMLHttpRequest not supported');
    
    req.open ('HEAD', url, false);
    req.send (null);
    
        return req.getResponseHeader('Content-Length'); 
}
function submit_f(form)
{
form.submit();	
}

function check_input_max_upload_slots(id)
{
if(document.getElementById(id).value.match(/[^0-9]/)!=null)
{
document.getElementById(id).value=100;	
alert('Insert only numbers 0-9');
return false;
}
return true;
}

function strtok (str, tokens) {
 
    if (tokens === undefined) {
        tokens = str;
        str = strtok.leftOver;
    }
    if (str.length === 0) {
        return false;
    }
    if (tokens.indexOf(str[0]) !== -1) {
        return strtok(str.substr(1), tokens);
    }
    for (var i=0; i < str.length; i++) {
        if (tokens.indexOf(str[i]) !== -1) {
            break;
        }
    }
    strtok.leftOver = str.substr(i+1);
    return str.substring(0, i);
}

function basename(path, suffix) {
 
    var b = path.replace(/^.*[\/\\]/g, '');
    
    if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
        b = b.substr(0, b.length-suffix.length);
    }
    
    return b;
}

function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}


function changeClass(id)
{
document.getElementById(activeclass).className="";
document.getElementById(id).className="active";
activeclass=id;
}

function gliterize_undo()
{
	gliterize_count=gliterize_count-1;
	

	if(gliterize_images[gliterize_count])
	{
		chekbr().getElementById('image_line').src=gliterize_images[gliterize_count];

	}
	else
	{
		gliterize_count=gliterize_count+1;

	}
	


}
function gliterize_redo()
{
	gliterize_count=gliterize_count+1;
	

	
	if(gliterize_images[gliterize_count])
	{
	chekbr().getElementById('image_line').src=gliterize_images[gliterize_count];
	}
	else
	{
	gliterize_count=gliterize_count-1;;
	}
}

function setImage_gliterize(p)
{
	
	document.getElementById('gl_for_fuzz').src = 'img/'+p;
	document.getElementById('gl_for_fuzz_value').value = 'img/'+p;
	iBox.hide();

}

function app_fill_gliter()
{
shou_Loading();
	
var control='<div class="sol_font">De foto is gewijzigd!<br/><br/></div>';
control+='<div class="sol_font_smal">De laatste wijziging in de foto is doorgevoerd, als je niet tevreden bent met het resultaat gebruik dan: <a href="javascript:createUndo();" class="n-batton">Undo</a>.</div>';
document.getElementById('undo').value=document.getElementById('save_img').value;
document.getElementById('control').innerHTML = control;

var fiil_im_shou=chekbr().getElementById('image_line').src;

fiil_im_shou='temp/'+basename(fiil_im_shou);

document.getElementById("cropWrap").innerHTML = '<img src="'+fiil_im_shou+'?s='+filesize(fiil_im_shou)+'" alt="Editable picture" id="cropImage" />';
document.getElementById('save_img').value=fiil_im_shou+'?s='+filesize(fiil_im_shou);

hide_Loading();

}