﻿// JScript 文件

var CloseButtonInfo = function()
{
    this.left = 0;
    this.top = 0;
    this.width = 0;
    this.height = 0;
    this.onClose = function(){}
}

function SetLoader(image,width,height,url,closeButton,addMargintop)
{
    if(window.attachEvent)
        window.attachEvent("onload",ShowCenterPngProc(image,width,height,url,closeButton,addMargintop))
    else
        window.addEventListener("load",ShowCenterPngProc(image,width,height,url,closeButton,addMargintop),false)
}

function ShowCenterPngProc(image,width,height,url,closeButton,addMargintop)
{
    
    return function()
    {
        if(!addMargintop) addMargintop = 0;
        var top = Math.floor((document.documentElement.clientHeight - height)/2) + addMargintop;
        var left = Math.floor((document.documentElement.clientWidth - width)/2);
        var pngDiv = document.createElement("div");
        pngDiv.style.width = width + "px";
        pngDiv.style.height = height + "px";
        pngDiv.style.left = left + "px";
        pngDiv.style.top = top + "px";
        pngDiv.style.position = "absolute";
        pngDiv.style.cursor = "pointer";
        
        pngDiv.onclick = function()
        {
            
                
                if(this.nonav == '1')
                {
                    return;
                }
                else
                {
                    window.open(url);
                }
            
        } 
        displayAlphaPNGEl(pngDiv,image)
        document.body.appendChild(pngDiv);
        
        if(closeButton)
        {
            var closeBtn = document.createElement("a")
            
            closeBtn.style.left = (left + closeButton.left)+"px";
            closeBtn.style.top = (top + closeButton.top)+"px";
            closeBtn.style.width = closeButton.width+"px";
            closeBtn.style.height = closeButton.height+"px";
            closeBtn.style.display = 'block';
            closeBtn.style.fontSize = '1px';
            closeBtn.style.position = "absolute";
            closeBtn.style.zIndex = '5'
            closeBtn.style.cursor = "default";
            closeBtn.innerHTML = "&nbsp;";
            
            
            if(window.attachEvent)
                closeBtn.attachEvent("onclick",function(el,closeEl){return function(){el.style.display='none';pngDiv.nonav = "1"; closeEl.style.display = "none";}}(pngDiv,closeBtn));
            else
                closeBtn.addEventListener("click",function(el,closeEl){return function(){el.style.display='none';pngDiv.nonav = "1";closeEl.style.display = "none";}}(pngDiv,closeBtn),false);
            document.body.appendChild(closeBtn);
        }
        
    }
}
function displayAlphaPNGEl(el, imgUrl) {
    if (/msie\s*6/i.test(window.navigator.appVersion + "")) {
        el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src=\"" + imgUrl + "\")";
    } else {
        el.style.backgroundImage = "url(" + imgUrl + ")";
    }
}



//SetLoader("images/hstg_main.png",600,600,"http://www.chenre.cn/tuan.aspx",{left:553,top:17,width:19,height:17});
