/* rotating image script */
var slideShowSpeed = 8000; /* 5 seconds */
var crossFadeDuration = 3; /* Duration of crossfade (seconds) */

var _SHOW=0;
var _ITEM=0;
var Pic = new Array();
Pic[_SHOW]=new Array(); /* for slide spot 0 */

// DEVELOPMENT LOCATIONS
//Pic[_SHOW][_ITEM++] = "http://dev.matrixgraphics.co.uk/naylors/wp-content/themes/naylors_V3/images/header_images/image_2.jpg";
//Pic[_SHOW][_ITEM++] = "http://dev.matrixgraphics.co.uk/naylors/wp-content/themes/naylors_V3/images/header_images/image_3.jpg";
//Pic[_SHOW][_ITEM++] = "http://dev.matrixgraphics.co.uk/naylors/wp-content/themes/naylors_V3/images/header_images/image_4.jpg";
// DEVELOPMENT LOCATIONS

// LIVE LOCATIONS
Pic[_SHOW][_ITEM++] = "http://www.naylors.co.uk/wp-content/themes/naylors_V3/images/header_images/image_2.jpg";
Pic[_SHOW][_ITEM++] = "http://www.naylors.co.uk/wp-content/themes/naylors_V3/images/header_images/image_3.jpg";
Pic[_SHOW][_ITEM++] = "http://www.naylors.co.uk/wp-content/themes/naylors_V3/images/header_images/image_4.jpg";
// LIVE LOCATIONS

var t = new Array(); /* set up in init() */
var j = new Array(); /* set up in init() */
var preLoad = new Array();

function init_ex()
{
  for (var i=0;i<Pic.length;i++)
  {
    j[i]=0;
	t[i]=null;
    preLoad[i]=new Array();
    for(var r=0;r<Pic[i].length;r++)
    {
      preLoad[i][r] = new Image();
      preLoad[i][r].src = Pic[i][r];
    }
  } 
}

init_ex();

function startShow(_n)
{
  if(t[_n])
  {
    clearInterval(t[_n]);
	t[_n]=null;
  }
  t[_n]=setInterval('runSlideShow('+_n+')',slideShowSpeed);
}

function runSlideShow(_n){ 
  if (document.all){ 
      document.images["SlideShow"+_n].style.filter="blendTrans(duration=2)";
      document.images["SlideShow"+_n].style.filter="blendTrans(duration=crossFadeDuration)";
      document.images["SlideShow"+_n].filters.blendTrans.Apply();
  }
  document.images["SlideShow"+_n].src = preLoad[_n][j[_n]].src;
  if (document.all){document.images["SlideShow"+_n].filters.blendTrans.Play(); } 
  j[_n] = j[_n] + 1;
  if (j[_n] > (Pic[_n].length-1)) j[_n]=0;
} 

function bodyOnload()
{
  for(var i=0;i<Pic.length;i++)
  {
    /* this starts each one at a separated interval */
    setTimeout('startShow('+i+')',slideShowSpeed*i/Pic.length);
    /* use this if you want them to all change at the "same time" */
	/* "same time" on a single processing machine ? :_) */
	// startShow(i);
  }
}

/* 
	Author:		Richard Elmes
	Date:		22-01-2009
	Description: 	Dynamically matches the height of the sidebar
			to the main content. Should be css/html driven
*/
function matchHeight(){
	if(document.getElementsByTagName){
       		var divs, maxHeight;
               	divs=document.getElementsByTagName('div');
              	maxHeight=0;
		if(divs['mainContainer'].offsetHeight) {
			if(divs['mainContainer'].offsetHeight > divs['sideBar'].offsetHeight){
                		divs['sideBar'].style.height=divs['mainContainer'].offsetHeight+'px';
			}
             	}else if(divs['mainContainer'].style.pixelHeight) {
			if(divs['mainContainer'].style.pixelHeight > divs['sideBar'].style.pixelHeight){
               			divs['sideBar'].style.height=divs['mainContainer'].style.pixelHeight+'px';
			}
             	}
	}
}




