
function onBefore() { 
    //这里面，this代表当前img对象
    
    //得到图片编号，设置页码选中状态 图片
    var id = this.id.substring(this.id.lastIndexOf('_')+1,this.id.length);
    var div_id = this.id.replace('_img_'+id,'');
    //$j('#'+div_id+'_nav a').removeClass('pic_selected');
    //$j('#'+div_id+'_nav a[text="'+(parseInt(id)+1)+'"]').addClass('pic_selected');
    var img_desc_list = img_desc_list_dict[div_id];
    if (img_desc_list != null) {
        var msg = img_desc_list[parseInt(id)];
        $j('#'+div_id+'_output').html(msg);
    }
}

function onAfter() { 
}

var img_src_list_dict = {};
var img_desc_list_dict = {};
var target_url_list_dict = {};

function img_slide_inint(div_id,fx,img_src_list,img_desc_list,target_url_list,width,height,timeout) {
    img_src_list_dict[div_id] = img_src_list;
    img_desc_list_dict[div_id] = img_desc_list;
    target_url_list_dict[div_id] = target_url_list;
    //在div中插入图片
    for (i=0;i<img_src_list.length;i++) {
        $j('#'+div_id).append('<img id="'+div_id+'_img_'+i+'" src="'+img_src_list[i]+'" width="'+width+'px" height="'+height+'px" />');
    }
    
    $j('#'+div_id) 
    .after('<div id="'+div_id+'_nav" class="img_nav"></div>') 
    .cycle({ 
        //~ fx:     'fade', 
        fx:     fx, 
        speed:  'slow', 
        timeout: typeof(timeout) == 'undefined'?6000:timeout, 
        //pager:  '#'+div_id+'_nav',
        before:  onBefore, 
        after:   onAfter
    });
    
    $j('#'+div_id+'_nav').after('<div id="'+div_id+'_output" class="output"></div>');

    $j('#'+div_id+' img').hover(
        function() {
            $j('#'+div_id).cycle('pause');
        },
        function() {
            $j('#'+div_id).cycle('resume');
        }
    ).click(
        function() {
            var id = this.id.substring(this.id.lastIndexOf('_')+1,this.id.length);
            var div_id = this.id.replace('_img_'+id,'');
            if (target_url_list_dict != null) {
                eval('var url = target_url_list_dict[div_id][1*id]');
                window.open(url);
            }
            return false;
        }
    );
    //$j('#'+div_id+'_nav a[text="1"]').addClass('pic_selected');
    if (img_desc_list != null) {
        var msg = img_desc_list[0];
        $j('#'+div_id+'_output').html(msg);
    }
}
