//使用定数
var EVENT_YEAR = "eventyear";
var EVENT_MONTH = "eventmonth";
var EVENT_SERVLET_FLAG = "serv";
var EVENT_SERIAL = "serial";
var EVENT_PROVIDER = "provider";
var EVENT_START_INDEX = "start";

//リンク情報
var EVENT_LINK_URL = "./KankoSearch?&act=rank&bhvr=dtl&prov=0&srl=";


//requestinfoタグ用
function EventRequestinfo(){
    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;
        }
}


//eventMetaタグ用
function EventMetaData(){
    this.nextFlag = -1;
    this.lastNextFlag = -1;
    this.lastPrevFlag = -1;
    this.prevFlag = -1;
    this.lastYear = 0;
    this.lastMonth = 0;
    this.nowYear = 0;
    this.nowMonth = 0;
    this.prevYear = 0;
    this.prevMonth = 0;
    this.modifyDate = null;

        this.init = function(xml){
            var index = 0;//eventMetaのデータは一件のみ
            var dataList = xml.getElementsByTagName("eventmeta");
            this.nextFlag = dataList[index].getAttribute("nextflag");
            this.lastNextFlag = dataList[index].getAttribute("lastnextflag");
            this.lastPrevFlag = dataList[index].getAttribute("lastprevflag");
            this.prevFlag = dataList[index].getAttribute("prevflag");
           
            //タグ位置変更為
            var modifylist = xml.getElementsByTagName("modifydate");
            if (modifylist){
                for (j = 0; j < modifylist[index].childNodes.length; j++){
                    var modifychild = modifylist[index].childNodes[j];

                     if (modifychild.tagName == "dates"){
                        if (modifychild.firstChild){
                            this.modifyDate = modifychild.firstChild.nodeValue;
                         }
                     }
                  }
             }


            for (i = 0; i < dataList[index].childNodes.length; i++){
                var child = dataList[index].childNodes[i];

                if (child.tagName == "lastyear"){
                    if (child.firstChild){
                        this.lastYear = child.firstChild.nodeValue;
                    }
                }

                if (child.tagName == "lastmonth"){
                    if (child.firstChild){
                        this.lastMonth = child.firstChild.nodeValue;
                     }
                }

                if (child.tagName == "nowyear"){
                    if (child.firstChild){
                        this.nowYear = child.firstChild.nodeValue;
                     }
                }

                if (child.tagName == "nowmonth"){
                    if (child.firstChild){
                        this.nowMonth = child.firstChild.nodeValue;
                     }
                }

                if (child.tagName == "nextyear"){
                    if (child.firstChild){
                        this.nextYear = child.firstChild.nodeValue;
                     }
                }

                if (child.tagName == "nextmonth"){
                    if (child.firstChild){
                        this.nextMonth = child.firstChild.nodeValue;
                     }
                }
                /*
                if (child.tagName == "dates"){
                    if (child.firstChild){
                        this.modifyDate = child.firstChild.nodeValue;
                     }
                }*/
            }//for
        }//init

        
        this.getModifyDate = function(){
            return this.modifyDate;
        }

        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.getLastYear = function(){
            return this.lastYear;
        }

        this.getLastMonth = function(){
            return this.lastMonth;
        }

        this.getNowYear = function(){
            return this.nowYear;
        }

        this.getNowMonth = function(){
            return this.nowMonth;
        }

        this.getNextYear = function(){
            return this.nextYear;
        }

        this.getNextMonth = function(){
            return this.nextMonth;
        }

 }
                         
                 
