document.write("<style type=\"text/css\">#banner { width:" + xsImgSize[0] + "px; height:" + xsImgSize[1] + "px; overflow: hidden; margin: 0 auto; text-align: center; } img {border: 0;} #banner img { width: " + xsImgSize[0] + "px; height: " + xsImgSize[1] + "px; } #slidefooter {width: " + xsImgSize[0] + "px; }</style>")
document.write("<div id=\"banner\">")
if (xsImgs.length != 0) {
    document.write("<a href=\""+ xsImgLinks[0] +"\" target=\"_blank\"><img src=\"" + xsImgs[0] + "\" onload=\"imgLoadNotify();\" \/><\/a>")
}
document.write("<\/div>")
if (xsTextBar != 0) {
    document.write("<div id=\"slidefooter\">")
    if (xsPlayBtn != 0) {
        document.write("<a id=\"slideplay\" title=\"\" href=\""+ xsImgLinks[0] +"\"><\/a>")
    }
    if (xsImgTexts.length != 0) {
        document.write("<a id=\"slideprev\" title=\"һ\" href=\"#\" onclick=\"rewind();return false\">&laquo;<\/a><a id=\"slidenext\" title=\"һ\" href=\"#\" onclick=\"forward();return false\" style=\"text-align: center; text-decoration: none;\">&raquo;<\/a><p id=\"slidetext\"><a href=\""+ xsImgLinks[0] +"\" target=\"_blank\">"+ xsImgTexts[0] +"<\/a><\/p>")
    }
    document.write("<\/div>")
}
var arrPreload = new Array();
var begImg  = 0;
var arrPreload = new Array();
var spd = 2;
function init()
{
    preloadRange(0,_PRELOADRANGE-1);
    curImg = begImg;
    if (curImg < 0 || curImg > xsImgs.length - 1)
    curImg = xsImgs.length - 1;
    changeSlide();
    setTimeout("play()", 3000)
}
var curImg = 0;
var timerId = -1;
var interval = 3500;
var imgIsLoaded = false;
var current_transition = 3;
var flag = true;
var bFirst = false;
var transitions = new Array;
transitions[0] = "progid:DXImageTransform.Microsoft.Fade(duration=1)";
transitions[1] = "progid:DXImageTransform.Microsoft.GradientWipe(duration=1)";
transitions[2] = "progid:DXImageTransform.Microsoft.Pixelate(maxSquare=10,duration=1)";
transitions[3] = "special case";
var transition_count = 3;
var _PRELOADRANGE = 5;
function preloadRange(intPic,intRange) {
    var divStr = "";
    for (var i=intPic; i<(intPic+intRange); i++) {
        arrPreload[i] = new Image();
        //arrPreload[i].src = xsImgs[i];
    }
    return false;
}
function imgLoadNotify()
{
    imgIsLoaded = true;
}
function changeSlide(n)
{
    if (document.all)
    {
        var do_transition;
        if (current_transition == (transition_count))
        {
            do_transition = Math.floor(Math.random() * transition_count);
        }
        else
        {
            do_transition = current_transition;
        }
        document.all.banner.style.filter=transitions[do_transition];
        document.all.banner.filters[0].Apply();
    }
    imgIsLoaded = false;
    if (xsImgs.length !=0) {
        var slideImage = "<a href=\""+ xsImgLinks[curImg] +"\" target=\"_blank\"><img src=\"" + xsImgs[curImg] + "\" onload=\"imgLoadNotify();\" /><\/a>";
        document.getElementById("banner").innerHTML = slideImage ;
        if (xsTextBar != 0) {
            var slideText = "<a href=\""+ xsImgLinks[curImg] +"\" target=\"_blank\">"+ xsImgTexts[curImg] +"<\/a>";
            document.getElementById("slidetext").innerHTML = slideText;
            if (xsPlayBtn != 0) {
                document.getElementById("slideplay").href = xsImgLinks[curImg];
            }
        }
        if (document.all)
        {
            document.all.banner.filters[0].Play();
        }
    }
}
function forward()
{
    imgIsLoaded = false;
    if (!arrPreload[curImg+1])
    {
        curImg++;
        if (curImg >= xsImgs.length)
        {
            curImg = 0;
        }
    }
    else
    {
        curImg++;
        if (curImg >= xsImgs.length)
        {
            curImg = 0;
        }
    }
    changeSlide();
}
function rewind()
{
    curImg--;
    if (curImg < 0)
    {
        curImg = xsImgs.length-1;
    }
    changeSlide();
}
function stop()
{
    window.clearInterval(timerId);
    timerId = -1;
    imgIsLoaded = true;
}
function play()
{
    if (timerId == -1)
        timerId = window.setInterval('forward();', interval);
}
init();