window.onload = Start;

var list = new Array('3301.jpg','kha301.jpg','240.jpg','6415.jpg','1302.jpg','1654.jpg','674.jpg','474.jpg','1925.jpg','341.jpg','853.jpg','436.jpg','1133.jpg','782.jpg','1438.jpg','733.jpg','1811.jpg','1312.jpg','545.jpg','722.jpg','304b2.jpg','1668.jpg','658.jpg','1005.jpg','101.jpg','813.jpg','5031.jpg','822.jpg','353.jpg','1412.jpg','6309.jpg','1017.jpg','304.jpg','1206.jpg','1359.jpg','1405.jpg','1656.jpg','5774.jpg','5010.jpg','540.jpg','1001.jpg','1447.jpg','372.jpg','1007.jpg','2059.jpg','1441.jpg','772.jpg','2061.jpg','804.jpg','658_wed.jpg','1010.jpg','371.jpg','1449.jpg','5479.jpg','1008.jpg','330.jpg','1701.jpg','536.jpg','216.jpg','313.jpg','5919.jpg','961.jpg','255.jpg','5642.jpg','5901.jpg','859.jpg','250.jpg','5656.jpg','568.jpg','6168.jpg','d7t.jpg','808.jpg','709.jpg','243.jpg','55.jpg','3.jpg','5545.jpg','264.jpg','1105.jpg','577.jpg','52533.jpg','526.jpg','67643.jpg','1002.jpg','2038.jpg','20202.jpg','537.jpg','33403.jpg','4943.jpg','67631.jpg','5436.jpg','439.jpg','6044.jpg','5174.jpg','668.jpg','231.jpg','1917.jpg','533.jpg','10177.jpg','518.jpg','3084.jpg','2050.jpg','1702.jpg','5125.jpg','1492.jpg','31454.jpg','33402.jpg','67241.jpg','2002.jpg','2002_b.jpg','1130.jpg','33405.jpg','3694.jpg','2418.jpg');

// var list = new Array('3301.jpg','2418.jpg','67241.jpg','2002.jpg','2002_b.jpg','1130.jpg','1492.jpg','3694.jpg');


var Pictures=new Array(list.lenght)
var tag=new Array(list.lenght)
Shuffle();

function LoadPicture(ImageSource) {
   var ImageObject=new Image();
   ImageObject.src=ImageSource;
   return ImageObject;
}
function CheckDownload() {
   if (Pictures[PixNo].complete) {
      NextPicture=true;
   }
   else {
   setTimeout("CheckDownload()",100);
   }
   return true;
}
function Start() {
   PixNo=0;
   GetPicture();
   NextPicture = true;
   FadePicture();
}
function FadePicture() {
   if (NextPicture) {
   bgpix.filters.blendTrans.apply()
   shad.filters.blendTrans.apply()
//   shad.filters.flipv.enabled=1;
   document.images.bgpix.src=Pictures[PixNo].src;
   document.images.shad.src=Pictures[PixNo].src;
   bgpix.filters.blendTrans.play()
   shad.filters.blendTrans.play()
   if (PixNo == (Pictures.length-1)) {
      PixNo=0
      }
      else {
      PixNo++
      }
   GetPicture();
   setTimeout("FadePicture()",10000)
   }
   else {
   setTimeout("FadePicture()",1000)
   }
}
function GetPicture() {
   if ((PixNo < Pictures.length)&&(typeof Pictures[PixNo]=='string')){
      NextPicture=false;
      Pictures[PixNo]=LoadPicture('/ns_frames/welcome/'+Pictures[PixNo]);
      CheckDownload();
   }
   return true;
}
function Shuffle() {
var rnd
var i=1
Pictures[0]=list[0]
while (i<list.length) {
  rnd=1+Math.floor(Math.random()*(list.length-1))
  if (tag[rnd]!="done"){
    Pictures[i]=list[rnd]
    tag[rnd]="done"
    i++
	}
  }
}
