/*************************************************************************
  This code is from Dynamic Web Coding at dyn-web.com
  Copyright 2001-5 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

    function initRotator() {
    // arguments: image name, rotation speed, (optional) path to images
    var rotator1 = new dw_Rotator('img1', 300, "");
    rotator1.addImages("smile.gif","logo.gif");
    
    var rotator2 = new dw_Rotator('img2', 5000, "/images/common/");
    rotator2.addImages("heron.gif","wader.gif","eagle.gif","balloon.gif");
    
    dw_Rotator.start();  
    }

	
// preload images function
function preloadimages() {
if (document.images)
	{
		preload_image_object = new Image();
		// set image url
      	image_url = new Array();
      	image_url[0] = "logo-0.gif";
		image_url[1] = "logo-radio.gif";
		image_url[2] = "logo-television.gif";
		image_url[3] = "logo-films.gif";

		var i = 0;
		for(i=0; i<=3; i++) 
			preload_image_object.src = image_url[i];
		}
}
	
function swapLogoImage() {
     setTimeout("document.IMG2.src = 'logo-radio.gif'", 300);
     setTimeout("document.IMG2.src = 'logo-television.gif'", 600); 
	 setTimeout("document.IMG2.src = 'logo-films.gif'", 900);
	 var milliseconds=1500; var interval=500;
	 setTimeout("document.PIC1.src = 'ny.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC1.src = 'ny3.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC1.src = 'homerun.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC1.src = 'camel_planetphotoF.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC1.src = 'ny2.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC2.src = 'africanfamily1.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC2.src = 'maize_path.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC2.src = 'crops_planetphotoF.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC2.src = 'maize_farmer.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC3.src = 'earth.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC3.src = 'neptune.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC3.src = 'navyworld.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC3.src = 'everest_acrossthedivideF.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC3.src = 'namibia_acrossthedivideF.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC3.src = 'sleddogs_acrossthedivideF.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC3.src = 'tajmahal_acrossthedivideF.jpg'", milliseconds); milliseconds+=interval;
	 setTimeout("document.PIC3.src = 'wave.jpg'", milliseconds); milliseconds+=interval;
    return(false);
 }
 


/* EILEEN trying to modify this so the images change without user interaction (pushing a Next or Prev button)

/* Array to hold preloaded images */
var pics = Array();

/* Number of increments to use when resizing */
var steps = 10;

/* Holds the DOM reference to the image */
var display;

/* Keeps track of where we are in the process */
var counter;

/* Total number of images in the gallery */
var totalimages = 6;

function init()
{
	counter = 1;
	display = document.getElementById('display_image');

	loadImage(1);
	loadImage(2);
	loadImage(totalimages);
}

function loadImage(index) {
	if (! pics[index]) {
		pics[index] = new Image();
		pics[index].src = 'slideshow/'+index+'.jpg';
	}
}

function advance()
{
	if (counter == totalimages) {
		previous = counter;
		counter = 1;
	} else if (counter == totalimages - 1) {
		previous = counter;
		counter++
	} else {
		previous = counter;
		counter++;
		loadImage(counter + 1);
	}
	
	initSlide();
}

function retreat()
{
	if (counter == 1) {
		previous = counter;
		counter = totalimages;
		loadImage(totalimages - 1);
		nextcounter = counter - 1;
	} else if (counter == 2) {
		previous = counter;
		counter--;
	} else {
		previous = counter;
		counter--;
		loadImage(counter - 1);
	}
	
	initSlide();
}

function initSlide()
{   
	width_diff = pics[counter].width - pics[previous].width; 
	width_increment = width_diff / steps;
	height_diff = pics[counter].height - pics[previous].height;
	height_increment = height_diff / steps;
	slide(100, width_increment, height_increment, 1);
}

function slide(opacity, width_increment, height_increment, tally_steps)
{
	if (tally_steps != steps) {
		tally_steps++;
		display.width += width_increment;
		display.height += height_increment;
		setOpacity(opacity)
		opacity -= 100/steps;
		window.setTimeout("slide("+opacity+","+width_increment+","+height_increment+","+tally_steps+")", 50);
	} else {
		display.style.backgroundImage = 'url(slideshow/1.jpg)';
		setOpacity(0);
		display.src = 'slideshow/'+counter+'.jpg';
		display.width = pics[counter].width;
		display.height = pics[counter].height;
		fadeIn(10);
	}
}

