﻿var tar=null;

var bgObj=null;
var msgObj=null
var imgObj=null;
var msgTime=null;
function RemoveObj()
{
    if(bgObj!=null)
    {
        clearTimeout(msgTime);
        msgTime=null;
        
        msgObj.removeChild(imgObj);
        document.body.removeChild(msgObj);
        document.body.removeChild(bgObj);        
        imgObj=null;
        msgObj=null;
        bgObj=null;        
    }
}
function UpdatePosition()
{
    msgObj.style.left = document.documentElement.scrollLeft+(document.documentElement.clientWidth-imgObj.width)/2+'px'
    msgObj.style.top = document.documentElement.scrollTop+(document.documentElement.clientHeight-imgObj.height)/2+'px'
    msgTime=setTimeout(UpdatePosition,100);    
}

function   ImgAlert(w,h){
    RemoveObj();
    var   msgw,msgh,bordercolor;
    msgw=w;//提示窗口的宽度
    msgh=h;//提示窗口的高度
    bordercolor= "#c51100 ";//提示窗口的边框颜色
    var   sWidth,sHeight;
    sWidth=document.documentElement.scrollWidth;
    sHeight=document.documentElement.scrollHeight;
    //bgObj
    bgObj=document.createElement("div");
    bgObj.setAttribute('id', 'bgDiv');
    bgObj.style.position="absolute";
    bgObj.style.top='0px';//document.documentElement.scrollTop+'px';
    bgObj.style.background="#cccccc";
    bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
    bgObj.style.opacity="0.6";
    bgObj.style.left="0";
    bgObj.style.width=sWidth+"px";
    bgObj.style.height=sHeight+"px";
    bgObj.style.zIndex="10000";
    document.body.appendChild(bgObj);
    //msgObj
    msgObj=document.createElement("div")
    msgObj.setAttribute("id", "msgDiv");
    msgObj.style.background="white";
    msgObj.style.border="1px solid "+ bordercolor;
    msgObj.style.position="absolute";
    msgObj.style.left = document.documentElement.scrollLeft+(document.documentElement.clientWidth-w)/2+'px';
    msgObj.style.top = document.documentElement.scrollTop+(document.documentElement.clientHeight-h)/2+'px';
    msgObj.style.width   =   msgw   +   "px";
    msgObj.style.height   =msgh   +   "px";
    msgObj.style.zIndex   =   "10001";
    msgObj.style.cursor ="pointer";
    msgObj.onclick=function(){
            RemoveObj();
    }
    imgObj=document.createElement( "img");
    imgObj.width=w;
    imgObj.height=h;
    imgObj.src='http://www.ourbuild.com/top/images/close.gif';
    msgObj.appendChild(imgObj);
    document.body.appendChild(msgObj);
    
    msgTime=setTimeout(UpdatePosition,100);
}
function updateVotes(retVal)
{
    if(tar!=null)
    {
        if(retVal!=0)
            tar.innerHTML=retVal;
        else
        {
            ImgAlert(301,191);            
        }
    }
}
function vote(id,tarid)
{
    tar=document.getElementById(tarid);
    ajax_callmyfunction('/ClientCall/TopVote.aspx','GET','ID='+id+'&k='+(new Date()).getTime(),updateVotes);
}


