var containerBgColor='#EDF2EC'
var containerBarColor='#C8D9C6'
var progressBarColor='#B5CEB1'

// the following three lines are site specific and can be removed...
if(bodyBgColor){containerBgColor=bodyBgColor}
if(itemDefaultColor){containerBarColor=itemDefaultColor}
if(itemActiveColor){progressBarColor=itemActiveColor}

var containerWidth=180;               
var allImagesLoaded=false;
var blocksize=0
var preLoadedImage=new Array();
var images2preLoad=new Array()
var lbc,lb,t
var progressBarStr=''


function preload(){
 afterPreload(arguments[arguments.length-1])
 for(a=0;a<arguments.length-2;a++){
  images2preLoad[a]=arguments[a]
 }
 blocksize=containerWidth/(images2preLoad.length);
 progressBarStr='<table id="preLoaderDisplay" style="position:absolute;font-family:verdana;font-size:10;color:'+progressBarColor+';background:'+containerBgColor+';border:1 solid '+progressBarColor+';z-index:1000;visibility:hidden;"><tr><td align="center" id="preLoaderMsg">'+arguments[arguments.length-2]+'</td></tr><tr><td id="preLoaderTxt" align="center">&nbsp;</td></tr><tr><td id="loaderBarContainer" align="center" style="width:'+containerWidth+';height:17;color:'+progressBarColor+';background:'+containerBarColor+';border:1 solid '+progressBarColor+';">'+
'<div id="loaderBar" style="position:absolute;top:;left:4;width:0;height:13;font-family:verdana;font-size:9;color:'+containerBarColor+';background:'+progressBarColor+';" align="center"></div></td></tr></table>'
 document.write(progressBarStr);
 loadimages()
}

function loadimages(){
 pageWidth = document.body.clientWidth;
 pageHeight = document.body.clientHeight
 pld=document.getElementById('preLoaderDisplay')
 plt=document.getElementById('preLoaderTxt')
 plm=document.getElementById('preLoaderMsg')
 lbc=document.getElementById('loaderBarContainer')
 lb=document.getElementById('loaderBar')
 lb.style.top=(plm.offsetHeight+plt.offsetHeight)+8
 pld.style.top=(pageHeight/2-(lbc.offsetHeight/2))
 pld.style.left=(pageWidth/2-(lbc.offsetWidth/2))
 pld.style.visibility='visible'
 lb.style.width=0
 i=images2preLoad.length
 for(a=0;a<i;a++){
  preLoadedImage[a]=new Image();
  preLoadedImage[a].src=images2preLoad[a];
  checkLoadStatus(a)
 } 
}

function checkLoadStatus(n){
 if(preLoadedImage[n].complete==true){
  lb.style.width=(lb.offsetWidth+blocksize)
   plt.innerHTML='Loaded '+(n+1)+' of '+images2preLoad.length+' images'
  if(n+1==images2preLoad.length){
   tmp=(lbc.offsetWidth-4)
   clearTimeout(t)
   lb.style.width=tmp
   setTimeout('removeProgressBar()',100)
  }
 }else{
  t=setTimeout('checkLoadStatus('+n+')',10)
 }
}

function removeProgressBar(){
 lb.removeNode(true)
 lbc.removeNode(true)
 pld.removeNode(true)
 allImagesLoaded=true
}

function afterPreload(what){
  if(allImagesLoaded){
   eval(what)
  }else{
   setTimeout('afterPreload("'+what+'")',100)
  }
}

