var divPopupOpen = 0;

function site_search() {

	if(document.getElementById('search_query')) {
		if(document.getElementById('search_query').value.length > 0) {
			window.location.href = '/search/'+document.getElementById('search_query').value+'/';
		}
	}

}

function site_search_enter(e) {

	var key=e.keyCode || e.which;

	if (key==13) {

		site_search();

	}

}

function imageSW(elm, img) {
	if (elm) {
		if (img) {
			elm.src = img;
		}
	}
}


function search_site_dropdown(id) {
	var elm = document.getElementById(id);

	if(elm.selectedIndex != 0) {
		window.location.href = '/search/'+elm.options[elm.selectedIndex].value+'/';
	}
}

function selectRedirect(elm) {
	if(elm) {
		var href = elm.options[elm.selectedIndex].value;
		if(href.length > 0) {
			window.location.href = href;
		}
	}
}


function showDIV(ID) {
	if (parseInt(navigator.appVersion) > 3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
		}

		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
	}

	divW = parseInt(document.getElementById('div_popup_' + ID).style.width);
	divH = parseInt(document.getElementById('div_popup_' + ID).style.minHeight);

	document.getElementById('div_popup_'+ID).style.display = 'block';
	document.getElementById('div_popup_'+ID).style.visibility = 'visible';
	document.getElementById('div_popup_'+ID).style.height = divH+'px';
	document.getElementById('div_popup_'+ID).style.marginTop = (winH-divH)/2 + 'px';
	document.getElementById('div_popup_'+ID).style.marginLeft = (winW-divW)/2 + 'px';

	divPopupOpen = ID;

}

function testfunctie() {

  if(divPopupOpen > 0) {
    showDIV(divPopupOpen);
  }

}

function closeDIV(ID) {
  document.getElementById('div_popup_'+ID).style.display = 'none';
  document.getElementById('div_popup_'+ID).style.visibility = 'hidden';

  divPopupOpen = 0;
}


window.onresize = function() { testfunctie(); };