// (c) 2007 by Rob Jansman, http://www.xs4all.nl/~rjansman/ict/

function Init()
{
	document.cookie = "yscreen=" + screen.height;
	document.cookie = "xscreen=" + screen.width;

	if ((screen.height > 960) || (screen.width > 1440))
		document.body.className = "res1600";
	else if ((screen.height > 768) || (screen.width > 1152))
		document.body.className = "res1440";
	else if ((screen.height > 600) || (screen.width > 900))
		document.body.className = "res1024";
	else
		document.body.className = "res800";
}

function CClientInfo()
{
	// convert all characters to lowercase to simplify testing
	var a = navigator.userAgent.toLowerCase();

	var nIndex = a.indexOf("msie");
	if (nIndex != -1)
	{
		this.ie = true;
		nIndex += 5;
		var sTemp = a.substring(nIndex);
		this.version = parseFloat(sTemp);
		if (this.version.toString().indexOf(".") == -1)
			this.version += ".0";

	  	if (a.indexOf("macintosh") != -1)
			this.mac = true;
  		else if (a.indexOf("win") != -1)
		{
			this.win = true;
			if (this.version >= 5.5)
				this.ie55win = true;
			if (this.version >= 4)
				this.ie4win = true;
		}
	}
}
var browser = new CClientInfo();

//_________________________________________

function CRollOver(sName, sSrc, sExt)
{
	this.name = sName;
	this.off = new Image();
	this.off.src = "img/" + sSrc + sExt;
	this.on = new Image();
	this.on.src = "img/" + sSrc + "_on" + sExt;
}
CRollOver.prototype.On = function() { document[this.name].src = this.on.src; };
CRollOver.prototype.Off = function() { document[this.name].src = this.off.src; };

var aRolls = new Array();
aRolls.Add = function(sName, sSrc, sExt) { this[this.length] = new CRollOver(sName, sSrc, sExt); };

function On(nIndex) { aRolls[nIndex].On(); };
function Off(nIndex) { aRolls[nIndex].Off(); };

//_________________________________________

var oPicLoad = new Image();
function CCacheImg(sName, sSrc, bTransferOnload, nFadeTime, nOverlap)
{
	this.name = sName;
	this.src = sSrc;
	if (bTransferOnload)
		this.bTransferOnload = true;
	if (nFadeTime)
		this.nFadeTime = nFadeTime;
	this.nOverlap = (nOverlap ? nOverlap : 1);
}
CCacheImg.prototype.Load = function() { oPicLoad = new Image(); oPicLoad.src = "img/" + this.src; };
CCacheImg.prototype.Transfer = function()
{
	if (document[this.name])
	{
		if (this.nFadeTime && browser.ie4win)
		{
			document[this.name].style.filter = (browser.ie55win ?
				("progid:DXImageTransform.Microsoft.Fade(duration=" + this.nFadeTime + ", overlap=" + this.nOverlap + ")") :
				("blendTrans(duration=" + this.nFadeTime + ")"));
			document[this.name].filters[0].apply();
		}
		document[this.name].src = "img/" + this.src;
		if (this.nFadeTime && browser.ie4win)
			document[this.name].filters[0].play();
	}
}

var aAllPics = new Array();
aAllPics.nIndex = -1;
aAllPics.Add = function(name, src, bTransferOnload, nFadeTime, nOverlap) { this[this.length] = new CCacheImg(name, src, bTransferOnload, nFadeTime, nOverlap); };
aAllPics.OnComplete = function() { if (this[this.nIndex].bTransferOnload) this[this.nIndex].Transfer(); };
aAllPics.LoadNext = function()
{
	if (++this.nIndex == this.length)
		return false;

	this[this.nIndex].Load();
	return true;
}

function LoadAllPictures()
{
	if (aAllPics.LoadNext())
		CanTransfer();
}

function CanTransfer()
{
	if (oPicLoad.complete)
	{
		aAllPics.OnComplete();
		LoadAllPictures();
	}
	else
		setTimeout("CanTransfer()", 50);
}


var swapper = { nIndex:-1, nTimer:null };
function Swap(nIndex)
{
	if (swapper.nTimer !== null)
	{
		clearTimeout(swapper.nTimer);
		swapper.nTimer = null;
	}
	swapper.nIndex = nIndex;
	aAllPics[nIndex].Transfer();
}

function SlideShow()
{
	do
	{
		if (++swapper.nIndex >= aAllPics.length)
			swapper.nIndex = 0;
	} while (aAllPics[swapper.nIndex].src == "binnenkort.png");

	aAllPics[swapper.nIndex].Transfer();
	swapper.nTimer = setTimeout("SlideShow()", 4000);
}


//_________________________________________


function SwapImg(sNewSrc, idImg)
{
	document[idImg].src = sNewSrc;
}

function WriteMeelToe(sTxt)
{
	var sAddress = "ete";
	sAddress += "n@d";
	sAddress += "evriesamsterdam.";
	sAddress += "nl";

	var sContent = "<nobr><a hr";
	sContent += "ef=\"ma";
	sContent += "ilto:";
	sContent += sAddress;
	sContent += "\">";
	sContent += (sTxt ? sTxt : sAddress);
	sContent += "</a></nobr>";

	document.write(sContent);
}

function DumpObj(obj, sHeader)
{
	var wnd = window.open("", "wndTmp");
	var d = wnd.document;
	d.open();
	if (sHeader)
		d.write("<h1>" + sHeader + "</h1>\n");
	for (var prop in obj)
		d.write(prop + ": " + obj[prop] + "<br />\n");
	d.close();
	wnd.focus();
}
