imgout=new Image(9,9);
imgin=new Image(9,9);

formChanged=0;

/////////////////BEGIN USER EDITABLE///////////////////////////////
	imgout.src="/v2/img/rest/up.gif";
	imgin.src="/v2/img/rest/down.gif";
///////////////END USER EDITABLE///////////////////////////////////

//this switches expand collapse icons on toggle(object, true)
function filter(imagename,objectsrc){
	if (document.images){
		document.images[imagename].src=eval(objectsrc+".src");
	}
}

//show or hide element
function toggle(id, img, blinds) {
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
            if(blinds)
                Effect.BlindDown(id);
            else
    			document.getElementById(id).style.display = '';
			if (img)
				filter(("img_"+id),'imgin');
		} else {
            if(blinds)
                Effect.BlindUp(id);
            else
    			document.getElementById(id).style.display = 'none';
			if (img)
				filter(("img_"+id),'imgout');
		}
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
                if(blinds)
    				Effect.BlindDown(id);
                else
    				document.id.display = '';
			if (img)
					filter(("img_"+id),'imgin');
			} else {
                if(blinds)
    				Effect.BlindUp(id);
                else
    				document.id.display = 'none';
			if (img)
					filter(("img_"+id),'imgout');
			}
		} else {
			if (document.all.id.style.visibility == "none"){
                if(blinds)
    				Effect.BlindDown(id);
                else
    				document.all.id.style.display = '';
			if (img)
					filter(("img_"+id),'imgin');
			} else {
                if(blinds)
    				Effect.BlindUp(id);
                else
    				document.all.id.style.display = 'none';
			if (img)
					filter(("img_"+id),'imgout');
			}
		}
	}
}

function toggleBlinds(id, img) {
  if(document.getElementById(id).style.display == "none"){
    Effect.BlindDown(document.getElementById(id));
    if(img)
      filter(("img_"+id),'imgin');
  } else {
    Effect.BlindUp(document.getElementById(id));
    if(img)
      filter(("img_"+id),'imgout');
  }
}

Number.prototype.formatMoney = function(c, d, t){
	var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
	return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};

function formatCurrency(amount)
{
        amount = amount.replace(".","");
        amount = amount.replace(",",".");
        amount = parseFloat(amount);
	return amount.formatMoney(2, ',', '.');
}


//checks if form has changed before saving
function chkSave() {
  if (formChanged == 1) {
    var agree=confirm('Doorgaan zonder wijzigingen te bewaren?');
    if(agree) {
      return true;
    } else {
      return false;
    }
  }
}
