// initialize jQTouch
// var jQT = new $.jQTouch({formSelector:false,useFastTouch: false});

$(function(){

    // load-job-more
    $(".more-job-loader").click(function(e){
        e.stopPropagation();
        var $that = $(this);
        var request_param = { page:$(this).data("page")+1
                              , 'limit':$("#limit").val()
                              , 'offset':$("#offset").val()
                              , 'more':1 };
                              
        if ($that.hasClass("loading")){ return false;}
        $that.addClass("loading");
        $.getJSON("./list.php",request_param,function(response){
            $("#limit").val(response.limit);
            $("#offset").val(response.offset);
            $("#add-area").append(response.content);

            if (response.hasMore != true){
                $that.fadeOut().remove();
            }else{
                $that.fadeOut("slow",function(){
                    $(this).appendTo("#job").removeClass("loading").show();
                });
            }
        });
    });
    
    // btn_add_clip
    $(".btn_add_clip").click(function(e){
        e.stopPropagation();
        var job_id = $(this).attr("id");
        var request_param = {'job_id':job_id};
        if ($(this).hasClass("loading")){ return false;}
        $(this).addClass("loading");
        $.getJSON("/sp/job/crip.php",request_param,function(response){
            if(response.result){
                $("#"+response.job_id).text('ﾌﾞｯｸﾏｰｸ済');
                $("#"+response.job_id).unbind('click');
            }
            $("#"+response.job_id).removeClass("loading").show();
        });
    });
    
});


