//加载行为逻辑,需要jQuery库
$(document).ready(function(){
    //根据锚点定位图片
    var url = getHref();
    var pos = url.indexOf("#id=");
    if (pos != -1) {
        var id = parseInt(url.substr(pos + 4)-1);
        if (id > 0) {
            changeImg(id);
        }
    }
    //速度控制
    $("input[name='ppt_speed']").each(function(){
      $(this).click(function(){
        if ($(this).attr('id') == 'auto_play_button'){
          if(autoPlayer) autoPlayer.play();
        }else{
          if(autoPlayer) {
              autoPlayer.set_speed($(this).val());
              if (autoPlayer._flag == 0)autoPlayer.start();
          }
        }
      });
    });
    //增加鼠标，移进、移出、点击事件
    $('#on_img').mouseover(function(){
        if (autoPlayer && autoPlayer._pause == 0) autoPlayer.pause();
        $(this).css('cursor','pointer');
    }).mouseout(function(){
        if (autoPlayer && autoPlayer._pause == 1) autoPlayer.resume();
        $(this).css('cursor','auto');
//        $('#prevPhotoCursor,#nextPhotoCursor').hide();
    }).mousemove(function(e){
        var img = $('#on_img');
        var direction = (e.pageX - img.offset().left)/img.width()>0.5;
        if (direction){
            $(this).css('cursor','url('+'../images/right.cur'+'),auto');
        }else{
            $(this).css('cursor','url('+'../images/left.cur'+'),auto');
        }
    }).click(function(e){
        var direction = (e.pageX - $(this).offset().left)/$(this).width()>0.5;
        changePic(direction);
    });
    $("#on_img").bind('load',function(){
        if (autoPlayer) autoPlayer.next();
        if (preloadPhoto) preloadPhoto();
    });

    //左右滚动按钮事件
    $('#leftSlide').attr('href','javascript:slide(false);');
    $('#rightSlide').attr('href','javascript:slide(true);');

    //显示播放速度
    if (autoPlayer) $("#ppt_"+autoPlayer.get_speed()).attr('checked',true);
});
