function addpicfield() {
	var count = $('#counter').val();
	var count=count*1;
	$('#picfields').append("<tr bgcolor='#ffe8c1' id='row_"+count+"'><td colspan='4'><input type='file' name='fotos[]' class='fotoinput_with_del'><span class='verplicht'><a href=\"javascript:delItem('row_"+count+"')\">Verwijder</a></span></td></tr>");
	$('#counter').val(count+1);
}

function delItem(item) {
	$('#'+item).remove();
}

function enableOrder(page_id) {
	$('#ordering_'+page_id).toggle();
	
	var disabled = $('#ordering_'+page_id).attr('disabled');
	if(disabled) {
		$('#ordering_'+page_id).removeAttr('disabled');
	} else {
		$('#ordering_'+page_id).attr('disabled','disabled')
	}
}

function deleteUser(userid) {
	if(confirm("Weet u zeker dat u deze gebruiker wilt verwijderen?")) {
		document.location.href='index.php?id=users&del='+userid;
	}
}

function editStatus() {
	var old_status_id = $('#status').val();
	var status = $('#status');
	var old_status = $('#status option:selected').text();
	var new_status = prompt("Nieuwe naam voor de status \""+old_status+"\"");
	if(new_status!=null) {
		$('#hidden_new_status').val(new_status);
		$('#status_action').val("edit");
		$('#editdel_status').submit();
	}
}

function delStatus() {
	var old_status_id = $('#status').val();
	var old_status = $('#status option:selected').text();
	if(confirm("Weet u zeker dat u de status \""+old_status+"\" wilt verwijderen?")) {
		$('#status_action').val("del");
		$('#editdel_status').submit();
	}
}

function editLigging() {
	var old_ligging_id = $('#ligging').val();
	var ligging = $('#ligging');
	var old_ligging = $('#ligging option:selected').text();
	var new_ligging = prompt("Nieuwe naam voor de ligging \""+old_ligging+"\"");
	if(new_ligging!=null) {
		$('#hidden_new_ligging').val(new_ligging);
		$('#ligging_action').val("edit");
		$('#editdel_ligging').submit();
	}
}

function delLigging() {
	var old_ligging_id = $('#ligging').val();
	var old_ligging = $('#ligging option:selected').text();
	if(confirm("Weet u zeker dat u de ligging \""+old_ligging+"\" wilt verwijderen?")) {
		$('#ligging_action').val("del");
		$('#editdel_ligging').submit();
	}
}

function editWoningsoort() {
	var old_woningsoort_id = $('#woningsoort').val();
	var old_woningsoort = $('#woningsoort option:selected').text();
	var new_woningsoort = prompt("Nieuwe naam voor de woningsoort \""+old_woningsoort+"\"");
	if(new_woningsoort!=null) {
		$('#hidden_new_woningsoort').val(new_woningsoort);
		$('#woningsoort_action').val("edit");
		$('#editdel_woningsoort').submit();
	}
}

function delWoningsoort() {
	var old_woningsoort_id = $('#woningsoort').val();
	var old_woningsoort = $('#woningsoort option:selected').text();
	if(confirm("Weet u zeker dat u de woningsoort \""+old_woningsoort+"\" wilt verwijderen?")) {
		$('#woningsoort_action').val("del");
		$('#editdel_woningsoort').submit();
	}
}

function editWoningtype() {
	var old_type_id = $('#type').val();
	var old_type = $('#type option:selected').text();
	var new_type = prompt("Nieuwe naam voor de type \""+old_type+"\"");
	if(new_type!=null) {
		$('#hidden_new_type').val(new_type);
		$('#type_action').val("edit");
		$('#editdel_type').submit();
	}
}

