﻿/// Flash自动循环播放图片类
function Flash(titId, picId) {
    var titLi = $("#" + titId).find('li');
    var picLi = $("#" + picId).find('li');

    Flash.prototype.MaxLen = titLi.length;
    Flash.prototype.Order = 0;
    Flash.prototype.AutoRunId;


//    titLi.bind('click', function() {
//        clearTimeout(Flash.prototype.AutoRunId);

//        titLi.removeClass("current");
//        $(this).addClass("current");

//        var titleName = $(this).attr("name");
//        var index = title.substring(titleName.indexOf('_') + 1, titleName.length);

//        picLi.attr("style", 'display: none;');
//        var pic = picLi.eq(index).removeAttr("style");
//    });

    titLi.bind('mousemove', function() {
        clearTimeout(Flash.prototype.AutoRunId);

        titLi.removeClass("current");
        $(this).addClass("current");

        var titleName = $(this).attr("name");
        var index = titleName.substring(titleName.indexOf('_') + 1, titleName.length);

        picLi.attr("style", 'display: none;');
        var pic = picLi.eq(index).removeAttr("style");
    });

    titLi.bind("mouseout", function() {
        Flash.prototype.AutoRunId = setTimeout("Flash.prototype.Show()", 1500);
    });


    Flash.prototype.Show = function() {
       
        titLi.removeClass("current");
        titLi.eq(this.Order).addClass("current");

        picLi.attr("style", 'display: none;');
        picLi.eq(this.Order).removeAttr("style");

        this.Order = this.Order + 1;

        if (this.Order == this.MaxLen) {
            this.Order = 0;
        }
        Flash.prototype.AutoRunId = setTimeout("Flash.prototype.Show()", 1500);
    };
}

function CreateFlash(titId, picId) {
    var f = new Flash(titId, picId);
    f.Show();
}
