﻿//--------------------------------------------------//
//			お知らせ情報用
//--------------------------------------------------//


/*-------------------------------------------------*/
/*           定数
/*--------------------------------------------------*/
var GEN_ACTION = "gen_action";
var GEN_BEHAVIOR = "gen_behavior";
var GEN_SERIAL = "gen_serial";
var GEN_LIMIT = "gen_limit";
var GEN_NEXT = "gen_next";
var INFO_BEHAVIOR_LIST = "list";      //一覧用
var DEFAULT_LIMIT = "10";
var DEFAULT_NEXT_INDEX = "0";
var INFO_BEHAVIOR_DETAIL = "detail";  //詳細用
	
//--------------------------------------------------//
//		requestinfoタグ用
//--------------------------------------------------//
function InformationRequestinfo(){
    this.next = 0;
    this.limit = 0;
    this.year = 0;
    this.month = 0;
    this.day = 0;

        //init関数
        this.init = function(xml){
            //requestinfoタグは一行のみ
            var infoList = xml.getElementsByTagName("requestinfo");

            for (i = 0; i < infoList[0].childNodes.length; i++){
                var child = infoList[0].childNodes[i];
                
                if (child.tagName == 'next'){
                    if (child.firstChild){
                        this.next = child.firstChild.nodeValue;
                    } 
                }

                if (child.tagName == 'limit'){
                    if (child.firstChild){
                        this.limit = child.firstChild.nodeValue;
                     }
                }

                if (child.tagName == 'date'){
                    this.year = child.getAttribute("year");
                    this.month = child.getAttribute("month");
                    this.day = child.getAttribute("day");
                }
            }//for
       }//init

       this.getNext = function(){
            return this.next;
       }

       this.getLimit = function(){
            return this.limit;
       }

       this.getYear = function(){
            return this.year;
       }

       this.getMonth = function(){
            return this.month;
       }

       this.getDay = function(){
            return this.day;
        }
}


//---------------------------------------------------------//
 //			informationmetaタグ用
 //---------------------------------------------------------//
