//图片加店庆标签
function dq_discount(scale,discount,showdiscount){
    var str="<span class=\"ddindex_content_celebrate\">";
    str+="<OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 WIDTH="+47*scale+" HEIGHT="+47*scale+"><PARAM NAME=movie VALUE=http://img3.dangdang.com/homeimg/2009_dq.swf> <PARAM NAME=menu VALUE=false>  <PARAM NAME=wmode VALUE=transparent><embed src=http://img3.dangdang.com/homeimg/2009_dq.swf width="+47*scale+" height="+47*scale+" type=application/x-shockwave-flash wmode=transparent  quality=high /></OBJECT>"
    str+="</span>";
    if(discount<=showdiscount&&discount>0)
        document.write(str);
}

function mouseOver(str,tag0,tag1,id){
    objT_id = tag0+id;
    objD_id = tag1+id;
    $("#"+objT_id).siblings("div.book_r_hot").hide();
    $("#"+objT_id).siblings("div.book_wx2").hide();
    $("#"+objT_id).siblings("div.book_detail").hide();
    $("#"+objD_id).siblings("h3").show();
    $("#"+objD_id).siblings("div.book_wx3").show();
    $("#"+objD_id).show();
    $("#"+objT_id).hide();
}

function change_bang(str,s,count,classon,classclose){
    tid = str+"_t"+s;
    id = str+""+s;
    for(i=1;i<=count;i++){
        if(i!=s){
            if($("#"+str+"_t"+i).attr("class") == classon) $("#"+str+"_t"+i).attr("class",classclose);
            if($("#"+str+""+i).css("display")=="block") $("#"+str+""+i).hide();
        }
    }
    if($("#"+tid).attr("class")!=classon) $("#"+tid).attr("class",classon);
    if($("#"+id).css("display")!="block") $("#"+id).show();
}

var Lant={
    cycTime:5000,//循环时间
    flashTime:30,//渐变时间
    imgNum:5,//显示数量
    info :[],//0.图片url  1.链接地址
    onChange:false,
    showNum:0,
    cycNum:0,
    obTO:[],
    obIV:[],
    opacityNum:0,
    img1:[],
    img2:[],

    init: function(){
        for(var i=0;i<Lant.info.length;i++)
        {
            var picTemp;
            picTemp=document.createElement('img');
            picTemp.id ="imgLant_"+i;
            picTemp.src = Lant.info[i][0];
            document.getElementById("div_LantImg_Temp").appendChild(picTemp);
            var aBtn;
            aBtn=document.createElement('a');
            aBtn.href="javascript:void(0)";
            aBtn.id ="aLantBtn_"+i;
            aBtn.name ="__Ad-LZ"+i;
            var imgBtn;
            imgBtn=document.createElement('img');
            imgBtn.id ="imgLantBtn_"+i;
            imgBtn.src = "images_child/child_foucs_button0"+(i+1)+".gif";
            imgBtn.name=i;
            imgBtn.onmouseover=function(){
                Lant.jump(this.name);
            };
            aBtn.appendChild(imgBtn);
            document.getElementById("divLantButton").appendChild(aBtn);
            if (i==Lant.imgNum-1) break;
        }
        document.getElementById("aLantBtn_0").className="now";
        document.getElementById("imgLantBtn_0").src="images_child/child_foucs_button01a.gif";
        var oDiv;
        oDiv=document.createElement('div');
        oDiv.id ="divLant";
        oDiv.style.cursor="pointer";
        oDiv.onclick=function(){
            window.open(Lant.info[0][1]);
        };
        oDiv.appendChild(document.getElementById("imgLant_0").cloneNode(true));
        var oDivTemp;
        oDivTemp=document.createElement('div');
        oDivTemp.id ="divLantT";
        oDivTemp.style.position ="absolute";
        oDivTemp.style.top ="5px";
        oDivTemp.style.display="none";
        document.getElementById("divLantMain").appendChild(oDivTemp);
        document.getElementById("divLantMain").appendChild(oDiv);
        Lant.obTO=setTimeout("Lant.cyc()",Lant.cycTime);
    },

    cyc:function(){
        if(!Lant.onChange)
        {
            Lant.onChange=true;
            if(Lant.cycNum==Lant.info.length-1)
                Lant.cycNum=0;
            else
                Lant.cycNum++;
            Lant.initChange();
        }
    },

    jump:function(i){
        if(Lant.showNum!=i)
        {
            clearTimeout(Lant.obTO);
            if(Lant.onChange)
            {
                clearInterval(Lant.obIV);
                document.getElementById("divLantT").style.display="none";
                document.getElementById("divLant").innerHTML="";
                document.getElementById("divLant").appendChild(document.getElementById("imgLant_"+Lant.cycNum).cloneNode(true));

                Lant.showNum=Lant.cycNum;
                Lant.opacityNum=0;
            }
            Lant.onChange=true;
            Lant.cycNum=i;
            Lant.initChange();
        }
    },

    initChange:function()
    {
        document.getElementById("divLantT").innerHTML="";
        document.getElementById("divLantT").appendChild(document.getElementById("imgLant_"+Lant.cycNum).cloneNode(true));
        if($.browser.msie )
            document.getElementById("divLantT").style.filter='alpha(opacity=0)';
        else
            document.getElementById("divLantT").style.opacity=0;
        document.getElementById("divLantT").style.display="";
        document.getElementById("imgLantBtn_"+Lant.cycNum).src="images_child/child_foucs_button0"+(Lant.cycNum-(-1))+"a.gif";
        document.getElementById("aLantBtn_"+Lant.cycNum).className="now";
        document.getElementById("imgLantBtn_"+Lant.showNum).src="images_child/child_foucs_button0"+(Lant.showNum-(-1))+".gif";
        document.getElementById("aLantBtn_"+Lant.showNum).className="";
        Lant.obIV=setInterval('Lant.change()',Lant.flashTime);
    },

    change:function(){
        if(Lant.opacityNum<100)
        {
            if($.browser.msie )
                document.getElementById("divLantT").style.filter='alpha(opacity='+(Lant.opacityNum)+')';
            else
                document.getElementById("divLantT").style.opacity=(Lant.opacityNum)/100;
            Lant.opacityNum+=20;
        }
        else
        {
            document.getElementById("divLantT").style.display="none";
            document.getElementById("divLant").innerHTML="";
            document.getElementById("divLant").appendChild(document.getElementById("imgLant_"+Lant.cycNum).cloneNode(true));
            document.getElementById("divLant").onclick=function(){
                window.open(Lant.info[Lant.cycNum][1]);
            };
            Lant.showNum=Lant.cycNum;
            Lant.opacityNum=0;
            clearInterval(Lant.obIV);
            Lant.onChange=false;
            Lant.obTO=setTimeout("Lant.cyc()",Lant.cycTime);
        }
    }
}


