function resize() {
	
	/* viewable height */
	var de = parseInt(document.documentElement.scrollHeight);
	
	/* body height */
	if (navigator.appVersion.indexOf('MSIE 8.0') != -1) {
		var by = parseInt(document.documentElement.clientHeight); // IE8
	}
	else if (window.XMLHttpRequest) {
		var by = parseInt(document.body.scrollHeight); // IE7, IE8, Mozilla, Safari, Opera 9, other newer browsers
	} 
	else {
		var by = parseInt(document.documentElement.clientHeight); // IE6, older browsers
	}
	
	//alert(de + ':' + by);
	
	if (by==de) {
		document.getElementById('footer').style.position='absolute';
		document.getElementById('footer').style.visibility='visible';
	}
	else {
		document.getElementById('footer').style.position='relative';
		document.getElementById('footer').style.visibility='visible';
	}
	
}

/* mediaplayer load */
function MP_load(objId) {
	obj = document.getElementById(objId);
    obj.outerHTML = obj.outerHTML;
}

function popUp(src) {
		window.open(src,'popup','width=700, height=600, toolbar=0, status=0, scrollbars=yes');
	}
	
function popUpDoc(src) {
		if (src.length > 0) {
		window.open(src,'popup','');
		}
		return false;
	}	

/* ajax search */
var url;
var tm;
var http;

function search(input,url,roxenChars) {
  if (input.length > 1) {
	document.getElementById('search-frame').innerHTML = '<div style="text-align:center;line-height:80px;"><img src="/img/loading.gif" width="16" height="16" alt=""/></div>';
	document.getElementById('search-frame').style.visibility='visible';
    http = getHTTPObject();
    http.open("GET", url + escape(input)+'&'+roxenChars, true); 
    //http.open("GET", url + '?query=' + escape(input), true); 
    http.onreadystatechange = handleSearch; 
    http.send(null);
  } else {
    clearSearchDiv();
  }
}

function timedSearch(e,input,url) {
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  if(keycode == 13){
    clearSearchTimeout();
  } else {
    clearSearchTimeout();
    if (input.length > 1) {
	  tm = setTimeout(function() { search(input,url) }, 750);
    } else {
      clearSearchDiv();
    } 
  }
}

function handleSearch() {
  if (http.readyState == 4) {
    //alert(http.responseText);
    document.getElementById('search-frame').innerHTML = http.responseText;
    document.getElementById('search-frame').style.visibility='visible';
  }
}
function clearSearch() {
  tm = setTimeout('clearSearchDiv()', 500);
}
function clearSearchTimeout() {
  window.clearTimeout(tm);
}
function clearSearchDiv(input) {
  document.getElementById('search-frame').innerHTML = '';
  document.getElementById('search-frame').style.visibility='hidden';
}

function getHTTPObject() { 
  var xmlhttp; 
  /*@cc_on 
  @if (@_jscript_version >= 5) 
    try { 
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
    } catch (e) { 
      try { 
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
      } catch (E) { 
        xmlhttp = false; 
      } 
    } 
  @else 
  xmlhttp = false; 
  @end @*/  
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { 
    try { 
      xmlhttp = new XMLHttpRequest(); 
    } catch (e) { 
      xmlhttp = false; 
    } 
  } 
  return xmlhttp; 
} 
function setSearchWord(word) {
	var str = word.replace(/[^a-zA-Z0-9_\(\)\-\/ ]/g,'');	
	document.getElementById('query').value=str;
}

/* country switch */
function switchCountry(code) {
	img = document.getElementById('country');
	eval('img.src='+code+'.src');
}

function switchOffCountry() {
	img = document.getElementById('country');
	img.src='landenkaart.gif';
}

function switchSite(requestedSite) {
	parent.window.location.href='http://www.walraven.com/redirect/?red='+requestedSite;
}


function setCookie( name, value, expires, path, domain, secure ){
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
		( ( path ) ? ";path=" + path : "" ) +
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}


/* code om unique ID te genereren voor Google Analytics als toevoeging voor &var.googleUID; in catalogus.xsl */
function randomString() {
	var sChrs = '0123456789abcdefghijklmonpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var iLen = 10;
	var sRnd = '';
	for (var i=0;i<iLen;i++){
		var randomPoz = Math.floor(Math.random() * sChrs.length);
		sRnd += sChrs.substring(randomPoz,randomPoz+1);
	}
	return(sRnd);
}