function setOpacity(opacity) 
{
	opacity = (opacity == 100)?99.999:opacity;
 
	// IE/Win
	display.style.filter = "alpha(opacity:"+opacity+")";
 
	// Safari<1.2, Konqueror
	display.style.KHTMLOpacity = opacity/100;
 
	// Older Mozilla and Firefox
	display.style.MozOpacity = opacity/100;
  
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	display.style.opacity = opacity/100;
}


function fadeIn(opacity) 
{
	if (opacity <= 100) 
	{
		setOpacity(opacity);
		opacity += 5;
		window.setTimeout("fadeIn("+opacity+")", 50);
	}
}

function fadeOut(opacity) 
{
	if (opacity <= 100) 
	{
		setOpacity(opacity);
		opacity -= 5;
		window.setTimeout("fadeOut("+opacity+")", 50);
	}
}



function setOpacityx(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

/*
The fadeIn function uses a Timeout to call itself every n milliseconds with an object Id and an opacity. The starting opacity is passed in - expressed as % - and increased a % at a time. The loop stops once the opacity reaches 100%:
The author set this at 10% increase every 100 ms. I changed this to 1% increase every 10ms to make the fadein smoother.
*/
function fadeInx(objId,opacity,milliseconds) {
  var opacity = (opacity == null) ? 0 : opacity; //default starting opacity is 0%
  var milliseconds = (milliseconds == null) ? 10 : milliseconds; //default milliseconds for repeat wall, with the timeout 
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacityx(obj, opacity);
      opacity += 2;
      window.setTimeout("fadeInx('"+objId+"',"+opacity+")", milliseconds);
    }  
  }
}
/* EILEEN made this by modifying FadeInx */
function fadeOutx(objId,opacity) {//opacity is starting opacity
  var opacity = (opacity == null) ? 100 : opacity; //default starting opacity is 100%
  var milliseconds = (milliseconds == null) ? 10 : milliseconds; //default milliseconds for repeat wall, with the timeout 
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity >= 0) {
      setOpacityx(obj, opacity);
      opacity -= 2;
      window.setTimeout("fadeOutx('"+objId+"',"+opacity+")", 10);
    }
  }
}

/* EILEEN made this by modifying FadeOutx */
function fadeOutFastx(objId,opacity) {//opacity is starting opacity
  var opacity = (opacity == null) ? 100 : opacity; //default starting opacity is 100%
  var milliseconds = (milliseconds == null) ? 10 : milliseconds; //default milliseconds for repeat wall, with the timeout 
  if (document.getElementById) {
    obj = document.getElementById(objId);
    //if (opacity >= 0) {
		opacity=0;
      setOpacityx(obj, opacity);
      //opacity -= 100;
      //window.setTimeout("fadeOutFastx('"+objId+"',"+opacity+")", 10);
    //}
  }
}

/* EILEEN made this by modifying FadeOutx */
function fadeInFastx(objId,opacity) {//opacity is starting opacity
  var opacity = (opacity == null) ? 0 : opacity; //default starting opacity is 100%
  var milliseconds = (milliseconds == null) ? 10 : milliseconds; //default milliseconds for repeat wall, with the timeout 
  if (document.getElementById) {
    obj = document.getElementById(objId);
    //if (opacity >= 0) {
		opacity=100;
      setOpacityx(obj, opacity);
      //opacity -= 100;
      //window.setTimeout("fadeOutFastx('"+objId+"',"+opacity+")", 10);
    //}
  }
}





/* and this by combining fadein and fadeout */


 


function fadeInOutx(objId,opacity) {


  if (document.getElementById) {
    obj = document.getElementById(objId); var i;
    fadeInx(objId,10);  window.setTimeout("i+=1;",0); window.setTimeout("fadeOutx('"+objId+"',"+"100"+")", 2000); /* FadeOutx needs at least 1000 mx to wait for fadeInx to execute (1% opacity X 10mx) - timer seems to start as soon as code is encountered, doesn't wait for previous function to finish*/
  }
}

