﻿// JScript 文件

//判断浏览器是否为IE
function isIE()
{
    return (document.all && window.ActiveXObject && !window.opera) ? true : false;
} 
//取得页面的高宽
function getBodySize()
{
    var bodySize = [];
    with(document.documentElement) 
    {
        bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;//如果滚动条的宽度大于页面的宽度，取得滚动条的宽度，否则取页面宽度
        bodySize[1] = (scrollHeight>clientHeight)?scrollHeight:clientHeight;//如果滚动条的高度大于页面的高度，取得滚动条的高度，否则取高度
    }
   return bodySize;
}
//page height
function $WH()
{
    var wh;
    switch(navigator.appName)
    {
        case 'Microsoft Internet Explorer':
        var myregex = /MSIE 7\.0/i;
        var myArray = navigator.appVersion.match(myregex);
//        if(myArray == null) 
//        {
//            with(document.body) 
//            {
//                wh = (scrollHeight>clientHeight)?scrollHeight:clientHeight - 20;//如果滚动条的高度大于页面的高度，取得滚动条的高度，否则取高度
//            }
//        }
        if(myArray == null) 
        {
            with(document.documentElement) 
            {
                wh = (scrollHeight>clientHeight)?scrollHeight:clientHeight;//如果滚动条的高度大于页面的高度，取得滚动条的高度，否则取高度
            }
        }
        else 
        {
            with(document.documentElement) 
            {
                wh = (scrollHeight>clientHeight)?scrollHeight:clientHeight;//如果滚动条的高度大于页面的高度，取得滚动条的高度，否则取高度
            }
        }
      break;
      default:
            with(document.body) 
            {
                wh = (scrollHeight>clientHeight)?scrollHeight:clientHeight;//如果滚动条的高度大于页面的高度，取得滚动条的高度，否则取高度
            }
    }
    return wh;
   //return window.screen.height<document.body.scrollHeight?document.body.scrollHeight+18:window.screen.height-160;
}
//page width
function $WW()
{
    var ww;
    switch(navigator.appName)
    {
        case 'Microsoft Internet Explorer':
        var myregex = /MSIE 7\.0/i;
        var myArray = navigator.appVersion.match(myregex);
//        if(myArray == null) 
//        {
//            with(document.body) 
//            {
//                ww = (scrollWidth>clientWidth)?scrollWidth:clientWidth;//如果滚动条的宽度大于页面的宽度，取得滚动条的宽度，否则取页面宽度
//            }
//        }
        if(myArray == null) 
        {
            with(document.documentElement) 
            {
                ww = (scrollWidth>clientWidth)?scrollWidth:clientWidth;//如果滚动条的宽度大于页面的宽度，取得滚动条的宽度，否则取页面宽度
            }
        }
        else 
        {
            with(document.documentElement) 
            {
                ww = (scrollWidth>clientWidth)?scrollWidth:clientWidth;//如果滚动条的宽度大于页面的宽度，取得滚动条的宽度，否则取页面宽度
            }
        }
      break;
      default:
            with(document.body) 
            {
                ww = (scrollWidth>clientWidth)?scrollWidth:clientWidth;//如果滚动条的宽度大于页面的宽度，取得滚动条的宽度，否则取页面宽度
            }
    }
    with(document.body) 
    {
        ww = (scrollWidth>clientWidth)?scrollWidth:clientWidth;//如果滚动条的宽度大于页面的宽度，取得滚动条的宽度，否则取页面宽度
    }
    return ww;
}
//创建遮盖层
function GetShieldDiv()
{
    var shield = $C("DIV");
    shield.id="shield";
    shield.className="shield";
    var sh=$WH();
    shield.style.height = sh+"px";
    var sw=$WW() + 20;
    shield.style.width = sw+"px";
    return shield;
}

//创建要弹出的DIV
function GetShieldFram(title)
{
    var popFram = document.createElement("DIV");
    with(document.documentElement) 
    {
//        popFram.width = "350px";
//        popFram.height = "120px";
        popFram.style.top = scrollTop + (clientHeight/2 - 100)+"px";
        popFram.style.left = scrollLeft + (clientWidth)/2+"px";
    }
    popFram.id="popFram";
    popFram.className="popFram";
    popFram.style.marginTop = document.documentElement.scrollTop+"px";
    if(title != "")
    {
        var str="<div id=\"divTitle\" class=\"titleBg\">" + 
                    "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" class=\"alerttb\">" + 
                        "<tr>" + 
                            "<td id='tdTitle' class='popTitle'>" + 
                                "" + "" + "</td>" + 
                            "<td align='right' class=\"titleBg\">" + 
                                "<div class='popClose' id='imgclose' onclick='PopIframeClose()'>" + 
                                "</div>" + 
                            "</td>" + 
                        "</tr>" + 
                    "</table>" + 
                "</div>";

        popFram.innerHTML =str;
    }
    return popFram;
}

//让登陆层显示为块 
function ShowPopFram(popFram)
{
    popFram.style.display = "block";
}

