var minIndex = 1;
var maxIndex = 26;
var switchDelay = 3000;
var fadeoutDelay = 2000;
var imgPath = "images/homepage/schools-";

var generatedIds = Array();
var order = Array();
var val = 0;

for(var i = minIndex; i <= maxIndex ; i++)
{
    val = Math.ceil(Math.random()*maxIndex);    
    while(order[val] != null || val==undefined)
    {
        val = Math.ceil(Math.random()*maxIndex);
    }            
    order[val] = i;
}

var wrapper = null;
var img = null;
var currentIndex = 1;

$().ready(function(){
       wrapper = $("#flashcontent");
       img = wrapper.find("img");
       /*
       var str="";
       for(var j=minIndex;j<=maxIndex;j++)
        str += j+" = "+order[j]+"\n";
       
       alert(str);
       */
       img.attr("alt","");
       SwitchImage();
});

function SwitchImage()
{
    var newPath = imgPath+order[currentIndex]+".jpg";
    wrapper.css("background","white url("+img.attr("src")+")");
    img.fadeOut(1,function(){
        $(this).attr("src",newPath);
        $(this).fadeIn(switchDelay,function(){
            currentIndex++;
            
            if(currentIndex > maxIndex)
                currentIndex = minIndex;
                
            setTimeout('SwitchImage()',switchDelay);
        });
    });
}