// JavaScript Document
// HEADER IMAGE LOADED
// (c) 2009 Magnetic Impact

function loadHeaderImages() {

    headerimgObj1 = MWJ_findObj('image1');
    headerimgObj2 = MWJ_findObj('image2');
    headerimgObj3 = MWJ_findObj('image3');
    headerimgObj4 = MWJ_findObj('image4');
    headerimgObj5 = MWJ_findObj('image5');
    headerimgObj6 = MWJ_findObj('image6');
    headerimgObj7 = MWJ_findObj('image7');
    headerimgObj8 = MWJ_findObj('image8');
    headerimgObj9 = MWJ_findObj('image9');
    headerimgObj10 = MWJ_findObj('image10');
    headerimgObj11 = MWJ_findObj('image11');
    headerimgObj12 = MWJ_findObj('image12');
    headerimgObj13 = MWJ_findObj('image13');
    headerimgObj14 = MWJ_findObj('image14');
    headerimgObj15 = MWJ_findObj('image15');
    headerimgObj16 = MWJ_findObj('image16');
    headerimgObj17 = MWJ_findObj('image17');
    headerimgObj18 = MWJ_findObj('image18');
    headerimgObj19 = MWJ_findObj('image19');
    headerimgObj20 = MWJ_findObj('image20');
    headerimgObj21 = MWJ_findObj('image21');
    headerimgObj22 = MWJ_findObj('image22');
    headerimgObj23 = MWJ_findObj('image23');
    headerimgObj24 = MWJ_findObj('image24');
    headerimgObj25 = MWJ_findObj('image25');

    headerimgObj1.src = headerimages[1];
    headerimgObj2.src = headerimages[2];
    headerimgObj3.src = headerimages[3];
    headerimgObj4.src = headerimages[4];
    headerimgObj5.src = headerimages[5];
    headerimgObj6.src = headerimages[6];
    headerimgObj7.src = headerimages[7];
    headerimgObj8.src = headerimages[8];
    headerimgObj9.src = headerimages[9];
    headerimgObj10.src = headerimages[10];
    headerimgObj11.src = headerimages[11];
    headerimgObj12.src = headerimages[12];
    headerimgObj13.src = headerimages[13];
    headerimgObj14.src = headerimages[14];
    headerimgObj15.src = headerimages[15];
    headerimgObj16.src = headerimages[16];
    headerimgObj17.src = headerimages[17];
    headerimgObj18.src = headerimages[18];
    headerimgObj19.src = headerimages[19];
    headerimgObj20.src = headerimages[20];
    headerimgObj21.src = headerimages[21];
    headerimgObj22.src = headerimages[22];
    headerimgObj23.src = headerimages[23];
    headerimgObj24.src = headerimages[24];
    headerimgObj25.src = headerimages[25];
}


/*
	Image Cross Fade Redux
	Version 1.0
	Last revision: 02.15.2006
	steve@slayeroffice.com

	Rewrite of old code found here: http://slayeroffice.com/code/imageCrossFade/index.html
*/

window.addEventListener?window.addEventListener('load',delay_start_1,false):window.attachEvent('onload',delay_start_1);

var d=document;
var imgs_1 = new Array(), zInterval = null, current_1=0, pause=false, delay_1=0, interval_1=500;

/* image 1 */
function delay_start_1()
{
  setTimeout(so_init_1,delay_1);
}

function so_init_1()
{

var default_ss = document.getElementById('default_ss')
default_ss.style.display='none';

  /* BEGIN -- ADDED by MAGIMPACT 2009 */
  //--------------------------------------------------
  // if previous slideshow position has been saved, start there
  cookiename = 'crs_header_slideshow';
  var search = cookiename + "=";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search);
    // if cookie exists
    if (offset != -1) {
      offset += search.length;
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      current_1 = parseInt(unescape(document.cookie.substring(offset, end)));
      }
      else
        current_1 = 0;
   }
   else
     current_1 = 0;
   //--------------------------------------------------
   /* END -- ADDED by MAGIMPACT 2009 */

	if(!d.getElementById || !d.createElement)return;

	imgs_1 = d.getElementById('header_rotating_pic').getElementsByTagName('img');
	for(i=1;i<imgs_1.length;i++) imgs_1[i].xOpacity = 0;
	imgs_1[current_1].style.display = 'block';
	imgs_1[current_1].xOpacity = .99;

	setTimeout(so_xfade_1,interval_1);
}

function so_xfade_1()
{
	cOpacity = imgs_1[current_1].xOpacity;
	nIndex = imgs_1[current_1+1]?current_1+1:0;
	nOpacity = imgs_1[nIndex].xOpacity;

	cOpacity-=.01;
	nOpacity+=.01;

	imgs_1[nIndex].style.display = 'block';
	imgs_1[current_1].xOpacity = cOpacity;
	imgs_1[nIndex].xOpacity = nOpacity;

	setOpacity(imgs_1[current_1]);
	setOpacity(imgs_1[nIndex]);

  if(cOpacity<=0)
	{
		imgs_1[current_1].style.display = 'none';
		current_1 = nIndex;

    /* BEGIN -- ADDED by MAGIMPACT 2009 */
    //--------------------------------------------------
    // Saves the position of the slideshow in a cookie,
    // so when you return to this page, the position in the slideshow
    // won't be lost.
    document.cookie = cookiename + '=' + current_1 + "; path=/";
    //--------------------------------------------------
    /* END - ADDED by MAGIMPACT 2009 */

    setTimeout(so_xfade_1,interval_1);
	}
	else
	{
		setTimeout(so_xfade_1,50);
	}

	function setOpacity(obj)
	{
		if(obj.xOpacity>.99)
		{
			obj.xOpacity = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	}
}

if(typeof MWJ_findObj != 'function') {
  // From: www.howtocreate.co.uk/tutorials/index.php?tut=0&part=15#genref
  // Finds the object
  function MWJ_findObj( oName, oFrame, oDoc ) {
    if( !oDoc ) { if( oFrame ) { oDoc = oFrame.document; } else { oDoc = window.document; } }
    if( oDoc[oName] ) { return oDoc[oName]; } if( oDoc.all && oDoc.all[oName] ) { return oDoc.all[oName]; }
    if( oDoc.getElementById && oDoc.getElementById(oName) ) { return oDoc.getElementById(oName); }
    for( var x = 0; x < oDoc.forms.length; x++ ) { if( oDoc.forms[x][oName] ) { return oDoc.forms[x][oName]; } }
    for( var x = 0; x < oDoc.anchors.length; x++ ) { if( oDoc.anchors[x].name == oName ) { return oDoc.anchors[x]; } }
    for( var x = 0; document.layers && x < oDoc.layers.length; x++ ) {
      var theOb = MWJ_findObj( oName, null, oDoc.layers[x].document ); if( theOb ) { return theOb; } }
    if( !oFrame && window[oName] ) { return window[oName]; } if( oFrame && oFrame[oName] ) { return oFrame[oName]; }
    for( var x = 0; oFrame && oFrame.frames && x < oFrame.frames.length; x++ ) {
      var theOb = MWJ_findObj( oName, oFrame.frames[x], oFrame.frames[x].document ); if( theOb ) { return theOb; } }
    return null;
  }
}


