// <![CDATA[


var canvasX = 0;
var canvasY = 0;
var timer = null;
var speed = 3;
var incX = 0;
var Xinc = 10;
var dirn = "";
var iPreload = 0;
var tPreload = null;
var imgsLoaded = false;
var browser=BrowserDetect.browser;
var iSlide = -1; // start so first next() incr = 0

function imagePreload()
{
  iPreload++;
  if (iPreload<slideCount)
  {
  	document.getElementById('dummy').src = mySlides[iPreload].picture;
	}
}function imagePreloadIE(oImage)
{
  if (oImage.readystate=="complete")
  {
    iPreload++;
    if (iPreload<slideCount)
    {
  	  document.getElementById('dummyIE').src = mySlides[iPreload].picture; 
	  }
	}  
}

function formnum()
{
var txt;

	txt = iSlide+1;
	txt = txt + " of ";
  txt = txt + (slideCount);
 
return txt;
}
function showSlide(n)
{
  if (canvasX<=0) { canvasX=parseInt(document.getElementById('slide-container').style.width);  }
  if (canvasY<=0) { canvasY=parseInt(document.getElementById('slide-container').style.height);  }
 
  if (mySlides[n].caption=="")
  {
     document.getElementById('imagecaption').style.display="none";
     maxHeight=canvasY-20; 
  }
  else
  {
    document.getElementById('imagecaption').style.display="inline";
     maxHeight=canvasY-80; 
  }
  maxWidth=canvasX-20;
  margins=10;
  
  h = mySlides[n].picHeight;
  w = mySlides[n].picWidth;
  if (h>w)
  {
  	if (h>maxHeight) {h=maxHeight;} 
  	p=h/mySlides[n].picHeight;
  	w=parseInt(w*p);
  }
  else
  {
    if (w>maxWidth) {w=maxWidth;}
    p=w/mySlides[n].picWidth;
  	h=parseInt(h*p);
  }
  document.getElementById('imageviewer').src="";
	document.getElementById('imagecaption').innerHTML="";
  document.getElementById('imageviewer').style.width=w+'px';
  document.getElementById('imageviewer').style.height=h+'px'; 
  document.getElementById('imageviewer').style.top=(margins+(maxHeight-h)/2)+'px'; 
  document.getElementById('imageviewer').style.left=margins+(maxWidth-w)/2+'px'; 
  document.getElementById('imagecaption').style.top=margins+((maxHeight-h)/2)+h+5+'px';
  document.getElementById('imagecaption').style.left=margins+'px';
  document.getElementById('imagecaption').style.width=maxWidth+'px';
  document.getElementById('imageviewer').src=mySlides[n].picture;
	document.getElementById('imagecaption').innerHTML=mySlides[n].caption;
	parent.document.getElementById('cnt').value=formnum();
	document.getElementById('slide-container').style.left=0+'px';
}

function prev()
{	
  dirn = "prev";
  iSlide--;
	if (iSlide<0) {iSlide=slideCount-1;}
	showSlide(iSlide);
}

function next()
{
  dirn = "next";
	iSlide++;
  if (iSlide>(slideCount-1)) { iSlide=0;  }
	showSlide(iSlide);
}

function parentInit()
{
  parent.document.getElementById('Prev').onclick=prev;
	parent.document.getElementById('Next').onclick=next;
	parent.document.getElementById('slidesTitle').innerHTML=showTitle;
}

function init() 
{
  getWindowCoords();
  parentInit();
	next();
	iPreload = 1;
	if (browser!="Explorer")
	{
	  document.getElementById('dummy').src = mySlides[iPreload].picture;
	}
	else
	{
	  document.getElementById('dummyIE').src = mySlides[iPreload].picture;
	}
}

function getWindowCoords()
{
  canvasX=pageWidth();
  canvasY=pageHeight();
  if (canvasX<=0) { canvasX=parseInt(document.getElementById('slide-container').style.width);  }
  if (canvasY<=0) { canvasY=parseInt(document.getElementById('slide-container').style.height);  }
}


window.onresize = getWindowCoords;
window.onload = init;

// ]]>
