var popWnd=null;
var closeWnd=true;

function pop_list_init(){
	 var a = document.getElementsByTagName("a"); 
 for(i=0; i<a.length; i++){ 
 	if(a[i].id != "" && a[i].className=="pop")
 		sp_addEvt(a[i], 'click', sp_showWnd);
 } 
 var d = document.getElementsByTagName("div");
 for(i=0; i<d.length; i++){ 
 	if(d[i].className == "pop-list"){
	 	sp_addEvt(d[i], 'mouseout', sp_closeWnd);
	 	sp_addEvt(d[i], 'mouseover', sp_keepWnd);
	}
 } 
}

function sp_showWnd(){
	 if(popWnd!=null){
	 	sp_closeWnd2(true);
	 }
	 closeWnd=false;	
	 popWnd = sp_getObj("p"+this.id);
	 sp_show(popWnd);
	 x = sp_getPageX(this);
	 y = sp_getPageY(this);
	 w = sp_getW(popWnd);
	 h = sp_getH(popWnd);
	 pw = sp_getDocW()+sp_getScrollX();
	 ph = sp_getDocH()+sp_getScrollY();
	 if((w+x)>pw)
	 	x = pw-w;
	 if((h+y)>ph)
	 	y = ph-h;
	 sp_moveTo(popWnd,x, y);
	 return false;
}

function sp_closeWnd(){
	if(popWnd!=null){
	 closeWnd=true;
	 window.setTimeout("sp_closeWnd2(false)", 1000);
	}
}

function sp_closeWnd2(force){
	if((force||closeWnd)&&popWnd!=null){
		sp_hide(popWnd);
		popWnd=null;
		}
}
function sp_keepWnd(){
	closeWnd=false;
}