function initPic(picname,idx){
	var picarray = eval(picname);
	if(picarray){
	  picarray[idx-1] = new Image();
 	  picarray[idx-1].src = 'images/headerpic/'+picname+'_'+idx+'.jpg';
	}
}

var showPicTimer;
var hidePictimer;
var picidx=0;
var showarray;
var picimg = document.all('picpanel');

function clearShowPic(){
	picidx = 0;
	if(showPicTimer)clearInterval(showPicTimer);
	if(hidePictimer) window.clearTimeout(hidePictimer);
}

function comeOutPic(picname,idx){
	var temp = eval(picname);
	if(temp&&temp.length>0){
		showarray = temp;
		clearShowPic();
		if(idx>0)picidx = idx;
     	if(picidx>showarray.length)picidx = 0;
		if(showarray.length>0)piclength = showarray.length;
		if(showPicTimer)window.clearInterval(showPicTimer);
		changePic();
		showPicTimer = window.setInterval('changePic()',6000);
	}
}

function changePic(){
  showPic();
 // hiddenPic();
  var picimg = document.all('picpanel');
  if(picidx+1>=showarray.length)picidx=0;
  picimg.src = showarray[picidx++].src;
//  showPic();
  if(hidePictimer) window.clearTimeout(hidePictimer);
  hidePictimer = window.setTimeout('hiddenPic()',5700);
}

function hiddenPic(){
  var picmain = document.all('picpanel');
  picmain.style.filter='BlendTrans(duration=0.3)';
  picmain.style.visibility="visible";
  picmain.filters[0].Apply();
  picmain.style.visibility="hidden";
  picmain.filters[0].play();
}

function showPic(){
  var picmain = document.all('picpanel');
  picmain.style.filter='BlendTrans(duration=2.5)';
  picmain.style.visibility="hidden";
  picmain.filters[0].Apply();
  picmain.style.visibility="visible";
  picmain.filters[0].play();
}


//init pics


var header = new Array();
for(i=1;i<=8;i++){
	initPic('header',i);
}

comeOutPic('header',0);
