window.tws=window.tws||{};window.tws.toLoad=window.tws.toLoad||[];window.tws.toLoad.push('residentPeriodDateCompare');window.tws.residentPeriodDateCompare=function(){var language=tws.language||'japanese';var archiveYear=$("subtitle").innerHTML.split("年")[0];var yearlyXmlPath='../'+archiveYear+'.xml';var httpObj=new JKL.ParseXML(yearlyXmlPath+'?cache='+(new Date).getTime());httpObj.setOutputArrayElements(['root','data','archiveyearly']);httpObj.async(onLoadCheckIfNextYearIsExist);httpObj.parse();function onLoadCheckIfNextYearIsExist(data){var lastYearOfExhist=data.root[0].archiveyearly[0];if(lastYearOfExhist>archiveYear){var nextYearlyXmlPath='../'+(parseInt(archiveYear)+1)+'.xml';var httpObj=new JKL.ParseXML(nextYearlyXmlPath+'?cache='+(new Date).getTime());httpObj.setOutputArrayElements(['root','data','archiveyearly']);httpObj.async(onLoadInjectNextYear);httpObj.parse()}}function onLoadInjectNextYear(data){for(var i=data.root[0].data.length-1;0<=i;i--){var startyear=data.root[0].data[i].residencestart.split("-")[0];if(startyear<=archiveYear){var target=$$('ul.yearly')[0];var addelement=new Element('li');addelement.set('html',data.root[0].data[i].residenthtml);addelement.injectTop(target)}}}};
