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

function onclickFunctionHotel() {
   startHotelArticleSlideshow();
}

function startHotelArticleSlideshow() {

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

function onclickHotelNext() {
    //previous = false;
    next = true;
    HotelArticleSlideshow();
}

function onclickHotelPrevious() {
    //next = false;
    previous = true;
    HotelArticleSlideshow();
}



function HotelArticleSlideshow() {
 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/hotelslideshowxml.php?id=" + articleID,
       dataType: "xml",
       success: function(xml) {
		document.getElementById("title-image").style.visibility = 'hidden';
		document.getElementById("mainImageCaption").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) {
                    $('#Hotel-article-slideshow').fadeOut(200, function() {
                        $('#Hotel-article-slideshow').css("background-image", "url(" + img + ")");
document.getElementById("img-caption").innerHTML = desc;

                    });                    
                    $('#Hotel-article-slideshow').fadeIn(500);
                }
           });
       }
   });
}

 
