/*
 *  Copyright (C) 2010 Efstathios Xatzikiriakidis (lafs@ixthis.gr)
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

// configuration variables.

var slide_speed = 1            // the speed of the sliders' movement.
var slider_width = "580px"     // the width of the slider (pixels).
var slider_height = "150px"    // the height of the slider (pixels).
var slide_bg_color = "#7b7b7b" // the background color of the slider.
var slides = new Array()       // the array of the slider's images.
var dir_data = 'data/'         // the directory of the graphics.
var image_border = 0           // the border attribute of the image.
var image_hspace = 1           // the hspace attribute of the image.
var image_height = 150         // the height attribute of the image.

slides[0]='<a class="link-opacity" href="../churches/"><img src="../../'+dir_data+'thumbnails/index/scroller/churches.jpg" height="'+image_height+'" hspace="'+image_hspace+'" border="'+image_border+'"></a>'
slides[1]='<a class="link-opacity" href="../worship/"><img src="../../'+dir_data+'thumbnails/index/scroller/worship.jpg" height="'+image_height+'" hspace="'+image_hspace+'" border="'+image_border+'"></a>'
slides[2]='<a class="link-opacity" href="../charity/"><img src="../../'+dir_data+'thumbnails/index/scroller/charity.jpg" height="'+image_height+'" hspace="'+image_hspace+'" border="'+image_border+'"></a>'
slides[3]='<a class="link-opacity" href="../juvenility/"><img src="../../'+dir_data+'thumbnails/index/scroller/juvenility.jpg" height="'+image_height+'" hspace="'+image_hspace+'" border="'+image_border+'"></a>'
slides[4]='<a class="link-opacity" href="../camp/"><img src="../../'+dir_data+'thumbnails/index/scroller/camp.jpg" height="'+image_height+'" hspace="'+image_hspace+'" border="'+image_border+'"></a>'
slides[5]='<a class="link-opacity" href="../look-high/"><img src="../../'+dir_data+'thumbnails/index/scroller/look-high.jpg" height="'+image_height+'" hspace="'+image_hspace+'" border="'+image_border+'"></a>'

slides='<nobr>'+slides.join('')+'</nobr>'

var copyspeed = slide_speed
var cross_slide, ns_slide
var actualwidth = ''

var iedom = document.getElementById || document.all
if (iedom)
 document.write('<span id="temp" style="position: absolute; visibility: hidden; top: -100px; left: -9000px">'+slides+'</span>')

function start_scrolling() {
 if (iedom) {
  cross_slide = document.getElementById ? document.getElementById("test2") : document.all.test2
  cross_slide2 = document.getElementById ? document.getElementById("test3") : document.all.test3
  cross_slide.innerHTML = cross_slide2.innerHTML = slides
  actualwidth = document.all ? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
  cross_slide2.style.left = actualwidth + "px"
 }
 else if (document.layers) {
  ns_slide = document.ns_slidemenu.document.ns_slidemenu2
  ns_slide2 = document.ns_slidemenu.document.ns_slidemenu3
  ns_slide.document.write(slides)
  ns_slide.document.close()
  actualwidth = ns_slide.document.width
  ns_slide2.left = actualwidth
  ns_slide2.document.write(slides)
  ns_slide2.document.close()
 }

 lefttime = setInterval("slide_movement()", 50)
}

function slide_movement() {
 if (iedom) {
  if (parseInt(cross_slide.style.left) > (actualwidth * (-1) + 8))
   cross_slide.style.left = parseInt(cross_slide.style.left) - copyspeed + "px"
  else
   cross_slide.style.left = parseInt(cross_slide2.style.left) + actualwidth + "px"

  if (parseInt(cross_slide2.style.left) > (actualwidth * (-1) + 8))
   cross_slide2.style.left = parseInt(cross_slide2.style.left) - copyspeed + "px"
  else
   cross_slide2.style.left = parseInt(cross_slide.style.left) + actualwidth + "px"
 }
 else if (document.layers) {
  if (ns_slide.left > (actualwidth * (-1) + 8))
   ns_slide.left -= copyspeed
  else
   ns_slide.left = ns_slide2.left + actualwidth

  if (ns_slide2.left > (actualwidth * (-1) + 8))
   ns_slide2.left -= copyspeed
  else
   ns_slide2.left = ns_slide.left + actualwidth
 }
}

function show_graphics_scrolling () {
 if (iedom || document.layers) {
  with (document) {
   document.write('<table style="position: relative; background-color: '+slide_bg_color+';" cellspacing="2" cellpadding="0" border="0"><tr><td>')
   if (iedom) {
    write('<div style="position: relative; width: '+slider_width+'; height: '+slider_height+'; overflow: hidden">')
    write(' <div style="position: absolute; width: '+slider_width+'; height: '+slider_height+';">')
    write('  <div id="test2" style="position: absolute; left: 0px; top: 0px"></div>')
    write('  <div id="test3" style="position: absolute; left: -1000px; top: 0px"></div>')
    write(' </div>')
    write('</div>')
   }
   else if (document.layers) {
    write('<ilayer width='+slider_width+' height='+slider_height+' name="ns_slidemenu">')
    write(' <layer name="ns_slidemenu2" left="0" top="0"></layer>')
    write(' <layer name="ns_slidemenu3" left="0" top="0"></layer>')
    write('</ilayer>')
   }
   document.write('</td></tr></table>')
  }
 }
}
