

function toggle_visibility(id) {
   var e = document.getElementById(id);
   if(e.style.display == 'block')
      e.style.display = 'none';
   else
      e.style.display = 'block';
}

function hide(id) {
   var e = document.getElementById(id);
   e.style.display = 'none';
}
function makevisible(id) {
   var e = document.getElementById(id);
   e.style.display = 'block';
}

function check_checkbox(box) {
  box.checked = true;
}

function uncheck_checkbox(box) {
  box.checked = false;
}

function check_if_amount(id_checkbox, id_amount) {
  var box = document.getElementById(id_checkbox);
  box = box.getElementsByTagName('input')[0];
  // alert(box.checked)
  var inp = document.getElementById(id_amount);
  if (inp.value.length > 0) {
    if (! box.checked) {
      check_checkbox(box);
    }
  } else {
    uncheck_checkbox(box);
  }
  // if (inp.value.length > 0) {
  //   alert('Vink ook aan dat u een donatie wilt doen.');
  // }
}

function addEvent( obj, type, fn ) {
  if ( obj.attachEvent ) {
    obj['e'+type+fn] = fn;
    obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
    obj.attachEvent( 'on'+type, obj[type+fn] );
  } else
    obj.addEventListener( type, fn, false );
}

function removeEvent( obj, type, fn ) {
  if ( obj.detachEvent ) {
    obj.detachEvent( 'on'+type, obj[type+fn] );
    obj[type+fn] = null;
  } else
    obj.removeEventListener( type, fn, false );
}

function insertPhotoBackLink() {
	
	// config
	photoPagePath = "/fotos/"

    // this function is available in IE 9+, Firefox, Safari, Opera, Chrome
	if (document.getElementsByClassName) {
		
		try {
			// only insert the back link at the photo overview page
			if(window.location.pathname == photoPagePath) {
			// console.log("Inserting photo back link at " + window.location.href)				
			theDiv = document.getElementsByClassName("slideshowlink")[0]
			a = document.createElement('a')
			a.href = "/fotos/"
			a.innerHTML = "&larr; Terug naar foto's"
			theDiv.insertBefore(document.createTextNode(' / '), theDiv.firstChild)
			theDiv.insertBefore(a, theDiv.firstChild)
		}
			
		} catch (err) { 
			
			}
		
	}
	
}

