﻿var div_id="";
var height=0;
var width=0;
function openPost(id,dwidth,dheight) {
    OpenLeftTop(id,dwidth,dheight);
    FloatShow();
    
    div_id=id;
    width=dwidth;
    height=dheight;
}
function FloatShow(){
    FloatAutoSize();
    $("main_div").style.display = "block";
    $("main_div").style.opacity = 0.70;
    $("main_div").style.filter = "alpha(opacity=70)";// 把覆盖一层透明度为70的DIV 
    window.scroll(0,0);
}

function FloatAutoSize(){
    $("main_div").style.width = window.screen.width-22+"px";//所要覆盖的DIV宽度为分辨率-滚动条（22）
     $("main_div").style.height = document.documentElement.offsetHeight+"px";
    if (window.ActiveXObject) {$("main_div").style.height = document.body.offsetHeight+"px";}
}

function OpenLeftTop(id,width,height){
    $(id).style.display = "block";
    $(id).style.left = (document.documentElement.offsetWidth-width)/2 + "px";
    if(document.documentElement.offsetHeight>height)
        $(id).style.top = (document.documentElement.offsetHeight-height)/2  + "px";
    else 
        $(id).style.top = "10px";
    //$(id).style.top = (screen.height/2 - 1.5*height)  + "px";
}

window.onresize=function(){
    if ($("main_div").style.display == "block") {
        FloatAutoSize();
    }
    if(div_id!="" && $(div_id).style.display=="block"){
        OpenLeftTop(div_id,width,height);
    }
}

function FloatClose(){
    $("divLeaveWord").style.display = "none"; //把留言框隐藏
    $("main_div").style.display="none";//把覆盖在主窗口上的DIV 隐藏
}

function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1) 
      return element;

    elements.push(element);
  }

  return elements;
}
function tb_onblur()
{

    var ctb = $(arguments[0]);
    if(ctb.value == "")
    {
        ctb.value = arguments[1];
    }
}
function tb_onfocus()
{
    var ctb = $(arguments[0]);
    if(ctb.value == arguments[1])
    {
        ctb.value = "";
    }
}
