var dizi = new Array();
var dizi2 = new Array();
var proID = new Array();
var sayi = 0;
dizi[6] = "Yukleniyor";
dizi2[6] = "Yukleniyor";
proID[6] = "Yukleniyor";



function mycarousel_itemLoadCallback(carousel, state)
{
    // Check if the requested items already exist
	x=carousel.last-1;
//	if(x==6)
//	{
//	x=2;
//	}
//	alert(carousel.last);
	if (x != 6) {
	    $("#manset_ozet").html("<a style='text-decoration: none; color: white;' href='YayinDetay.aspx?proid=" + proID[x] + "'><span style='font-weight:bold;'>"+dizi[x]+"</span><br/>" + dizi2[x] + "</a>" )
	}
	
	//$("#manset_ozet").css("top","395px");
//	$("#manset_ozet").animate({"top": "395px"}, "fast")
//	$("#manset_ozet").animate({"top": "303px"}, "slow");		


    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

    jQuery.get(
        'dynamicdata.aspx',
        {
            first: carousel.first,
            last: carousel.last
        },
        function(xml) {
            mycarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);			
        },
        'xml'
    );
	
	
	
};

function mycarousel_itemAddCallback(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));
    
    // desc  = PROGRAM_ADI - PROGRAM_SAATI
    jQuery('desc', xml).each(function(i) {
      	  dizi[i]=jQuery(this).text();
    });

    // desc1 = PROGRAM_ACIKLAMA
    jQuery('desc1', xml).each(function(i) {
        dizi2[i] = jQuery(this).text();
    });

    // url = proID
    jQuery('url', xml).each(function(i) {
         proID[i] = jQuery(this).text();
    });
    
    //image = RESIM YOLU
    jQuery('image', xml).each(function(i) {
        carousel.add(first + i, mycarousel_getItemHTML(jQuery(this).text(), proID[i]));
    });

    $("#manset_ozet").html("<a style='text-decoration: none; color: white;' href='YayinDetay.aspx?proid=" + proID[0] + "'><span style='font-weight:bold;'>"+dizi[0]+"</span><br/>" + dizi2[0] + "</a>" )
	
};


/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(resimURL, programID) {
    return '<a href="YayinDetay.aspx?proid=' + programID + '" style="border: 0px;"><img src="' + resimURL + '" width="433" height="292" alt="" /></a>';
};



jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
		visible: 1,
		scroll: 1,
		auto: 8,
		wrap: 'last',
		animation:'slow',
        itemLoadCallback: mycarousel_itemLoadCallback
    });
});

// ESKI RESIM GOSTERME SURESI  = auto: 4