
function createRequestObject(){
	if (navigator.appName == 'Microsoft Internet Explorer') {
		return new ActiveXObject('Microsoft.XMLHTTP');
	}	else {
		return new XMLHttpRequest();
	}
}

function default_ajax(obj, source){
 var http = createRequestObject();
 http.open('get', source);

 http.onreadystatechange = function(){
 	if (http.readyState == 4) {
 		document.getElementById(obj).innerHTML = http.responseText;
 	}
 }
	http.send(null);
}

function ajax(obj, source){
	var http, target;

	target = document.getElementById(obj);
	if (!target)
		return;

	http = createRequestObject();
	http.open('get', source);

	http.onreadystatechange = function() {
		if (http.readyState == 4) {
			target.parentNode.innerHTML = http.responseText;
		}
	}

	http.send(null);
}



function resizeWindow(){
 nWidth  = document.images[0].width;
 nHeight = document.images[0].Height;

 if (window.innerWidth) {
  window.innerWidth = nWidth;
  window.innerHeight = nHeight;
 }else if(document.all){
  window.resizeTo(nWidth, nHeight);
  nWidth  -= (document.body.clientWidth - nWidth);
  nHeight -= (document.body.clientHeight - nHeight);
  window.resizeTo(nWidth, nHeight);
 }
}

function toggleDiv(id, selected, select){
 var divDiv = document.getElementById(id);
 if(selected == select){
  divDiv.style.display = "block";
 }else{
  divDiv.style.display = "none";  
 }
}

function ableElement(id, selected, select, bln_not){
 if(bln_not ? selected != select : selected == select){
  document.getElementById(id).disabled              = false;
  document.getElementById(id).style.backgroundColor = "FFFFFF";
 }else{
  document.getElementById(id).value                 = "";
  document.getElementById(id).disabled              = true;
  document.getElementById(id).style.backgroundColor = "D4D0C8";
 }
}

function switchPhoto(obj){
 document.getElementById('photo').src = obj.href.replace('extra_large', 'large');
 document.getElementById('photo').alt = obj.firstChild.getAttribute('alt');
 document.getElementById('zoom').href = obj.href;
}

function sortList(row){
	if(document.getElementById('frm_list').row.value == row){
		document.getElementById('frm_list').sort.value = (document.getElementById('frm_list').sort.value == 'ASC' ? 'DESC' : 'ASC');
	}else{
	 document.getElementById('frm_list').sort.value = 'ASC';
	}
	document.getElementById('frm_list').row.value = row;
	document.getElementById('frm_list').submit();
}

/**
 *	Post the search form with the current page variable
 */ 
function postSearchPagination(page){
	$('#search_begin_at').val(page);
	$('#verzenden').trigger('click');
}