
/***********************************************************************
************************************************************************
**                                                                    **
**  Copyright 2010 by Bas Tummers                                     **
**  tummers.org b.v.                                                  **
**  www.tummers.org                                                   **
**                                                                    **
**  No part of this file may be used, modified, reproduced or copied  **
**  in any form or by any means without the express written consent   **
**  of the owner.                                                     **
**                                                                    **
************************************************************************
***********************************************************************/

function htplogo()
{
	var o = document.getElementById('htp_logo' + htplogo.current);
	var n = document.getElementById('htp_logo' + htplogo.other);
	if(!o || !n) return;
	var w = n.width;
	var h = n.height;
	if(w > 0 && h > 0)
	{
		var dw = n.parentNode.offsetWidth;
		var dh = n.parentNode.offsetHeight;
		var scale = Math.min(dw / w, dh / h);
		var iw = Math.round(scale * w);
		var ih = Math.round(scale * h);
		var mx = Math.round((dw - iw) / 2);
		var my = Math.round((dh - ih) / 2);
		n.style.marginLeft = mx + "px";
		n.style.marginTop = my + "px";
		n.style.opacity = 0;
		n.style.filter = "alpha(opacity=0)";
		n.style.zIndex = 20;
		o.style.zIndex = 19;
		n.style.visibility = 'visible';
		o.onload = htplogo;
		var tmp = htplogo.current;
		htplogo.current = htplogo.other;
		htplogo.other = tmp;
		htplogo.initem = n;
		htplogo.outitem = o;
		htplogo.opacity = 0;
		htplogo.timer = window.setInterval("htplogo.fadein()", 50);
	}
}

htplogo.current = 1;
htplogo.other = 2;
htplogo.opacity = 0;

htplogo.setlogo = function()
{
	var logo = document.getElementById('htp_logo' + htplogo.other);
	if(logo)
	{
		logo.src = "http://htpgids.mikrocentrum.nl/randomlogo.php?t=" + (new Date()).getTime();
	}
}

htplogo.fadein = function()
{
	htplogo.opacity += 5;
	htplogo.initem.style.opacity = .01 * htplogo.opacity;
	htplogo.initem.style.filter = "alpha(opacity=" + htplogo.opacity + ")";
	htplogo.outitem.style.opacity = 1 - .01 * htplogo.opacity;
	htplogo.outitem.style.filter = "alpha(opacity=" + (100 - htplogo.opacity) + ")";
	if(htplogo.opacity >= 100)
	{
		window.clearInterval(htplogo.timer);
		htplogo.outitem.style.visibiliy = "hidden";
	}
}
window.setInterval("htplogo.setlogo()", htplogo_refreshtime ? htplogo_refreshtime : 3000);

