﻿// ========================================================================
// ROCOCO Library
//
// Copyright (c) 2006-2007, NARO (National Agriculture and Food Research Organization, Japan)
// All rights reserved.
// ------------------------------------------------------------------------
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
//  this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
//  this list of conditions and the following disclaimer in the documentation
//  and/or other materials provided with the distribution.
// 3. Neither the name of NARO (National Agriculture and Food Research
//  Organization, Japan) nor the names of its contributors may be used to
//  endorse or promote products derived from this software without specific
//  prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// ------------------------------------------------------------------------
// ソース形式およびバイナリ形式における再配布および使用は、改変の有無によらず、
// 以下の条件が満たされれば許可する。
// 1. ソースコードの再配布については、上にある著作権表示、この条件一覧および次
//  の免責事項を含めること。
// 2. バイナリ形式の配布については、上にある著作権表示、この条件一覧および次の
//  注意書きが、配布物に含まれる文書または他の資料の中に含めること。
// 3. 特定の書面による許諾なく、農業・食品産業技術総合研究機構の名前およびコン
//  トリビュータの名前を、このソフトウェアから派生した製品の宣伝または販売促進
//  に用いないこと。
//
// 本ソフトウェアは、著作権者とコントリビュータによって「現状のまま」提供されて
// おり、商業利用可能性および特定目的に対する適合性を含みかつこれらに限定されな
// い、いかなる明示または暗黙の保証を放棄します。
// 著作権者またはコントリビュータは、原因および責任理論のいかんを問わず、本ソフ
// トウェアの利用から発生するいかなる契約、無過失責任または不法行為 (過失その他
// を含む）に関係なく、直接的損害、間接的損害、付帯的損害、特別損害、懲罰的損害
// または結果的損害 (代替の物品または役務の入手ならびに業務の中断を含み、かつこ
// れらに限定されない) は、このような損害の可能性を知らされていたとしても、責任
// を負いません。
// ========================================================================
var Rococo = new Object();
if( Rococo.local == null ) {
  Rococo.local = new Object();
}
Rococo.browser = new function() {
  var ua = navigator != null ? navigator.userAgent : null;
  var av = navigator != null ? navigator.appVersion : null;
  if( window.opera ) {
    this.agent = 'op';
  }
  else if( ua != null && ua.indexOf('PlayStation Portable') >= 0 ) {
    this.agent = 'psp';
  }
  else if( ua != null && ua.indexOf("AppleWebKit") >= 0  ) {	// Safariで検索するとAdobeAirがひっかからない(2008/7/26)
    this.agent = 'saf';
  }
  else if( document.layers != null ) {
    this.agent = 'nn';
  }
  else if( document.all != null ) {
    this.agent = 'ie';
  }
  else if( document.getElementById != null ) {
    this.agent = 'moz';
  }
  if( this.agent == 'ie' ) {
    var ix_start = av.indexOf('MSIE',0);
    var av_1 = av.substring(ix_start+5);
    var ix_end = av_1.indexOf(';',0);
    var av_2 = av_1.substring(0,ix_end);
    this.version = av_2.split('.');
  }
  else {
    if( av != null ) {
      var arr = av.split(' ');
      if( arr != null ) {
        var ver = arr[0];
        if( ver != null ) {
          this.version = ver.split('.');
        }
      }
    }
  }
};
Rococo.lang = 'ja';
Rococo.init = new Array();
Rococo.uninit = new Array();
window.onload = function() {
  if( Rococo.init == null ) { return; }
  for( var k in Rococo.init ) {
    var fnc = Rococo.init[k];
    fnc();
  }
};
window.onunload = function() {
  if( Rococo.uninit == null ) { return; }
  for( var k in Rococo.uninit ) {
    var fnc = Rococo.uninit[k];
    fnc();
  }
};
Rococo.local.initOpera = function() {
  if( window.opera ) {
    var fc = document.firstChild;
    if( fc ) {
      var e = document.firstChild.firstChild;
      if( e && e.tagName == null ) {
        fc.removeChild(e);
      }
    }
  }
}
Rococo.init.push(Rococo.local.initOpera);
Rococo.local.vmlready = false;
Rococo.initIeVml = function() {
  if( Rococo.browser.agent == 'ie' && !(Rococo.local.vmlready == true) && document != null && document.namespaces && document.styleSheets ) {
    document.namespaces.add("v","urn:schemas-microsoft-com:vml","#default#VML");
    var sheet = null;
    if( document.styleSheets.length > 0 ) {
      sheet = document.styleSheets[0];
    }
    else {
      sheet = document.createStyleSheet();
    }
    if( sheet != null ) {
      var style = "{behavior: url(#default#VML); display:inline-block;}";
      sheet.addRule("v\\:line",style);
      sheet.addRule("v\\:rect",style);
      sheet.addRule("v\\:roundrect",style);
      sheet.addRule("v\\:oval",style);
      sheet.addRule("v\\:shape",style);
    }
    Rococo.local.vmlready = true;
  }
};
Rococo.ut = new Object();
Rococo.ut.local = new Object();
Rococo.ut.local.digit_str = "0123456789";
Rococo.ut.CssNumberUnit = function(str) {
  str = '' + str;  // numericなものを string に
  this.number = 0;
  this.unit = 'px';
  if( str ) {
    str = str.toLowerCase();
    if( str.match(/^-?([0-9]*\.?[0-9]+|[0-9]+\.)+\s*(pt|mm|cm|pc|in|px|em|ex|%)?\s*$/) ) {
      var snumber = str.replace(/^(-?([0-9\.]+)).*$/,'$1');
      this.number = parseFloat(snumber);
      this.unit = str.replace(/^-?[0-9\.]+([a-z%]+)?$/,'$1' );
      if( this.unit == null || this.unit == '' ) {
        this.unit = 'px';
      }
    }
  }
}
Rococo.ut.CssNumberUnit.prototype.ToString = function() {
  return this.number + this.unit;
}
Rococo.ut.CssNumberUnit.prototype.ToStringNeg = function() {
  return '' + (-this.number) + this.unit;
}
Rococo.ut.local.whitespace = " \t\r\n\0";
Rococo.ut.rtrim = function(str) {
  if( str == null ) {
    return null;
  }
  str = str + '';
  for( var n = str.length-1; n >= 0 && Rococo.ut.local.whitespace.indexOf(str.charAt(n)) >= 0; n-- ) {}
  return str.substr(0,n+1);
};
Rococo.ut.ltrim = function(str) {
  if( str == null ) {
    return null;
  }
  str = str + '';
  var len = str.length;
  for( var n = 0; n < len && Rococo.ut.local.whitespace.indexOf(str.charAt(n)) >= 0 ; n++ ) {}
  if( n == len ) {
    return '';
  }
  else {
    return str.substr(n,len-n);
  }
};
Rococo.ut.trim = function(str) {
  if( str == null ) {
    return null;
  }
  return Rococo.ut.rtrim(Rococo.ut.ltrim(str));
};
Rococo.ut.isNumeric = function( str ) {
  if( str == null ) { return false; }
  var typename = typeof str;
  if( typename != null && typename.toLowerCase() == 'number' ) { return true; }
  str = '' + str;
  if( str == null || str == '' ) { return false; }
  var st = 0;
  var len = str.length;
  for( var n = 0; n < len; n++ ) {
    ch = str.charAt(n);
    if( st == 0 ) {
      if( Rococo.ut.local.digit_str.indexOf(ch) >= 0 || ch == '-' ) { st = 1; }
      else if( ch == '.' ) { st = 2; }
      else { return false; }
    }
    else if( st == 1 ) {
      if( ch == '.' ) { st = 2; }
      else if( Rococo.ut.local.digit_str.indexOf(ch) < 0 ) { return false; }
    }
    else if( st == 2 ) {
      if( Rococo.ut.local.digit_str.indexOf(ch) < 0 ) { return false; }
    }
  }
  return true;
};
Rococo.ut.isDigit = function(str) {
  if( str == null ) { return false; }
  str = '' + str;
  if( str == '' ) { return false; }
  var ch;
  var len = str.length;
  for( var n = 0; n < len; n++ ) {
    ch = str.charAt(n);
    if( Rococo.ut.local.digit_str.indexOf(ch) < 0 ) {
      return false;
    }
  }
  return true;
};
Rococo.ut.isArray = function( obj ) {
  if( !obj ) {
    return false;
  }
  var typename = typeof obj;
  return ( Rococo.ut.isObject(obj) && obj.constructor != null && obj.constructor == Array );
};
Rococo.ut.isObject = function( obj ) {
  var typename = typeof obj;
  return (typename != null && typename.toLowerCase() == 'object');
};
Rococo.ut.getParamArray = function( url ) {
  if( url != null ) {
    var index_cut = url.indexOf("?");
    if( index_cut > 0 && index_cut < url.length - 1 ) {
      var ret = new Object();
      var arr_args = url.substr(index_cut+1).split("&");
      var n;
      for( n = 0; n < arr_args.length; n++ ) {
        var arr_varval = arr_args[n].split("=");
        if( arr_varval != null && arr_varval.length > 0 ) {
          var varname = arr_varval.shift();
          ret[varname] = arr_varval.join("=");
        }
      }
      return ret;
    }
  }
  return null;
};
Rococo.ut.getUrlBody = function( url ) {
  var ret = null;
  if( url != null ) {
    var index_cut = url.indexOf("?");
    if( index_cut > 0 && index_cut < url.length - 1 ) {
      ret = url.substr(0,index_cut);
    }
    else {
      ret = url;
    }
  }
  return ret;
};
Rococo.ut.itoa = function( num, fig ) {
  var minus;
  if( num < 0 ) {
    num = -num;
    minus = true;
  }
  else {
    minus = false;   
  }
  if( fig == null || fig <= 0 ) {
    fig = 1;
  }
  var s_num = '' + num;
  var s_zero = '';
  var diff = fig - s_num.length;
  var n;
  for( n = 0; n < diff; n++ ) {
    s_zero = s_zero + '0';
  }
  var s_minus = '';
  if( minus == true ) {
    s_minus = '-';
  }
  return s_minus + s_zero + s_num;
};
Rococo.ut.encode_uri = function( txt ) {
  if( Rococo.browser == 'ie' ) {
    return escape(txt);
  }
  else {
    return txt;
  }
};
Rococo.ut.getLastMday = function( year, month ) {
  if( month >= 1 && month <= 12 ) {
    var leap = year == null ? 1: ( (year%4==0) && ( (year%400==0)||(year%100!=0) ) ? 1 : 0 );
    return 31-((month+9)%12%5)%2-(month==2?(2-leap):0);   
  }
  else {
    return 31; // always 1-31
  }
}
Rococo.ut.isCorrectDate = function( date ) {
  if( date == false ) { return false; }
  var lastMday = Rococo.ut.getLastMday(date.year,date.month);
  return (date.mday>=1 && date.mday<=lastMday);
};
Rococo.ut.inherit = function( parent, child ) {
  if( parent != null && child != null ) {
    var k;
    for( k in parent ) {
      if( child[k] == undefined ) {
        child[k] = parent[k];
      }
    }
    if( parent.prototype != null ) {
      for( k in parent.prototype ) {
        if( child.prototype[k] == undefined ) {
          child.prototype[k] = parent.prototype[k];
        }
      }
    }
  }
};
Rococo.ut.extentInt = function( value, minvalue, maxvalue, nullvalue ) {
  var v = parseInt(v);
  if( v == null ) {
    v = nullvalue;
  }
  if( v < minvalue ) {
    return minvalue;
  }
  if( v > maxvalue ) {
    return maxvalue;
  }
  return v;
};
Rococo.ut.writeText = function(element,text,append) {
  element.appendChild(document.createTextNode(text));
  return element;
}
Rococo.ut.writeXhtml = function(element,xhtmltext) {
  if( xhtmltext == null ) { return; }
  var xmlDoc = null;
  if( Rococo.ut.isArray(xhtmltext) ) {
    xhtmltext = xhtmltext.join("\n");
  }
  xhtmltext=xhtmltext.toString();
  if( window.DOMParser ) {
    var parser = new DOMParser();
    xmlDoc = parser.parseFromString(xhtmltext,'text/xml');
  }
  else if( window.ActiveXObject ) {
    xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
    xmlDoc.loadXML(xhtmltext);
  }
  if( xmlDoc.childNodes != null ) {
    var len = xmlDoc.childNodes.length;
    for( var n=0; n < len; n++ ) {
      element.appendChild(Rococo.ut.xmlToXhtml(xmlDoc.childNodes[n]));
    }
  }
  return element;
};
Rococo.ut.xmlToXhtml = function(xmlelement) {
  var element = Rococo.em.createElement(xmlelement.tagName);
  var xmlattrs = xmlelement.attributes;
  var len, n;
  len = xmlattrs.length;
  for( n = 0; n < len; n++ ) {
    var xmlattr = xmlattrs[n];
    element.setAttribute(xmlattr.nodeName,xmlattr.nodeValue);
  }
  len = xmlelement.childNodes.length;
  for( n = 0; n < len; n++ ) {
    var child = xmlelement.childNodes[n];
    if( child.nodeType == 3 ) {
      element.appendChild( document.createTextNode(child.nodeValue) );
    }
    else if( child.nodeType == 1 ) {
      element.appendChild( Rococo.ut.xmlToXhtml(child) );
    }
  }
  return element;
};
Rococo.ut.xmlToObject = function( element ) {
  if( element == null ) { return null; }
  var type = element.nodeType;
  if( type == 3 ) {
    return element.nodeValue;
  }
  if( type == 9 ) {
    var ret = new Object();
    if( element.childNodes && element.childNodes.length > 0 ) {
      for( var n = 0; n < element.childNodes.length; n++ ) {
        var ch = element.childNodes[n];
        if( ch && ch.tagName ) {
          ret[ch.tagName] = Rococo.ut.xmlToObject(ch);
        }
      }
    }
    return ret;
  }
  if( type == 1 ) {
    var children = new Object();
    var bChildren = false;
    var txt = '';
    var attrs = element.attributes;
    if( attrs != null && attrs.length > 0 ) {
      var len_attr = attrs.length;
      for( var n_attr = 0; n_attr < len_attr; n_attr++ ) {
        bChildren = true;
        var attr = attrs[n_attr];
        var attrname = attr.nodeName;
        children[attrname] = attr.nodeValue;
      }
    }
    var nodes = element.childNodes;
    if( nodes != null && nodes.length > 0 ) {
      var len = nodes.length;
      for( var n = 0; n < len; n++ ) {
        var node = nodes[n];
        var tagname = node.tagName;
        var chtype = node.nodeType;
        if( chtype == 1 ) {
          bChildren = true;
          var chret = Rococo.ut.xmlToObject(node);
          if( children[tagname] == null ) {
            children[tagname] = chret;
          }
          else if( Rococo.ut.isArray(children[tagname]) ) {
            children[tagname].push(chret);
          }
          else {
            var tmp = children[tagname];
            children[tagname] = new Array();
            children[tagname].push(tmp);
            children[tagname].push(chret);
          }
        }
        else if( chtype == 3 ){
          txt = txt + node.nodeValue;
        }
      }
    }
    if( txt == '' && bChildren == false ) {
      return null;
    }
    if( txt != '' ) {
      if( bChildren ) {
        children['#text'] = txt;
      }
      else {
        return txt;
      }
    }
    return children;
  }
  return null;
};
Rococo.ut.getObjectByPathArray = function( object, arr_path ) {
  if( object == null ) { return null; }
  if( arr_path == null ) { return object; }
  var len = arr_path.length;
  for( var n = 0; n < len; n++ ) {
    var subpath = arr_path[n];
    var child = object[subpath];
    if( child == null ) { return null; }
    object = child;
  }
  return object;
};
Rococo.ut.hideNoScript = function() {
  var arr = document.getElementsByTagName('noscript');
  var len = arr.length;
  for( var n = 0; n < len; n++ ) {
    arr[n].style.display = 'none';
  }
};
Rococo.ut.getElementsByClassName = function(element,className,checkMyself) {
  if( element == null ) {
    element = document;
  }
  var ret = new Array();
  if( checkMyself && element.className == className ) {
    ret.push(element);
  }
  if( element.childNodes ) {
    var children = element.childNodes;
    var len_c = children.length;
    for( var n_c = 0; n_c < len_c; n_c++ ) {
      var result = Rococo.ut.getElementsByClassName(children.item(n_c),className,true);
      if( result ) {
        var len_r = result.length;
        for( var n_r = 0; n_r < len_r; n_r++ ) {
          ret.push(result[n_r]);
        }
      }
    }
  }
  if( ret.length > 0 ) {
    return ret;
  }
  else {
    return null;
  }
};
Rococo.init.push(Rococo.ut.hideNoScript);
Rococo.cl = new Object();
Rococo.cl.local = new Object();
Rococo.cl.locale = new Object();
Rococo.cl.UrlSetting = function( url_body, rparams, method, caller ) {
  this.url_body = url_body;
  this.rparams = rparams;
  this.method = (method!=null && method.toUpperCase()=='POST') ? 'POST' : 'GET';
  this.caller = caller;  // only for jsonp
};
Rococo.cl.UrlSetting.prototype.createFullUrl = function() {
  var arr = new Array();
  if( this.rparams != null && this.rparams != '' ) {
    arr.push(this.rparams);
  }
  var ac = arguments.length;
  for( var n = 0; n < ac; n++ ) {
    if( arguments[n] != null && arguments[n] != '' ) {
      arr.push(arguments[n]);
    }
  }
  if( arr.length > 0 ) {
    return this.url_body+'?'+arr.join('&');
  }
  else {
    return this.url_body;
  }
};
Rococo.cl.DecisionSetting = function( decisionpath, decisionvalue, errorpath ) {
  this.decisionpath = decisionpath;
  this.decisionvalue = Rococo.ut.isArray(decisionvalue) ? decisionvalue : [decisionvalue];
  this.errorpath = errorpath;
};
Rococo.cl.DecisionSetting.prototype.checkStatus = function( object ) {
  if( this.decisionpath == null ) { return true; }
  var target = Rococo.ut.getObjectByPathArray( object, this.decisionpath );
  var len = this.decisionvalue.length;
  for( var n = 0; n < len; n++ ) {
    if( target == this.decisionvalue[n] ) {
      return true;
    }
  }
  return false;
};
Rococo.cl.DecisionSetting.prototype.getMessage = function( object ) {
  if( this.errorpath == null ) { return null; }
  return Rococo.ut.getObjectByPathArray( object, this.errorpath );
};
Rococo.cl.jsonp = new Object();
Rococo.cl.local.jsonp = new Object();
Rococo.cl.locale.jsonp = {
  fail_jsonp : function() {
	  return Rococo.lang == 'en' ?
		'The response JSONP document contains information which indicates ERROR' :
		'応答JSONP文書にエラーを示す情報が含まれていました';
	},
  fail_connection: function() {
	  return Rococo.lang == 'en' ?
		' fail to setup JSONP connection' :
		'JSONP接続に失敗しました';
	},
  connection_timedout: function() {
	  return Rococo.lang =='en' ?
		'JSONP connection timed out' :
		'JSONP接続で制限時間を超過しました';
	},
  connection_canceled: function() {
	  return Rococo.lang == 'en' ?
		'JSONP connection canceled' :
		'JSONP接続をキャンセルしました';
	}
};
Rococo.cl.local.jsonp.reciever = new Object();
Rococo.cl.local.jsonp.reciever.watching = false; // まだウォッチを開始していない
Rococo.cl.local.jsonp.reciever.timeoutms = 30000; // 30秒待機
Rococo.cl.local.jsonp.reciever.watchinterval = 500; // 0.5秒ごと傍受
Rococo.cl.local.jsonp.reciever.holder = new Array(); // ホルダ
Rococo.cl.local.jsonp.reciever.RecCell = function( callback_function ) {
  this.status = 0;
  this.startms = (new Date()).getTime();
  this.callback_function = callback_function;
  this.element = null;
  this.parent = null;
  this.handle = -1;
};
Rococo.cl.local.jsonp.reciever.RecCell.prototype.callback = function(result,succeeded) {
  if( this.status == 1 ) {
    this.result = result;
    this.succeeded = succeeded == null ? true : succeeded;
    this.status = 11;
  }
  else {
    this.status = -1;
  }
};
Rococo.cl.local.jsonp.reciever.RecCell.prototype.firecallback = function() {
  var cbf = this.callback_function;
  var s = this.succeeded;
  var r = this.result;
  this.status = -1;
  if( cbf ) {
    cbf(s,r);
  }
};
Rococo.cl.local.jsonp.reciever.RecCell.prototype.firecancel = function() {
  var cbf = this.callback_function;
  var s = this.succeeded;
  var r = this.result;
  this.status = 23;
  if( cbf ) {
    cbf(s,r);
  }
};
Rococo.cl.local.jsonp.reciever.request = function( urlset, params, callback )  {
  if( callback == null ) { return -1; }
  var obj = new Rococo.cl.local.jsonp.reciever.RecCell(callback);
  if( Rococo.cl.local.jsonp.reciever.watching == false ) {
    setTimeout(Rococo.cl.local.jsonp.reciever.watch,Rococo.cl.local.jsonp.reciever.watchinterval);
    Rococo.cl.local.jsonp.reciever.watching = true;
  }
  Rococo.cl.local.jsonp.reciever.holder.push( obj );
  var ix = 0;
  var len = Rococo.cl.local.jsonp.reciever.holder.length;
  for( var ix = 0; Rococo.cl.local.jsonp.reciever.holder[ix] != obj && ix < len; ix++ ) {}
  if( ix >= len ) {
    callback( { 'status': false, 'error': Rococo.cl.locale.jsonp.lang_message.fail_connection() } );
    return -1;
  }
  obj.handle = ix;
  var parent_list = document.getElementsByTagName('head');
  if( parent_list == null ) { parent_list = document.getElementsByTagName('body'); }
  if( parent_list == null ) { parent_list = document.getElementsByTagName('html'); }
  if( parent_list == null ) {
    callback( { 'status': false, 'error': Rococo.cl.locale.jsonp.fail_connection() } );
    return -1;
  }
  var param_caller = null;
  if( urlset.caller != null ) {
    param_caller = urlset.caller+'='+'Rococo.cl.local.jsonp.reciever.holder['+ix+'].callback';
  }
  obj.element = document.createElement('script');
  obj.parent = parent_list[0];
  obj.element.type = 'text/javascript';
  obj.element.charset = 'utf-8';
  obj.element.setAttribute('defer','defer');
  obj.element.src = urlset.createFullUrl(params,param_caller);
  obj.status = 1;
  var setter = function() {
    obj.parent.appendChild(obj.element);
  };
  setTimeout( setter,0 );
  return ix;
};
Rococo.cl.local.jsonp.reciever.cancel = function( id ) {
  if( !Rococo.cl.local.jsonp.reciever.holder || !Rococo.cl.local.jsonp.reciever.holder[id] ) {
    return;
  }
  if( Rococo.cl.local.jsonp.reciever.holder[id].status == 1 ) {
    Rococo.cl.local.jsonp.reciever.holder[id].status = 21;
  }
};
Rococo.cl.local.jsonp.reciever.watch = function() {
  if( Rococo.cl.local.jsonp.reciever.holder == null ) { return; }
  var nowms = (new Date).getTime();
  var len = Rococo.cl.local.jsonp.reciever.holder.length;
  for( var n = 0; n < len; n++ ) {
    var item = Rococo.cl.local.jsonp.reciever.holder[n];
    if( item != null ) {
      if( item.status == -1 ) {
        if( item.parent != null && item.element != null ) {
          item.parent.removeChild(item.element);
        }
        Rococo.cl.local.jsonp.reciever.holder[n] = null;
      }
      else if( item.status == 11 ) {
        item.status = 12;
        setTimeout('Rococo.cl.local.jsonp.reciever.holder['+n+'].firecallback()',0);
      }
      else if( item.status == 21 ) {
        item.status = 22;
        item.succeeded = false;
        item.result = Rococo.cl.locale.jsonp.connection_canceled();
        setTimeout('Rococo.cl.local.jsonp.reciever.holder['+n+'].firecancel()',0);
      }
      else if( item.status == 1 && item.startms + Rococo.cl.local.jsonp.reciever.timeoutms < nowms ) {
        item.callback(Rococo.cl.locale.jsonp.connection_timedout(), false );
      }
      else if( item.status == 23 && item.startms + Rococo.cl.local.jsonp.reciever.timeoutms < nowms ) {
        item.status = -1;
      }
    }   
  }
  setTimeout(Rococo.cl.local.jsonp.reciever.watch,Rococo.cl.local.jsonp.reciever.watchinterval);
};
Rococo.cl.jsonp.JsonpRequest = function( title, urlset, decisionset ) {
  this.urlset = urlset;
  this.decisionset = decisionset;
  this.title = title;
};
Rococo.cl.jsonp.JsonpRequest.prototype.request = function(vparams, callback) {
  var thisobj = this;
  return Rococo.cl.local.jsonp.reciever.request(
	  thisobj.urlset,
	  vparams,
	  function(status,result) { thisobj.onScriptLoad(status,callback,result); }
	);
};
Rococo.cl.jsonp.JsonpRequest.prototype.cancel = function(id) {
  Rococo.cl.local.jsonp.reciever.cancel(id);
};
Rococo.cl.jsonp.JsonpRequest.prototype.onScriptLoad = function(status,callback,result) {
  if( status == false ) {
    callback(false,result);
    return;
  }
  if( this.decisionset != null ) {
    if( !this.decisionset.checkStatus(result) ) {
      var mess = this.decisionset.getMessage(result);
      if( mess == null ) {
        mess = Rococo.cl.locale.jsonp.fail_jsonp();
      }
      callback( false, mess );
      return false;
    }
  }
  callback( true, result );
  return true;
};
Rococo.cl.xml = new Object();
Rococo.cl.local.xml = new Object();
Rococo.cl.locale.xml = {
  fail_plain : function( caption, reason ) {
	  return Rococo.lang == 'en' ?
		caption+' failed ('+ (reason == null ? 'unkown reason' : reason) +')' :
		caption+' に失敗しました('+ (reason == null ? '原因不明' : reason) +')';
	},
  fail_http: function( caption, http_status ) {
	  return Rococo.lang == 'en' ?
		this.fail_plain(caption,'HTTP error, status='+http_status) :
		this.fail_plain(caption,'HTTP エラー ステータス=' + http_status);
	},
  fail_xml: function() {
	  return Rococo.lang == 'en' ?
		'The response XML document contains information which indicates ERROR' :
		'応答XML文書にエラーを示す情報が含まれていました';
	},
  dupecall: function( caption ) {
	  return Rococo.lang == 'en' ?
		caption+' is now working by another request' :
		caption+' は現在他の処理を実行中です';
	}
};
Rococo.cl.xml.XmlRequest = function( title, urlset, decisionset ) {
  this.urlset = urlset;
  this.decisionset = decisionset;
  this.title = title;
};
Rococo.cl.xml.XmlRequest.prototype.request = function(vparams, callback, data ) {
  var url_full = this.urlset.createFullUrl(vparams);
  var req = window.XMLHttpRequest != null ? new XMLHttpRequest() : new ActiveXObject("MICROSOFT.XMLHTTP");
  var thisobj = this;
  req.onreadystatechange = function() { thisobj.onReadyStateChange(req,callback); }
  req.open(this.urlset.method,url_full,true);
  if( data == null ) { data = ''; }
  req.send(data);
};
Rococo.cl.xml.XmlRequest.prototype.onReadyStateChange = function(req,callback) {
  if( req.readyState != 4 ) { return; }
  if( req.status != 200 ) {
    callback( false, Rococo.cl.locale.xml.fail_http(this.title,req.status) );
    return false;
  }
  var doc = req.responseXML;
  if( doc == null ) {
    callback( true, null );
    return true;
  }
  var result = Rococo.ut.xmlToObject(doc);
  if( this.decisionset != null ) {
    if( !this.decisionset.checkStatus(result) ) {
      var mess = this.decisionset.getMessage(result);
      if( mess == null ) {
        mess = Rococo.cl.locale.xml.fail_xml();
      }
      callback( false, mess );
      return false;
    }
  }
  callback( true, result );
  return true;
};
Rococo.em = new Object();
Rococo.em.local = new Object();
Rococo.em.DEFAULT_CN_PREFIX = 'rococo';
Rococo.em.createElement = function( tagName, cn_prefix, id, attributes ) {
  var element = document.createElement(tagName);
  element = Rococo.em.recreateElement( element, cn_prefix, attributes );
  if( id != null ) { element.id = id; }
  return element;
}
Rococo.em.recreateElement = function( element, cn_prefix, attributes ) {
  if( element.rococo == null ) {
    element.rococo = new Object();
    element.rococo.events = new Object();
    element.rococo.roothandlers = new Object();
    element.rococo.children = new Object();
    element.createChild = function(subid, tagname, subcn, attributes) {
	  return Rococo.em.local.createChild(element,subid,tagname,subcn,attributes);
	};
    element.recreateChild = function(subid, child, subcn, attributes) {
	  return Rococo.em.local.recreateChild(element,subid,child,subcn,attributes);
	};
    element.setChild = function(subid, child) {
	  return Rococo.em.local.setChild(element,subid,child);
	};
    element.getChild = function(subid) {
	  return Rococo.em.local.getChild(element,subid);
	};
    element.clearAllChildren = function() {
	  return Rococo.em.local.clearAllChildren(element);
	};
    element.initValue = function(value) {
	  return Rococo.em.local.initValue(element,value);
	};
    element.getValue = function() {
	  return Rococo.em.local.getValue(element);
	};
    element.setValue = function(value) {
	  return Rococo.em.local.setValue(element, value);
	};
    element.getText = function() {
	  return Rococo.em.local.getText(element);
	};
    element.addEventHandler = function( type, handler ) {
	  return Rococo.em.local.addEventHandler(element,type,handler);
	};
    element.writeText = function( text ) {
	  return Rococo.ut.writeText(element,text);
	};
    element.writeXhtml = function( xhtmltext ) {
	  return Rococo.ut.writeXhtml(element,xhtmltext);
	};
    element.switchVisible = function( visible ) {
	  return Rococo.em.local.switchVisible(element,visible);
	};
    element.createCssClassName = function( subcn ) {
	  return element.rococo.cn_prefix == null ? subcn : element.rococo.cn_prefix + '-' + subcn;
	};
    element.setCssMargin4 = function(top,right,bottom,left) {
	  Rococo.em.local.setCssMargin4(element,top,right,bottom,left);
	};
    element.setCssBorder4 = function(style,color,top,right,bottom,left) {
	  Rococo.em.local.setCssBorder4(element,style,color,top,right,bottom,left);
	};
    element.setCssPadding4 = function(top,right,bottom,left) {
	  Rococo.em.local.setCssPadding4(element,top,right,bottom,left);
	};
    element.getCssProperty = function(name) {
	  return Rococo.em.local.getCssProperty(element,name);
	};
    element.setOpacity = function(opacity) {
	  return Rococo.em.local.setOpacity(element,opacity);
	};
  }
  if( element.tagName.toLowerCase() == 'form' && (element.action == null || element.action== '' ) ) {
    element.action='javascript:void(0)';
  }
  if( element.rococo.cn_prefix == null ) {
    element.rococo.cn_prefix = (cn_prefix!=null) ? cn_prefix : Rococo.em.DEFAULT_CN_PREFIX;
  }
  if( attributes != null ) {
    for( var k in attributes ) {
      if( k.toLowerCase() == 'style' ) {
        for( var s in attributes[k] ) {
          element[k][s] = attributes[k][s];
        }
      }
      else if( k.toLowerCase() == 'value' ) {
        element.initValue(attributes[k]);
      }
      else {
        element[k] = attributes[k];
      }
    }
  }
  var tagname = element.tagName.toLowerCase();
  if( tagname == 'select' ) {
    element.setSelectedIndex = function( value, error_index ) {
	  return Rococo.em.local.setSelectedIndex(element,value,error_index);
	};
  }
  return element;
};
Rococo.em.local.createChild = function( element, subid, tagname, subcn, attributes ) {
  return Rococo.em.local.recreateChild( element, subid, document.createElement(tagname), subcn, attributes );
}
Rococo.em.local.recreateChild = function ( element, subid, child, subcn, attributes ) {
  Rococo.em.recreateElement(child, attributes );
  if( child.id == null || child.id == '' ) {
    child.id = (element.id != null && element.id != '') ? element.id+'-'+subid : subid;
  }
  if( subcn == null ) { subcn = subid; }
  if( subcn != null ) {
    child.className = element.createCssClassName(subcn);
  }
  return child;
};
Rococo.em.local.setChild = function( element, subid, child ) {
  if( subid != null ) {
    Rococo.em.local.unsetChild( element, subid );
    element.appendChild(child);
    element.rococo.children[subid] = child;
  }
  return child;
}
Rococo.em.local.unsetChild = function( element, subid ) {
  if( subid != null && element.rococo.children[subid] != null ) {
    var child = element.rococo.children[subid];
    if( child != null ) {
      element.removeChild(child);
    }
    var newchildren = new Object();
    var key = subid.toLowerCase();
    for( var k in element.rococo.children ) {
      if( k.toLowerCase() != key ) {
        newchildren[k] = element.rococo.children[k];
      }
    }
    element.rococo.children = newchildren;
    return child;
  }
}
Rococo.em.local.clearAllChildren = function(element) {
  while( element.lastChild != null ) {
    element.removeChild( element.lastChild );
  }
  element.rococo.children = new Object();
};
Rococo.em.local.getChild = function( element, subid ) {
  if( subid != null ) {
    return element.rococo.children[subid];
  }
}
Rococo.em.local.initValue = function(element,value) {
  var tagname = element.tagName.toLowerCase();
  if( value == null ) { value = ''; }
  if( tagname == 'input' ) {
    if( element.type.toLowerCase() == 'checkbox' ) {
      element.defaultChecked = value ? true: false;
    }
    else {
      element.defaultValue = value;
    }
  }
  return Rococo.em.local.setValue(element,value);
};
Rococo.em.local.getValue = function( element ) {
  var tagname = element.tagName.toLowerCase();
  if( tagname == 'input' ) {
    if( element.type.toLowerCase() == 'checkbox' ) {
      return element.checked;
    }
    return element.value;
  }
  else if( tagname == 'textarea' ) {
    return element.value;
  }
  else if( tagname == 'select' ) {
    if( element.multiple ) {
      var ret = new Array();
      var arr_opts = element.getElementsByTagName('option');
      var len = arr_opts.length;
      for( var n = 0; n < len; n++ ) {
        if( arr_opts[n].selected ) {
          ret.push(arr_opts[n].value);
        }
      }
      return ret;
    }
    else {
      return element.value;
    }
  }
  else if( element.value != null ){
    return element.value;
  }
  else {
    return Rococo.em.local.extractText(element);
  }
};
Rococo.em.local.extractText = function(element) {
  var children = element.childNodes;
  var len = children.length;
  var ret = '';
  for( var n = 0; n < len; n++ ) {
    var ch = children[n];
    var t = ch.nodeType;
    if( t == 3 ) {
      ret = ret + ch.nodeValue;
    }
    else if( t != 8 ) {
      if( ch.childNodes.length > 0 ) {
        var ch_ret = Rococo.em.local.extractText(ch);
        if( ch_ret != null ) { ret = ret + ch_ret; }
      }
    }
  }
  return ret;
};
Rococo.em.local.setSelectedIndex = function(element,value,error_index) {
  var ix = 0;
  if( error_index != null ) { ix = error_index; }
  if( value != null ) {
    var childNodes = element.getElementsByTagName('option');
    if( childNodes != null ) {
      var len = childNodes.length;
      for( var n = 0; n < len; n++ ) {
        var node = childNodes[n];
        if( node != null && node.value == value ) {
          ix = n;
        }
      }
    }
  }
  element.selectedIndex = ix;
  return ix;
}
Rococo.em.local.setValue = function(element,value) {
  var tagname = element.tagName.toLowerCase();
  if( value == null ) { value = ''; }
  if( tagname == 'input' ) {
    if( element.type.toLowerCase() == 'checkbox' ) {
      element.checked = value ? true: false;
    }
    else {
      element.value = value;
    }
  }
  else if( tagname == 'textarea' ) {
    element.value = value;
  }
  else if( tagname == 'select' ) {
    Rococo.em.local.setSelectedIndex(element,value);
  }
  else {
    Rococo.em.local.clearAllChildren(element);
    element.appendChild(document.createTextNode(value));
  }
  return value;
};
Rococo.em.local.getText = function(element) {
  var tagname = element.tagName.toLowerCase();
  if( tagname == 'select' && !element.multiple ) {
    var ix = element.selectedIndex;
    if( ix >= 0 ) {
      var option = element.getElementsByTagName('option')[ix];
      return Rococo.em.local.extractText(option);
    }
    else {
      return '';
    }
  }
  var value = Rococo.em.local.getValue(element);
  if( value == null ) { return ''; }
  if( tagname == 'select' && element.multiple ) {
    return value.join(',');
  }
  else {
    return value;
  }
};
Rococo.em.local.addEventHandler = function(element,type,handler) {
  if( !(window.opera && element.attachEvent) && element.addEventListener && (Rococo.browser == null || (Rococo.browser.agent != 'psp' && Rococo.browser.agent != 'saf' ))  ) {
    var domeventtype;
    if( type == 'mousewheel' ) {
      domeventtype = 'DOMMouseScroll';
    }
    else {
      domeventtype = type;
    }
    element.addEventListener(domeventtype,handler,false);
  }
  else {
    if( element.rococo.events[type] == null ) {
      element.rococo.events[type] = new Array();
    }
    if( element.rococo.roothandlers[type] == null ) {
      var eventtype = 'on'+type;
      var fnc = function(event) {
	  var len = element.rococo.events[type].length;
	  for( var n = 0; n < len; n++ ) {
	    element.rococo.events[type][n](event);
	  }
	};
      element.rococo.roothandlers[type] = {
	  'handler' : fnc,
	  'eventtype': 'on'+type
	};
      if( element[eventtype] != null ) {
        element.rococo.events[type].push(element[eventtype]);
      }
      if( element.attachEvent ) {
        element.attachEvent( eventtype, fnc );
      }
      else {
        element[eventtype] = fnc;
      }
    }
    element.rococo.events[type].push(handler);
  }
};
Rococo.em.local.setCssMargin4 = function(element,top,right,bottom,left) {
  element.style.marginTop = (top == null ? '0px' : top);
  element.style.marginRight = (right == null ? '0px' : right);
  element.style.marginBottom = (bottom == null ? '0px' : bottom);
  element.style.marginLeft = (left == null ? '0px' : left);
};
Rococo.em.local.setCssBorder4 = function(element,style,color,top,right,bottom,left) {
  element.style.borderStyle = style;
  element.style.borderColor = color;
  element.style.borderTopWidth = (top == null ? '0px' : top);
  element.style.borderRightWidth = (right == null ? '0px' : right);
  element.style.borderBottomWidth = (bottom == null ? '0px' : bottom);
  element.style.borderLeftWidth = (left == null ? '0px' : left);
};
Rococo.em.local.setCssPadding4 = function(element,top,right,bottom,left) {
  element.style.paddingTop = (top == null ? '0px' : top);
  element.style.paddingRight = (right == null ? '0px' : right);
  element.style.paddingBottom = (bottom == null ? '0px' : bottom);
  element.style.paddingLeft = (left == null ? '0px' : left);
};
Rococo.em.local.getCssProperty = function(element,name) {
  if( document.defaultView && document.defaultView.getComputedStyle ) {
    return document.defaultView.getComputedStyle(element, '')[name];
  }
  else if( element.currentStyle ) {
    return element.currentStyle[name];
  }
  else {
    return null;
  }
};
Rococo.em.local.setOpacity = function(element,opacity) {
  var style_key;
  var style_value;
  if( Rococo.browser.agent == 'ie' ) {
    style_key = 'filter';
    style_value = 'alpha(opacity=' + Math.floor(opacity * 100) + ')';
  }
  else if( Rococo.browser.agent == 'moz' ) {
    style_key = 'MozOpacity';
    style_value = Math.floor(opacity * 100) / 100.0;
  }
  else {
    style_key = 'opacity';
    style_value = opacity;
  }
  element.style[style_key] = style_value;
};
Rococo.em.local.switchVisible = function( element, visible ) {
  if( visible == null ) {
    var d = element.style.display;
    visible = !(d == 'block' || d == '');    
  }
  element.style.display = visible ? 'block' : 'none';
  return visible;
};
Rococo.em.addVisibleSwitch = function( element, anchor, type ) {
  if( anchor.rococo == null ) {
    anchor = recreateElement(anchor);
  }
  if( type == null ) {
    type = 'click';
  }
  anchor.addEventHandler(
	  type,
	  function() {
		element.switchVisible();
	  }
	);
};
Rococo.tk = new Object();
Rococo.tk.local = new Object();
Rococo.tk.locale = new Object();
Rococo.tk.preset = {
  emptyline_integer : { value: -1, text: '------' },
  emptyline_string : { value: '', text: '------' }
};
Rococo.tk.Color = function(red,green,blue) {
  this.red = red;
  this.green = green;
  this.blue = blue;
};
Rococo.tk.Color.prototype.join = function(delimiter) {
  if(delimiter == null ) { delimiter = ','; }
  return ''+this.red+delimiter+this.green+delimiter+this.blue;
};
Rococo.tk.Color.prototype.getCssText = function() {
  return 'rgb(' + this.join() + ')';
};
Rococo.tk.Color.prototype.equals = function( color ) {
  return this.red == color.red && this.green == color.green && this.blue == color.blue;
};
Rococo.tk.em = new Object();
Rococo.tk.local.em = new Object();
Rococo.tk.em.createElement = function( tagName, cn_prefix, id, attributes ) {
  var element;
  var t = tagName.toLowerCase();
  var realtagname;
  if( attributes == null ) { attributes = new Object(); }
  if( t == 'date' ) {
    return Rococo.tk.createDate('span',  cn_prefix, id, attributes );
  }
  if( t == 'list' ) {
    attributes.multiple = true;
    realtagname = 'select';
    element = document.createElement('select');
  }
  else if( t == 'checkbox' || t == 'text' || t == 'radio' || t == 'submit' || t == 'button' ) {
    realtagname = 'input';
    attributes.type = t;
  }
  else {
    realtagname = tagName;
  }
  element = document.createElement(realtagname);
  return Rococo.tk.em.recreateElement(element,cn_prefix,id,attributes);
};
Rococo.tk.em.recreateElement = function(element,cn_prefix,id,attributes) {
  var list = null, seq = null, value = null, firstrow = null, legend_setting = null;
  var attr = new Object();
  for( var k in attributes ) {
    var key = k.toLowerCase();
    if( key == 'list' ) {
      list = attributes[k];
    }
    else if( key == 'sequence' ) {
      seq = attributes[k];
    }
    else if( key == 'value' ) {
      value = attributes[k];
    }
    else if( key == 'firstrow' ) {
      firstrow = attributes[k];
    }
    else if( key == 'legend' ) {
      legend_setting = attributes[k];
    }
    else {
      attr[k] = attributes[k];
    }
  }
  element = Rococo.em.recreateElement(element,cn_prefix,attr);
  if( id != null ) { element.id = id; }
  if( element.rococo.tk == null ) {
    element.rococo.tk = new Object();
    if( legend_setting != null && legend_setting.legend != null && legend_setting.target != null ) {
      element.rococo.tk.legend = {
	  'legend': legend_setting.legend,
	  'target': legend_setting.target
	};
      element.setValue = function(value) {
	  Rococo.em.local.setValue(element,value);
	  Rococo.tk.local.em.setColor(element,value);
	};
      element.setColor = function(value) {
	  Rococo.tk.local.em.setColor(element,value);
	};
    }
    else {
      element.setColor = function(value) {};
    }
    element.createChild = function(subid,tagname,subcn,attributes) {
	  var child = Rococo.tk.em.createElement(tagname,null,null,attributes);
	  return element.recreateChild(subid,child,subcn);
	};
  }
  if( element.tagName.toLowerCase() == 'select' ) {
    element.appendOptions = function(arr_textvalue) {
	  Rococo.tk.local.em.appendOptions(element,arr_textvalue);
	};
    element.appendOptionsSequencial = function( setting ) {
	  Rococo.tk.local.em.appendOptionsSequencial( element, setting );
	};
    element.getSelectedValues = function() {
	  return Rococo.tk.local.em.getSelectedValues(element);
	};
    if( firstrow != null ) {
      Rococo.tk.local.em.appendOptions(element,[firstrow]);
    }
    if( list != null ) {
      Rococo.tk.local.em.appendOptions(element,list);
    }
    else if( seq != null ) {
      Rococo.tk.local.em.appendOptionsSequencial(element,seq);
    }
  }
  if( value != null ) {
    element.initValue(value);
  }
  return element;
};
Rococo.tk.local.em.setColor = function(element,value) {
  if( element.rococo.tk.legend == null ) { return null; }
  var legend = element.rococo.tk.legend.legend;
  var target = element.rococo.tk.legend.target;
  if( legend == null || target == null ) { return; }
  var cssText = null;
  var color = legend.getColor(value);
  if( color != null ) {
    var cssText = color.getCssText();
    if( cssText != null ) {
      element.style[target] = cssText;
    }
  }
  return cssText;
};
Rococo.tk.local.em.appendOptions = function( select, arr_textvalue ) {
  var ret = new Array();
  if( arr_textvalue != null ) {
    var len = arr_textvalue.length;
    for( var n = 0; n < len; n++ ) {
      var option = Rococo.em.createElement('option');
      var txtval = arr_textvalue[n];
      var t = txtval.text != null ? txtval.text : txtval.value;
      var v = txtval.value != null ? txtval.value : txtval.text;
      option.value = v != null ? v : '';
      option.appendChild(document.createTextNode(t != null ? t : ''));
      select.appendChild(option);
      ret.push(option);
    }
  }
  return ret;
};
Rococo.tk.local.em.appendOptionsSequencial = function( select, setting ) {
  var firstrow = setting.firstrow;
  var lastrow = setting.lastrow;
  var figure = setting.figure;
  if( firstrow == null || lastrow == null ) {
    return null;
  }
  if( firstrow == lastrow ) {
    return Rococo.tk.appendOptions(select,{text:firstrow,value:firstrow});
  }
  var skipabs = setting.skip == null ? 1 : (setting.skip>=0 ? setting.skip: -setting.skip);
  var skip = firstrow < lastrow ? skipabs : -skipabs;
  var v = firstrow;
  var ret = new Array();
  while( (skip > 0 && v <= lastrow) || (skip < 0 && v >= lastrow) ) {
    var option = document.createElement('option');
    option.value = v;
    option.appendChild(document.createTextNode(Rococo.ut.itoa(v,figure)));
    select.appendChild(option);
    ret.push(option);
    v = v + skip;
  }
  return ret;
};
Rococo.tk.local.em.getSelectedValues = function(element) {
};
Rococo.tk.legend = new Object();
Rococo.tk.local.LinearLegend = new Object();
Rococo.tk.legend.LinearLegend = function(minvalue, maxvalue, minColor, maxColor) {
  this.exValue = [minvalue,maxvalue];
  this.exRed = [minColor.red,maxColor.red-minColor.red];
  this.exBlue = [minColor.blue,maxColor.blue-minColor.blue];
  this.exGreen = [minColor.green,maxColor.green-minColor.green];
};
Rococo.tk.legend.LinearLegend.prototype.getColor = function(value) {
  var r = (value-this.exValue[0])/this.exValue[1];
  if( r < 0 || r > 1 ) { return null; }
  var red = parseInt(r * this.exRed[1] + this.exRed[0]);
  var green = parseInt(r * this.exGreen[1] + this.exGreen[0]);
  var blue = parseInt(r * this.exBlue[1] + this.exBlue[0]);
  var color = new Rococo.tk.Color(red,green,blue);
  return new Rococo.tk.Color(red,green,blue);
};
Rococo.tk.legend.ExtentLegend = function(boundaries,colors) {
  this.colors = colors;
  this.boundaries = boundaries;
};
Rococo.tk.legend.ExtentLegend.prototype.getColor = function(value) {
  var len_b = this.boundaries.length;
  var n_b;
  if( (this.boundaries[0] != null && value < this.boundaries[0])
	|| (this.boundaries[len_b-1] != null && value > this.boundaries[len_b-1]) ) {
    return null;
  }
  for( n_b = 0; n_b < len_b; n_b++ ) {
    var b = this.boundaries[n_b];
    if( b != null && value < b ) {
      return this.colors[n_b-1];
    }
  }
  return this.colors[len_b-2];
};
Rococo.tk.legend.ExtentLegend.prototype.createElementTree = function(element,cn_prefix) {
  var cn_cell, cn_clr, cn_txt;
  if( cn_prefix == null && element.createCssClassName != null ) {
      cn_cell = element.createCssClassName('legendcell');
      cn_clr = element.createCssClassName('color');
      cn_txt = element.createCssClassName('text');
  }
  else {
    if( cn_prefix == null ) { cn_prefix = 'rococo'; }
      cn_cell = cn_prefix+'-legendcell';
      cn_clr = cn_prefix+'-color';
      cn_txt = cn_prefix+'-text';
  }
  var len_b = this.boundaries.length;
  var b4 = '';
  var n = 0;
  if( this.boundaries[0] == null ) {
    b4 = '';
  }
  else {
    b4 = this.boundaries[0];
  }
  for( var nb = 1; nb < len_b; nb++ ) {
    var newval = this.boundaries[nb];
    if( newval == null ) { newval = ''; }
    var cell = document.createElement('div');
    cell.className = cn_cell;
    var clr = document.createElement('div');
    clr.style.backgroundColor = this.colors[nb-1].getCssText();
    clr.className = cn_clr;
    var txt = document.createElement('p');
    txt.className = cn_txt;
    txt.appendChild(document.createTextNode(b4+'-'+newval));
    cell.appendChild(clr);
    cell.appendChild(txt);
    element.appendChild(cell);
    b4 = newval;
  }
  return element;
};
Rococo.tk.legend.DummyLegend = function(settings) {
  this.settings = settings;
};
Rococo.tk.legend.DummyLegend.prototype.getColor = function(value) {
  if( this.settings == null ) { return null; }
  for( var k in this.settings ) {
    var vc = this.settings[k];
    if( vc != null && vc.value != null && vc.value == value ) {
      return this.settings[k].color;
    }
  }
  return null;
};
Rococo.tk.legend.DummyLegend.prototype.createLegendElementTree = function(element,cn_prefix) {
  var cn_cell, cn_clr, cn_txt;
  if( cn_prefix == null && element.createCssClassName != null ) {
      cn_cell = element.createCssClassName('legendcell');
      cn_clr = element.createCssClassName('color');
      cn_txt = element.createCssClassName('text');
  }
  else {
    if( cn_prefix == null ) { cn_prefix = 'rococo'; }
      cn_cell = cn_prefix+'-legendcell';
      cn_clr = cn_prefix+'-color';
      cn_txt = cn_prefix+'-text';
  }
  for( var k in this.settings ) {
    var vc = this.settings[k];
    if( vc != null && vc.value != null && vc.color != null ) {
      var cell = document.createElement('div');
      cell.className = cn_cell;
      var clr = document.createElement('div');
      clr.style.backgroundColor = vc.color.getCssText();
      clr.className = cn_clr;
      var txt = document.createElement('p');
      txt.className = cn_txt;
      txt.appendChild(document.createTextNode(vc.value));
      cell.appendChild(clr);
      cell.appendChild(txt);
      element.appendChild(cell);
    }
  }
  return element;
};
Rococo.tk.local.Date = new Object();
Rococo.tk.locale.Date = new Object();
Rococo.tk.locale.Date.local = {
  monthList: {
	ja: [
	  {text:  1, value:  1}, {text:  2, value:  2}, {text:  3, value:  3},
	  {text:  4, value:  4}, {text:  5, value:  5}, {text:  6, value:  6},
	  {text:  7, value:  7}, {text:  8, value:  8}, {text:  9, value:  9},
	  {text: 10, value: 10}, {text: 11, value: 11}, {text: 12, value: 12}
	],
	en: [
	  {text:'Jan', value:  1}, {text:'Feb', value:  2}, {text:'Mar', value:  3},
	  {text:'Apr', value:  4}, {text:'May', value:  5}, {text:'Jun', value:  6},
	  {text:'Jul', value:  7}, {text:'Aug', value:  8}, {text:'Sep', value:  9},
	  {text:'Oct', value: 10}, {text:'Nov', value: 11}, {text:'Dec', value: 12}
	]
  },
  dateFormat : {
	ja: 'Y年M月D日',
	en: 'D / M , Y'
  }
};
Rococo.tk.locale.Date.dateFormat =  function() {
  return Rococo.tk.locale.Date.local.dateFormat[Rococo.lang=='en'? 'en' : 'ja'];
};
Rococo.tk.locale.Date.monthList = function() {
  return Rococo.tk.locale.Date.local.monthList[Rococo.lang=='en'? 'en' : 'ja'];
};
Rococo.tk.local.Date.pushTextToFormat = function(element,buff) {
  if( buff != null && buff != '' ) {
    element.rococo.dateFormat.push({istext: true, value: buff});
    element.appendChild(document.createTextNode(buff));
  }
};
Rococo.tk.createDate = function(tagname,cn_prefix,id,attributes) {
  return Rococo.tk.recreateDate(document.createElement(tagname),cn_prefix,id,attributes);
};
Rococo.tk.recreateDate = function(element,cn_prefix,id,attributes) {
  if( element.rococo == null ) {
    element = Rococo.tk.em.recreateElement(element,cn_prefix,id);
  }
  var format = null;
  var yearlist = null;
  var value = null;
  if( attributes != null ) {
    format = attributes.format;
    yearlist = attributes.yearlist;
    value = attributes.value;
  }
  element.getLastMday = function() {
	  return Rococo.tk.local.Date.getLastMday(element);
	};
  element.resetMdayList = function() {
	  return Rococo.tk.local.Date.resetMdayList(element);
	};
  element.getValue = function() {
	  return Rococo.tk.local.Date.getValue(element);
	};
  element.setValue = function(value) {
	  return Rococo.tk.local.Date.setValue(element,value);
	};
  element.getText = function() {
	  return Rococo.tk.local.Date.getText(element);
	};
  if( value == null ) {
    var dobj = new Date();
    var y = dobj.getYear();
    value = { year: y < 2000 ? y+1900 : y, month: dobj.getMonth()+1, mday: dobj.getDate() };
  }
  element.rococo.defaultYear = value.year;
  element.rococo.defaultMonth = value.month;
  element.rococo.defaultMday = value.mday;
  element.rococo.dateFormat = new Array();
  if( format == null ) { format = Rococo.tk.locale.Date.dateFormat(); }
  var f_year = false, f_month = false, f_mday = false;
  var len_format = format.length;
  var buff = '';
  for( var n_format = 0; n_format < len_format; n_format++ ) {
    var ch = format.charAt(n_format);
    if( f_year == false && ch == 'y' ) {
      Rococo.tk.local.Date.pushTextToFormat(element,buff);
      buff = '';
      element.rococo.yearType = 'lower';
      element.rococo.yearElement = element.createChild('year','select',null,{'sequence': {firstrow:0, lastrow:99, skip:1, figure: 2}, 'value': value.year%100});
      element.setChild('year',element.rococo.yearElement);
      element.rococo.dateFormat.push({istext: false, value: element.rococo.yearElement, adder: value.year - value.year % 100});
      f_year =true;
    }
    else if( f_year == false && ch == 'Y' ) {
      Rococo.tk.local.Date.pushTextToFormat(element,buff);
      buff = '';
      if( yearlist != null ) {
        element.rococo.yearType = 'select';
        if( buff != null && buff != '' ) {
          element.appendChild(document.createTextNode(buff));
          buff = '';
        }
        element.rococo.yearElement = element.createChild('year','select',null,{'list': yearlist, 'value': value.year});
      }
      else {
        element.rococo.yearType = 'textbox';
        element.rococo.yearElement = element.createChild('year','input',null,{type: 'text', size: 4});
        element.rococo.yearElement.setValue(value.year);
      }
      element.setChild('year',element.rococo.yearElement);
      element.rococo.dateFormat.push({istext: false, value: element.rococo.yearElement, adder: 0});
      f_year = true;
    }
    else if( f_month == false && (ch == 'm' || ch == 'M') ) {
      Rococo.tk.local.Date.pushTextToFormat(element,buff);
      buff = '';
      element.rococo.monthElement =
        element.createChild('month','select',null,{'list':  Rococo.tk.locale.Date.monthList()});
      element.rococo.monthElement.setValue(value.month);
      element.setChild('month',element.rococo.monthElement);
      element.rococo.dateFormat.push({type: 'element', value: element.rococo.monthElement, adder: 0});
      f_month =true;
    }
    else if( f_mday == false && (ch == 'd' || ch == 'D') ) {
      Rococo.tk.local.Date.pushTextToFormat(element,buff);
      buff = '';
      element.rococo.mdayElement =
        element.createChild('mday','select');
      element.setChild('mday',element.rococo.mdayElement);
      Rococo.tk.local.Date.resetMdayList(element);
      element.rococo.mdayElement.setValue(value.mday);
      element.rococo.dateFormat.push({istext: false, value: element.rococo.mdayElement, adder: 0});
      f_mday =true;
    }
    else {
      buff = buff + ch;
    }
  }
  if( f_year && f_month && f_mday ) {
    element.rococo.yearElement.addEventHandler('change',
	function() { Rococo.tk.local.Date.resetMdayList(element); } );
  }
  if( f_month && f_mday ) {
    element.rococo.monthElement.addEventHandler('change',
	function() { Rococo.tk.local.Date.resetMdayList(element); } );
  }
  if( buff != null && buff != '' ) {
    Rococo.tk.local.Date.pushTextToFormat(element,buff);
  }
  return element;
};
Rococo.tk.local.Date.getLastMday = function(element) {
  var y = element.rococo.yearElement != null ? parseInt(element.rococo.yearElement.getValue()) : element.rococo.defaultYear;
  var m = element.rococo.monthElement != null ? parseInt(element.rococo.monthElement.getValue()) : element.rococo.defaultMonth;
  return Rococo.ut.getLastMday(y,m);
};
Rococo.tk.local.Date.resetMdayList = function(element) {
  var mdayElement = element.rococo.mdayElement;
  if( mdayElement == null ) { return; }
  var v = mdayElement.getValue();
  var md = Rococo.tk.local.Date.getLastMday(element);
  element.rococo.mdayElement.clearAllChildren();
  element.rococo.mdayElement.appendOptionsSequencial(
	  {firstrow: 1, lastrow: md }
	);
  if( v != null ) {
    if( v > md ) { mdayElement.setValue(md); }
    else { mdayElement.setValue(v); }
  }
};
Rococo.tk.local.Date.getValue = function(element) {
  var ret = new Object();
  var eY = element.rococo.yearElement;
  var eM = element.rococo.monthElement;
  var eD = element.rococo.mdayElement;
  if( eY != null ) { ret.year = parseInt(eY.getValue()); }
  if( eM != null ) { ret.month = parseInt(eM.getValue()); }
  if( eD != null ) { ret.mday = parseInt(eD.getValue()); }
  return ret;
};
Rococo.tk.local.Date.setValue = function(element,value) {
  if( value == null ) { value = new Date(); }
  var y = value.getYear();
  var m = value.getMonth() + 1;
  var d = value.getDate();
  if( y < 2000 ) { y = y+1900; }
  var eY = element.rococo.yearElement;
  var eM = element.rococo.monthElement;
  var eD = element.rococo.mdayElement;
  if( eY != null ) {
    if( element.rococo.yearType == 'lower' ) {
      eY.setValue(y%100);
    }
    else {
      eY.setValue(y);
    }
  }
  if( eM != null ) { eM.setValue(m); }
  if( eD != null ) { eD.setValue(d); }
  return value;
};
Rococo.tk.local.Date.getText = function(element) {
  var ret = '';
  var arr = element.rococo.dateFormat;
  var len = arr.length;
  for( var n = 0; n < len; n++ ) {
    var obj = arr[n];
    if( obj.istext && obj.value != null ) {
      ret = ret + obj.value;
    }
    else {
      ret = ret + obj.value.getText();
    }
  }
  return ret;
};
Rococo.pnl = new Object();
Rococo.pnl.locale = new Object();
Rococo.pnl.local = new Object();
Rococo.pnl.local.Alert = new Object();
Rococo.pnl.locale.Alert = new Object();
Rococo.pnl.locale.Alert.local = {};
Rococo.pnl.locale.Alert.close = function() {
  return Rococo.lang == 'en' ? 'CLOSE' : '閉じる';
};
Rococo.pnl.locale.Alert.accept = function() {
  return Rococo.lang == 'en' ? 'ACCEPT' : '了承する';
};
Rococo.pnl.locale.Alert.decline = function() {
  return Rococo.lang == 'en' ? 'DECLINE' : '了承しない(続行しません)';
}
Rococo.pnl.createAlert = function(alertlines,type,listener,cn_prefix) {
  return Rococo.pnl.recreateAlert(document.createElement('div'),type,alertlines,listener,cn_prefix);
};
Rococo.pnl.recreateAlert = function(element,visible,cn_prefix) {
  if( element.rococo == null ) {
    element = Rococo.em.recreateElement(element,cn_prefix);
  }
  element.show = function(title,lines,type,listener) {
	  Rococo.pnl.local.Alert.show(element,title,lines,type,listener);
	};
  element.hide = function() {
	  Rococo.pnl.local.Alert.hide(element);
	};
  element.clear = function() {
	  Rococo.pnl.local.Alert.clear(element);
	};
  var div_alertholder = element.createChild('alertholder','div');
  element.setChild('alertholder',div_alertholder);
  var div_background = element.createChild('background','div');
  element.setChild('background',div_background);
  div_background.setOpacity(0.7);
  var div_mainholder = div_alertholder.createChild('mainholder','div');
  div_alertholder.setChild('mainholder',div_mainholder);
  var form_actionholder = div_alertholder.createChild('actionholder','form');
  form_actionholder.action = 'javascript:void(0)';
  div_alertholder.setChild('actionholder',form_actionholder);
  element.switchVisible(visible == null ? false: visible);
};
Rococo.pnl.local.Alert.show = function(element,title,lines,type,listeners) {
  var afnc_accept = new Array();
  var afnc_decline = new Array();
  var afnc_close = new Array();
  if( listeners ) {
    var llen = listeners.length;
    for( var ln = 0; ln < llen; ln++ ) {
      if( listeners[ln].type == 'accept' ) {
        afnc_accept.push(listeners[ln].handler);
      }
      else if( listeners[ln].type == 'decline' ) {
        afnc_decline.push(listeners[ln].handler);
      }
      else if( listeners[ln].type == 'close' ) {
        afnc_close.push(listeners[ln].handler);
      }
    }
  }
  afnc_close.push(function(){element.switchVisible(false);});
  Rococo.pnl.local.Alert.clear(element);
  var alertholder = element.getChild('alertholder');
  var mainholder = alertholder.getChild('mainholder');
  var actionholder = alertholder.getChild('actionholder');
  if( title != null && title != '' ) {
    var h2 = document.createElement('h2');
    h2.appendChild(document.createTextNode(title));
    mainholder.appendChild(h2);
  }
  if( lines != null ) {
    if( !Rococo.ut.isArray(lines) ) {
      lines = [lines];
    }
    var len = lines.length;
    for( var n = 0; n < len; n++ ) {
      mainholder.writeXhtml('<p>'+lines[n]+'</p>');
    }
  }
  var fnc_close = function() {  };
  var input_text;
  if( type == 'confirm' ) {
    var accept = Rococo.pnl.local.Alert.createCB(
			actionholder,
			'accept',
			Rococo.pnl.locale.Alert.accept(),
			[afnc_accept,afnc_close] );
    actionholder.setChild('accept',accept);
    var decline = Rococo.pnl.local.Alert.createCB(
			actionholder,
			'decline',
			Rococo.pnl.locale.Alert.decline(),
			[afnc_decline,afnc_close] );
    actionholder.setChild('decline',decline);
  }
  else {
    var close = Rococo.pnl.local.Alert.createCB(
			actionholder,
			'close',
			Rococo.pnl.locale.Alert.close(),
			[afnc_close] );
    actionholder.setChild('close',close);
  }
  element.switchVisible(true);
  return element;
};
Rococo.pnl.local.Alert.clear = function(element) {
  var alertholder = element.getChild('alertholder');
  var mainholder = alertholder.getChild('mainholder');
  if( mainholder != null ) { mainholder.clearAllChildren(); }
  var actionholder = alertholder.getChild('actionholder');
  if( actionholder != null ) { actionholder.clearAllChildren(); }
  return element;
};
Rococo.pnl.local.Alert.hide = function(element) {
  element.style.display = 'none';
  return element;
};
Rococo.pnl.local.Alert.createCB = function(element,subid,text,aahandlers) {
  var btn = element.createChild(subid,'input');
  btn.type = 'submit';
  btn.value = text;
  if( aahandlers ) {
    var aalen = aahandlers.length;
    for( var aan = 0; aan < aalen; aan++ ) {
      var ahandlers = aahandlers[aan];
      if( ahandlers ) {
        var alen = ahandlers.length;
        for( var an = 0; an < alen; an++ ) {
          btn.addEventHandler('click',ahandlers[an]);
        }
      }
    }
  }
  return btn;
};
Rococo.pnl.local.Panel = new Object();
Rococo.pnl.locale.Panel = new Object();
Rococo.pnl.locale.Panel.local = {};
Rococo.pnl.locale.Panel.openForm = function(title) {
  return Rococo.lang == 'en' ? 'open ' + title : title + 'を開く';
};
Rococo.pnl.locale.Panel.closeForm = function(title) {
  return Rococo.lang == 'en' ? 'close ' + title : title + 'を閉じる';
};
Rococo.pnl.locale.Panel.openHelp = function() {
  return Rococo.lang == 'en' ? 'view help' : 'ヘルプを表示する';
};
Rococo.pnl.locale.Panel.closeHelp = function() {
  return Rococo.lang == 'en' ? 'hide help' : 'ヘルプを非表示にする';
};
Rococo.pnl.locale.Panel.open = function() {
  return Rococo.lang == 'en' ? 'open' : '開く';
};
Rococo.pnl.locale.Panel.close = function() {
  return Rococo.lang == 'en' ? 'close' : '閉じる';
};
Rococo.pnl.createPanel = function( title, need_message, helplines, cn_prefix, opened, childrensettings, childsubcn ) {
  return Rococo.pnl.recreatePanel(document.createElement('div'),title,need_message,helplines,cn_prefix,opened,childrensettings,childsubcn);
};
Rococo.pnl.recreatePanel = function(element,title,need_message,helplines,cn_prefix,opened,childrensettings,childsubcn) {
  if( element.rococo == null ) {
    element = Rococo.tk.em.recreateElement(element,cn_prefix);
  }
  if( element.rococo.panel == null ) {
    element.rococo.panel = new Object();
  }
  element.rococo.panel.childsubcn = childsubcn;
  element.appendItem = function(subid,tagname,subcn,attributes,itemsubcn){
	  return Rococo.pnl.local.Panel.appendItem(element,subid,tagname,subcn,attributes,itemsubcn);
	};
  element.clearAllItems = function() {
	  return Rococo.pnl.local.Panel.clearAllItems(element);
	};
  element.getItem = function(subid) {
	  return Rococo.pnl.local.Panel.getItem(element,subid);
	};
  element.setItem = function(subid,child) {
	  return Rococo.pnl.local.Panel.setItem(element,subid,child);
	};
  element.writeMessageText = function(text,append) {
	  return Rococo.pnl.local.Panel.writeMessageText(element,text,append);
	};
  element.writeMessageXhtml = function(xhtmltext,append) {
	  return Rococo.pnl.local.Panel.writeMessageXhtml(element,xhtmltext,append);
	};
  element.switchMainVisible = function( visible ) {
	  return Rococo.pnl.local.Panel.switchMainVisible( element, visible );
	};
  if( opened == null ) { opened = true; }
  var h2_title, div_rootholder, div_mainholder, a_switchmain, a_switchhelp, div_helpholder;
  if( title != null || helplines != null ) {
    h2_title = element.createChild('title','h2');
    a_switchmain = h2_title.createChild('switchmain','a');
    a_switchmain.href = 'javascript:void(0)';
    a_switchmain.appendChild(document.createTextNode(title));
    h2_title.setChild('switchmain',a_switchmain);
    element.setChild('title',h2_title);
  }
  var div_rootholder = element.createChild('rootholder','div');
  var div_mainholder = div_rootholder.createChild('mainholder','div');
  div_mainholder.style.display = opened ? 'block' : 'none';
  div_rootholder.setChild('mainholder',div_mainholder);
  element.setChild('rootholder',div_rootholder);
  if( a_switchmain != null ) {
    Rococo.em.addVisibleSwitch(div_mainholder,a_switchmain);
    element.changeSwitchMain = function() {
	  return Rococo.pnl.local.Panel.changeSwitchMain(a_switchmain,div_mainholder,title);
	};
    a_switchmain.addEventHandler('click',element.changeSwitchMain);
    element.changeSwitchMain();
  }
  var div_messageholder = null;
  if( need_message == true ) {
    div_messageholder = div_rootholder.createChild('messageholder','div');
    var div_message = div_messageholder.createChild('message','div');
    div_messageholder.setChild('message',div_message);
    div_rootholder.setChild('messageholder',div_messageholder);
    if( a_switchmain != null ) {
      Rococo.em.addVisibleSwitch(div_messageholder,a_switchmain);
    }
    element.rococo.panel.messageholder = div_messageholder;
    element.rococo.panel.message = div_message;
  }
  if( helplines != null ) {
    if( !Rococo.ut.isArray(helplines) ) {
      helplines = [helplines];
    }
    div_helpholder = div_rootholder.createChild('helpholder','div');
    div_helpholder.switchVisible(false);
    var div_help = div_helpholder.createChild('help','div');
    var len = helplines.length;
    for( var n = 0; n < len; n++ ) {
      var p = Rococo.em.createElement('p');
      var hl = helplines[n];
      if( hl != null ) {
        p.writeXhtml('<p>'+helplines[n]+'</p>');
        div_help.appendChild(p);
      }
    }
    var p_closehelp = div_help.createChild('closehelpholder','p');
    p_closehelp.title = Rococo.pnl.locale.Panel.closeHelp();
    var a_closehelp = p_closehelp.createChild('closehelp','a',null,{href: 'javascript:void(0)'});
    a_closehelp.appendChild( document.createTextNode(Rococo.pnl.locale.Panel.close()) );
    p_closehelp.setChild('closehelp',a_closehelp);
    div_help.setChild('closehelpholder',p_closehelp);
    div_helpholder.setChild('help',div_help);
    Rococo.em.addVisibleSwitch(div_helpholder,a_closehelp);
    div_rootholder.setChild('helpholder',div_helpholder);
    element.switchHelpVisible = function(visible) {
	  return Rococo.pnl.local.Panel.switchHelpVisible( element, visible );
	};
    if( h2_title != null ) {
      a_switchhelp = h2_title.createChild('switchhelp','a');
      a_switchhelp.href = 'javascript:void(0)';
      a_switchhelp.appendChild(document.createTextNode('?'));
      Rococo.em.addVisibleSwitch(div_helpholder,a_switchhelp);
      a_switchhelp.addEventHandler(
	'click',
	function() {
	  Rococo.pnl.local.Panel.changeSwitchHelp(a_switchhelp,div_helpholder);
	});
      Rococo.pnl.local.Panel.changeSwitchHelp(a_switchhelp,div_helpholder);
      h2_title.setChild('switchhelp',a_switchhelp);
      element.changeSwitchHelp = function() {
	  return Rococo.pnl.local.Panel.changeSwitchHelp(a_switchhelp,div_helpholder);
	};
    }
  }
  if( childrensettings != null ) {
    for( var k in childrensettings ) {
      var cs = childrensettings[k];
      Rococo.pnl.local.Panel.appendItem(element,cs.subid,cs.tagname,cs.subcn,cs.attributes,cs.itemsubcn);
    }
  }
  return element;
};
Rococo.pnl.local.Panel.appendItem = function(element,subid,tagname,subcn,attributes,itemsubcn) {
  var mainholder = element.getChild('rootholder').getChild('mainholder');
  if( subcn == null ) {
    subcn = element.rococo.panel.childsubcn;
  }
  var child = mainholder.createChild(subid,tagname,subcn,attributes);
  if( tagname == 'form' ) {
    child = Rococo.pnl.recreateForm(child,null,null,itemsubcn);
  }
  return Rococo.pnl.local.Panel.setItem(element,subid,child);
};
Rococo.pnl.local.Panel.clearAllItems = function(element) {
  element.getChild('rootholder').getChild('mainholder').clearAllChildren();
};
Rococo.pnl.local.Panel.getItem = function(element,subid) {
  return element.getChild('rootholder').getChild('mainholder').getChild(subid);
};
Rococo.pnl.local.Panel.setItem = function(element,subid,child) {
  return element.getChild('rootholder').getChild('mainholder').setChild(subid,child);
};
Rococo.pnl.local.Panel.writeMessageText = function( element, text, append ) {
  var message = element.rococo.panel.message;
  if( message == null ) { return null; }
  if( append == null || append != true ) {
    message.clearAllChildren();
  }
  return message.writeText(text);
};
Rococo.pnl.local.Panel.writeMessageXhtml = function( element, xhtmltext, append ) {
  var message = element.rococo.panel.message;
  if( message == null ) { return null; }
  if( append == null || append != true ) {
    message.clearAllChildren();
  }
  return message.writeXhtml(xhtmltext);
};
Rococo.pnl.local.Panel.switchMainVisible = function(element,visible) {
  var rootholder = element.getChild('rootholder');
  if( rootholder == null ) { return null; }
  var mainholder = rootholder.getChild('mainholder');
  var messageholder =rootholder.getChild('messageholder');
  if( mainholder == null && messageholder == null ) { return null; }
  visible = visible ? true: false;
  if( mainholder ) { mainholder.switchVisible(visible); }
  if( messageholder ) { mainholder.switchVisible(visible); }
  if( element.changeSwitchMain ) { element.changeSwitchMain(); }
  return visible;
};
Rococo.pnl.local.Panel.switchHelpVisible = function(element,visible) {
  var rootholder = element.getChild('rootholder');
  if( rootholder == null ) { return null; }
  var helpholder = rootholder.getChild('helpholder');
  if( helpholder == null ) { return null; }
  var help = helpholder.getChild('help');
  if( help == null ) { return null; }
  visible = visible ? true: false;
  help.switchVisible(visible);
  if( element.changeSwitchHelp ) { element.changeSwitchHelp(); }
  return visible;
};
Rococo.pnl.local.Panel.changeSwitchMain = function(anchor,mainholder,title) {
  if( mainholder.style.display == 'none' ) {
    anchor.title = Rococo.pnl.locale.Panel.openForm(title);
    anchor.className = anchor.createCssClassName('closed');
  }
  else {
    anchor.title = Rococo.pnl.locale.Panel.closeForm(title);
    anchor.className = anchor.createCssClassName('opened');
  }
  return anchor.className;
};
Rococo.pnl.local.Panel.changeSwitchHelp = function(anchor,helpholder) {
  if( helpholder.style.display == 'none' ) {
    anchor.title = Rococo.pnl.locale.Panel.openHelp();
    anchor.className = anchor.createCssClassName('help-closed');
  }
  else {
    anchor.title = Rococo.pnl.locale.Panel.closeHelp();
    anchor.className = anchor.createCssClassName('help-opened');
  }
  return anchor.className;
};
Rococo.pnl.local.PanelHolder = new Object();
Rococo.pnl.locale.PanelHolder = new Object();
Rococo.pnl.locale.PanelHolder.local = {};
Rococo.pnl.createPanelHolder = function( cn_prefix, itemsettings ,itemsubcn ) {
  return Rococo.pnl.recreatePanelHolder( document.createElement('div'), cn_prefix. itemsettings, itemsubcn);
};
Rococo.pnl.recreatePanelHolder = function(element,cn_prefix,itemsettings,itemsubcn) {
  if( element.rococo == null ) {
    element = Rococo.tk.em.recreateElement(element,cn_prefix);
  }
  if( element.rococo.panelholder == null ) {
    element.rococo.panelholder = new Object();
  }
  element.rococo.panelholder.itemsubcn = itemsubcn;
  element.appendItem = function(subid,title,need_message,helplines,opened,childrensettings,childsubcn,subcn) {
	  return Rococo.pnl.local.PanelHolder.appendItem(element,subid,title,need_message,helplines,opened,childrensettings,childsubcn,subcn);
	};
  element.getItem = function(subid) {
	  return Rococo.pnl.local.PanelHolder.getItem(element,subid);
	};
  if( itemsettings != null ) {
    for( var k in itemsettings ) {
      var s = itemsettings[k];
      Rococo.pnl.local.PanelHolder.appendItem(element, s.subid , null, s.title, s.need_message, s.helplines, s.cn_prefix, s.opened, s.childrensettings, s.childsubcn);
    }
  }
  return element;
};
Rococo.pnl.local.PanelHolder.appendItem = function(element,subid,title,need_message,helplines,opened,childrensettings,childsubcn,subcn) {
  if( subcn == null ) { subcn = element.rococo.panelholder.itemsubcn; }
  var ch = element.createChild(subid,'div',subcn);
  Rococo.pnl.recreatePanel(ch,title,need_message,helplines,null,opened,childrensettings,childsubcn);
  element.setChild(subid,ch);
  return ch;
}
Rococo.pnl.local.PanelHolder.getItem = function(element,subid) {
  return element.getChild(subid);
};
Rococo.pnl.local.Form = new Object();
Rococo.pnl.locale.Form = new Object();
Rococo.pnl.locale.Form.local = {};
Rococo.pnl.createForm = function( cn_prefix, itemsettings, itemsubcn ) {
  var element = document.createElement('form');
  return Rococo.pnl.recreateForm(element,cn_prefix,itemsubcn,itemsettings);
};
Rococo.pnl.recreateForm = function( element, cn_prefix, itemsettings, itemsubcn ) {
  element = Rococo.tk.em.recreateElement( element, cn_prefix );
  if( itemsubcn == null ) { itemsubcn = 'item'; }
  if( element.rococo.form == null ) {
    element.rococo.form = new Object();
  }
  element.rococo.form.itemsubcn = itemsubcn;
  element.appendItem = function( subid, tagname, title, subcn, attributes, events ) {
	  return Rococo.pnl.local.Form.appendItem(element,subid,tagname,title,subcn,attributes,events);
	};
  element.getItem = function( subid ) {
	  return element.getChild(subid);
	};
  for( var k in itemsettings ) {
    var itemset = itemsettings[k];
    if( itemset != null ) {
      var child = element.appendItem(itemset.subid,itemset.tagname,itemset.title,itemset.subcn,itemset.attributes, itemset.events );
      element.setChild(itemset.subid,child);
    }
  }
  return element;
};
Rococo.pnl.local.Form.appendItem = function( element, subid, tagname, title, subcn, attributes, events ) {
  if( subcn == null ) { subcn = element.rococo.form.itemsubcn; }
  var child = element.createChild(subid,'div',subcn);
  if( tagname != null ) {
    if( title != null ) {
      var titleElement = child.createChild('title','span');
      titleElement.appendChild(document.createTextNode(title));
      child.setChild('title',titleElement);
    }
    var inputElement = child.createChild('input',tagname,'input',attributes);
    child.setChild('input',inputElement);
    if( events != null ) {
      for( var k in events ) {
        var e = events[k];
        if( e!=null && e.type!=null && e.listener!=null ) {
          inputElement.addEventHandler( e.type, e.listener );
        }
      }
    }
  }
  element.setChild(subid,child);
  return child;
};
Rococo.pnl.local.Result = new Object();
Rococo.pnl.locale.Result = new Object();
Rococo.pnl.locale.Result.local = {};
Rococo.pnl.createResult = function( cn_prefix, itemsettings, itemsubcn ) {
  var element = document.createElement('div');
  return Rococo.pnl.recreateResult(element,cn_prefix,itemsettings,itemsubcn);
};
Rococo.pnl.recreateResult = function( element, cn_prefix, itemsettings, itemsubcn ) {
  element = Rococo.tk.em.recreateElement( element, cn_prefix );
  if( itemsubcn == null ) { itemsubcn = 'item'; }
  if( element.rococo.result == null ) {
    element.rococo.result = new Object();
  }
  element.rococo.result.itemsubcn = itemsubcn;
  element.appendItem = function( subid, title, subcn, attributes ) {
	  return Rococo.pnl.local.Result.appendItem(element,subid,title,subcn,attributes);
	};
  element.getItem = function( subid ) {
	  return element.getChild(subid);
	};
  for( var k in itemsettings ) {
    var itemset = itemsettings[k];
    if( itemset != null ) {
      var child = element.appendItem(itemset.subid,itemset.title,itemset.subcn,itemset.attributes);
    }
  }
  return element;
};
Rococo.pnl.local.Result.appendItem = function( element, subid, title, subcn, attributes ) {
  if( subcn == null ) { subcn = element.rococo.result.itemsubcn; }
  var child = element.createChild(subid,'div',subcn);
  child.action='javascript:void(0)';
  if( title != null ) {
    var titleElement = child.createChild('title','span');
    titleElement.appendChild(document.createTextNode(title));
    child.setChild('title',titleElement);
  }
  var valueElement = child.createChild('value','span');
  child.setChild('value',valueElement);
  element.setChild(subid,child);
  return child;
};
Rococo.pnl.local.FreePanelHolder = new Object();
Rococo.pnl.createFreePanelHolder = function( cn_prefix,itemsettings ,itemsubcn ) {
  return Rococo.pnl.recreateFreePanelHolder( document.createElement('div'), cn_prefix, itemsettings, itemsubcn );
};
Rococo.pnl.recreateFreePanelHolder = function(element,cn_prefix,itemsettings,itemsubcn) {
  element = Rococo.pnl.recreatePanelHolder(element,cn_prefix,itemsettings,itemsubcn!=null?itemsubcn:'freepanel');
  return element;
};
Rococo.pnl.local.Menu = new Object();
Rococo.pnl.locale.Menu = new Object();
Rococo.pnl.locale.Menu.local = {};
Rococo.pnl.createMenu = function( title, helplines, cn_prefix, opened, childrensettings ) {
  var element = document.createElement('div');
  return Rococo.pnl.recreateMenu(element,title,helplines,cn_prefix,opened,childrensettings);
};
Rococo.pnl.recreateMenu = function( element, title, helplines, cn_prefix, opened, childrensettings ) {
  element = Rococo.pnl.recreatePanel( element, title, false, helplines, cn_prefix, opened, [{subid:'input',tagname:'form'}] );
  if( element.rococo.menu == null ) {
    element.rococo.menu = new Object();
  }
  element.rococo.menu.input = Rococo.pnl.local.Panel.getItem(element,'input');
  element.appendItem = function( subid, tagname, title, subcn, attributes, events ) {
	  return Rococo.pnl.local.Menu.appendItem(element,subid,tagname,title,subcn,attributes,events);
	};
  element.getItem = function(subid) {
	  return Rococo.pnl.local.Menu.getItem(element,subid);
	};
  for( var k in childrensettings ) {
    var itemset = childrensettings[k];
    if( itemset != null ) {
      element.appendItem(itemset.subid,itemset.tagname,itemset.title,itemset.subcn,itemset.attributes, itemset.events );
    }
  }
  return element;
};
Rococo.pnl.local.Menu.appendItem = function( element, subid, tagname, title, subcn, attributes, events ) {
  var holder = element.rococo.menu.input;
  var child = holder.appendItem(subid,tagname,title,subcn,attributes,events);
  return child;
};
Rococo.pnl.local.Menu.getItem = function(element,subid) {
  return element.rococo.menu.input.getChild(subid);
};
Rococo.pnl.local.MenuHolder = new Object();
Rococo.pnl.locale.MenuHolder = new Object();
Rococo.pnl.locale.MenuHolder.local = {};
Rococo.pnl.createMenuHolder = function( cn_prefix, itemsettings ,itemsubcn ) {
  return Rococo.pnl.recreateMenuHolder( document.createElement('div'), cn_prefix, itemsettings, itemsubcn);
};
Rococo.pnl.recreateMenuHolder = function(element,cn_prefix,itemsettings,itemsubcn) {
  Rococo.pnl.recreatePanelHolder(element,cn_prefix,null,itemsubcn!=null?itemsubcn:'menu');
  element.appendItem = function(subid,title,helplines,cn_prefix,opened,childrensettings,subcn) {
	  return Rococo.pnl.local.MenuHolder.appendItem(element,subid,title,helplines,cn_prefix,opened,childrensettings,subcn);
	};
  if( itemsettings != null ) {
    for( var k in itemsettings ) {
      var s = itemsettings[k];
      Rococo.pnl.local.MenuHolder.appendItem(element, s.subid, s.title, s.helplines, s.cn_prefix, s.opened, s.childrensettings, s.subcn);
    }
  }
  return element;
};
Rococo.pnl.local.MenuHolder.appendItem = function(element,subid,title,helplines,cn_prefix,opened,childrensettings,subcn) {
  if( subcn == null ) { subcn = element.rococo.panelholder.itemsubcn; }
  var ch = element.createChild(subid,'div',subcn);
  Rococo.pnl.recreateMenu(ch,title,helplines,cn_prefix,opened,childrensettings);
  element.setChild(subid,ch);
  return ch;
}
Rococo.pnl.local.Console = new Object();
Rococo.pnl.locale.Console = new Object();
Rococo.pnl.locale.Console.local = {};
Rococo.pnl.createConsole = function( need_input, need_result, title, need_message, helplines, cn_prefix, opened, inputchildrensettings, resultchildrensettings ) {
  var element = document.createElement('div');
  return Rococo.pnl.recreateConsole(element,need_input, need_result, title,need_message,helplines,cn_prefix,opened,inputchildrensettings,resultchildrensettings);
};
Rococo.pnl.recreateConsole = function( element, need_input, need_result, title, need_message, helplines, cn_prefix, opened, inputchildrensettings, resultchildrensettings ) {
  element = Rococo.pnl.recreatePanel( element, title, need_message, helplines, cn_prefix, opened );
  if( element.rococo.console == null ) {
    element.rococo.console = new Object();
  }
  var k, itemset;
  if( need_input ) {
    var input = element.appendItem('input','form');
    element.appendInputItem = function( subid, tagname, title, subcn, attributes, events ) {
	  return input.appendItem(subid,tagname,title,subcn,attributes,events);
	};
    element.getInputItem = function(subid) {
	  return input.getItem(subid);
	};
    if( inputchildrensettings != null ) {
      for( k in inputchildrensettings ) {
        itemset = inputchildrensettings[k];
        if( itemset != null ) {
          input.appendItem(itemset.subid,itemset.tagname,itemset.title,itemset.subcn,itemset.attributes, itemset.events );
        }
      }
    }
    element.rococo.console.input = input;
  }
  if( need_result ) {
    var result = element.appendItem('result','div');
    Rococo.pnl.recreateResult(result);
    element.appendResultItem = function(subid, title, subcn, attributes) {
	  return element.rococo.console.result.appendItem(subid,title,subcn,attributes);
	};
    element.getResultItem = function(subid) {
	  return element.rococo.console.result.getItem(subid);
	};
    if( resultchildrensettings != null ) {
      for( k in resultchildrensettings ) {
        itemset = resultchildrensettings[k];
        if( itemset != null ) {
          result.appendItem(itemset.subid,itemset.title,itemset.subcn,itemset.attributes);
        }
      }
    }
    element.rococo.console.result = result;
  }
  return element;
};
Rococo.pnl.local.ConsoleHolder = new Object();
Rococo.pnl.createConsoleHolder = function( cn_prefix,itemsettings ,itemsubcn ) {
  return Rococo.pnl.recreateConsoleHolder( document.createElement('div'), cn_prefix, itemsettings, itemsubcn );
};
Rococo.pnl.recreateConsoleHolder = function(element,cn_prefix,childrensettings,itemsubcn) {
  element = Rococo.pnl.recreatePanelHolder(element,cn_prefix,null,itemsubcn!=null?itemsubcn:'console');
  element.appendItem = function(subid, need_input, need_result, title, need_message,helplines, cn_prefix, opened, inputchildrensettings,resultchildrensettings, subcn) {
	  return Rococo.pnl.local.ConsoleHolder.appendItem(element,subid,need_input,need_result, title,need_message,helplines, cn_prefix, opened, inputchildrensettings, resultchildrensettings, subcn);
	};
  if( childrensettings != null ) {
    for( var k in childrensettings ) {
      var s = childrensettings[k];
      Rococo.pnl.local.ConsoleHolder.appendItem(element,s.subid,s.need_input,s.need_result,s.title,s.need_message,s.need_message,s.helplines,s.cn_prefix,s.inputchildrensettings,s.resultchildrensettings,s.opened,s.subcn);
    }
  }
  return element;
};
Rococo.pnl.local.ConsoleHolder.appendItem = function(element, subid, need_input, need_result, title, need_message, helplines, cn_prefix, opened, inputchildrensettings, resultchildrensettings, subcn) {
  if( subcn == null ) { subcn = element.rococo.panelholder.itemsubcn; }
  var ch = element.createChild(subid,'div',subcn);
  Rococo.pnl.recreateConsole(ch,need_input,need_result,title,need_message,helplines,cn_prefix,opened,inputchildrensettings,resultchildrensettings);
  element.setChild(subid,ch);
  return ch;
}
Rococo.eui = new Object();
Rococo.eui.locale = new Object();
Rococo.eui.local = new Object();
Rococo.eui.local.BarChart = new Object();
Rococo.eui.locale.BarChart = new Object();
Rococo.eui.locale.BarChart.local = {};
Rococo.eui.createBarChart = function( settings, cn_prefix ) {
  return Rococo.eui.recreateBarChart(document.createElement('table'),settings,cn_prefix);
};
Rococo.eui.recreateBarChart = function( element, settings ,cn_prefix ) {
  if( element.rococo == null ) {
    element = Rococo.em.recreateElement(element,cn_prefix);
  }
  element.resetHeadRow = function(settings) {
	  Rococo.eui.local.BarChart.resetHeadRow(element,settings);
	};
  element.clearDataRows = function() {
	  Rococo.eui.local.BarChart.clearDataRows( element );
	};
  element.appendData = function( data ) {
	  Rococo.eui.local.BarChart.appendData( element, data );
	};
  element.appendDataRow = function( datarow ) {
	  Rococo.eui.local.BarChart.appendDataRow( element, datarow );
	};
  element.rococo.barchart = new Object();
  var tbody = element.createChild('tbody','tbody');
  element.rococo.barchart.tbody = tbody;
  element.resetHeadRow( settings );
  element.setChild('tbody',tbody);
  return element;
};
Rococo.eui.local.BarChart.resetHeadRow = function( element, settings ) {
  var tbody = element.rococo.barchart.tbody;
  tbody.clearAllChildren();
  element.rococo.barchart.settings = new Array();
  var tr;
  tr = Rococo.em.createElement( 'tr', null, null, {className:tbody.createCssClassName('headrow')} );
  var th;
  var len = settings.length;
  for( var n = 0; n < len; n++ ) {
    var s = settings[n];
    var sn;
    if( s.type == 'bar' && s.barwidth != null && s.barwidth.value != null && s.maxvalue != null && s.minvalue != null ) {
      sn = {
	  type: s.type,
	  barwidth: {
		  value: s.barwidth.value,
		  unit: s.barwidth.unit != null ? s.barwidth.unit : 'px'
	  },
	  maxvalue : s.maxvalue,
	  minvalue : s.minvalue,
	  valueunit: s.valueunit != null ? s.valueunit : '',
	  textwidth: s!=null ? s.textwidth : null,
          title: s.title != null ? s.title: ''
	};
      if( s.color != null ) {
        sn.color = s.color.getCssText();
      }
      if( s.legend != null  ) {
        sn.legend = { 'legend': s.legend, 'target': 'borderColor' };
      }
      th = Rococo.em.createElement('th', null, null, { className: tr.createCssClassName('bar') });
      th.scope = 'col';
      th.style.width = sn.barwidth.value + sn.barwidth.unit;
      var span = Rococo.em.createElement('span');
      span.appendChild(document.createTextNode(sn.title));
      th.appendChild(span);
      tr.appendChild(th);
      th = Rococo.em.createElement('th', null, null, { className: tr.createCssClassName('padding') });
      if( sn.textwidth != null ) { th.style.width = sn.textwidth; }
      tr.appendChild(th);
    }
    else {
      sn = {
	  type: s!=null && s.type!=null && s.type!='bar' ? s.type : 'data',
	  textwidth: s!=null ? s.textwidth : null,
          title: s.title != null ? s.title: ''
	};
      th = Rococo.em.createElement('th', null, null, { className : tr.createCssClassName(sn.type), scope: 'col' });
      th.appendChild(document.createTextNode(sn.title));
      tr.appendChild(th);
      if( sn.textwidth != null ) { th.style.width = sn.textwidth; }
    }
    element.rococo.barchart.settings.push(sn);
  }
  tbody.setChild( 'headrow', tr );
  return tr;
};
Rococo.eui.local.BarChart.clearDataRows = function( element ) {
  var tbody = element.rococo.barchart.tbody;
  var cn_head = tbody.createCssClassName('headrow');
  var deleted = new Array();
  var rows = tbody.getElementsByTagName('tr');
  var len_rows = rows.length;
  for( var n_row = 0; n_row <  len_rows; n_row++ ) {
    var row = rows[n_row];
    if( row.className != cn_head ) {
      deleted.push(row);
    }
  }
  var len_del = deleted.length;
  for( var n_del = 0; n_del < len_del; n_del++ ) {
    tbody.deleteChild(deleted[n_del]);
  }
};
Rococo.eui.local.BarChart.appendData = function( element, data ) {
  var len = data.length;
  var ret = new Array();
  for( var n = 0; n < len; n++ ) {
    var ch = element.appendDataRow(data[n]);
    ret.push(ch);
  }
  return ret;
};
Rococo.eui.local.BarChart.appendDataRow = function( element, datarow ) {
  var tbody = element.rococo.barchart.tbody;
  tr = Rococo.em.createElement( 'tr', null, null, {className:tbody.createCssClassName('datarow')} );
  var len = datarow.length;
  var settings = element.rococo.barchart.settings;
  for( var n = 0; n < len; n++ ) {
    var s = settings[n];
    var d = datarow[n];
    var obj;
    if( s.type == 'bar' ) {
      obj = Rococo.em.createElement('td', null, null, {className: tr.createCssClassName(s.type), colSpan: 2});
      var span = Rococo.tk.em.createElement('span', null, null, {className: tr.createCssClassName('value'), legend: s.legend });
      span.style.borderLeftWidth = ( (d - s.minvalue)/(s.maxvalue-s.minvalue)*s.barwidth.value ) + s.barwidth.unit;
      span.style.borderRightWidth = '0px';
      span.style.borderTopWidth = '0px';
      span.style.borderBottomWidth = '0px';
      span.style.borderStyle = 'solid';
      if( s.color != null ) { span.style.borderColor = s.color; }
      if( s.legend != null ) { span.setColor(d); }
      span.appendChild(document.createTextNode('' + d + s.valueunit));
      obj.appendChild(span);
    }
    else if( s.type == 'head' ) {
      obj = Rococo.em.createElement('th', null, null, {className: tr.createCssClassName(s.type)});
      obj.className = tr.createCssClassName(s.type);
      obj.appendChild(document.createTextNode(d!=null?d:''));
    }
    else {
      obj = Rococo.em.createElement('td', null, null, {className: tr.createCssClassName(s.type)});
      obj.appendChild(document.createTextNode(d!=null?d:''));
    }
    tr.appendChild(obj);
  }
  tbody.appendChild(tr);
  return tr;
}
Rococo.eui.local.VBarChart = new Object();
Rococo.eui.locale.VBarChart = new Object();
Rococo.eui.locale.VBarChart.local = {};
Rococo.eui.createVBarChart = function( settings, cn_prefix ) {
  return Rococo.eui.recreateVBarChart(document.createElement('table'),settings,cn_prefix);
};
Rococo.eui.recreateVBarChart = function( element, settings ,cn_prefix ) {
  if( element.rococo == null ) {
    element = Rococo.em.recreateElement(element,cn_prefix);
  }
  element.resetAll = function(settings) {
	  Rococo.eui.local.VBarChart.resetAll(element,settings);
	};
  element.clearData = function() {
	  Rococo.eui.local.VBarChart.clearData( element );
	};
  element.appendData = function( data ) {
	  Rococo.eui.local.VBarChart.appendData( element, data );
	};
  element.appendDataColumn = function( data ) {
	  Rococo.eui.local.VBarChart.appendDataColumn( element, data );
	};
  element.rococo.vbarchart = new Object();
  var tbody = element.createChild('tbody','tbody');
  element.rococo.vbarchart.tbody = tbody;
  element.resetAll( settings );
  element.setChild('tbody',tbody);
  return element;
};
Rococo.eui.local.VBarChart.resetAll = function( element, settings ) {
  var tbody = element.rococo.vbarchart.tbody;
  tbody.clearAllChildren();
  element.rococo.vbarchart.revrows = new Array();
  element.rococo.vbarchart.revsettings = new Array();
  var row, sn;
  var len = settings.length;
  for( var n = 0; n < len; n++ ) {
    var s = settings[n];
    if( s.type == 'bar' && s.barheight != null && s.barheight.value != null && s.maxvalue != null && s.minvalue != null ) {
      sn = {
	  type: s.type,
	  barheight: {
		  value: s.barheight.value,
		  unit: s.barheight.unit != null ? s.barheight.unit : 'px'
	  },
	  maxvalue : s.maxvalue,
	  minvalue : s.minvalue,
	  valueunit: s.valueunit != null ? s.valueunit : '',
          title: s.title != null ? s.title: ''
	};
      if( s.color != null ) {
        sn.color = s.color.getCssText();
      }
      if( s.legend != null  ) {
        sn.legend = { 'legend': s.legend, 'target': 'borderColor' };
      }
      tr = Rococo.em.createElement('tr',null,null,{className: tbody.createCssClassName('padding')});
      tr.style.height = '' + sn.barheight.value + sn.barheight.unit;
      th = Rococo.em.createElement('th',null,null,{className: tr.createCssClassName('headcol') });
      th.scope='row';
      tr.appendChild(th);
      row = { 'tr' : tr, 'head': th };
      element.rococo.vbarchart.revrows.push(row);
      tr = Rococo.em.createElement('tr',null,null,{className: tbody.createCssClassName('bar')});
      th = Rococo.em.createElement('th',null,null,{className: tr.createCssClassName('headcol') });
      th.scope='row';
      span = Rococo.em.createElement('span');
      span.appendChild(document.createTextNode(sn.title));
      th.appendChild(span);
      tr.appendChild(th);
      row = { 'tr' : tr, 'head': th };
      element.rococo.vbarchart.revrows.push(row);
    }
    else {
      sn = {
	  type: s!=null && s.type!=null && s.type!='bar' ? s.type : 'data',
          title: s.title != null ? s.title: ''
	};
      tr = Rococo.em.createElement('tr',null,null,{className: tbody.createCssClassName('head')});
      th = Rococo.em.createElement('th',null,null,{className: tr.createCssClassName('headcol') });
      th.scope='row';
      span = Rococo.em.createElement('span');
      span.appendChild(document.createTextNode(sn.title));
      th.appendChild(span);
      tr.appendChild(th);
      row = { 'tr' : tr, 'head': th };
      element.rococo.vbarchart.revrows.push(row);
    }
    element.rococo.vbarchart.revsettings.push(sn);
  }
  len = element.rococo.vbarchart.revrows.length;
  for( n = len-1; n >= 0; n-- ) {
    tbody.appendChild(element.rococo.vbarchart.revrows[n].tr);
  }
}
Rococo.eui.local.VBarChart.XXXresetAll = function( element, settings ) {
  var tbody = element.rococo.vbarchart.tbody;
  tbody.clearAllChildren();
  element.rococo.vbarchart.settings = new Array();
  var tr_datarow = Rococo.em.createElement( 'tr', null, null, {className:tbody.createCssClassName('datarow')} );
  var tr_padding = Rococo.em.createElement( 'tr', null, null, {className:tbody.createCssClassName('padding')} );
  var tr_headrow = Rococo.em.createElement( 'tr', null, null, {className:tbody.createCssClassName('headrow')} );
  element.rococo.vbarchart.tr_datarow = tr_datarow;
  element.rococo.vbarchart.tr_padding = tr_padding;
  element.rococo.vbarchart.tr_headrow = tr_headrow;
  var th, td, span;
  var len = settings.length;
  for( var n = 0; n < len; n++ ) {
    var s = settings[n];
    var sn;
    if( s.type == 'bar' && s.barheight != null && s.barheight.value != null && s.maxvalue != null && s.minvalue != null ) {
      sn = {
	  type: s.type,
	  barheight: {
		  value: s.barheight.value,
		  unit: s.barheight.unit != null ? s.barheight.unit : 'px'
	  },
	  maxvalue : s.maxvalue,
	  minvalue : s.minvalue,
	  valueunit: s.valueunit != null ? s.valueunit : '',
          title: s.title != null ? s.title: ''
	};
      if( s.color != null ) {
        sn.color = s.color.getCssText();
      }
      if( s.legend != null  ) {
        sn.legend = { 'legend': s.legend, 'target': 'borderColor' };
      }
      th = Rococo.em.createElement('th',null,null,{className: tr_datarow.createCssClassName('head') });
      th.scope = 'col';
      span = Rococo.em.createElement('span');
      span.appendChild(document.createTextNode(sn.title));
      th.appendChild(span);
      tr_datarow.appendChild(th);
      element.rococo.vbarchart.th_datarow = th;
      th = Rococo.em.createElement('th',null,null,{className: tr_padding.createCssClassName('head') });
      th.scope = 'col';
      tr_padding.appendChild(th);
      element.rococo.vbarchart.th_padding = th;
      th = Rococo.em.createElement('th',null,null,{className: tr_headrow.createCssClassName('head') });
      th.scope = 'col';
      tr_headrow.appendChild(th);
      element.rococo.vbarchart.th_headrow = th;
      tr_padding.style.height = '' + sn.barheight.value + sn.barheight.unit;
    }
    else {
      sn = {
	  type: s!=null && s.type!=null && s.type!='bar' ? s.type : 'data',
          title: s.title != null ? s.title: ''
	};
      td = Rococo.em.createElement('td',null,null,{className: tr_datarow.createCssClassName(sn.type), rowSpan: 2});
      tr_datarow.appendChild(td);
      th = Rococo.em.createElement('th', null, null, { className : tr_headrow.createCssClassName(sn.type), scope: 'col' });
      th.appendChild(document.createTextNode(sn.title));
      tr_headrow.appendChild(th);
    }
    element.rococo.vbarchart.settings.push(sn);
  }
  tbody.setChild( 'datarow',element.rococo.vbarchart.tr_datarow );
  tbody.setChild( 'padding',element.rococo.vbarchart.tr_padding );
  tbody.setChild( 'headrow',element.rococo.vbarchart.tr_headrow );
  return element.rococo.vbarchart.tr_datarow;
};
Rococo.eui.local.VBarChart.clearData = function( element ) {
  if( element.rococo.vbarchart.revrows == null ) {
    return;
  }
  var len = element.rococo.vbarchart.revrows.length
  for( var n = 0; n < len; n++ ) {
    Rococo.eui.local.VBarChart.clearDataColumn(element.rococo.vbarchart.revrows[n].tr, element.rococo.vbarchart.revrows[n].head);
  }
};
Rococo.eui.local.VBarChart.clearData = function(tr,excepted) {
  var children = element.childNodes;
  var deleted = new Array();
  if( children == null ) {
    return;
  }
  var len = children.length;
  var n;
  var child;
  for( n = 0; n < len; n++ ) {
    child = children.item(n);
    if( child && child != excepted ) {
      deleted.push(row);
    }
  }
  len = deleted.length;
  for( n = 0; n < len; n++ ) {
    element.removeChild(deleted[n]);
  }
};
Rococo.eui.local.VBarChart.appendData = function( element, data ) {
  var len = data.length;
  var ret = new Array();
  for( var n = 0; n < len; n++ ) {
    Rococo.eui.local.VBarChart.appendDataColumn(element,data[n]);
  }
};
Rococo.eui.local.VBarChart.appendDataColumn= function( element, datacol ) {
  var settings = element.rococo.vbarchart.revsettings;
  var len = datacol.length < settings.length ? datacol.length : settings.length;
  var n;
  var r = element.rococo.vbarchart.revrows.length - 1;
  for( var n = len-1; n >=0; n-- ) {
    var s = settings[n];
    var d = datacol[n];
    var tr = element.rococo.vbarchart.revrows[r].tr;
    if( s.type == 'bar' ) {
      var td = Rococo.em.createElement('td',null,null,{className: tr.createCssClassName(s.type), rowSpan: 2 });
      span = Rococo.tk.em.createElement('span', null, null, {className: td.createCssClassName('value'), legend: s.legend });
      span.style.verticalAlign = 'bottom';
      span.style.borderLeftWidth = '0px';
      span.style.borderRightWidth = '0px';
      span.style.borderTopWidth = '0px';
      span.style.borderBottomWidth = ( (d - s.minvalue)/(s.maxvalue-s.minvalue)*s.barheight.value ) + s.barheight.unit;
      span.style.borderStyle = 'solid';
      if( s.color != null ) { span.style.borderColor = s.color; }
      if( s.legend != null ) { span.setColor(d); }
      span.appendChild(document.createTextNode('' + d + s.valueunit));
      td.appendChild(span);
      tr.appendChild(td);
      r = r - 2;
    }
    else if( s.type == 'head' ) {
      var th = Rococo.em.createElement('th',null,null,{className: tr.createCssClassName(s.type) });
      th.appendChild(document.createTextNode(d!=null?d:''));
      tr.appendChild(th);
      r = r - 1;
    }
    else {
      r = r - 1;
    }
  }
}
Rococo.eui.local.Matrix = new Object();
Rococo.eui.local.MatrixCell = {};
Rococo.eui.locale.Matrix = new Object();
Rococo.eui.locale.Matrix.local = {};
Rococo.eui.local.Matrix.createCell = function( tagname, legend_settings, attributes ) {
  return Rococo.eui.local.Matrix.recreateCell( document.createElement(tagname), legend_settings, attributes );
};
Rococo.eui.local.Matrix.recreateCell = function( element, legend_settings, attributes ) {
  if( legend_settings != null ) {
    if( attributes == null ) {
      attributes = new Object();
    }
    attributes.legend = legend_settings;
  }
  Rococo.tk.em.recreateElement(element,null,null,attributes);
  element.setValue = function(value) {
	  Rococo.eui.local.MatrixCell.setValue(element,value);
	};
  return element;
};
Rococo.eui.local.MatrixCell.setValue = function(element,value) {
  element.clearAllChildren();
  var e;
  var v = null;
  if( Rococo.ut.isArray(value) ) {
    var len = value.length;
    for( var n = 0; n < len; n++ ) {
      e = document.createElement('p');
      e.appendChild(document.createTextNode(value[n]));
      element.appendChild(e);
    }
    v = value[0];
  }
  else if( value && Rococo.ut.isObject(value) ) {
    for( var k in value ) {
      if( v == null ) { v = value[k]; }
      e = document.createElement('p');
      e.appendChild(document.createTextNode(value[k]));
      element.appendChild(e);
    }
    if( value.value != null ) {
      v = value.value;
    }
  }
  else {
    element.appendChild(document.createTextNode(value));
    v = value;
  }
  element.setColor(v);
  return value;
};
Rococo.eui.createMatrix = function( settings , cn_prefix ) {
  return Rococo.eui.recreateMatrix(document.createElement('table'), settings, cn_prefix);
};
Rococo.eui.recreateMatrix = function( element, settings ,cn_prefix ) {
  if( element.rococo == null ) {
    element = Rococo.em.recreateElement(element,cn_prefix);
  }
  element.resetAll = function( settings ) {
	  Rococo.eui.local.Matrix.resetAll( element, settings ) 
	};
  element.clearData = function() {
	  Rococo.eui.local.Matrix.clearData( element );
	};
  element.setData = function( data ) {
	  Rococo.eui.local.Matrix.setData( element, data );
	};
  element.setDataRow = function( row, datarow ) {
	  Rococo.eui.local.Matrix.setDataRow( element, row, datarow );
	};
  element.rococo.matrix = new Object();
  var tbody = element.createChild('tbody','tbody');
  element.rococo.matrix.tbody = tbody;
  element.resetAll( settings );
  element.setChild('tbody',tbody);
  return element;
};
Rococo.eui.local.Matrix.resetAll = function( element, settings ) {
  var tbody = element.rococo.matrix.tbody;
  var legend_settings = settings.legend != null ? {'legend': settings.legend, 'target': 'backgroundColor' } : null;
  tbody.clearAllChildren();
  element.rococo.matrix.elements = new Array();
  if( settings == null || settings.rowheads == null || settings.colheads == null ) {
    return;
  }
  var rows = settings.rowheads;
  var cols = settings.colheads;
  var len_rows = rows.length;
  var len_cols = cols.length;
  var r, c, s;
  var tr, th, td;
  var cn_head = tbody.createCssClassName('head');
  var cn_center = tbody.createCssClassName('center');
  var row_center = Math.floor(len_rows/2);
  var col_center = Math.floor(len_cols/2);
  tr = document.createElement('tr');
  tr.className = tbody.createCssClassName('headrow');
  th = document.createElement('th');
  th.className = cn_head;  // only first column
  tr.appendChild(th);
  for( c = 0; c < len_cols; c++ ) {
    th = document.createElement('th');
    if( settings.width != null ) { th.style.width = settings.width; }
    s = cols[c];
    th.appendChild(document.createTextNode(s!=null?s:''));
    tr.appendChild(th);
  }
  tbody.appendChild(tr);
  var cn_bodyrow = tbody.createCssClassName('bodyrow');
  for( r = 0; r < len_rows; r++ ) {
    var lines = new Array();
    tr = document.createElement('tr');
    tr.className = cn_bodyrow;
    th = document.createElement('th');
    if( settings.height != null ) { th.style.height = settings.height; }
    th.className = cn_head;
    s = rows[r];
    th.appendChild(document.createTextNode(s!=null?s:''));
    tr.appendChild(th);
    for( c = 0; c < len_cols; c++ ) {
      td = Rococo.eui.local.Matrix.createCell('td',legend_settings);
      if( settings.width != null ) { td.style.width = settings.width; }
      if( settings.height != null ) { td.style.height = settings.height; }
      if( c == col_center && r == row_center ) {
        td.className = cn_center;
      }
      lines.push(td);
      tr.appendChild(td);
    }
    tbody.appendChild(tr);
    element.rococo.matrix.elements.push(lines);
  }
  element.rococo.matrix.rows = len_rows;
  element.rococo.matrix.cols = len_cols;
};
Rococo.eui.local.Matrix.clearData = function( element ) {
  var tbody = element.rococo.matrix.tbody;
  var elements = element.rococo.matrix.elements;
  for( var r in elements ) {
    var row = elements[r];
    for( var c in row ) {
      row[c].clearAllChildren();
    }
  }
};
Rococo.eui.local.Matrix.setData = function( element, data ) {
  var len = data.length;
  for( var n = 0; n < len; n++ ) {
    element.setDataRow(n,data[n]);
  }
  return data;
};
Rococo.eui.local.Matrix.setDataRow = function( element, row, datarow ) {
  var row = element.rococo.matrix.elements[row];
  for( var c = 0; c < element.rococo.matrix.cols; c++ ) {
    var td = row[c];
    td.clearAllChildren();
    var d = datarow[c];
    td.setValue(d);
  }
  return row;
};
Rococo.geo = new Object();
Rococo.geo.local = new Object();
Rococo.geo.local.Mesh = new Object();
Rococo.geo.Mesh = function( sec, skip, offset ) {
  this.skip = skip;
  this.offset = offset;
  this.orig = {
	  lat : Math.floor( sec.lat / skip.lat )*skip.lat,
	  lon : Math.floor( sec.lon / skip.lon )*skip.lon
	};
};
Rococo.geo.Mesh.prototype.add = function( op ) {
  return new Rococo.geo.Mesh( {
	    lat: this.orig.lat + op.orig.lat - op.offset.lat,
	    lon: this.orig.lon + op.orig.lon - op.offset.lon
	  },
	  this.skip,
	  this.offset );
};
Rococo.geo.Mesh.prototype.addByMeshNumber = function( meshnum ) {
  return new Rococo.geo.Mesh( {
	    lat: this.orig.lat + meshnum.lat * this.skip.lat,
	    lon: this.orig.lon + meshnum.lon * this.skip.lon
	  },
	  this.skip,
	  this.offset );
};
Rococo.geo.Mesh.prototype.addBySec = function( sec ) {
  return new Rococo.geo.Mesh( {
	    lat: this.orig.lat + sec.lat,
	    lon: this.orig.lon + sec.lon
	  },
	  this.skip,
	  this.offset );
};
Rococo.geo.Mesh.prototype.getMeshNumber = function() {
  return {
	  lat: Math.floor((this.orig.lat-this.offset.lat)/this.skip.lat),
	  lon: Math.floor((this.orig.lon-this.offset.lon)/this.skip.lon)
	};
};
Rococo.jp = new Object();
Rococo.jp.cl = new Object();
Rococo.jp.cl.xml = new Object();
Rococo.jp.cl.jsonp = new Object();
Rococo.jp.cl.jsonp.municipalitylist = {
  url : new Rococo.cl.UrlSetting(
	  'http://www.finds.jp/ws/municipalitylist.php',
	  null,
	  'GET',
	  'jsonp'
	),
  decision : new Rococo.cl.DecisionSetting(
	  [ 'status' ],
	  200,
	  [ 'error' ]
	)
};
Rococo.jp.cl.jsonp.rgeocode = {
  url : new Rococo.cl.UrlSetting(
	  'http://www.finds.jp/ws/rgeocode.php',
	  null,
	  'GET',
	  'jsonp'
	),
  decision : new Rococo.cl.DecisionSetting(
	  [ 'status' ],
	  [ 200, 201],
	  [ 'error' ]
	)
};
Rococo.jp.cl.jsonp.geocode = {
  url : new Rococo.cl.UrlSetting(
	  'http://www.finds.jp/ws/geocode.php',
	  null,
	  'GET',
	  'jsonp'
	),
  decision : new Rococo.cl.DecisionSetting(
	  [ 'status' ],
	  200,	// jsonpは型も入ってくる
	  [ 'error' ]
	)
};
Rococo.jp.geo = new Object();
Rococo.jp.geo.JPMesh = function( level, sec ) {
  Rococo.ut.inherit(new Rococo.geo.Mesh(sec,{lat: 30, lon: 45}, {lat: 0, lon: 3600}),this);
  this.level = level < 0 ? 1 : (level > 3 ? 3: level );
};
Rococo.jp.geo.JPMesh.prototype.getMeshCode = function() {
  var mn3d = this.getMeshNumber();
  var mesh = new Array();
  if( this.level >= 3 ) {
    mesh[2] = {lat: mn3d.lat % 10, lon: mn3d.lon % 10};
  }
  if( this.level >= 2 ) {
    mesh[1] = {lat: Math.floor(mn3d.lat/10) % 8, lon: Math.floor(mn3d.lon/10) % 8};
  }
  if( this.level >= 1 ) {
    mesh[0] = {lat: Math.floor(mn3d.lat/80), lon: Math.floor(mn3d.lon/80)};
  }
  return mesh;
};
Rococo.jp.geo.JPMesh.prototype.addByMeshCode = function( meshcode ) {
  var nlat = this.orig.lat;
  var nlon = this.orig.lon;
  if( meshcode != null ) {
    if( meshcode.length >= 1 ) {
      nlat = nlat + meshcode[0].lat * 80 *  this.skip.lat;
      nlon = nlon + meshcode[0].lon * 80 *  this.skip.lon;
    }
    if( meshcode.length >= 2 ) {
      nlat = nlat + meshcode[1].lat * 10 *  this.skip.lat;
      nlon = nlon + meshcode[1].lon * 10 *  this.skip.lon;
    }
    if( meshcode.length >= 3 ) {
      nlat = nlat + meshcode[2].lat * this.skip.lat;
      nlon = nlon + meshcode[2].lon * this.skip.lon;
    }
  }
  return new Rococo.geo.Mesh( {lat: nlat, lon: nlon}, this.skip, this.offset );
};
