// Copyright Planet Real Estate, Inc 2002-2003
var pic;
var picPos;
var picArr;
var tempImg;
var tempArr;
var timer;
var playing=false;
var doneLoading=false;
var windowmedia;
var origNumericProgress;

pic=new Array();
picPos=new Number(0);
picArr=new Array();

function showcase(image)
{
  var i;

  stopSlideShow();
  for (i=0;i<picArr.length;i++){
    if (picArr[i][0] == image){
      break;
    }
  }
  picPos=i;
  document.images["show_image"].src=pic[picPos].src;
  if (document.all){
    document.images["show_image"].alt=picArr[picPos][1];
    document.all["show_caption"].innerText = picArr[picPos][1];
  }else{
    document.getElementById("show_caption").innerHTML = picArr[picPos][1];
  }
  picPos++;
}

function toggleSlideShow()
{
  if (playing){
    stopSlideShow();
  }else{
    startSlideShow();
  }
}

function startSlideShow()
{
  if (!playing && doneLoading){
    playing=true;
    runSlideShow();
    if ( document.all )
    {
      document.images["vcrstop"].style.filter="alpha(opacity=100)";
      document.images["vcrplay"].style.filter="alpha(opacity=70)";
    }
    else
    {
      document.images["vcrstop"].style.MozOpacity=1;
      document.images["vcrplay"].style.MozOpacity=.7;
    }
    timer=window.setInterval("runSlideShow()",5000);
  }
}

function stopSlideShow()
{
  if (playing && doneLoading){
    playing=false;
    if ( document.all )
    {
      document.images["vcrstop"].style.filter="alpha(opacity=70)";
      document.images["vcrplay"].style.filter="alpha(opacity=100)";
    }
    else
    {
      document.images["vcrstop"].style.MozOpacity=.7;
      document.images["vcrplay"].style.MozOpacity=1;
    }
    window.clearInterval(timer);
  }
}

function runSlideShow()
{
  if (picPos > (pic.length-1)){
    picPos=0;
  }

  if (document.all){
    document.images["show_image"].style.filter="blendTrans(duration=crossFadeDuration)";
    document.images["show_image"].filters.blendTrans.Apply();
  }

  document.images["show_image"].src=pic[picPos].src;

  if (document.all){
    document.images["show_image"].alt=picArr[picPos][1];
    document.all["show_caption"].innerText = picArr[picPos][1];
    document.images["show_image"].filters.blendTrans.Play();
  }else{
    document.getElementById("show_caption").innerHTML=picArr[picPos][1];

  }
  picPos++;
}

function init()
{
  var i;

  for (i=0;i<picArr.length;i++){
    tempImg=new Image(550,366);
    tempImg.src=picArr[i][3];
    //pic.push(tempImg);
    pic[pic.length]=tempImg;
  }

  window.setTimeout("finishLoading()",200);
}

function finishLoading()
{
  var done;
  var i;
  var numComplete;

  done=1;
  numComplete=0;
  for (i=0;i<picArr.length;i++){
    if (!pic[i].complete){
      done=0;
    }else{
      numComplete=numComplete+1;
    }
  }

  if (document.getElementById("ID_NUMERIC_PROGRESS")){
    if (!String(document.getElementById("ID_NUMERIC_PROGRESS").innerHTML).match(/Please/g)){
      origNumericProgress = document.getElementById("ID_NUMERIC_PROGRESS").innerHTML;
      document.getElementById("ID_NUMERIC_PROGRESS").innerHTML='<b>Please wait </b>... loading photo <span style="font-family:Courier New, Courier, mono" id="ID_NUMERIC_PROGRESS_POSITION">00</span> of <span style="font-family:Courier New, Courier, mono" id="ID_NUMERIC_PROGRESS_LENGTH">'+((picArr.length<10)?"0"+picArr.length:picArr.length)+'</span>';
      /*document.getElementById("ID_NUMERIC_PROGRESS_CONTAINER").style.zIndex = '1';*/
    }
    document.getElementById("ID_NUMERIC_PROGRESS_POSITION").innerText=((numComplete<10)?"0"+numComplete:numComplete);
  }

  if (done){
    /* start slideshow
    if (document.all){
      document.all("message").innerHTML="Done Loading Images";
    }*/
    document.getElementById("ID_NUMERIC_PROGRESS").innerHTML=origNumericProgress;
    doneLoading=true;
    startSlideShow();
    /*document.images["PROGRESS_BAR"].src="http://images.planetrealestate.com/images/v2/object/slideshow/progressbar_3.gif";*/
  }else{
    /*if (document.all){
      document.all("message").innerHTML="Loading Images";
    }*/
    setTimeout("finishLoading()",200);
  }
}

function showcaseImap(image,imageid){
  if (document.all){
    document.all["idshow_image"].src=String(document.images[image].src).replace("small","large");
    document.all["show_caption"].innerText = document.images[image].alt;
  }else{
    document.getElementById("idshow_image").src=String(document.images[image].src).replace("small","large");
    document.getElementById("show_caption").innerText = document.images[image].alt;
  }
  document.forms["show_form"].action="map.pl/"+imageid+".html";
}

