$(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "_assets/xml/banners.xml",
        dataType: "xml",
        success: function (xml) {
            $(xml).find('item').each(function () {
                var image = $(this).attr('image');
                var tit = $(this).find('title').text();
                var sub = $(this).find('sub').text();
                var url = $(this).find('link').text();
                var rel = $(this).attr('id');
                $('<div class="items"></div>').html('<a href="' + url + '" style="background:url(' + image + ') no-repeat left top;"><span class="bTit">' + tit + '</span><span class="bSub">' + sub + '</span></a>').appendTo('#banner');
            });
            Cufon.replace('.bTit', { color: "#ffffff", fontSize: "26px", fontFamily: 'DIN Tr', letterSpacing: '-1px' });
            Cufon.replace('.bSub', { color: "#ffffff", fontSize: "16px", fontFamily: 'DIN Tr', letterSpacing: '-1px' });
            $(".newnext").click(function () {
                nextHaber();
                clearInterval(slideInterval);
                slideInterval = setInterval(nextHaber, 3000);
            });

            $(".newprev").click(function () {
                prevHaber();
                clearInterval(slideInterval);
                slideInterval = setInterval(nextHaber, 3000);
            });

        }

    });
});
		var haberIndex = 0;
		var sTimeOut = null;
        function setHaber(index){
            clearTimeout(sTimeOut);
            $(".items a.selected").removeClass("selected");
            $(".items a").eq(index).addClass("selected");
            $(".items a").fadeOut(250);
            sTimeOut = setTimeout(function(){$(".items a").eq(index).stop().fadeIn();},300)
        }		
		
        function nextHaber(){
			haberIndex++;
            if(haberIndex > $(".items a").length-1){
             haberIndex = 0
            }
            setHaber(haberIndex);
        }
		
		function prevHaber(){
            haberIndex--;
            if(haberIndex < 0){
             haberIndex = 0
            }
            setHaber(haberIndex);  
        }		
		
		slideInterval = setInterval(nextHaber, 3000);
