function memberParts(memberId) {
        $.ajax({
                type:'get',
                url:'http://api-paco.ameba.jp/parts/recent',
                data:{"memberId":memberId,"page":1,"limit":12},
                dataType:'jsonp',
                success:function(data){
                        var tmp = '';
                        $(data.partsList).each(function(){
                                if (this.tag != null) {
                                        tmp += '<li><h3>' + this.tag + '</h3>';
                                } else {
                                        tmp += '<li><h3></h3>';
                                }
                                tmp += '<a href="/parts/detail.do?partsId=' + this.partsId + '&categoryId=' + this.categoryId + '">';
                                tmp += '<img width="60px" height="60px" src="' + this.thumbnailPath + '" /></a>';
                                tmp += '</li>';
                        });
                        $('.partsLi').html(tmp);
        },
        error:function(data){
        }
        });
        return false;
}

function addFavorite(partsId, partsCategoryId) {
        $.ajax({
                 type:'post',
                 url:'http://api-paco.ameba.jp/api/favorite.do',
                 dataType:'xml',
                 data:{"partsId":partsId,"partsCategoryId":partsCategoryId,"slotId":1},
                 success:function(data){
                         
                 },
                 error:function(data){
                         
                 }
        });
}
$(document).ready( function() {
        //popular parts
        $('#popularparts').attr('href','javascript:void(0);').click(function(){
                $.ajax({
                        type:'get',
                        url:'http://api-paco.ameba.jp/parts/popular',
                        dataType:'jsonp',
                        success:function(data){
                                var tmp = '';
                                $(data.partsList).each(function(){
                                if (this.tag != null) {
                                        var str = "";
                                        if (this.tag instanceof Array ){
                                                str = this.tag[0];
                                        } else {
                                                str = this.tag;
                                        }
                                tmp += '<li><h3><a href="/search/result.do?page=1&partsCategoryId=' + this.categoryId + '&keyword=' + str + '">' + str + '</a></h3>';
                                } else {
                                tmp += '<li>';
                                }
                                tmp += '<a href="/parts/detail.do?partsId=' + this.partsId + '&categoryId=' + this.categoryId + '">';
                                tmp += '<img src="' + this.thumbnailPath + '" /></a>';
                                tmp += '</li>';
                                });
                                $('.partsLi:first').html(tmp);
                        },
                        error:function(data){
                                
                        }
                });
        return false;
        });
        $('#newparts').attr('href','javascript:void(0);').click(function(){
                $.ajax({
                        type:'get',
                        url:'http://api-paco.ameba.jp/parts/new',
                        dataType:'jsonp',
                        success:function(data){
                                var tmp = '';
                                $(data.partsList).each(function(){
                                tmp += '<li>';
                                if (this.tag != null) {
                                        var str = "";
                                        if (this.tag instanceof Array ){
                                                str = this.tag[0];
                                        } else {
                                                str = this.tag;
                                        }
                                        tmp += '<h3><a href="/search/result.do?page=1&partsCategoryId=' + this.categoryId + '&keyword=' + str + '">' + str + '</a></h3>';
                                }       
                                tmp += '<a href="/parts/detail.do?partsId=' + this.partsId + '&categoryId=' + this.categoryId + '">';
                                tmp += '<img src="' + this.thumbnailPath + '" /></a>';
                                tmp += '</li>';
                                });
                                $('.partsLi:last').html(tmp);
                        },
                        error:function(data){
                                
                        }
                });
        return false;
        });
});

function member(memberId,page,limit){
                $.ajax({
                        type:'get',
                        url:'http://api-paco.ameba.jp/parts/recent',
                        data:{"memberId":memberId,"page":page,"limit":limit},
                        dataType:'jsonp',
                        success:function(data){
                                var tmp = '';
                                $(data.partsList).each(function(){
                                if (this.tag != null) {
                                        var str = "";
                                        if (this.tag instanceof Array ){
                                                str = this.tag[0];
                                        } else {
                                                str = this.tag;
                                        }
                                        tmp += '<li><h3><a href="/search/result.do?page=1&partsCategoryId=' + this.categoryId + '&keyword=' + str + '">' + str + '</a></h3>';
                                } else {
					tmp += '<li>';
				}       
                                tmp += '<a href="/parts/detail.do?partsId=' + this.partsId + '&categoryId=' + this.categoryId + '">';
                                tmp += '<img width="94px" height="94px" src="' + this.thumbnailPath + '" /></a>';
                                tmp += '</li>';
                                });
                                $('.partsLi').html(tmp);
                        },
                        error:function(data){
                        }
                });
}
function recentComic(memberId,page,limit){
                $.ajax({
                        type:'get',
                        url:'http://api-paco.ameba.jp/comic/recent',
                        data:{"memberId":memberId,"page":page,"limit":limit},
                        dataType:'jsonp',
                        success:function(data){
                                var tmp = '';
                                $(data.partsList).each(function(){
                                if (this.tag != null) {
                                        var str = "";
                                        if (this.tag instanceof Array ){
                                                str = this.tag[0];
                                        } else {
                                                str = this.tag;
                                        }
                                        tmp += '<li><h3><a href="/search/result.do?page=1&partsCategoryId=' + this.categoryId + '&keyword=' + str + '">' + str + '</a></h3>';
                                }       
                                tmp += '<a href="/parts/detail.do?partsId=' + this.partsId + '&categoryId=' + this.categoryId + '">';
                                tmp += '<img width="60px" height="60px" src="' + this.thumbnailPath + '" /></a>';
                                tmp += '</li>';
                                });
                                $('.partsLi').html(tmp);
                        },
                        error:function(data){
                                
                        }
                });
        return false;
}
//画像リサイズﾞ onload、非table式
function imageResize(imgObj,imageMaxSizeCount){
        var imageMaxSize = imageMaxSizeCount + "px";
        var imageWidth = imgObj.width;
        var imageHeight = imgObj.height;
        //imageMaxSize以下用
        var minImageTop = Math.abs(Math.round((imageMaxSizeCount - imageWidth) / 2)) + "px";
        if (imageMaxSizeCount > imageHeight) {
                imgObj.style.paddingTop = Math.abs(Math.round((imageMaxSizeCount - imgObj.height) / 2))  + "px";
                imgObj.style.width = imageWidth  + "px";
                imgObj.style.height = imageHeight  + "px";              
        }
}

