var image_list = new Array();
var il_index = 0;
//
function setImgList(arr, index)
{
	image_list = arr;
}
//
function imgTakeOver(img, iw, ih, cap, index)
{
	index!=undefined?il_index=index:il_index=il_index;
	creatediv('display_screen');
	creatediv('display_wrapper', embedImage(img, iw, ih, cap));
}
function flashTakeOver(file, fw, fh)
{
	creatediv('display_screen');
	creatediv('display_wrapper', embedFlash(file, fw, fh));
}
function creatediv(id, html) {
	var newdiv = document.createElement('div');
	newdiv.setAttribute('id', id);
	newdiv.setAttribute("align", "center");
	if(html){newdiv.innerHTML = html;}
	document.body.appendChild(newdiv);
}
function embedImage(iFile, iw, ih, cap)
{
	if(image_list.length>0)
	{
		var header = "<div style='background-color:#333333; height:24px; width:"+iw+";'>";
		header += "<span class='display_txt'>"+cap+"</span>";
		header += "<span class='display_btn'><img src='layout/popup_btns_x.png' width='20px' height='20px'onclick='killContainers()'/></span>";
		header += "<span class='display_btn'><img src='layout/popup_btns_right.png' width='20px' height='20px' onclick='shiftImgUp()'/></span>";	
		header += "<span class='display_btn'><img src='layout/popup_btns_left.png' width='20px' height='20px' onclick='shiftImgDown()'/></span>";
		header += "</div>";
	}else{
		var header = "<div align='right' style='background-color:#333333; height:24px; width:"+iw+";'><span class='display_btn'><img src='layout/popup_btns_x.png' width='20px' height='20px'onclick='killContainers()'/></span></div>";
	}
	var footer = "<div align='left' style='background-color:#333333; height:15px; width:"+iw+";'></div>";
	var setImage = "<img width="+iw+" height="+ih+" src='"+iFile+"'>";
	creatediv('display_holder', header+setImage+footer);
}
function embedFlash(emFile, ew, eh)
{
	var header = "<div align='right' style='background-color:#333333; height:24px; width:"+ew+";'><span class='display_btn'><img src='layout/popup_btns_x.png' width='20px' height='20px'onclick='killContainers()'/></span></div>";
	var footer = "<div align='left' style='background-color:#333333; height:15px; width:"+ew+";'>file: "+emFile+"</div>";
	var setFlash = "<object width="+ew+" height="+eh+"><param name='movie' value='swfs/"+emFile+".swf'><embed src='swfs/"+emFile+".swf' width="+ew+" height="+eh+"></embed></object>";
	creatediv('display_holder', header+setFlash+footer);
}
function shiftImgDown()
{
	il_index--;
	if(il_index<=0)
	{	
		il_index = image_list.length;
	}
	var file = "img/"+image_list[il_index][1];
	var width = image_list[il_index][2];
	var height = image_list[il_index][3];
	var text = image_list[il_index][4];
	killContainers();
	imgTakeOver(file, width, height, text);
}
function shiftImgUp()
{
	il_index++;
	if(il_index>=image_list.length)
	{
		il_index = 0;
	}
	var file = "img/"+image_list[il_index][1];
	var width = image_list[il_index][2];
	var height = image_list[il_index][3];
	var text = image_list[il_index][4];
	killContainers();
	imgTakeOver(file, width, height, text);
}
function killContainers()
{
	killdiv('display_screen');
	killdiv('display_holder');
	killdiv('display_wrapper');
}
function killdiv(id)
{
	var killIt = document.getElementById(id);
	document.body.removeChild(killIt);
}
/*
function imgDisplayBtn($thumb, $img, $iw, $ih, $cap)
{
	index!=undefined?il_index=index:il_index=il_index;
	echo "<a href='#'><span onclick='displayImage(\"$img\", $iw, $ih, \"$cap\")'><img src='images/$thumb'/></span></a>";	
}

function setElementHTMLById( id, html ){ 
   try { 
      var El = document.getElementById(id); 
      if( El.attachEvent ){ 
         var elTmp = document.createElement(‘div'); 
         elTmp.innerHTML = html; 
         El.innerHTML = "; 
         for( var i = 0; i < elTmp.childNodes.length; i++ ){ 
            El.appendChild( elTmp.childNodes[i] ); 
         } 
      } 
      else { 
         El.innerHTML = html; 
      } 
   } 
   catch( Er ){ 
      return false; 
   } 
   return El.innerHTML; 
}

*/
