var count;
var articleID;
var previous;
var next;

function onclickFunctionGuide() {
   startGuideArticleSlideshow();
}

function startGuideArticleSlideshow() {
	document.getElementById("prev_button").style.visibility = 'visible';
	document.getElementById("next_button").style.visibility = 'visible';
   articleID = document.getElementById("hdArticleID").value;
   count = 0;
   GuideArticleSlideshow();
   setInterval("GuideArticleSlideshow()", 12000);
}

function onclickGuideNext() {
    //previous = false;
    next = true;
    GuideArticleSlideshow();
}

function onclickGuidePrevious() {
    //next = false;
    previous = true;
    GuideArticleSlideshow();
}


function GuideArticleSlideshow() {
if (next == true) {
        count = count + 1;
        next = false;
    }
    else if (previous == true) {
        if(count > 0)
            count = count - 1;
        previous = false;
    }
    else {
        count = count + 1;
    }


   $.ajax({
       type: "GET",
     
       url: "/xml/otherslideshowxml.php?id=" + articleID,
       dataType: "xml",
       success: function(xml) {

	  document.getElementById("title-image").style.visibility = 'hidden';
           var banners = $(xml).find('slideshowItems');
           if (count > banners.length) {
               count = 1;
           }

           $(xml).find('slideshowItems').each(function() {
               var id = $(this).find('id').text();
               var img = $(this).find('img').text();
var desc = $(this).find('desc').text();
               if (count == id) {                    
                                       $('#Guide-article-slideshow').fadeOut(200, function() {

                   
                   $('#Guide-article-slideshow').css("background-image", "url(" + img + ")");
document.getElementById("img-caption").innerHTML = desc;

});                    
                    $('#Guide-article-slideshow').fadeIn(500);
               }
           });
       }
   });
}// JavaScript Document