function GetPopIfm(ww)
{
    var ifm=document.createElement("IFRAME");
    ifm.id="popIfm";
    ifm.width = ww - 3 + "px";
    ifm.className="popIfm";
    ifm.frameborder = "0";
    ifm.marginheight = "0";
    ifm.marginwidth = "0";
    ifm.style.display = "none";
    return ifm;
}

//打开DIV层
function PopIframeOpen(title, src, ww, wh)//参数分别为:弹出层ID,弹出层宽度，弹出层高度
{
    //循环变大效果
    //change();
    //展开效果
    var shieldFram = GetShieldFram(title);
    var popIfm = GetPopIfm(ww);
    shieldFram.appendChild(popIfm);
    document.body.appendChild(shieldFram);
    ExpandpopFram(shieldFram, ww, wh, title, src);
    ShowPopFram(shieldFram);
    document.body.appendChild(GetShieldDiv());
    void(0);//不进行任何操作,如：<a href="#">aaa</a>
}

//关闭DIV层
function PopIframeClose()
{
    //document.body.removeChild(ifm);
	document.body.removeChild($F("popFram"));
	document.body.removeChild($F("shield"));	
	document.body.onselectstart = function(){return true;}
	document.body.oncontextmenu = function(){return true;}
    void(0);
}


/***************************#engin: div显示样式*****************************************/
//设置DIV层的样式
function change(){
    var popFram = $F("popFram");
    var i=0;
    with(document.body) 
    {
        popFram.style.left = scrollLeft + (clientWidth-i*i*4)/2+"px";
        popFram.style.top = scrollTop + (clientHeight/2-100-i*i)+"px";
    }
    popFram.style.width = i*i*4 + "px";
    popFram.style.height = i*i*1.5 + "px";
     
    popChange(i);
}
//让DIV层大小循环增大
function popChange(i,j)
{
    var popFram = $F("popFram");
    with(document.documentElement) 
    {
        popFram.style.left = scrollLeft + (clientWidth-i*i*4)/2+"px";
        popFram.style.top = scrollTop + (clientHeight/2-250-i*i)+"px";
    }
    popFram.style.width = i*i*4 + "px";
    popFram.style.height = i*i*1.8+ "px";
    if(i<=10)
    {
        i++;
        setTimeout("popChange("+i+")",10);//设置超时10毫秒
    }
}

//设置popFram打开动作样式
var prox;
var proy;
var proxc;
var proyc;
//从左到右 自上而下展开
function ExpandpopFram(o, ww, wh, title, src)//参数分别为:弹出层ID,弹出层宽度，弹出层高度
{
    clearInterval(prox);
    clearInterval(proy);
    clearInterval(proxc);
    clearInterval(proyc);
    switch(navigator.appName)
    {
        case 'Microsoft Internet Explorer':
        var myregex = /MSIE 7\.0/i;
        var myArray = navigator.appVersion.match(myregex);
//        if(myArray == null) 
//        {
//            with(document.body) 
//            {
//                o.style.left = scrollLeft + (clientWidth-ww)/2+"px";
//                o.style.top = scrollTop + (((clientHeight-wh-100)>0)?(clientHeight-wh-100):0)/2+"px";
//            }
//        }
        if(myArray == null) 
        {
            with(document.documentElement) 
            {
                o.style.left = scrollLeft + (clientWidth-ww)/2+"px";
                o.style.top = (((clientHeight-wh-100)>0)?(clientHeight-wh-100):0)/2+"px";
            }
        }
        else 
        {
            with(document.documentElement) 
            {
                o.style.left = scrollLeft + (clientWidth-ww)/2+"px";
                o.style.top = (((clientHeight-wh-100)>0)?(clientHeight-wh-100):0)/2+"px";
            }
        }
      break;
      default:
            with(document.body) 
            {
                o.style.left = scrollLeft + (clientWidth-ww)/2+"px";
                o.style.top = scrollTop + (((clientHeight-wh-100)>0)?(clientHeight-wh-100):0)/2+"px";
            }
    }
    o.style.width = "1px";
    o.style.height = "1px"; 
    prox = setInterval(function(){openx(o,ww,wh, title, src)},10);
}
function openx(o,x,y, title, src)
{//打开横向
   var cx = parseInt(o.style.width);
   if(cx < x)
   {
    o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
   }
   else
   {
    clearInterval(prox);
    proy = setInterval(function(){openy(o,y,title, src)},10);
   }
} 
function openy(o,y, title, src)
{//打开竖向
    var cy = parseInt(o.style.height);
    if(cy < y)
    {
        o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
    }
   else
   {
        var popIfm = $F("popIfm");
        if($F("divTitle") == null)
            popIfm.height = (y-3) + "px";
        else
        {
            $F("tdTitle").innerHTML = title;
            popIfm.height = (y - 20-3) + "px";
        }
        popIfm.style.display = "";
        popIfm.src = src;
        clearInterval(proy);
   }
} 
/***************************#engin end: div显示样式*****************************************/
