﻿

var _animate = false;

if (Sys.Browser.agent == Sys.Browser.InternetExplorer && Sys.Browser.version < 7) {
    _animate = true;
}
if (_animate) {
    // Make the control use absolute positioning to hover
    // appropriately and move it to its new home
    document.getElementById("ads").style.position = 'absolute';
    document.getElementById("LinkUrl").style.position = 'absolute';
} else {
    // Make the control use fixed positioning to keep it from moving
    // while the content behind it slides around
    document.getElementById("ads").style.position = 'fixed';
    document.getElementById("LinkUrl").style.position = 'fixed';
}

var x = 0;
var y = 0;

// Compute the initial offset if we're animating
if (_animate) {
    if (document.documentElement && document.documentElement.scrollTop) {
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    } else {
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    }
}

var width = 500;
var height = 287;

HttpUrl = location.href;/*
if (HttpUrl.indexOf("En") != -1) {
    document.getElementById("ads").style.background = "url('../Images/Ad/En.gif')";
}
else*/ if (HttpUrl.indexOf("Sc") != -1) {
     document.getElementById("ads").style.background = "url('../Images/Ad/2011-10-26.jpg')";
     document.getElementById("LinkUrl").style.width = 110 + 'px';
     document.getElementById("LinkUrl").style.height = 20 + 'px';
     document.getElementById("LinkUrl").style.right = 50 + 'px';
     document.getElementById("LinkUrl").style.bottom = 40 + 'px';
     document.getElementById("LinkUrl").href = "http://www.cdcic.com/Sc/JoinUs.aspx?MenuID=30";
    //height = 374;
}/*
else if (HttpUrl.indexOf("Jp") != -1) {
    document.getElementById("ads").style.background = "url('../Images/Ad/Jp.gif')";
    height = 374;
}
else {
    document.getElementById("ads").style.background = "url('../Images/Ad/En.gif')";
}*/
document.getElementById("ads").style.width = width + 'px';
document.getElementById("ads").style.height = height + 'px';

//x = Math.max(0, Math.floor(x + document.body.clientWidth / 2.0 - width / 2.0));
//y = Math.max(0, Math.floor(y + document.body.clientHeight / 2.0 - height / 2.0));
//alert(Math.max(0, Math.floor(x + document.body.clientWidth / 2.0 - width / 2.0)));
document.getElementById("ads").style.right = 0 + 'px';
document.getElementById("ads").style.bottom = 0 + 'px';
 
var time = 100;
var h = 0;
function addCount() {
    if (time > 0) {
        time--;
        h = h + 10;
    }
    else {
        return;
    }
    if (h > height)  //高度
    {
        return;
    }
    document.getElementById("ads").style.display = "";
    document.getElementById("ads").style.height = h + "px";
    setTimeout("addCount()", 30);
}
window.onload = function showAds() {
    addCount();
    setTimeout("noneAds()", 15000); //停留时间自己适当调整
}

var T = 100;
var N = height; //高度
function noneAds() {
    if (T > 0) {
        T--;
        N = N - 10;
    }
    else {
        return;
    }
    if (N < 0) {
        document.getElementById("ads").style.display = "none";
        return;
    }
    document.getElementById("ads").style.height = N + "px";
    setTimeout("noneAds()", 30);
}

function noneAds2() {
    document.getElementById("ads").style.display = "none";
}




/*
        $(function(){            
            //获取当前浏览器的宽度
           var winWidth=$(window).width();
           //获取当前浏览器的高度
           var winHeight=$(window).height();
           //标题层的高度--提示打开或关闭
           var titHeight=$("#ditTitle").height();
           //内容层的高度
           var conHeight=$("#divContent").height();
           //临时变量,存储内容层的高度
           var temp = conHeight;
            //alert(conHeight);
            //加载时设置层的位置
            $("#msgDiv").css({top:$(window).height()-$("#ditTitle").height(),left:$(window).width()-$("#ditTitle").width()-16});
            //窗体改变大小时,重新设置
            $(window).resize(function(){
                //重新获取窗口的宽高
                winWidth=$(window).width();
                winHeight=$(window).height();
                $("#msgDiv").css({top:winHeight-$("#ditTitle").height()-conHeight,left:winWidth-$("#ditTitle").width()-16});
           });
           
            $(window).scroll(function(){
                 //重新获取窗口的宽高
                winWidth=$(window).width();
                winHeight=$(window).height();
                $("#msgDiv").css({top:winHeight-$("#ditTitle").height()-conHeight+$(window).scrollTop()});        
           });    
            //打开过关闭
            $("#close").toggle(function(){
                //改变提示
                $("#close").text("关闭");
                //还原内容层的高度
                //alert(titHeight+conHeight);
                //return;
                $("#divContent").height(temp);
                conHeight=temp;
                //动画--一秒内消息层高度增加,top增加
                //$("#msgDiv").height($(this).height()+temp);
                $("#msgDiv").animate({top:winHeight-titHeight-conHeight+$(window).scrollTop(),height:titHeight+conHeight},1000,function(){                    
                    //展开后执行的函数
                });
            },function(){
                //改变提示
                $("#close").text("打开");                
                //alert(temp+" "+titHeight);
                $("#msgDiv").animate({top:winHeight-titHeight+$(window).scrollTop(),height:titHeight},1000,function(){
                    //关闭后执行的函数
                    conHeight=0;
                    //设置内容层的高度为0
                    $("#divContent").height(0);
                });
            })
            
            //执行
            var myTimer,i=8;
            function starFun()
            {
                //触发click事件,显示            
                if(i==4)
                {
                    $("#close").click();
                }
                //清除timeout,触发click事件,关闭层
                if(i==0)
                {
                    window.clearTimeout(myTimer);
                    if($("#close").text()!="打开")
                    $("#close").click();
                }
                myTimer=window.setTimeout(starFun,1000);
                i=i-1;
            }
            
             starFun()
        });
        */
