// JavaScript Document
function favoriteController(){
	var URL = "/api/bookmark/update"
	
	var msg=
		{
			notyet:'<img src="/images/btn/fav_add.gif" align="absmiddle" alt="お気に入り登録" class="over">',
			already:'<img align="absmiddle" src="/images/btn/fav_del.gif" alt="お気に入り解除" class="over">'
		}
	
	this.callAPI = function(iid,type,msg_box){
			$.ajax({
			dataType: "xml",    
			data: {              
				"itemid":iid,
				"type":type
			},
			cache: false,
			type:"POST",
			url: URL,
			success: function (data) {
				$(data).find("shmo_status").each(function() {
					if($(this).text() == "0"){
						if(type == 1){
							msg_box.html(msg.already);
							msg_box.attr("stats","1");
						}
						if(type == 2){
							msg_box.html(msg.notyet);
							msg_box.attr("stats","0");
						}
					}else if($(this).text() == "3"){
						msg_box.html(msg.already);
						msg_box.attr("stats","1");
					}else{
					}
				});
			},
			error:function(a,b,c){
				//alert(a,b,c);
			}
			});
	}
}