//Javascript document
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1;
var ns6=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1;
var ns4=document.layers;

if (document.layers) var doc = 'document.', vis = '.visibility', left = '.left', top = '.top', zed = '.zIndex';
if (document.all) var doc = 'document.all.', vis = '.style.visibility', left = '.style.pixelLeft', top = '.style.pixelTop', zed = '.style.zIndex';

function placeDiv(imageId, layerId) {
        offsetX = 5;            // aligned with left of "theImage"
        offsetY = 10;           // 20 pixels below "theImage"
        imageHeight = document.images[imageId].height;

        newXpos = findPosX(document.images[imageId]) + offsetX;
        newYpos = findPosY(document.images[imageId]) + offsetY + imageHeight;

        eval(doc + layerId + left + '=' + newXpos);
        eval(doc + layerId + top + '=' + newYpos);
}


function findPosX(obj)
{

        var curleft = 0;
        if (document.getElementById || document.all)
        {
                while (obj.offsetParent)
                {
                        curleft += obj.offsetLeft
                        obj = obj.offsetParent;
                }
        }
        else if (document.layers)
                curleft += obj.x;
        //alert(curleft);
        return curleft;
}

function findPosY(obj)
{
        var curtop = 0;
        if (document.getElementById || document.all)
        {
                while (obj.offsetParent)
                {
                        curtop += obj.offsetTop
                        obj = obj.offsetParent;
                }
        }
        else if (document.layers)
                curtop += obj.y;
        //alert(curtop);
        return curtop;
}


function preloadImages(ImgArray)
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = ImgArray;
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}




function prePreLoad(imgArray, folder)
{
daArray = new Array();
for(i=0; i<imgArray.length; i++){

if(imgArray[i][0]){
for(j=0; j<imgArray[i].length; j++){
//alert(daArray.length);
	daArray[daArray.length] = (folder + imgArray[i][j]);
}
}else daArray[daArray.length] = (folder + imgArray[i]);

	daArray[i] = folder + imgArray[i];	
}
preloadImages(daArray);
}





function switchImage(imgName, imgSrc, imgAlt){ 


  if (document.images){
    if (imgSrc != "none"){
      document.images[imgName].src = imgSrc;
	  document.images[imgName].alt = imgAlt;
    }
  }
}


//added altList
function SlideShow(slideList, image, speed, name, textList, textLayer, imgFolder, altList)          
{
  this.slideList = slideList;
  //added this.altList
  this.altList = altList;
  this.image = image;
  this.speed = speed;
  this.name = name;
  this.current = 0;
  this.timer = 0;
  this.textList = textList
  this.textLayer = textLayer
  this.imgFolder = imgFolder
}
SlideShow.prototype.play = SlideShow_play;
SlideShow.prototype.back = SlideShow_back;  
SlideShow.prototype.forward = SlideShow_forward; 
SlideShow.prototype.evalbuttons = SlideShow_evalButtons; 
  
function SlideShow_play()       
{
  with(this)
  {
    if(current++ == slideList.length-1) current = 0;
    switchImage(image, imgFolder + slideList[current], altList[current]);
	if(textLayer !="none"){
	switchText(textLayer, textList[current]);
	}
    clearTimeout(timer);
    timer = setTimeout(name+'.play()', speed);
  }
}

function SlideShow_back(){       

  with(this)
  {
    switchImage(image, imgFolder + slideList[current-1], altList[current-1]);
	if(textLayer !="none"){
	switchText(textLayer, textList[current-1]);
	}
	current--;
	evalbuttons();
}
}

function SlideShow_forward(){       

  with(this) {
 
    switchImage(image, imgFolder + slideList[current+1], altList[current+1]);
	if(textLayer !="none"){
	switchText(textLayer, textList[current+1]);
	}
	current++;
	evalbuttons();
  }
}

function ucSlideShowQofS(imgName, imgArray, layerName, textSrc, ImageFolder, altList){
switchImage(imgName, ImageFolder + imgArray[0], altList[0]);
switchText(layerName, textSrc[0]);
QofSSlideShow = new SlideShow(imgArray, imgName, 2000, "QofSSlideShow", textSrc, layerName, ImageFolder, altList);
QofSSlideShow.evalbuttons();
}


function SlideShow_evalButtons(){
with(this){
MM_showHideLayers('forwardButton','','show');
MM_showHideLayers('backButton','','show');
if(current >= slideList.length -1) MM_showHideLayers('forwardButton','','hide');
if(current <= 0) MM_showHideLayers('backButton','','hide');
}
}
function regularQofS(imgName, imgSrc, layerName, textSrc, ImgFolder, altList){
switchImage(imgName, ImgFolder + imgSrc, altList);
switchText(layerName, textSrc);
}




function animationQofS(imgName, imgArray, layerName, textSrc, ImageFolder, altList){
QofSSlideShow = new SlideShow(imgArray, imgName, 2000, "QofSSlideShow", "none", "none", ImageFolder, altList);
switchText(layerName, textSrc);
QofSSlideShow.play();
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function switchText(objName, newText) { //v4.01

  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {
	document.open()
	document.write(newText); 
	document.close();
	}
    else innerHTML = unescape(newText);
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function thumbNTextQofS(layerName, textSrc){
	switchText(layerName, textSrc);
}

function mapSlideShowForward(mapSlideShow, contentSlideShow){

contentSlideShow.forward();
mapSlideShow.forward();
}

function mapSlideShowBack(mapSlideShow, contentSlideShow){
contentSlideShow.back();
mapSlideShow.back();
}

