// JavaScript Document
document.writeln('<style type="text/css">');
document.writeln('#serverbox{position:absolute;width:500px;float:right;text-align:right;}');
document.writeln('#minibut{ display:block;}');
document.writeln('#showbox{ display:none;}');
document.writeln('</style>');
document.writeln('<div id="serverbox">');
document.writeln('<div id="minibut" class="servernote"  onclick="openNewDiv();"><a class="button"  style="cursor:pointer"><img src="http://love.ah163.net/ah163/images/serverbut.jpg" border="0"></a></div>');
document.writeln('<div id="showbox">');
document.writeln('');
document.writeln('</div>');
document.writeln('</div>');
document.writeln('<script language="javascript">');
   document.writeln('setInterval("run()",100 )');
document.writeln('</script>');

var docEle = function() {
   return document.getElementById(arguments[0]) || false;
}
function openNewDiv() {
   var m = "mask"; var _id="newDiv";
   if (docEle(_id)) document.removeChild(docEle(_id));
   if (docEle(m)) document.removeChild(docEle(m));
    //新激活图层
   var newDiv = document.createElement("div");
   newDiv.id = "newDiv";
   newDiv.style.position = "absolute";
   newDiv.style.zIndex = "9999";
   newDiv.style.width = "500px";
   newDiv.style.height = "385px";
   newDiv.style.top = (parseInt( document.documentElement.scrollTop+100))+"px";
   newDiv.style.left = (parseInt(document.body.scrollWidth) - 500) / 2 + "px"; // 屏幕居中
   newDiv.style.background = "EEEEEE";
   newDiv.style.border = "0px solid #0066cc";
   newDiv.style.padding = "0px";
   newDiv.innerHTML = '<a class="button" style="cursor:pointer;text-align:right;" onclick="CloseBox()">&times;Close</a><iframe src="http://love.ah163.net/ah163/advice/add.php?from='+parent.location.href+'" frameborder="0" height="385" width="500" scrolling="no"></iframe>';
   document.body.appendChild(newDiv);
   // mask图层
   var newMask = document.createElement("div");
   newMask.id = m;
   newMask.style.position = "absolute";
   newMask.style.zIndex = "1";
   newMask.style.width = document.body.scrollWidth + "px";
   newMask.style.height = document.body.scrollHeight + "px";
   newMask.style.top = "0px";
   newMask.style.left = "0px";
   newMask.style.background = "#000";
   newMask.style.filter = "alpha(opacity=40)";
   newMask.style.opacity = "0.40";
   document.body.appendChild(newMask);
   // docutment www.codefans.net 
   // 关闭mask和新图层
   /*
   var newA = document.createElement("a");
   newA.href = "";
   newA.innerHTML = "关闭";
   newA.onclick = function() {
    document.body.removeChild(docEle("newDiv"));
    document.body.removeChild(docEle(m));
    return false;
   }
   newDiv.appendChild(newA);
   */
}

function run() {
  var ab = ( document.compatMode.toLowerCase()=="css1compat" ) ? document.documentElement : document.body;
  var notice = document.getElementById("serverbox").style;
  var offtop=0;
  var box=document.getElementById('showbox');
  if(box.style.display=='block'){
     offtop=420;
  }else{
     offtop=30;
  }
  notice.top = ( ab.scrollTop + ab.clientHeight -offtop  ) + "px";
  notice.left = ( ab.scrollLeft + ab.clientWidth - 510) + "px";
}

function CloseBox(){
   document.body.removeChild(docEle("newDiv"));
    document.body.removeChild(docEle("mask"));
    return false;

}

