$(document).ready(function () {


    $.ajax({
        type: "GET", url: "xml/content.xml", dataType: "xml", success: function (xml) {
            $(xml).find("item[category=" + pagenode + "]").each(function () {
                var i = 0;

                var stringposition = "";
                var hideslidecontrol = "";
                $(this).find("image").each(function (n) //finds each image in the xml
                {

                    //var path = $(this).attr("path"); //path to the image from the xml 
                    var imgURL = $(this).find("imgurl").text(); //picture link url 
                    var imgDesc = $(this).find("imgdesc").text(); //pic description 

                    if (i > 0) {

                        stringposition = "";

                    } else {
                        stringposition = "position: absolute;"

                    }

                    $("#slideshow").append('<div id="' + n + '"  style="' + stringposition + ' background-image:url(' + imgURL + ')" class="imagerotate">' +
                            '<div class="logoman"></div>' +
                            '<div class="slideshowinfo">' +
                            '<div class="slidecontrol">' +
                            '<div class="prev"><div class="prevtext">zurück</div></div>' +
                            '<div class="next"><div class="nexttext">weiter</div></div>' +
                            '</div> ' +

                            ' </div> </div>');


                 //   $(".slideshowinfo").css({ opacity: 1 });
                 //   $(".slidecontrol").css({ opacity: 0.5 });
                    i++;
                });

            });


            $('#slideshow').cycle({
                fx: 'scrollLeft',
                startingSlide: 0,
                timeout: 0,
                speed: 500,
                prev: '.prev',
                next: '.next'

            });

            var count = $('#slideshow > div:hidden').size();
            if (!count > 0) {
                $(".slidecontrol").css("display", "none");
            }
        }

    });



   

});
