var imgWidth=48;   //The images width in the imgBox;
var imgHeight=48;  //The images height in the imgBox;
var selectedNo=1;  //The image's No which is eslected;
var selecteSize=2; //the count of items which be show in the list;
var imgSrc="images/userface/image数字序号.gif";  //Don't Replace "数字序号" to figure;
var isnum="数字序号";

/*************  Write images   *************/
var myHTML='<SPAN onmouseover="javascript:isin=true" onmouseout="javascript:isin=false">';
myHTML+='<table width="1" onclick="javascript:showlist(this)" title="选择提示框" border="0" cellspacing="0" cellpadding="0"><tr><td  valign=top><img name="imgselected" border=0 src="'+imgSrc.replace("数字序号",selectedNo)+'" WIDTH='+(imgWidth)+' HEIGHT='+imgHeight+'></td><td valign=top><img src="images/menu.gif"></td></tr></table>';
myHTML+='<DIV onscroll="javascript:scrollud()" id="imgBox" \n';
myHTML+='style="position:absolute;left=-800;top=0;background-color:#FFFFFF;border: 1px solid #000000;overflow-x:hidden;overflow-y:scroll; width:'+(imgWidth+20)+'px; height: '+imgHeight*selecteSize+'px">';
for(i=1;i<21;i++){
  myHTML+="<img listID="+i+" src='"+imgSrc.replace("数字序号",i)+"' alt='"+imgSrc.replace("数字序号",i)+"' width="+imgWidth+" height="+imgHeight+" onclick='javascript:selectme(this)' onload='javascript:if(init)init()'><BR>";
}
myHTML+= "</DIV></SPAN>";
imgBox.outerHTML=myHTML;

/****** show or hide list *****/
function showlist(obj){
  if(imgBox.style.pixelLeft!=-800){imgBox.style.pixelLeft=-800; return;}
  
  var mytop=obj.offsetTop; 
  var myleft=obj.offsetLeft; 
  while(obj=obj.offsetParent){ 
    myleft+=obj.offsetLeft; 
    mytop+=obj.offsetTop; 
  }
  imgBox.style.left=myleft;
  imgBox.style.top=mytop+imgHeight+2;

}

var isin=false;
function selectme(obj){
  if(!isin||obj){imgBox.style.pixelLeft=-800;}
  if(obj){
    frmadd.txtface.value=isnum.replace("数字序号",obj.listID);
    document.images["imgselected"].src=imgSrc.replace("数字序号",obj.listID);
  }
}

/***** Scroll to appropriate position *****/
var mytime=setTimeout("",0);
var pre_X=0;
function scrollud(){
  var current_X=imgBox.scrollTop;
  if(current_X>pre_X && imgBox.scrollTop< Math.ceil(imgBox.scrollTop/imgHeight)*imgHeight){
    clearTimeout(mytime);
    mytime=setTimeout("imgBox.scrollTop=Math.round(imgBox.scrollTop+1);",1);
  }
  else if(current_X<pre_X && imgBox.scrollTop> Math.floor(imgBox.scrollTop/imgHeight)*imgHeight){
    clearTimeout(mytime);
    mytime=setTimeout("imgBox.scrollTop=Math.round(imgBox.scrollTop-1);",1);
  }
  pre_X=current_X;
}

function init(){
  imgBox.scrollTop=selectedNo*imgHeight;
  frmadd.txtface.value=isnum.replace("数字序号",selectedNo);
}

myActivation="selectme(null)";
if(document.body.onclick)
{
eval(document.body.onclick.toString().replace('anonymous()','bodyclick()'));
document.body.onclick=new Function("bodyclick();"+myActivation);
}
else document.body.onclick=new Function(myActivation);