function delWoningtype() {
	var old_type_id = $('#type').val();
	var old_type = $('#type option:selected').text();
	if(confirm("Weet u zeker dat u de type \""+old_type+"\" wilt verwijderen?")) {
		$('#type_action').val("del");
		$('#editdel_type').submit();
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var Timer;

function ScrollLeft()
{
  Timer = setInterval("document.getElementById('panorama').scrollLeft -= 5;", 15);
}

function checkEdgeLeft() {
	if(document.getElementById('panorama').scrollLeft<5) { 
		//document.getElementById('slideshow_left_holder_middle').innerHTML = "<img src=\"images/index_left.jpg\" />"; 
		document.getElementById('slideshow_left_holder_middle').innerHTML = "<img src=\"images/index_10.jpg\" name=\"slideshow_left_holder_arrow\" width=\"28\" height=\"24\" border=\"0\" alt=\"\" onMouseOut=\"MM_swapImgRestore(); clearInterval(Timer);\" onMouseOver=\"MM_swapImage('slideshow_left_holder_arrow','','images/1.jpg',1); ScrollLeft();\">";
	} else {
		document.getElementById('slideshow_left_holder_middle').innerHTML = "<img src=\"images/index_10.jpg\" name=\"slideshow_left_holder_arrow\" width=\"28\" height=\"24\" border=\"0\" alt=\"\" onMouseOut=\"MM_swapImgRestore(); clearInterval(Timer);\" onMouseOver=\"MM_swapImage('slideshow_left_holder_arrow','','images/1.jpg',1); ScrollLeft();\">";
	}
}

function ScrollRight()
{
    Timer = setInterval("document.getElementById('panorama').scrollLeft += 5;", 15);
}

function checkEdgeRight() {
	var width = document.getElementById('slideshow_container').offsetWidth;
	if(document.getElementById('panorama').scrollLeft=width) { 
		//document.getElementById('slideshow_right_holder_middle').innerHTML = "<img src=\"images/index_right.jpg\" />"; 
		document.getElementById('slideshow_right_holder_middle').innerHTML = "<img src=\"images/index_11.jpg\" name=\"slideshow_right_holder_arrow\" width=\"28\" height=\"24\" border=\"0\" alt=\"\" onMouseOut=\"MM_swapImgRestore(); clearInterval(Timer);\" onMouseOver=\"MM_swapImage('slideshow_right_holder_arrow','','images/2.jpg',1); ScrollRight();\">";
	} else {
		document.getElementById('slideshow_right_holder_middle').innerHTML = "<img src=\"images/index_11.jpg\" name=\"slideshow_right_holder_arrow\" width=\"28\" height=\"24\" border=\"0\" alt=\"\" onMouseOut=\"MM_swapImgRestore(); clearInterval(Timer);\" onMouseOver=\"MM_swapImage('slideshow_right_holder_arrow','','images/2.jpg',1); ScrollRight();\">";
	}
}

function popup(theURL,winName,features) 
	{ 
		window.open(theURL,winName,features);
	}

function closescreen()
	{
		opener.location.reload(true);
		self.close();
	}

var ival, imgname, total, steps, maxx, maxy, currentx, currenty, dx, dy;
function resizeImg(imgname, dx, dy, maxx, maxy) {
objref = eval("document.getElementById('"+imgname+"')");
currentx = objref.width;
currenty = objref.height;
if ((currentx<maxx-dx) && (currenty<maxy-dy)) {
objref.height = currenty + dy;
objref.width = currentx + dx;
}
else {
clearInterval(ival);
objref.height = maxy;
objref.width = maxx;
   }
}
function zoomImg(imgname, total, steps, maxx, maxy)	{
// convert the total from seconds to miliseconds
total = total * 1000;
objref = eval("document.getElementById('"+imgname+"')");
currentx = objref.width;
currenty = objref.height;
// work out how much we need to increase the image by each step
// devide image sizes by number of steps to get the amount we need to change each step
stepx = maxx / steps;
stepy = maxy / steps;
// devide the total time (in ms) by the number of steps to get the interval time
inttime = total / steps;
// set the interval to increase the size of the image by the required pixels 
functionRef = "resizeImg('"+imgname+"', "+stepx+", "+stepy+", "+maxx+", "+maxy+")";
ival = setInterval(functionRef, inttime);
}


var ival, imgname, total, steps, minx, miny, currentx, currenty, dx, dy;
		function resizeImgOut(imgname, dx, dy, minx, miny) {
			objref = eval("document.getElementById('"+imgname+"')");
			currentx = objref.width;
			currenty = objref.height;
				if ((currentx>minx) && (currenty>miny)) {
					objref.height = currenty - dy;
					objref.width = currentx - dx;
				}
				else {
					clearInterval(ival);
					objref.height = miny;
					objref.width = minx;
					}
}

function zoomImgOut(imgname, total, steps, minx, miny)	{
		// convert the total from seconds to miliseconds
		total = total * 1000;
		objref = eval("document.getElementById('"+imgname+"')");
		currentx = objref.width;
		currenty = objref.height;
		// work out how much we need to increase the image by each step
		// devide image sizes by number of steps to get the amount we need to change each step
		stepx = 500 / steps;
		stepy = 400 / steps;
		// devide the total time (in ms) by the number of steps to get the interval time
		inttime = total / steps;
		// set the interval to increase the size of the image by the required pixels 
		functionRef = "resizeImgOut('"+imgname+"', "+stepx+", "+stepy+", "+minx+", "+miny+")";
		ival = setInterval(functionRef, inttime);
}



function zoom(imgname) {
	       var target = document.getElementById(imgname);
	       var width = target.width;
		   if (width < '250') { zoomImg(imgname,'1','100','500','400'); }
	       if (width >= '250') { zoomImgOut(imgname,'1','100','125','100'); }
}
function ShowHide(id)
{
    if(document.getElementById(id).style.display == 'none')
    {
        document.getElementById(id).style.display = '';
    }
    else
    {
        document.getElementById(id).style.display = 'none';
    }
}
function Schakel()
{
	if(document.foutgevonden.fout.value == 'kies')
		{ Hide('verstuur'); Hide('andersveld')  }
	if(document.foutgevonden.fout.value == 'anders')
		{ Show('andersveld'); Show('verstuur') }
		else {
		Show('verstuur')
		}
}

function Show(id)
{
    if(document.getElementById(id).style.display == 'none')
    {
        document.getElementById(id).style.display = '';
    }
}

function Hide(id)
{
    if(document.getElementById(id).style.display == '')
    {
        document.getElementById(id).style.display = 'none';
    }
}