/* and this by combining fadein and fadeout */
function fadeOutInx(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId); var i;
    fadeOutx(objId,100);  window.setTimeout("i+=1;",0); window.setTimeout("fadeInx('"+objId+"',"+"0"+")", 2000); /* FadeOutx needs at least 1000 mx to wait for fadeInx to execute (1% opacity X 10mx) - timer seems to start as soon as code is encountered, doesn't wait for previous function to finish*/
  }
}

/* EILEEN try to make this fade in a NEW image, then fade the new image out again. image newimagename fades in, starting with opacity% opacity*/
function fadeInOuty(objId,newimagename,opacity) {
  if (document.getElementById) {
    var i;
     /*obj = document.getElementById(objId);
     setOpacityx(obj,0); * quickly make this invisible, before swapping the image and fading the new image in - maybe unnecessary, I'm trying to eliminate a ficker*/
     setTimeout("document."+objId+".src = '"+newimagename+"'", 0); /* next stmt does same thing:       document.earth5.src='2.gif';  */
    fadeInx(objId,0);  window.setTimeout("i+=1;",0,0); 
    /*window.setTimeout("document.earth5.src='3.gif'",2000);  
    window.setTimeout("fadeInx(objId,0)",2000);*/    
    /*window.setTimeout("fadeOutx('"+objId+"',"+"100"+")", 2000);  FadeOutx needs at least 1000 mx to wait for fadeInx to execute (1% opacity X 10mx) - timer seems to start as soon as code is encountered, doesn't wait for previous function to finish*/
  }
}



/* EILEEN make this swap in image newimagename, then fadein. First swap the new image in. Then fade in in from 0% opacity. It appears this needs an adequate interval in milliseconds if we call this function in successfion, otherwise we see a flicker */
function SwapFadeIn(objId,newimagename) {
  if (document.getElementById) {
  setTimeout("setOpacity(objId,0)", 0); // First make the image disappear with opacity
  setTimeout("document."+objId+".src = '"+newimagename+"'", 10); // Swap in the new image     
  fadeInx(objId,0); // Fadein the new image 
  }
}

/* EILEEN make this swap in image newimagename, then fadeout. First swap the new image in. Then fade out from 1000% opacity. It appears this needs an adequate interval in milliseconds if we call this function in successfion, otherwise we see a flicker */
function SwapFadeOut(objId,newimagename) {
  if (document.getElementById) {
  setTimeout("setOpacity(objId,0)", 0); // First make the image disappear with opacity=0
  setTimeout("document."+objId+".src = '"+newimagename+"'", 100); // Swap in the new image     
  fadeOutx(objId,100); // Fadeout the new image 
  }
}

/* EILEEN make this swap in image newimagename, then fadein. First swap the new image in. Then fade in in from 0% opacity. It appears this needs an adequate interval in milliseconds if we call this function in successfion, otherwise we see a flicker */
function SwapFadeOutIn(objId,newimagename,opacity) {
  if (document.getElementById) 
  fadeOutx(objId,100);{
  setTimeout("document."+objId+".src = '"+newimagename+"'", 1000);     
  setTimeout("fadeInx(objId,0)",1001);
  }
}



// Builds the logo by displaying bits at a time. Works by swapping in images, then fading them in from 0% opacity. Haven't added the fadein part yet.
function showLogo() {     
  var interval=300; var ms=interval;
  setTimeout("document.LOGO.src = 'IN2.gif'", ms); ms+=interval;     
  setTimeout("document.LOGO.src = 'IN2Radio.gif'", ms); ms+=interval;     
  setTimeout("document.LOGO.src = 'IN2Television.gif'", ms); ms+=interval;     
  setTimeout("document.LOGO.src = 'IN2Film.gif'", ms); ms+=interval;     ms+=interval;ms+=interval;
  setTimeout("document.LOGO.src = 'IN2itiv.gif'", ms); ms+=interval;     ms+=interval;ms+=interval;
  setTimeout("document.LOGO.src = 'IN2itivF-lms.gif'", ms); ms+=interval;     ms+=interval;ms+=interval;
  setTimeout("document.LOGO.src = 'IN2itivFilms.gif'", ms); ms+=interval;     ms+=interval;ms+=interval;    
  return(false);
}


