﻿// JScript File

function $(id)
{
	return document.getElementById(id);
}

function setTransition(){
if (document.all){
  document.images.bannerADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);
  document.images.bannerADrotator.filters.revealTrans.apply();
}
}

function MM_openBrWindow(theURL,winName,features)
{
	window.open(theURL,winName,features);
	return false;
}

function playTransition()
{
if (document.all)
  document.images.bannerADrotator.filters.revealTrans.play()
}

function PlayImg(){
if(adNum<bannerAD.length-1)adNum++ ;
  else adNum=0;
    setTransition();
    document.images.bannerADrotator.src=bannerAD[adNum];
    $("bannerADLink").setAttribute("href", bannerADlink[adNum]);
    playTransition();
    theTimer=setTimeout("PlayImg()", 4000);
}

function ResizeImgByFixHeight(ImgD, FitHeight)
{
    var image = new Image();
    image.src = ImgD.src;
    if(image.height <= FitHeight)
    {
        return;
    }
    else
    {
        ImgD.height = FitHeight;
    }
}

function ResizeImg(ImgD, FitWidth, FitHeight)
{
    var image = new Image();
    image.src = ImgD.src;
    if((image.width <= 0) || (image.height <= 0))
    {
        return;
    }
    if(image.width <= FitWidth && image.height <= FitHeight)
    {
        return;
    }
    
    //第一种 宽大,高小; 2. 宽大,高稍大. 3.宽稍大,高大. 4.宽小高大.
    
    if(image.width/image.height >= FitWidth/FitHeight)
    {
    //宽比高厉害.
        ImgD.width = FitWidth;
        ImgD.height = image.height * (FitWidth / image.width);

    } 
    else
    {
        ImgD.height = FitHeight;
        ImgD.width = image.width * (FitHeight / image.height);
    }
}

function $(id)
{
	return document.getElementById(id);
}

function ResumeError() 
{ 
return true; 
} 
window.onerror = ResumeError; 

