﻿function SwichHotEShop(Id, hidId)
{
    if($('li'+Id).className !=  'Current')
    {
        $('li'+Id).className = 'Current';
        $(Id).style.display = 'block';
        $('li'+hidId).className = '';
        $(hidId).style.display = 'none';
    }        
}
function ImageRepeat(arrAdData)//广告轮换
{
    this.Count = arrAdData.length;
    this.Timer = null;
    this.CurrentImg = -1;    //当前图片数组下标
    this.TransType = 'reveal'; // 'reveal' | 'blend' 
    this.DurationTime = 2000; //毫秒
    this.Transition = 23; //滤镜总数
    this.IntermissionTime = 6000; //毫秒 间隔   
    this.ImgData = arrAdData;        
    this.DoFilter = function () //滤镜的启动 
    {     
        if(this.CurrentImg == -1)
        {
            $('0').style.color = 'White';
            $('0').style.backgroundColor = '#fc6602';            
        }
        else
        {
            $(this.CurrentImg).style.color = 'White';
            $(this.CurrentImg).style.backgroundColor = '#fc6602';            
        }                    
     
        if( this.CurrentImg == (this.ImgData.length - 1)) { 
            this.CurrentImg = -1;                 
        }
        if(document.all){ 
            with($('ImageRepeat')) { 
                if(this.TransType == 'reveal') { 
                    filters(0).transition = this.Transition; 
                } 
                this.CurrentImg++;
                filters(0).apply(); 
                src = _CityPicUrl+'ASD/'+this.ImgData[this.CurrentImg].LA_ImagePath; 
                filters(0).play();
            } 
        } 
        else{
            this.CurrentImg++; 
            $('ImageRepeat').src = _CityPicUrl+'ASD/'+this.ImgData[this.CurrentImg].LA_ImagePath;
        }
        $('ImageRepeat').parentNode.target = this.ImgData[this.CurrentImg].LA_Target;
        $('ImageRepeat').parentNode.href = this.ImgData[this.CurrentImg].LA_LinkUrl;
        $(this.CurrentImg).style.color = '#fc6602'; 
        $(this.CurrentImg).style.backgroundColor = 'White';       
    };
    this.ClearTimer = function()
    {
        window.clearInterval(this.Timer); 
    };
    this.Start = function()
    {
        var repeat = this;
        this.Timer = window.setInterval(function ()
        {
            repeat.DoFilter(); 
        },this.IntermissionTime); 
    };
    //构造
    (function()
    { 
        var repeat = this;           
        for(var i=0; i<this.ImgData.length; i++)
        {
            if(i==0)
            {
                $('HotFeature').innerHTML += '<span id="'+i+'" onclick="spanClick(this.id)" style="cursor:pointer;color:#fc6602;border:solid 1px #f0510a;padding:2px 4px;position:absolute;bottom:10px;right:'+(10+(this.ImgData.length-i-1)*20)+'px;background-color:#fffff;font-family:宋体">'+(i+1)+'</span>';
            }
            else
            {
                $('HotFeature').innerHTML += '<span id="'+i+'" onclick="spanClick(this.id)" style="cursor:pointer;color:White;border:solid 1px #f0510a;padding:2px 4px;position:absolute;bottom:10px;right:'+(10+(this.ImgData.length-i-1)*20)+'px;background-color:#fc6602;font-family:宋体">'+(i+1)+'</span>';
            }
        }                

        if(document.all)
        {
            with($('ImageRepeat')){ 
               style.filter = (this.TransType == 'reveal')? 'revealTrans':'blendTrans'; 
               style.filter.duration = this.DurationTime; 
               style.filter.transition = this.Transition; 
             } 
        }
        this.DoFilter();            
        this.Start();
    }).call(this);
}
var _Repeat;
window.onload = function()
{
    var adUrl1 = _DataCenterUrl+'local/AD.aspx?citycode='+_CityCode+'&l='+_Language+'&req=1&key='+_AdKeyword[1]; 
    ENetwork.DownloadScript(adUrl1, function(){
        if(typeof LocalAd != 'undefined' && LocalAd.length > 0)
        {  
            _Repeat = new ImageRepeat(LocalAd);
        }
    })           
}
window.onunload = function()
{
    if(_Repeat != null)
    {
        _Repeat.ClearTimer();
    }
}

function spanClick(id) 
{
    for(var i=0; i<_Repeat.ImgData.length;i++)
    {
        if(i==parseInt(id))
        {
            $(i.toString()).style.color = '#fc6602'; 
            $(i.toString()).style.backgroundColor = 'White';  
        }
        else
        {
            $(i.toString()).style.color = 'White';
            $(i.toString()).style.backgroundColor = '#fc6602';
        }
    }
    _Repeat.CurrentImg = parseInt(id);
     if(document.all){ 
        with($('ImageRepeat')) { 
            if(_Repeat.TransType == 'reveal') { 
                filters(0).transition = _Repeat.Transition; 
            }                 
            filters(0).apply(); 
            src = _CityPicUrl + 'ASD/' + _Repeat.ImgData[_Repeat.CurrentImg].LA_ImagePath; 
            filters(0).play();
        } 
    } 
    else{
        $('ImageRepeat').src = _CityPicUrl + 'ASD/' + _Repeat.ImgData[_Repeat.CurrentImg].LA_ImagePath;
    }
    $('ImageRepeat').parentNode.target = _Repeat.ImgData[_Repeat.CurrentImg].LA_Target;
    $('ImageRepeat').parentNode.href = _Repeat.ImgData[_Repeat.CurrentImg].LA_LinkUrl;
}
