﻿//Specify the slider's width (in pixels)
var sliderwidth = parseInt(document.getElementById('holder').style.width)
//alert (sliderwidth)

//Specify the slider's height
var sliderheight = parseInt(document.getElementById('holder').style.height)

//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed = document.getElementById(getActualID('hdnSlideSpeed')).value

//configure background color:
slidebgcolor = document.getElementById('holder').style.backgroundColor

//Specify the slider's images
var leftrightslide = new Array()

var finalslide = ''
leftrightslide[5] = '<a href="http://www.tourismlarissa.gr" target="blank"><img alt="Τουρισμός στο Ν.Λάρισας" src="images/basic/ribbon/rib1.gif" border=0></a>'
leftrightslide[1] = '<a href="http://www.larissamuseums.gr" target="blank"><img alt="Μουσεία Ν.Λάρισας" src="images/basic/ribbon/rib2.gif" border=0></a>'
leftrightslide[2] = '<a href="http://agrotes.larissa.gr" target="blank"><img alt="Αγροτικά Θέματα Ν.Λάρισας" src="images/basic/ribbon/rib3.gif" border=0></a>'
leftrightslide[3] = '<a href="http://www.ergasialarissa.gr" target="blank"><img alt="Αναζήτηση Εργασίας" src="images/basic/ribbon/rib4.gif" border=0></a>'
leftrightslide[4] = '<a href="http://www.achilles.gr" target="blank"><img alt="Φάρσαλα - Αχιλλέας" src="images/basic/ribbon/rib5.gif" border=0></a>'
leftrightslide[0] = '<a href="http://ekloges.larissa.gr" target="blank"><img alt="Εκλογές Ν.Λάρισας (online)" src="images/basic/ribbon/rib6.gif" border=0></a>'
//leftrightslide[6] = '<a href="http://www.in.gr" target="blank"><img src="images/basic/kairos/6.gif" border=0></a>'
//leftrightslide[7] = '<a href="http://www.in.gr" target="blank"><img src="images/basic/kairos/9.gif" border=0></a>'
//leftrightslide[8]='<a href="HYPERLINK"><img src="IMAGE LINK" border=0>'
//leftrightslide[9]='<a href="HYPERLINK"><img src="IMAGE LINK" border=0>'
//leftrightslide[10]='<a href="HYPERLINK"><img src="IMAGE LINK" border=0>'

var copyspeed = slidespeed
leftrightslide = '<nobr>' + leftrightslide.join() + '</nobr>'
//alert(leftrightslide)
var iedom = document.all || document.getElementById
if (iedom)
    document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-600px;">' + leftrightslide + '</span>')
var actualwidth = ''
var cross_slide, ns_slide

function fillup() {
    if (iedom) {
        cross_slide1 = document.getElementById ? document.getElementById("slide1") : document.all.slide1
        //alert("slide=" + cross_slide)
        cross_slide2 = document.getElementById ? document.getElementById("slide2") : document.all.slide2
        //alert("slide2=" + cross_slide2)
        cross_slide1.innerHTML = cross_slide2.innerHTML = leftrightslide
        //alert (cross_slide1.offsetWidth)
        //actualwidth = document.all ? cross_slide1.offsetWidth : document.getElementById("temp").offsetWidth
        actualwidth = Math.max(cross_slide1.offsetWidth, document.getElementById("temp").offsetWidth)
        cross_slide2.style.left = actualwidth / 2 + 20 + 'px'
        //alert("cross_slide2.style.left [in fillup]=" + cross_slide2.style.left)
    }
//    else if (document.layers)
//        alert ("Layers not supported");
    lefttime = setInterval("slideleft()", 30)
}

window.onload = fillup

function slideleft() {
    if (iedom) {
        //alert(parseInt(cross_slide.style.left) + "---" + (actualwidth * (-1) + 8))
        if (parseInt(cross_slide1.style.left) > (actualwidth * (-1) + 8))
            cross_slide1.style.left = (parseInt(cross_slide1.style.left) - copyspeed) + 'px'
        else
            cross_slide1.style.left = (parseInt(cross_slide2.style.left) + actualwidth + 30) + '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_slide1.style.left) + actualwidth + 30) + 'px'

    }
//    else if (document.layers)
//        alert("Layers not supported");
}

function getActualID(controlID) {
    var c = document.getElementsByTagName("input"); // the tag name you want
    var a = null;

    for (var i = 0; i < c.length; i++) // loop through all the elements in the collection
    {
        var f = c[i].id.split('_'); // split the id of the element and put the result into an array
        if (f[f.length - 1].indexOf(controlID) > -1)//match the last chunk with the control id your looking for
        {
            a = c[i].id; // set the 'a' variable to the id that matches, then break out of the loop
            break;
        }
    }

    return a; // return the actual controls (elements) id.
}


