﻿function addFav(id){
    var pagerUrl = "/command.aspx";
    var jxreq = new jx(pagerUrl);
    jxreq.onCompletion = function() { AddFavCallback(jxreq.response); };
    var query = new Array();
    query.push("cmd=addfav");
    query.push("id="+id);
    jxreq.invoke(query);
}

function AddFavCallback(data){
    var html = "<p style='text-align:center;width:100%;height:70px;padding-top:40px'>"+data+"</p>"
    +"<center><img src='images/car_close.gif' alt='关 闭' border='0' onclick='Close()'/> "
    +"<img src='images/car_jrst.gif' alt='我的收藏夹' border='0' onclick='window.location=\"/account/favorite.aspx\"'/></center>";
    AlertMesg(html);
}

function DivAlert(message){
    this.messageDIV=document.createElement("div");
    this.messageDIV.style.width="300px";
    this.messageDIV.style.height="210px";
    this.messageDIV.style.border="1px solid #000000";
    this.messageDIV.style.backgroundColor="#FFFFFF";
    this.messageDIV.innerHTML = "<p style='margin:0;padding:5px 0; background-color:#949494;text-align:right;'><img style='margin-right:10px ' alt='关闭' onclick='Close()' src='images/closesmall.gif'></p>"
    + message;
    
    //创建提示框底层 
    this.bottomDIV = document.createElement("div");
    //获取body中间点
    var x=document.documentElement.clientWidth/2,y=document.documentElement.clientHeight/2+document.documentElement.scrollTop;
    
    //配置样式
    this.bottomDIV.style.opacity="0.50";
    this.bottomDIV.style.filter="Alpha(opacity=50);";
    this.bottomDIV.style.backgroundColor="#CCCCCC";
    this.bottomDIV.style.height=document.body.scrollHeight+"px";
    this.bottomDIV.style.width="100%";
    this.bottomDIV.style.marginTop="0px";
    this.bottomDIV.style.marginLeft="0px";
    this.bottomDIV.style.position="absolute";
    this.bottomDIV.style.top="0px";
    this.bottomDIV.style.left="0px";
    this.bottomDIV.style.zIndex=100;

    this.show = function(){
        document.body.appendChild(this.bottomDIV);
        document.body.appendChild(this.messageDIV);
        this.messageDIV.style.position="absolute";
        x=x-this.messageDIV.clientWidth/2;
        y=y-this.messageDIV.clientHeight/2;
        this.messageDIV.style.top=y+"px";
        this.messageDIV.style.left=x+"px";
        this.messageDIV.style.zIndex=101;
    }
    //移除提示框
     this.remove = function(){
        document.body.removeChild(this.bottomDIV);
        document.body.removeChild(this.messageDIV);
    }
}

var dc;
function AlertMesg(mesg){
     dc = new DivAlert(mesg);
     dc.show();
}
function Close(){
    dc.remove();
}



