function preloader() {if(d.images){
	if(!d.loaderarray) { d.loaderarray=new Array(); }
	var i,j=d.loaderarray.length,a=preloader.arguments;
	for(i=1; i<a.length; i++) { if (a[i].indexOf("#")!=0) { d.loaderarray[j]=new Image;
	d.loaderarray[j++].src= a[0]+a[i]; } }
}}

function preload(intro) {
	preloader('nav/','nav_on.jpg','nav_off.jpg');
	preloader('img/','spacer.gif');
}

// example specific
function showsub(id,opacity,delay) {
//	alert('id: '+id+'\nopacity: '+opacity+ '\ndelay: '+delay);
	setTimeout("setOpacity('"+id+"',"+opacity+")",delay);
}

var group_remember = '';
function showOverlayItem(group,arr_dir) {
  document.getElementById('overlay_image').src = 'img/grijs.png';
  setOpacity('overlay_bg',75);
  setOpacity('overlay_content',100);
  setOpacity('overlay_nav',100);
// id="overlay_image" src="img/grijs.png"
  current_nr = showItem(group,arr_dir);
  group_remember = group;
  return current_nr;
}
function hideOverlayItem() {
  setOpacity('overlay_content',0);
  setOpacity('overlay_bg',0);
  setOpacity('overlay_nav',0);
  if (group_remember.length > 0 ) {
  setOpacity(group_remember+'_prev',0);
  setOpacity(group_remember+'_next',0);
    setOpacity(group_remember,0);
  }
  return 0;
}

function showItem(group,arr_dir) {
  the_array = eval(group+'_items');
  if (the_array.length == 0 ) { return 0 }
  setOpacity(group,100);
  setOpacity(group+'_prev',25);
  setOpacity(group+'_next',25);
  
  current_nr = eval(group+'_active')+arr_dir;
  if (current_nr > the_array.length-1) {
    current_nr = the_array.length-1;
  } else if (current_nr < 0 ) {
    current_nr = 0;
  }
  if (current_nr < the_array.length-1) { setOpacity(group+'_next',100); }
  if (current_nr > 0                 ) { setOpacity(group+'_prev',100); }

	document.getElementById(group).innerHTML = document.getElementById(group+'_item_'+the_array[current_nr]).innerHTML;

  if (group == 'content_sub') {
    the_array = eval(group+'_images');
//    alert(current_nr+"\n"+the_array);
    if (the_array && the_array.length > current_nr && the_array[current_nr].length > 0 ) {
      document.getElementById('overlay_image').src = the_array[current_nr];
    } else {
      document.getElementById('overlay_image').src = 'img/spacer.gif';
    }
//    alert(document.getElementById('overlay_image').src);
  }

  return current_nr;
}

function IE6HoverFix() {
  var allTags=document.getElementsByTagName("*");
  for (i=0; i<allTags.length; i++) {
    if (allTags[i].className.indexOf('nav') == 0 && allTags[i].tagName.toUpperCase() == 'UL' ) {
//    if (allTags[i].className=="nav" && allTags[i].tagName == 'UL' ) {
      var allListItems = allTags[i].getElementsByTagName('LI');
//alert(allTags[i].className+' '+allListItems.length+' '+allTags[i].tagName);
      for (var ii=0; ii<allListItems.length; ii++) {
//d.title = ii+' '+d.title;
      	allListItems[ii].onmouseover=function() {
      		this.className+=" navon";
      	}
      	allListItems[ii].onmouseout=function() {
      		this.className=this.className.replace(new RegExp(" navon\\b"), "");
      	}
      }
    }
  }
}
if ((parseFloat(navigator.appVersion.split("MSIE")[1])<8) || 1 ) {	//alert('crappie IE 6 or 7');
	if (typeof(window.onload) == 'undefined' ) {
		window.onload = function() {              IE6HoverFix();}
	} else {
		window.onload = function() {window.onload;IE6HoverFix();}
	}
}

function LeftRightMarginFix() {
  var allTags=document.getElementById('content').getElementsByTagName("*");
  for (i=0; i<allTags.length; i++) {
    if (allTags[i].tagName.toUpperCase() == 'IMG' && typeof(allTags[i].align) != 'undefined' ) {
			if (allTags[i].align.toLowerCase() == 'left' ) {
				allTags[i].style.marginRight = '5px';
			} else
			if (allTags[i].align.toLowerCase() == 'right' ) {
				allTags[i].style.marginLeft = '5px';
			}
		}
	}
}

prev_inner_height = 0;
function fix_height(stretch_div,substract,min_height,prev_inner_height) {
  if (d.getElementById) {
    if (d.getElementById(stretch_div)) {
      inner_height  = d.body.clientHeight;
      if (typeof(min_height) == 'undefined' ) { min_height = 1; }
      fixed_it = false;
      if (typeof(prev_inner_height) == 'undefined' || prev_inner_height != inner_height ) {
        fixed_it = true;
        // start with the minimum height (in case of smaller -> larger -> smaller)
        d.getElementById(stretch_div).style.height = min_height+'px';
        // start with the largest one..
        new_height = inner_height;
        if (d.body.parentNode.scrollHeight > new_height ) { new_height = d.body.parentNode.scrollHeight; }
        if (d.body.scrollHeight            > new_height ) { new_height = d.body.scrollHeight; }
        // substract the pixels you desired
        new_height -= substract;
        // set the minimum height or at least prevent a negative height
        if (new_height < min_height ) {
          new_height = min_height;
      	}
        // set the height of the stretch_div
        d.getElementById(stretch_div).style.height = (new_height)+'px';
      }
/*      document.title=
      +inner_height+' '
      +new_height+' '
      +fixed_it+' '
*/
     	setTimeout('fix_height(\''+stretch_div+'\','+substract+','+min_height+','+inner_height+');',250);
    } else {
      alert('Can\'t find the div to stretch ('+stretch_div+')');
    }
  }
}