//データ一覧取得用                
function EventData(){
        //datainfo用
        this.listCount = 0;
        this.serial = 0;
        this.provider = 0;
        this.name = null;
        this.dates = null;
        this.place = null;
        this.areaname = null;
        this.eventEnd = null;
        this.linkURL = null;
        this.readData = null;
        this.modifydate = null;

        this.init = function(xml){

            var dataList = xml.getElementsByTagName("datainfo");
            this.listCount = dataList.length;
            this.serial = new Array();
            this.provider = new Array();
            this.name = new Array();
            this.dates = new Array();
            this.place = new Array();
            this.areaname = new Array();
            this.eventEnd = new Array();
            this.linkURL = new Array();
            this.readData = new Array();
            this.modifydate = new Array();

            for (i = 0; i < this.listCount; i++){

                this.serial[i] = dataList[i].getAttribute("serial");
                this.provider[i] = dataList[i].getAttribute("provider");
                this.name[i] = "";
                this.dates[i] = "";
                this.place[i] = "";
                this.areaname[i] = "";
                this.eventEnd[i] = "";
                this.linkURL[i] = "";
                this.readData[i] = "";
                this.modifydate[i] = "";


                for (j = 0; j < dataList[i].childNodes.length; j++){
                    var child = dataList[i].childNodes[j];
                    if (child.tagName == 'name'){
                        if (child.firstChild){
                            this.name[i] = child.firstChild.nodeValue;
                         }
                    }

                    if (child.tagName == "dates"){
                        if (child.firstChild){
                            this.dates[i] = child.firstChild.nodeValue;
                         }
                     }

                     if (child.tagName == "place"){
                        if (child.firstChild){
                            this.place[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "areaname"){
                        if (child.firstChild){
                            this.areaname[i] = child.firstChild.nodeValue;
                         }
                    }

                    if (child.tagName == "eventend"){
                        if (child.firstChild){
                            this.eventEnd[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "base"){
                        if (child.firstChild){
                            var baseNum = child.firstChild.nodeValue;
                                baseNum = parseInt(baseNum);
                            if (baseNum == 0){
                                this.linkURL[i] = "";
                            } else {
                                 this.linkURL[i] = EVENT_LINK_URL + baseNum;
                            }
                        }
                    }

                    if (child.tagName == "readdata"){
                        if (child.firstChild){
                            this.readData[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "modifydate"){
                        if (child.firstChild){
                            this.modifydate[i] = child.firstChild.nodeValue;
                         }
                     }
                }// for j
           }//for i
      }//init

      this.getListcount = function(){
        return this.listCount;
      }

      this.getSerial = function(){
        return this.serial;
      }

      this.getProvider = function(){
        return this.provider;
      }

      this.getName = function(){
        return this.name;
      }

      this.getDate = function(){
        return this.dates;
      }

      this.getPlace = function(){
        return this.place;
      }

      this.getAreaname = function(){
        return this.areaname;
      }

      this.getEventend = function(){
        return this.eventEnd;
     }   

     this.getLinkURL = function(){
        return this.linkURL;
     }

     this.getReadData = function(){
        return this.readData;
     }

     this.getModifyDate = function(){
        return this.modifydate;
     }
}

                 
//イベントピックアップ用                
function EventPickUp(){
        //datainfo用
        this.listCount = 0;
        this.serial = 0;
        this.provider = 0;
        this.name = null;
        this.dates = null;
        this.place = null;
        this.areaname = null;
        this.eventEnd = null;
        this.startIndex = 0;
        this.linkURL = null;
        this.readData = null;
        this.modifydate = null;

        this.init = function(xml){

            var dataList = xml.getElementsByTagName("datainfo");
            this.listCount = dataList.length;
            this.serial = new Array();
            this.provider = new Array();
            this.name = new Array();
            this.dates = new Array();
            this.place = new Array();
            this.areaname = new Array();
            this.eventEnd = new Array();
            this.startIndex = new Array();
            this.linkURL = new Array();
            this.readData = new Array();
            this.modifydate = new Array();

            for (i = 0; i < this.listCount; i++){

                this.serial[i] = dataList[i].getAttribute("serial");
                this.provider[i] = dataList[i].getAttribute("provider");
                this.name[i] = "";
                this.dates[i] = "";
                this.place[i] = "";
                this.areaname[i] = "";
                this.eventEnd[i] = "";
                this.startIndex[i] = "";
                this.linkURL[i] = "";
                this.readData[i] = "";
                this.modifydate[i] = "";


                for (j = 0; j < dataList[i].childNodes.length; j++){
                    var child = dataList[i].childNodes[j];
                    if (child.tagName == 'name'){
                        if (child.firstChild){
                            this.name[i] = child.firstChild.nodeValue;
                         }
                    }

                    if (child.tagName == "dates"){
                        if (child.firstChild){
                            this.dates[i] = child.firstChild.nodeValue;
                         }
                     }

                     if (child.tagName == "place"){
                        if (child.firstChild){
                            this.place[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "areaname"){
                        if (child.firstChild){
                            this.areaname[i] = child.firstChild.nodeValue;
                         }
                    }

                    if (child.tagName == "eventEnd"){
                        if (child.firstChild){
                            this.eventEnd[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "startindex"){
                        if (child.firstChild){
                            this.startIndex[i] = child.firstChild.nodeValue;
                        }
                    }

                     if (child.tagName == "base"){
                        if (child.firstChild){
                            var baseNum = child.firstChild.nodeValue;
                                baseNum = parseInt(baseNum);
                            if (baseNum == 0){
                                this.linkURL[i] = "";
                            } else {
                                 this.linkURL[i] = EVENT_LINK_URL + baseNum;
                            }
                        }
                    }

                    if (child.tagName == "readdata"){
                        if (child.firstChild){
                            this.readData[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "modifydate"){
                        if (child.firstChild){
                            this.modifydate[i] = child.firstChild.nodeValue;
                         }
                     }
                }// for j
           }//for i
      }//init

      this.getListcount = function(){
        return this.listCount;
      }

      this.getSerial = function(){
        return this.serial;
      }

      this.getProvider = function(){
        return this.provider;
      }

      this.getName = function(){
        return this.name;
      }

      this.getDate = function(){
        return this.dates;
      }

      this.getPlace = function(){
        return this.place;
      }

      this.getAreaname = function(){
        return this.areaname;
      }

      this.getEventend = function(){
        return this.eventEnd;
     }   

     this.getStartIndex = function(){
        return this.startIndex;
     }

     this.getLinkURL = function(){
        return this.linkURL;
     }

     this.getReadData = function(){
        return this.readData;
     }

     this.getModifyDate = function(){
        return this.modifydate;
     }
}


//データ詳細取得用                
function EventDetailData(){
        //datainfo用
        this.listCount = 0;
        this.serial = 0;
        this.provider = 0;
        this.prevSerial = 0;
        this.prevProvider = 0;
        this.nextSerial = 0;
        this.nextProvider = 0;
        this.name = null;
        this.dates = null;
        this.place = null;
        this.areaname = null;
        this.description = null;
        this.contactname = null;
        this.contactphone = null;
        this.modifydate = null;
        this.linkURL = null;
        this.readData = null;

        this.init = function(xml){

            var dataList = xml.getElementsByTagName("datainfo");
            this.listCount = dataList.length;
            this.serial = new Array();
            this.provider = new Array();
            this.prevSerial = new Array();
            this.prevProvider = new Array();
            this.nextSerial = new Array();
            this.nextProvider = new Array();
            this.name = new Array();
            this.dates = new Array();
            this.place = new Array();
            this.areaname = new Array();
            this.description = new Array();
            this.contactname = new Array();
            this.contactphone = new Array();
            this.modifydate = new Array();
            this.linkURL = new Array();
            this.readData = new Array();

            for (i = 0; i < this.listCount; i++){

                this.serial[i] = dataList[i].getAttribute("serial");
                this.provider[i] = dataList[i].getAttribute("provider");
                this.prevSerial[i] = dataList[i].getAttribute("prevserial");
                this.prevProvider[i] = dataList[i].getAttribute("prevprovider");
                this.nextSerial[i] = dataList[i].getAttribute("nextserial");
                this.nextProvider[i] = dataList[i].getAttribute("nextprovider");
                this.name[i] = "";
                this.dates[i] = "";
                this.place[i] = "";
                this.areaname[i] = "";
                this.description[i] = "";
                this.contactname[i] = "";
                this.contactphone[i] = "";
                this.modifydate[i] = "";
                this.linkURL[i] = "";
                this.readData[i] = "";

                for (j = 0; j < dataList[i].childNodes.length; j++){
                    var child = dataList[i].childNodes[j];
                    if (child.tagName == 'name'){
                        if (child.firstChild){
                            this.name[i] = child.firstChild.nodeValue;
                         }
                    }

                    if (child.tagName == "dates"){
                        if (child.firstChild){
                            this.dates[i] = child.firstChild.nodeValue;
                         }
                     }

                     if (child.tagName == "place"){
                        if (child.firstChild){
                            this.place[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "areaname"){
                        if (child.firstChild){
                            this.areaname[i] = child.firstChild.nodeValue;
                         }
                    }

                    if (child.tagName == "description"){
                        if (child.firstChild){
                            this.description[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "contactname"){
                        if (child.firstChild){
                            this.contactname[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "contactphone"){
                        if (child.firstChild){
                            this.contactphone[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "modifydate"){
                        if (child.firstChild){
                            this.modifydate[i] = child.firstChild.nodeValue;
                        }
                    }

                    if (child.tagName == "base"){
                        if (child.firstChild){
                            var baseNum = child.firstChild.nodeValue;
                                baseNum = parseInt(baseNum);
                            if (baseNum == 0){
                                this.linkURL[i] = "";
                            } else {
                                 this.linkURL[i] = EVENT_LINK_URL + baseNum;
                            }
                        }
                    }

                    if (child.tagName == "readdata"){
                        if (child.firstChild){
                            this.readData[i] = child.firstChild.nodeValue;
                        }
                    }
                }// for j
           }//for i
      }//init

      this.getListcount = function(){
        return this.listCount;
      }

      this.getSerial = function(){
        return this.serial;
      }

      this.getProvider = function(){
        return this.provider;
      }

      this.getNextSerial = function(){
        return this.nextSerial;
      }

      this.getNextProvider = function(){
        return this.nextProvider;
      }

      this.getPrevSerial = function(){
        return this.prevSerial;
      }

      this.getPrevProvider = function(){
        return this.prevProvider;
      }

      this.getName = function(){
        return this.name;
      }

      this.getDate = function(){
        return this.dates;
      }

      this.getPlace = function(){
        return this.place;
      }

      this.getAreaname = function(){
        return this.areaname;
      }

      this.getDescription = function(){
        return this.description;
     }          

     this.getContactname = function(){
        return this.contactname;
     }

     this.getContactphone = function(){
        return this.contactphone;
     }

     this.getModifydate = function(){
        return this.modifydate;
     }
     
     this.getLinkURL = function(){
        return this.linkURL;
     }

     this.getReadData = function(){
        return this.readData;
     }
}
