/**
 *@class CategoryAll
 *@extends Div
 */


var CategoryAll = Class.create();


CategoryAll.prototype = Object.extend(new Div, {


	/**
	 *@constructor initialize
	 */
	initialize: function (id,parentObj) {
		this.id=id;
		this.parentObj=parentObj;


		this.createDiv();
		//this.display();
		this.setStyle();


		this.categoryNum=0;
		this.category_id=new Array();
		this.category_name=new Array();
		this.category_display_name=new Array();
		this.category_color=new Array();
		this.category_priority=new Array();


		this.reqCategory();
	},



	/**
	 *display
	 */
	display: function () {
		var html=this.id;
		$(this.id).innerHTML=html;
	},



	/**
	 *reqCategory
	 *DBのcategoryテーブルからデータをリクエスト
	 */
	reqCategory: function(){


		/* Ajax.Request */
		var req = new Ajax.Request("../src/php/request/category.php",{
			method: "get",
			parameters: "",
			asynchronous: false
			//onComplete: this.reqCategoryCallBack.bind(this)
		});


		/* json */
		var json=eval("("+req.transport.responseText+")");


		/* set array */
//		if(brwType==IE){
//			this.categoryNum=json.category.length-1;
//		}else{
			this.categoryNum=json.category.length;
//		}
		for(var i=0;i<this.categoryNum;i++){
			this.category_id[i] = json.category[i].category_id;
			this.category_name[i] = json.category[i].category_name;
			this.category_display_name[i] = json.category[i].category_display_name;
			this.category_color[i] = json.category[i].category_color;
			this.category_priority[i] = json.category[i].category_priority;
		}



		//console.log(this.category_id);
		//console.log(this.category_name);
		//console.log(this.category_display_name);
		//console.log(this.category_color);
		//console.log(this.category_priority);


	},


	/**
	 *getCategoryDisplayName
	 */
	getCategoryDisplayName: function (category_id) {
		for(var i=0;i<this.categoryNum;i++){
			if(category_id==this.category_id[i]){
				return this.category_display_name[i];
			}
		}
	},


	/**
	 *getCategoryNo
	 */
	getCategoryNo: function (category_id) {
		for(var i=0;i<this.categoryNum;i++){
			if(category_id==this.category_id[i]){
				return i;
			}
		}
	},



	/**
	 *setStyle
	 */
	setStyle: function () {
		Element.setStyle($(this.id),{
			//backgroundColor	:'#eeeeee',


			marginLeft		:'0px',
			marginRight		:'0px',
			marginTop		:'10px',
			marginBottom	:'0px',
			paddingLeft		:'0px',
			paddingRight	:'0px',
			paddingTop		:'0px',
			paddingBottom	:'0px',


			position		:'relative'	//配置方式:static(default),relative,absolute,fixed,inherit
		});
	}






});
