if(document.images) {
	space = new Image();

	hoofdmenu1 = new Image();
	hoofdmenu2 = new Image();
	hoofdmenu3 = new Image();
	hoofdmenu4 = new Image();
	hoofdmenu5 = new Image();
	hoofdmenu6 = new Image();
}

// define the image sources

if(document.images) {
	space.src = "images/space.gif";
	hoofdmenu1.src = "images/hoofdmenu1.jpg";
	hoofdmenu2.src = "images/hoofdmenu2.jpg";
	hoofdmenu3.src = "images/hoofdmenu3.jpg";
	hoofdmenu4.src = "images/hoofdmenu4.jpg";
	hoofdmenu5.src = "images/hoofdmenu5.jpg";
	hoofdmenu6.src = "images/hoofdmenu6.jpg";
}

function swapit(imgLocation, imgName) {
	if(document.images) {
		document.images[imgLocation].src = eval(imgName + ".src");
	}
}

function goparent(pagina){
	parent.frames['mainframe'].location.href=pagina;
}

function go(pagina){
	frames['mainframe'].location.href=pagina;
}

function rego(pagina){
	location.href=pagina;
}


function edit(pagina){
	document.formnaam.naam.value=pagina;
	document.formnaam.submit();
}

function scrollOn(){
	parent.frames[0].scrolling="yes";
	alert(parent.frames[0].name);
}

function setPageNr(page){
	parent.document.getElementById('pagenr').innerHTML='('+page+')';
}


function menuReset(){
	parent.document.getElementById('menuref2').style.color='#ffffff';
	parent.document.getElementById('menuref3').style.color='#ffffff';
	parent.document.getElementById('menuref4').style.color='#ffffff';
	parent.document.getElementById('menuref5').style.color='#ffffff';
	parent.document.getElementById('menuref6').style.color='#ffffff';
	parent.document.getElementById('menuref7').style.color='#ffffff';
}

function homeMenuSet(){
	menuSet('#ff6600','#ffffff')
	parent.document.getElementById('menucell2').style.border='thin solid #ffffff';
	parent.document.getElementById('menucell3').style.border='thin solid #ffffff';
	parent.document.getElementById('menucell4').style.border='thin solid #ffffff';
	parent.document.getElementById('menucell5').style.border='thin solid #ffffff';
	parent.document.getElementById('menucell6').style.border='thin solid #ffffff';
	parent.document.getElementById('menucell7').style.border='thin solid #ffffff';
}

function menuSet(bgcolor, txtcolor){
	parent.document.getElementById('menuref2').style.color=txtcolor;
	parent.document.getElementById('menuref3').style.color=txtcolor;
	parent.document.getElementById('menuref4').style.color=txtcolor;
	parent.document.getElementById('menuref5').style.color=txtcolor;
	parent.document.getElementById('menuref6').style.color=txtcolor;
	parent.document.getElementById('menuref7').style.color=txtcolor;
	parent.document.getElementById('menucell8').style.color='#ffffff';

	parent.document.getElementById('menucell2').style.backgroundColor=bgcolor;
	parent.document.getElementById('menucell3').style.backgroundColor=bgcolor;
	parent.document.getElementById('menucell4').style.backgroundColor=bgcolor;
	parent.document.getElementById('menucell5').style.backgroundColor=bgcolor;
	parent.document.getElementById('menucell6').style.backgroundColor=bgcolor;
	parent.document.getElementById('menucell7').style.backgroundColor=bgcolor;
}


function changeParentStyleById(id, bgcolor, txtcolor){
	if (parent.document.getElementById){
	   var nodeObj = parent.document.getElementById(id);
	   nodeObj.style.backgroundColor = bgcolor;
	   nodeObj.style.color = txtcolor;
   }
}

function changeStyleById(id, bgcolor, txtcolor){
	if (document.getElementById){
	   var nodeObj = document.getElementById(id);
	   nodeObj.style.backgroundColor = bgcolor;
	   nodeObj.style.color = txtcolor;
   }
}

function scaleWindow(){
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);
	w = screen.width;
	h = screen.height;
//	obj=document.getElementById('menucolumn');
//	obj.style.width=w/10;
	changecss('.menucolumn','width',w/10);
	changecss('.menucel','height',100*h/1030);
	changecss('.topmenucel','height',30*h/1030);
	changecss('.botmenucel','height',5*h/1030);
}

// Scaling functions for home.php
function scaleHome(){
	w = screen.width;
	h = screen.height;
	newImgH=250*h/1030;
	changecss('.homeImg','height',newImgH);
	changecss('.homeImg','width',newImgH);

	changecss('.headerbig','fontSize',50*h/1030);
	changecss('.headersmall','fontSize',28*h/1030);
	changecss('.ondermenu','fontSize',12*h/1030);
}

