
//クラス定義
var cls_zoome_video = function(arg){
	this.className = "cls_zoome_video";
	this.page = 0;
	this.zoome_data = null;
	this.requestFlg = true;
	this.total = 0;
	this.get_count = 0;
	this.per_page = arg;
	this.zoome_pool_data = null;
}

//メソッド定義
cls_zoome_video.prototype = {

	//画像検索メソッド
	search : function(page) {
		if(!this.requestFlg){
			return true;
		}
		this.page += 1;
		$j.ajax({
			dataType: "json",
			data: {
				"act": "api_getzoome",
				"q": (typeof z_word == "undefined") ? word : z_word,
				"o": ((this.page-1)*this.per_page),
				"l":this.per_page
			},
			url: "/",
			timeout: 3000,
			success: function(data){
				if(data && data['count'] != 0){
					video_search.zoome_video.total = data['count'];
					if(!cls_zoome_video.zoome_data) cls_zoome_video.zoome_data = new Array;
					cls_zoome_video.zoome_data = cls_zoome_video.zoome_data.concat(data['list']);
				}
			}
		});
		return false;
	},

	getImages : function() {

		image = new Array;

		if(cls_zoome_video.zoome_pool_data) {
			image = cls_zoome_video.zoome_pool_data;
			cls_zoome_video.zoome_pool_data = null;
		}
		var data = cls_zoome_video.zoome_data;

		if(data == null){
			this.requestFlg = false;
			return image;
		}

		for( var i=0; i<this.per_page; i++ ) {
			tmp = data.shift();
			if(!tmp){
				//取得できるデータが無い＝結果の末尾
				this.requestFlg = false;
				return image;
			}
			if(tmp['playtime'] == "") continue;
			this.get_count++;
			info  = {};
			info['video'] = tmp['diaryurl'];
			info['thumb'] = tmp['thumburl'][0];
			info['name'] = tmp['title'];
			info['id'] = tmp['diaryurl'].replace("http://zoome.jp/", "");
			image.push(info);
		}

		return image;
	},
	setImages : function(data) {
		cls_zoome_video.zoome_pool_data = data;
	}
};

