function bgRand(element1,element2,element3,src,num)
{
    var num;
    
    num = Math.random() * num;
    num = Math.ceil(num);
    str = src + '-' + num + '.jpg';
    document.getElementById(element1).src = str;
    document.getElementById(element2).src = str;
	document.getElementById(element3).src = str;
}

function findPosX(obj)
{
   	var curleft = 0;
   	if (obj.offsetParent)
   	{
   		while (obj.offsetParent)
   		{
   			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
//alert("left:"+curleft);
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
 	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
//alert("top:"+curtop);
	return curtop;
}

function findWidth(obj)
{
	var curwidth = 0;
	if(obj.offsetParent)
	{
		curwidth += obj.offsetWidth;
	}
	else
	{
        	curwidth += obj.style.pixelWidth;
	}
    return curwidth;
}

function findHeight(obj)
{
	var curwidth = 0;
	if(obj.offsetParent)
	{
		curwidth += obj.offsetHeight;
	}
	else
	{
        	curwidth += obj.style.pixelHeight;
	}
    return curwidth;
}

function GetScrollY()
{
	return document.body.scrollTop;
}

function GetVisibleHeight()
{
	var y;
	if (self.innerHeight)
	{
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		y = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		y = document.body.clientHeight;
	}
        return y;
}

function GetVisibleWidth()
{
	var x;
	if (self.innerHeight)
	{
		x = self.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		x = document.documentElement.clientWidth;
	}
	else if (document.body)
	{
		x = document.body.clientWidth;
	}
}

function PlaceObj(obj,target,direction)
{
   var nx,ny;
   
   if (direction == "left") {
      nx = findPosX(target)+findWidth(target)-findWidth(obj) + 1;
      ny = findPosY(target)+findHeight(target)-findHeight(obj);
   }
   if (direction == "right") {
      nx = findPosX(target);
      ny = findPosY(target)+findHeight(target)-findHeight(obj);
   }
   if (direction == "center") {

      nx = 200;
      ny = GetScrollY() + 100;
   }

// tijdelijk RHa 3-11-2011 : ik snap het even niet!
nx = 10;
// eind tijdelijk   
 
   obj.style.left = nx+'px';
   obj.style.top = ny+'px';

   if(ny-30 < GetScrollY()) { scroll(0,ny-30); }
   if(ny+findHeight(obj)+30 > GetScrollY()+GetVisibleHeight()) { scroll(0, ny+findHeight(obj)+30-GetVisibleHeight()); }

}


var overPict=false;

function SwapImg(obj) {
   str = obj.src;
   if (str.charAt(str.length-5)=='t') str=str.substring(0,str.length-5)+'.jpg';
   document.getElementById("mainpict").src=str;
}

function PopImg1(name,direction) {
   document.getElementById("popupImg").src=name.src;
   PlaceObj(document.getElementById('popup'),name,direction);
   document.getElementById("popup").style.visibility="visible";
}
 
function unPopImg1() {
   if (overPict == false)
      document.getElementById("popup").style.visibility="hidden"; 
}

function PopImgFocus() {
   overPict=true;
   document.getElementById("popup").style.visibility="visible"; 
}

function PopImgBlur() {
   overPict=false;
   if (overPict == false)
      document.getElementById("popup").style.visibility="hidden"; 
}

function SwapImage(image) {
   d = document.getElementById('popupImg');

   if (image == 'images/nixel.gif') d.style.border='0px';
   else d.classname='img'; 
   d.src=image;
}


