var opac;
var fadedir;
var fading;
var fadetext;

function overlay(mode,text)
{
	clearTimeout(fading);
	if (mode == 1) {
	overlaydiv.style.pixelLeft = event.x;
	overlaydiv.style.pixelTop = event.y;
	overlaydiv.style.filter = 'alpha(opacity=0)'
	opac = 0; fadedir = 10;
	fadetext = text;
	setTimeout("fade()",500);
	} else {
	opac = 100; fadedir = -5;
	fade();
	}
}

function fade()
{
	opac = opac + fadedir;
	overlaydiv.innerHTML = fadetext.substring(0,Math.round(fadetext.length*(opac/100)));
	overlaydiv.style.filter = 'alpha(opacity='+opac+')'
	if (opac > 0 && opac < 100)
            fading = setTimeout("fade()",20);
}

function resizeimage(){

   var width = 0;
   var height = 0;
   var image = document.getElementById("postimage");
   if (image){
      width = image.width;
      height = image.height;
      if (width > 0 && height> 0 && (width!=28 || height!=30)){
         if (width>height) {
            // liggende afbeelding
            var newwidth = 150;
            var newheight = height * newwidth / width;
         } else {
            // staande afbeelding
            var newheight = 150;
            var newwidth = width * newheight / height;
         }
         image.width = newwidth;
         image.height = newheight;

         var postimagediv = document.getElementById("postimagediv");
         postimagediv.style.width = newwidth + 2;
         postimagediv.style.height = newheight + 2;
         postimagediv.style.marginRight = 10;
         postimagediv.style.marginBottom = 10;
      }
   }
}

var viewfiles = 0;

var filesdefault = '<div onMouseDown="togglefiles();" style="cursor: hand; border: 1px solid #23568A; border-top: 0px; text-align: center; font-family: Trebuchet MS,Arial; font-weight: bold; font-size: 10px; background-image: url(parheader.gif); color: #517496;">Klik hier voor een overzicht</div>';
var filescontent = '0';

function togglefiles()
{
	if (viewfiles == 0) {
	fo.innerHTML = filescontent;
	viewfiles = 1;
	} else {
	fo.innerHTML = filesdefault;
	viewfiles = 0;
	}
}

var popupstat = 0;

function popup(mode,text,nr,design)
{
	if (mode == 1)
	{
	if (popupstat == 1)
	{
	popupbox.innerHTML = "";
	closepopup.style.visibility = "hidden";
	popupshadow.style.visibility = "hidden";
	}

	popupstat = 1;
	buffer = 250;
	if (design == 1) buffer = 100;
	positiex = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft - buffer;
	if (positiex < 0) positiex = 0;

	popupbox.style.left = positiex;
	popupbox.style.top = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;

	if (design == 1) popupbox.insertAdjacentHTML('BeforeEnd','<table style="border: 3px solid #B6B6C6; font-family: arial, sans-serif; font-size: 11px; background-color: #E4E4F8;" border=0 cellspacing=0 cellpadding=5><tr><td style="padding-top: 15px;">'+text+'</td></table>');
	if (design == 2) popupbox.insertAdjacentHTML('BeforeEnd','<table style="border: 3px solid #B6B6C6; font-family: arial, sans-serif; font-size: 11px; background-color: #E4E4F8;" border=0 cellspacing=0 cellpadding=5><tr><td colspan=2 style="padding-left: 6px; background-color: #D5D5E8;"><img src="http://www.ftd.nu/gfx/note1.gif"> <b>FTD Profiel van '+text+'</b></td><tr><td><iframe width=300 height=200 scrolling=no src="'+makeurl+'"></iframe></td></table>');

	popupshadow.style.left = parseInt(popupbox.style.left) + 5;
	popupshadow.style.top = parseInt(popupbox.style.top) + 5;
	popupshadow.style.width = popupbox.offsetWidth;
	popupshadow.style.height = popupbox.offsetHeight;
	popupshadow.style.backgroundColor = "#000000";
	popupshadow.style.visibility = "visible";

	cross = document.getElementById("closepopup");
	cross.style.left = parseInt(popupbox.style.left) + popupbox.offsetWidth - 15;
	cross.style.top = parseInt(popupbox.style.top) + 6;
	cross.style.visibility = "visible";
	}

	if (popupstat == 1 && mode == 0)
	{
	popupbox.innerHTML = "";
	closepopup.style.visibility = "hidden";
	popupshadow.style.visibility = "hidden";
	popupstat = 0;
	}
}