function InformationMetaData(){
    this.nextFlag = -1;
    this.lastNextFlag = -1;
    this.lastPrevFlag = -1;
    this.prevFlag = -1;
    this.listCount = 1;//データ件数は一件
  
        this.init = function(xml){
            var index = 0;//eventMetaのデータは一件のみ
            var dataList = xml.getElementsByTagName("informationmeta");
            this.nextFlag = dataList[index].getAttribute("nextflag");
            this.lastNextFlag = dataList[index].getAttribute("lastnextflag");
            this.lastPrevFlag = dataList[index].getAttribute("lastprevflag");
            this.prevFlag = dataList[index].getAttribute("prevflag");
           
        }//init

        this.getNextFlag = function(){
            return this.nextFlag;
        }

        this.getLastNextFlag = function(){
            return this.lastNextFlag;
        }

        this.getPrevFlag = function(){
            return this.prevFlag;
        }

        this.getLastPrevFlag = function(){
            return this.lastPrevFlag;
        }

		this.getListCount = function(){
			return this.listCount;
		}
 }
 
 
 //---------------------------------------------------------//
 //			datainfoタグ用
 //---------------------------------------------------------//
 function InformationDataInfo(){
 	 this.listCount;
 	 this.provider;
 	 this.serial;
 	 this.user;
 	 this.kikan;
 	 this.title;
 	 this.description;
 	 this.url;
 	 this.email;
 	 this.dispmode;
 	 
 	 //初期化
 	 this.init = function(xmlData){
 	 	 this.listCount = 0;
 	 	 this.provider = new Array();
 	 	 this.serial = new Array();
 	 	 this.user = new Array();
 	 	 this.kikan = new Array();
 	 	 this.title = new Array();
 	 	 this.description = new Array();
 	 	 this.url = new Array();
 	 	 this.email = new Array();
 	 	 this.dispmode = new Array();
 	 	 
 	 	 var dataObj = xmlData.getElementsByTagName("datainfo");
 	 	 this.listCount = dataObj.length;
 	 	 
 	 	 for (i = 0; i < this.listCount; i++){
 	 	 	 this.provider[i] = dataObj[i].getAttribute("provider");
 	 	 	 this.serial[i] = dataObj[i].getAttribute("serial");
 	 	 	 this.user[i] = "";
 	 	 	 this.kikan[i] = "";
 	 	     this.title[i] = "";
 	 	     this.description[i] = "";
 	 	     //this.url[i] = "";
 	 	     this.url[i] = new Array();
 	 	 	 this.email[i] = "";
 	 	 	 this.dispmode[i] = "";
 	 	 	 	 
 	 	 	 for (j = 0; j < dataObj[i].childNodes.length; j++){
 	 	 	 	 var child = dataObj[i].childNodes[j];
 	 	 	 	 
 	 	 	 	 if  (child.tagName == "user"){
 	 	 	 	 	 if (child.firstChild){
 	 	 	 	 	 	 this.user[i] = child.firstChild.nodeValue;
 	 	 	 	 	 }
 	 	 	 	 }
 	 	 	 	 
 	 	 	 	 if  (child.tagName == "dates"){
 	 	 	 	 	 if (child.firstChild){
 	 	 	 	 	 	 this.kikan[i] = child.firstChild.nodeValue;
 	 	 	 	 	 }
 	 	 	 	 }
 	 	 	 	 
 	 	 	 	 if  (child.tagName == "title"){
 	 	 	 	 	 if (child.firstChild){
 	 	 	 	 	 	 this.title[i] = child.firstChild.nodeValue;
 	 	 	 	 	 }
 	 	 	 	 }
 	 	 	 	 
 	 	 	 	 if  (child.tagName == "description"){
 	 	 	 	 	 if (child.firstChild){
 	 	 	 	 	 	 this.description[i] = child.firstChild.nodeValue;
 	 	 	 	 	 }
 	 	 	 	 }
 	 	 	 	 
 	 	 	 	 if  (child.tagName == "url"){
 	 	 	 	 	 if (child.firstChild){
 	 	 	 	 	 	 //this.url[i] = child.firstChild.nodeValue;
 	 	 	 	 	 	 var urlObj = child.firstChild.nodeValue;
 	 	 	 	 	 	 var arrObj = urlObj.split(",");
 	 	 	 	 	 	 for (k = 0; k < arrObj.length; k++){
 	 	 	 	 	 	 	 this.url[i][k] = arrObj[k];
 	 	 	 	 	 	 }
 	 	 	 	 	 }
 	 	 	 	 }
 	 	 	 	 
 	 	 	 	 if  (child.tagName == "email"){
 	 	 	 	 	 if (child.firstChild){
 	 	 	 	 	 	 this.email[i] = child.firstChild.nodeValue;
 	 	 	 	 	 }
 	 	 	 	 }
 	 	 	 	 
 	 	 	 	 if  (child.tagName == "dispmode"){
 	 	 	 	 	 if (child.firstChild){
 	 	 	 	 	 	 this.dispmode[i] = child.firstChild.nodeValue;
 	 	 	 	 	 }
 	 	 	 	 }
 	 	 	 }//for-j
 	 	 }//for-i
 	 }//init
 	 
 	 this.getListCount = function(){
 	 	 return this.listCount;
 	 }
 	 
 	 this.getProvider = function(){
 	 	 return this.provider;
 	 }
 	 
 	 this.getSerial = function(){
 	 	 return this.serial;
 	 }
 	 
 	 this.getUser = function(){
 	 	 return this.user;
 	 }
 	 
 	 this.getKikan = function(){
 	 	 return this.kikan;
 	 }
 	 
 	 this.getTitle = function(){
 	 	 return this.title;
 	 }
 	 
 	 this.getDescription = function(){
 	 	 return this.description;
 	 }
 	 
 	 this.getURL = function(){
 	 	 return this.url;
 	 }
 	 
 	 this.getEMail = function(){
 	 	 return this.email;
 	 }
 	 
 	 this.getDispMode = function(){
 	 	 return this.dispmode;
 	 }
 }
 
