// JScript 文件

//浮动广告代码  开始//

var ballWidth = 40;
var ballHeight = 40;
var BallSpeed = 11;

var maxBallSpeed = 50;
var xMax;
var yMax;
var xPos = 0;
var yPos = 0;
var xDir = 'right';
var yDir = 'down';
var superballRunning = true;
var tempBallSpeed;
var currentBallSrc;
var newXDir;
var newYDir;

function initializeBall() 
{
   if (document.all) 
   {
      xMax = document.body.clientWidth
      yMax = document.body.clientHeight
      document.all("superball").style.visibility = "visible";
   }
   else if (document.layers) 
   {
      xMax = window.innerWidth;
      yMax = window.innerHeight;
      document.layers["superball"].visibility = "show";
   }
   setTimeout('moveBall()',500);
}

function moveBall() 
{
   if (superballRunning == true) 
   {
      calculatePosition();
      if (document.all) 
      {
         document.all("superball").style.left = xPos + document.body.scrollLeft;
         document.all("superball").style.top = yPos + document.body.scrollTop;
      }
      else if (document.layers) 
      {
         document.layers["superball"].left = xPos + pageXOffset;
         document.layers["superball"].top = yPos + pageYOffset;
      }
      setTimeout('moveBall()',300);
  }
}

function calculatePosition() 
{
    if (xDir == "right") 
    {
        if (xPos > (xMax - ballWidth - BallSpeed)) 
        { 
            xDir = "left";
        }
    }
    else if (xDir == "left") 
    {
      if (xPos < (0 + BallSpeed)) 
      {
         xDir = "right";
      }
   }
   if (yDir == "down") 
   {
      if (yPos > (yMax - ballHeight - BallSpeed)) 
      {
         yDir = "up";
      }
   }
   else if (yDir == "up") 
   {
      if (yPos < (0 + BallSpeed)) 
      {
         yDir = "down";
      }
   }
   if (xDir == "right") 
   {
      xPos = xPos + BallSpeed;
   }
   else if (xDir == "left") 
   {
      xPos = xPos - BallSpeed;
   }
   else 
   {
      xPos = xPos;
   }
   if (yDir == "down") 
   {
      yPos = yPos + BallSpeed;
   }
   else if (yDir == "up") 
   {
      yPos = yPos - BallSpeed;
   }
   else 
   {
      yPos = yPos;
   }
}

//浮动广告代码  结束//
/*****************************************************************************************/
//左边对联广告代码  开始//
function initLeftAd() 
{
    document.all.AdLayer1.style.posTop = -100;
    document.all.AdLayer1.style.visibility = 'visible';
    MoveLeftLayer('AdLayer1');
}
function MoveLeftLayer(layerName) 
{
    var x = 5;
    var y = 40;
    var diff = (document.body.scrollTop + y - document.all.AdLayer1.style.posTop)*.40;
    var y = document.body.scrollTop + y - diff;
    eval("document.all." + layerName + ".style.posTop = y");
    eval("document.all." + layerName + ".style.posLeft = x");
    setTimeout("MoveLeftLayer('AdLayer1');", 20);
}

//左边对联广告代码  结束//
/***************************************************************************************/
//右边对联广告代码  开始//
function initRightAd() 
{
    document.all.AdLayer2.style.posTop = -100;
    document.all.AdLayer2.style.visibility = 'visible';
    MoveRightLayer('AdLayer2');
}
function MoveRightLayer(layerName) 
{
    var x = 5;
    var y = 40;
    var diff = (document.body.scrollTop + y - document.all.AdLayer2.style.posTop)*.40;
    var y = document.body.scrollTop + y - diff;
    eval("document.all." + layerName + ".style.posTop = y");
    eval("document.all." + layerName + ".style.posRight = x");
    setTimeout("MoveRightLayer('AdLayer2');", 20);
}

//右边对联广告代码  结束//
/***************************************************************************************/
//弹出广告代码  开始//

function AdPop(url)
{
    var str = document.all.AdPop.innerHTML;
    window.open("pop.aspx?url="+url,"pop","width=300,height=300");
}
//弹出广告代码  结束//
/**************************************************************************************/
//图片新闻代码  开始//

var i = 0;
var my_array = new Array();//图片或flash地址
var my_array2 = new Array();//连接地址
  
   
function ImgNews()
{  
    my_array = document.getElementById("Hid").value.split('|') 
    my_array2 = document.getElementById("Hid2").value.split('|') 
    Cyc();
    setInterval('Cyc()',3000);
}
    
function Cyc()
{
    if(i > my_array.length -2)
        i = 0;
    document.getElementById("ImgHref").href = my_array2[i].toString();
    if(my_array[i].toString().length > 3)
    {
        if(my_array[i].toString().substring(my_array[i].toString().length-3,my_array[i].toString().length).toLowerCase() == "swf")
        {
            document.getElementById("NewImg").style.display = "none";
            document.getElementById("NewFlash").style.display = "";
            document.getElementById("NewFlash").LoadMovie(0,my_array[i].toString());
        }
        else
        {
            document.getElementById("NewImg").style.display = "";
            document.getElementById("NewFlash").style.display = "none";
            document.getElementById("NewImg").src = my_array[i].toString();
        }
    }
    else
    {
        document.getElementById("NewImg").style.display = "";
        document.getElementById("NewFlash").style.display = "none";
        document.getElementById("NewImg").src = my_array[i].toString();
    }
    
    i++;
}      

//图片新闻代码  结束//
/**************************************************************************************/
//初始化代码  开始//

if (document.all||document.layers)
window.onload = function()
{
    //浮动广告
    try
    {
        initializeBall();
    }
    catch(e)
    {
    }
    //对联左边广告
    try
    {
        initLeftAd();
    }
    catch(e)
    {    
    }
    //对联右边广告
    try
    {
        initRightAd()
    }
    catch (e)
    {
    }
    //图片新闻
    try
    {
        ImgNews()
    }
    catch(e)
    {
    }
}

//初始化代码  结束//