isIE=document.all;
isNN=!document.all&&document.getElementById;
isHot=false;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.adLayer : document.getElementById("adLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="adLayer"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="adLayer"){
    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 : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function hideMe(){
  whichDog=isIE ? document.all.adLayer : document.getElementById("adLayer");  
  if (isIE||isNN) whichDog.style.visibility="hidden";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
}

function positionAd() {
        whichDog=isIE ? document.all.adLayer : document.getElementById("adLayer");  
	winW = (!isIE)? window.innerWidth : document.body.offsetWidth
	winH = (!isIE)? window.innerHeight : document.body.offsetHeight
	if (isIE||isNN) whichDog.style.top=winH-510;
	if (isIE||isNN) whichDog.style.left=winW-525;
	setTimeout('moveMe()', 15000);
}

function moveMe(){
  whichDog=isIE ? document.all.adLayer : document.getElementById("adLayer");  
  if (isIE||isNN) {
	whichDog.style.height=200;
	whichDog.style.width=200;
  	imgObj=isIE ? document.all.adImg : document.getElementById("adImg");  
	imgObj.style.height=200;
	imgObj.style.width=200;
	winW = (!isIE)? window.innerWidth : document.body.offsetWidth
	winH = (!isIE)? window.innerHeight : document.body.offsetHeight
	whichDog.style.top=winH-210;
	whichDog.style.left=winW-225;
	imgObj.onclick=restoreAd;
  } else {
	hideMe();
  }
}

function restoreAd(){
  whichDog=isIE ? document.all.adLayer : document.getElementById("adLayer");  
  if (isIE||isNN) {
	whichDog.style.height=500;
	whichDog.style.width=500;
  	imgObj=isIE ? document.all.adImg : document.getElementById("adImg");  
	imgObj.style.height=500;
	imgObj.style.width=500;
	whichDog.style.top=100;
	whichDog.style.left=100;
  } else {
	showMe();
  }
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");