// Scaling functions for produkt.php
function scaleProdukt(){
	w = screen.width;
	h = screen.height;
	maxw=370*w/1280;
	maxh=270*h/1100;

	obj=getObject("image1");
	if(obj!=null) resizeObject(obj, maxw, maxh);
	obj=getObject("image2");
	if(obj!=null) resizeObject(obj, maxw, maxh);
	obj=getObject("image3");
	if(obj!=null) resizeObject(obj, maxw, maxh);
	obj=getObject("image4");
	if(obj!=null) resizeObject(obj, maxw, maxh);

  	obj=getObject("tekst1");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=18*h/1030+'px';
	}
  	obj=getObject("tekst2");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=18*h/1030+'px';
	}
  	obj=getObject("tekst3");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=18*h/1030+'px';
	}
  	obj=getObject("tekst4");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=18*h/1030+'px';
	}

	changecss('.blokregel','height',300*h/1100);
	changecss('.bloktitel','fontSize',14*h/1030);

	changecss('.headerbig','fontSize',50*h/1200);
	changecss('.headersmall','fontSize',28*h/1200);
	changecss('.ondermenu','fontSize',12*h/1100);

	changecss('.inlink','fontSize',14*h/1100);

}

// Scaling functions for nieuwsbrief.php
function scaleNieuws(){
	w = screen.width;
	h = screen.height;
	maxw=370*w/1280;
	maxh=270*h/1100;


	obj=getObject("image1");
	if(obj!=null) resizeObject(obj, maxw, maxh);
	obj=getObject("image2");
	if(obj!=null) resizeObject(obj, maxw, maxh);
	obj=getObject("image3");
	if(obj!=null) resizeObject(obj, maxw, maxh);
	obj=getObject("image4");
	if(obj!=null) resizeObject(obj, maxw, maxh);
	obj=getObject("image5");
	if(obj!=null) resizeObject(obj, maxw, maxh);
	obj=getObject("image6");
	if(obj!=null) resizeObject(obj, maxw, maxh);

  	obj=getObject("tekst1");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=14*h/1030+'px';
	}
  	obj=getObject("tekst2");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=14*h/1030+'px';
	}
  	obj=getObject("tekst3");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=14*h/1030+'px';
	}
  	obj=getObject("tekst4");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=14*h/1030+'px';
	}

  	obj=getObject("tekst5");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=14*h/1030+'px';
	}
  	obj=getObject("tekst6");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=14*h/1030+'px';
	}
  	obj=getObject("tekst7");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=14*h/1030+'px';
	}
  	obj=getObject("tekst8");
	if(obj!=null){
		obj.style.fontSize=12*h/1030;
		obj.style.lineHeight=14*h/1030+'px';
	}

	changecss('.headerbig','fontSize',50*h/1200);
	changecss('.headersmall','fontSize',28*h/1200);

	changecss('.inlink','fontSize',14*h/1100);
	changecss('a','fontSize',14*h/1100);

	changecss('.newstext','fontSize',12*h/1030);
	changecss('.newskolom','width',40*w/1280);

}

function resizeObject(obj, maxw, maxh){
	if(obj!=null){
		relw=obj.width/maxw;
		relh=obj.height/maxh;
//		alert(relw+' '+relh);
		if(relw>relh){
			if(relw>1) obj.style.width=maxw;
		}else{
			if(relh>1) obj.style.height=maxh;
		}
	}
}

// Get object from ID
function getObject( obj ) {
  // Most browsers
  if ( document.getElementById ) {
    obj = document.getElementById( obj );

  // IE4
  } else if ( document.all ) {
    obj = document.all.item( obj );

  //Didn't work
  } else {
    obj = null;
  }

 return obj;
}


// Let object appear relative to mouse
function showNearMouse( obj, e ) {
  // step 1: Initialise
  var tempX = 0;
  var tempY = 0;
  var offset = 5;				// offset from mouse position
  var objHolder = obj;

  // step 2: Get object
  obj = getObject( obj );
  if (obj==null) return;

  // step 3: Get mouse coordinates (exception for IE)
  if (document.all) {
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {
    tempX = e.pageX;
    tempY = e.pageY;
  }

  // step 4: Stay on the screen
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}

  // step 5: new coordinates
  obj.style.top  = (tempY + offset) + 'px';
  obj.style.left = (tempX + offset) + 'px';

  // step 6: show
  displayObject( objHolder, true );
}


// Toggle visibility
function displayObject( obj, show ) {
  // step 1: Get object
  obj = getObject( obj );
  if (obj==null) return;

  // step 2: Show or hide object
  obj.style.display = show ? 'block' : 'none';
  obj.style.visibility = show ? 'visible' : 'hidden';
//alert('top: '+obj.style.top);

}

function changecss(theClass,attribute,value) {
/*Voorbeeld
<span class="exampleA">Example A</span>
<span class="exampleB">Example B</span>
<span class="exampleA">Example A</span>
<input type="button" value="Change A Red" onclick="changecss('.exampleA','color','red')"/>
<input type="button" value="Change A Black" onclick="changecss('.exampleA','color','black')"/>
*/
 var cssRules;
 if (document.all) {
  cssRules = 'rules';
 }
 else if (document.getElementById) {
  cssRules = 'cssRules';
 }
 for (var S = 0; S < document.styleSheets.length; S++){
  for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
   if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
    document.styleSheets[S][cssRules][R].style[attribute] = value;
   }
  }
 }
}

