/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * 根据日期是不是过去的三天，返回相应的图片代码。
 */
function imgCode(date){
    var img=new Array("images00/new.gif","images/bullet1.gif");
    var arr=date.split("-");
    var b=new Date(arr[0],arr[1]-1,arr[2]).getTime();
    var a=new Date().getTime();
    if(a-b<=3*1000*3600*24){
        return "<img src='"+img[0]+"'/>";
    }else {
        return "<img src='"+img[1]+"'/>";
    }
}
/**
 * 此方法使图片自动保持长宽比缩放在一个方形的框内。
 */
function drawImage(em,length){
    var img=new Image();
    img.src=em.src;
    var w=img.width;
    var h=img.height;
    if(w>h){
        em.style.width=length;
        em.style.height=Math.round(h*length/w);
    }else {
        em.style.height=length;
        em.style.width=Math.round(w*length/h);
    }
}
function ColorEffect(id){
    this.Em=document.getElementById(id);
    if(this.Em==null){
        alert("\u60a8\u8981\u8bbe\u7f6e\u7684\""+id+"\"\u521d\u59cb\u5316\u9519\u8bef\r\n\u8bf7\u68c0\u67e5\u6807\u7b7eID\u8bbe\u7f6e\u662f\u5426\u6b63\u786e!");
        return ;
    }
    this.colorArray=new Array("#66CCFF","#9999FF","#99CC33","#CC66FF","#D2691E");
    if(arguments[1] instanceof Array){
        this.colorArray=arguments[1];
    }
    this.time=200;
    if(typeof arguments[2]=="number"){
        this.time=arguments[2];
    }
}
ColorEffect.prototype.Start=function(){
    if(this.Em==null){
        return ;
    }
    var em=this.Em;
    var title=em.innerHTML;
    var colorArray=this.colorArray;
    var time=this.time;
    var sum=0;
    setInterval(function(){
        var i=sum%title.length;
        var j=sum%colorArray.length;
        sum=(i==0&&j==0)?0:sum;
        var a=title.substr(0,i);
        var b="<span style='color:"+colorArray[j]+";'>"+title.substr(i,1)+"</span>";
        var c=title.substr(i+1,title.length);
        em.innerHTML=a+b+c;
        sum++;
    },time);
};
