var images = new Array();
var myControll = 0;
var anim;

var url = '/FeaturedHome.aspx';


var request = new Json.Remote(url, {
    onComplete: function(response){
        images = response.Items;
        imageWrite();
    }
}).send();

function imageWrite(){

    $('preview').innerHTML = images[myControll];
}

anim = setInterval('next()', 6000);

function clear(){
    clearInterval(anim);
    anim = setInterval('next()', 6000);
}

function previous(){
   
    myControll--;
    if(myControll < 0)
    {
        myControll =  images.length - 1;
    }
    imageWrite()
}

function next(){
   
   myControll++;
    if(myControll > images.length - 1)
    {
        myControll = 0;
    }
    imageWrite()
}
