isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;

function setCookieHour(name,value,expirehours)
{
	var todaydate = new Date();
	unixtime = todaydate.getTime();
	if(value==null) expirehours = 0;
	if(expirehours != null){
		extime = unixtime+(expirehours*3600*1000);
		todaydate.setTime(extime);
		expiretime = " expires=" + todaydate.toUTCString() +";";
	}
	else expiretime = "";
	document.cookie = name + "=" + escape(value) + "; path=/;"+expiretime;
}
function ddInit(e){
	topDog=isIE ? "BODY" : "HTML";
	hotDog=isIE ? event.srcElement : e.target;
	idx=hotDog.id.substr(hotDog.id.length-1,1);
	whichDog=isIE ? eval("document.all.poplayer"+idx) : document.getElementById("poplayer" + idx);

	while (hotDog.id!=hotDog.id&&hotDog.tagName!=topDog){
		hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
	}
	if (hotDog.id==("titleBar"+idx)){
		offsetx=isIE ? event.clientX : e.clientX;
		offsety=isIE ? event.clientY : e.clientY;
		nowX=parseInt(whichDog.style.left);
		nowY=parseInt(whichDog.style.top);
		ddEnabled=true;
		document.onmousemove=dd;
	}
}
function dd(e){
	if (!ddEnabled) return;
	whichDog.style.left=isIE ? nowX+event.clientX-offsetx+'px' : nowX+e.clientX-offsetx+'px';
	whichDog.style.top=isIE ? nowY+event.clientY-offsety+'px' : nowY+e.clientY-offsety+'px';
	return false;
}
function ddN4(whatDog){
	if (!isN4) return;
	N4=eval(whatDog);
	N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
	N4.onmousedown=function(e){
		N4.captureEvents(Event.MOUSEMOVE);
		N4x=e.x;
		N4y=e.y;
	}
	N4.onmousemove=function(e){
		if (isHot){
			N4.moveBy(e.x-N4x,e.y-N4y);
			return false;
		}
	}
	N4.onmouseup=function(){
		N4.releaseEvents(Event.MOUSEMOVE);
	}
}
function popupHideMe(id){
	if (isIE||isNN) document.getElementById('poplayer'+id).style.visibility="hidden";
	else if (isN4) document.poplayer.visibility="hide";
}
function popupHideLayer(name,uid,hour) 
{ 
	var nowcookie = getCookie("popview");
	if ( nowcookie.indexOf('['+uid+']') == -1)
        setCookieHour( name, "["+uid+"]" + nowcookie , hour);
	return;
}
function popupLayerDisp(uid,top,left,width,height)
{
	var id = getId('poplayer'+uid);
	var cp = getId('popcont'+uid);
	
	if ( getCookie( "popview" ).indexOf('['+uid+']') == -1)
	{
		id.style.top = top+'px';
		id.style.left = left+'px';
		id.style.width = width+'px';
		id.style.height = parseInt(height)+(isIE6()?30:77)+'px';
		cp.style.height = parseInt(height)-(isIE6()?70:17)+'px';
		id.style.display = 'block';
	}
}
document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");
cookiedata = document.cookie;
