// JavaScript Document

fadingOut = false;
fadingIn = false;
targetImg = '/struct/b/rp.jpg';
stepInc = 0.1;
tmr=null;

function switchBanner(target)
{
	// check that we are not already on this image
	if (targetImg == '/struct/b/'+target+'.jpg')
		return;
		
	targetImg = '/struct/b/'+target+'.jpg';
	fadingOut = true;
	fadingIn = false;
	if (tmr!=null)
		window.clearTimeout(tmr);
	tmr=window.setTimeout("fadeBanner();",10);
}

function fadeBanner()
{
	if (parseFloat(document.getElementById('bannerImg').style.opacity) < 0)
	{
		// BUGFIX code
		fadingIn = true;
		currentTrans = 0;
		nextTrans = currentTrans + stepInc;
		document.getElementById('bannerImg').style.opacity = nextTrans;
		document.getElementById('bannerImg').style.filter = "alpha(opacity="+(nextTrans*100)+")";
		if (nextTrans == 1) // fully opaque
		{
			fadingOut = false;
			fadingIn = false;
		}
		tmr=window.setTimeout("fadeBanner();",10);
		return nextTrans;
	}
	else if (fadingOut)
	{
		// parse the style on the img element
		currentTrans = parseFloat(document.getElementById('bannerImg').style.opacity);
		nextTrans = currentTrans - stepInc;
		document.getElementById('bannerImg').style.opacity = nextTrans;
		document.getElementById('bannerImg').style.filter = "alpha(opacity="+(nextTrans*100)+")";
		if (nextTrans == 0) // fully transparent
		{
			document.getElementById('bannerImg').src = targetImg;
			fadingOut = false;
			fadingIn = true;
		}
		tmr=window.setTimeout("fadeBanner();",10);
		return nextTrans;
	}
	else if (fadingIn)
	{
		// parse the style on the img element
		currentTrans = parseFloat(document.getElementById('bannerImg').style.opacity);
		nextTrans = currentTrans + stepInc;
		document.getElementById('bannerImg').style.opacity = nextTrans;
		document.getElementById('bannerImg').style.filter = "alpha(opacity="+(nextTrans*100)+")";
		if (nextTrans == 1) // fully opaque
		{
			fadingOut = false;
			fadingIn = false;
		}
		tmr=window.setTimeout("fadeBanner();",10);
		return nextTrans;
	}
}

function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}

preloadImages('/struct/b/rp.jpg',
			  '/struct/b/c2.jpg',
			  '/struct/b/roket3d.jpg',
			  '/struct/b/thing3.jpg',
			  '/struct/b/thing2.jpg',
			  '/struct/b/gmr.jpg',
			  '/struct/b/valhalla.jpg',
			  '/struct/b/pattack.jpg',
			  '/struct/b/docwatcher.jpg',
			  '/struct/b/zeropc.jpg',
			  '/struct/b/ggmonkey.jpg',
			  '/struct/b/roketgames.jpg');