﻿var ns4 = document.layers ? 1 : 0;
var ns6 = document.getElementById && !document.all ? 1 : 0;
var ie = document.all ? 1 : 0;

var imgpreload = new Array();
for (i = 0; i <= sSliderURL.length - 1; i++) {
  imgpreload[i] = new Image();
  imgpreload[i].src = sSliderURL[i];
}

var pos_left = 0;
var pos_top = 0;
var speed = 20;
var step = 10;
var i_loop = 0;
var i_image1 = 0;
var i_image2 = 1;
var i_space = "";
var all_space = "";
var max_space = 20;
var content = "";
var i_slide = 0;
pause *= 1000;

function stretchimage() {
  if (i_loop <= slidewidth) {
    if (ie) {
      imgcontainer1.innerHTML = "<img width='" + i_loop + "' height='" + slideheight + "' src='" + sSliderURL[i_image1] + "' border='0'>";
      //document.all.imgcontainer2.style.posLeft = document.all.imgcontainer1.style.posLeft + i_loop;

      imgcontainer2.innerHTML = "<img width='" + (slidewidth - i_loop) + "' height='" + slideheight + "' src='" + sSliderURL[i_image2] + "' border='0'>";
    }
    if (ns6) {
      document.getElementById('imgcontainer1').innerHTML = "<img width='" + i_loop + "' height='" + slideheight + "' src='" + sSliderURL[i_image1] + "' border='0'>";
      //document.getElementById('imgcontainer2').style.left = parseInt(document.getElementById('imgcontainer1').style.left) + i_loop;

      document.getElementById('imgcontainer2').innerHTML = "<img width='" + (slidewidth - i_loop) + "' height='" + slideheight + "' src='" + sSliderURL[i_image2] + "' border='0'>";
    }
    i_loop = i_loop + step;
    var timer = setTimeout("stretchimage()", speed);
  }
  else {
    clearTimeout(timer)
    var imgcontent = "<img width='" + i_loop + "' height='" + slideheight + "' src='" + sSliderURL[i_image1] + "' border='0'>";
    //var imgcontent = "<a href='" + sSliderLink[i_image1] + "' target='" + sSliderTarget[i_image1] + "'><img width='" + i_loop + "' height='" + slideheight + "' src='" + sSliderURL[i_image1] + "' border='0'></a><br><font face='" + slidefont + "' size=" + slidefontsize + " color='" + slidefontcolor + "'>" + sSliderComment[i_image1] + "</font>";
    if (ie) {
      imgcontainer1.innerHTML = imgcontent;
      //document.all.imgcontainer2.style.posLeft = document.all.imgcontainer1.style.posLeft + i_loop;
      imgcontainer2.innerHTML = ""
    }
    if (ns6) {
      document.getElementById('imgcontainer1').innerHTML = imgcontent;
      //document.getElementById('imgcontainer2').style.left = parseInt(document.getElementById('imgcontainer1').style.left) + i_loop;
      document.getElementById('imgcontainer2').innerHTML = "";

    }
    changeimage();
  }
}

function changeimage() {
  i_loop = 0;
  i_image1++;
  if (i_image1 > sSliderURL.length - 1) { i_image1 = 0 }
  i_image2 = i_image1 - 1;
  if (i_image2 > sSliderURL.length - 1) { i_image2 = 0 }
  if (i_image2 < 0) { i_image2 = sSliderURL.length - 1 }
  if (ie) {
    document.all.imgcontainer2.style.posLeft = document.all.imgcontainer1.style.posLeft
  }
  if (ns6) {
    document.getElementById('imgcontainer2').style.left = parseInt(document.getElementById('imgcontainer2').style.left)
  }
  var timer = setTimeout("stretchimage()", pause);
}

function simpleslideshow() {
  i_slide++;
  if (i_slide >= sSliderURL.length) { i_slide = 0 }
  document.slideimage.src = preloadedimages[i_slide].src
  //simpleSlideShowComment();
  var fadetimer = setTimeout("simpleslideshow()", pause);
}

function simpleSlideShowComment() {
  if (i_space >= 0) {
    all_space = "";
    content = "";
    for (i = 0; i < i_space; i++) {
      all_space += " ";
    }
    for (i = 0; i < sSliderComment[i_slide].length; i++) {
      var thisletter = sSliderComment[i_slide].substring(i, i + 1);
      thisletter = thisletter + all_space;
      content += thisletter;
    }
    window.status = content;
    i_space--;
    //var fadetimer = setTimeout("simpleSlideShowComment()", 20);
  }
  else {
    clearTimeout(fadetimer);
    i_space = max_space;
  }
}

function simpleSlideShowJump() {
  if (sSliderTarget[i_slide] == "_self") {
    document.location.href = sSliderLink[i_slide]
  }
  else if (sSliderTarget[i_slide] == "_blank") {
    codepopup = window.open(sSliderLink[i_slide], "code", "status=yes,location=yes,toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes,width=780,height=580,top=10,left=10");
  }
  else if (sSliderTarget[i_slide] == "_top") {
    top.location.href = sSliderLink[i_slide]
  }

  else if (sSliderTarget[i_slide] == "_parent") {
    parent.location.href = sSliderLink[i_slide]
  }
  else {
    var jumpto = eval("parent." + sSliderTarget[i_slide])
    jumpto.location.href = sSliderLink[i_slide]
  }
}

if (ie || ns6) {
  var slideh = slideheight;
  document.write("<span style=\"position:relative;width:" + slidewidth + "px;height:" + slideh + "px;overflow:hidden;\">");
  document.write("<span id=\"imgcontainer1\" style=\"position:relative;width:" + slidewidth + "px;height:" + slideh + "px;top:0px;left:0px;margin:0px\"><img src=\"" + sSliderURL[0] + "\"></span>");
  document.write("<span id=\"imgcontainer2\" style=\"position:relative;width:" + slidewidth + "px;height:" + slideh + "px;top:0px;left:0px;margin:0px\"><img src=\"" + sSliderURL[1] + "\"></span>");
  document.write("</span>");
  window.onload = stretchimage;
}
else {
  document.write("<a href=\"javascript:simpleSlideShowJump()\"><img name=\"slideimage\" src=\"" + sSliderURL[0] + "\" border=0></a>");
  window.onload = simpleslideshow;
}
