//======================================================================
// EPSON Offirio site
//   enquete tracking function
//======================================================================

//==================================================
// global values
//==================================================
var gOET_TARGET_URL = "http://www.epson.jp/products/offirio/";
var gOET_COOKIE_PATH = "/";
var gOET_MAX_URL_COUNT = 30;
var gOET_MAX_URL_SIZE  = 2048;
var gOET_TARGET_DIR_LIST  = {"ad":"01","dms":"02","emp":"03","emp/EasyMP":"04","emp/casestudy":"05","emp/casestudy/case01":"06","emp/casestudy/case02":"07","emp/casestudy/case03":"08","emp/casestudy/case04":"09","emp/casestudy/case05":"0a","emp/casestudy/case06":"0b","emp/casestudy/case07":"0c","emp/casestudy/case08":"0d","emp/casestudy/case09":"0e","emp/casestudy/case10":"0f","emp/casestudy/case11":"0g","emp/casestudy/case12":"0h","emp/casestudy/imglib":"0i","emp/datalib":"0j","emp/emp1700":"0k","emp/emp1705":"0l","emp/emp1710":"0m","emp/emp1715":"0n","emp/emp6100":"0o","emp/emp750":"0p","emp/emp755":"0q","emp/emp755_750":"0r","emp/emp760":"0s","emp/emp765":"0t","emp/emp765_760":"0u","emp/emp7900":"0v","emp/emp7950":"10","emp/emp7950_7900":"11","emp/emp82":"12","emp/emp82/img/void":"13","emp/emp830":"14","emp/emp830/img/old_quicklinkImg":"15","emp/emp8300":"16","emp/emp835":"17","emp/emp835/img/non":"18","emp/emp835_830":"19","emp/emp_demo":"1a","emp/emp_demo/img/multi":"1b","emp/emp_img":"1c","emp/emps4":"1d","emp/emps4/img/non":"1e","emp/emps4/img/old_imgs":"1f","emp/etorl":"1g","emp/feature":"1h","emp/firstguide":"1i","emp/function":"1j","emp/imglib":"1k","emp/imglib/ecoleaf":"1l","emp/include":"1m","emp/option":"1n","emp/pdf":"1o","emp/pdf/data":"1p","emp/point":"1q","emp/sim_projector":"1r","emp/spec":"1s","emp/top_emp_img":"1t","img_dummy":"1u","img_menu":"1v","img_top":"20","include":"21","kousei_simulation":"22","lp9800c":"23","lp9800c/img-option":"24","lp9800c/jpg":"25","lpm5500":"26","lpm5500/img-option":"27","lpm5500/img-option-a":"28","lpm5500/img-option-f":"29","lps5500":"2a","lps5500/img-option":"2b","lps7000":"2c","lps7000/img-option":"2d","media":"2e","mfp":"2f","mfp/before_after":"2g","mfp/before_after/function":"2h","mfp/before_after/office01":"2i","mfp/before_after/office02":"2j","mfp/before_after/pdf":"2k","mfp/before_after/question":"2l","mfp/before_after/shinseihin":"2m","mfp/before_after/shop":"2n","mfp/cs_p":"2o","mfp/jirei":"2p","mfp/jirei/pdf":"2q","mfp/lp9800c":"2r","mfp/lpa500":"2s","mfp/lpm5500":"2t","mfp/lpm5500/200607":"2u","mfp/lpm5500/img/storagepac":"2v","mfp/lps6500":"30","mfp/swf":"31","navi":"32","news":"33","oshiete":"34","oshiete/count":"35","oshiete/swf":"36","oshiete/xml":"37","oshietetv":"38","printer":"39","printer/img_ps":"3a","printer/lp1400":"3b","printer/lp2500":"3c","printer/lp7900":"3d","printer/lp8800c":"3e","printer/lp8900":"3f","printer/lp9100n":"3g","printer/lp9100nps":"3h","printer/lp9800c":"3i","printer/lp9800cpl":"3j","printer/lps1100":"3k","printer/lps4500":"3l","printer/lps5500":"3m","printer/lps6500":"3n","printer/lps6500pd":"3o","printer/lps7000":"3p","printer/lps7000sr":"3q","printer/lpv500":"3r","printer/map":"3s","printer/swf":"3t","scanner":"3u","scanner/es10000g":"3v","scanner/es7000h":"40","scanner/es9000h":"41","scanner/esh300":"42","scanner/whats":"43","shindan":"44","shindan/200607":"45","solution":"46","station":"47","sw":"48","sw/document":"49","sw/document/ad":"4a","sw/document/ad/060331":"4b","sw/document/browser":"4c","sw/document/catalog":"4d","sw/document/example":"4e","sw/document/example/db":"4f","sw/document/example/db/popup":"4g","sw/document/example/ds":"4h","sw/document/example/ds/popup":"4i","sw/document/img/arrange":"4j","sw/document/img/backup":"4k","sw/document/img/bs":"4l","sw/document/img/button":"4m","sw/document/img/contents_frame":"4n","sw/document/img/main":"4o","sw/document/img/main_header":"4p","sw/document/img/main_nav":"4q","sw/document/img/moji":"4r","sw/document/img/personal_btn":"4s","sw/document/img/recommend":"4t","sw/document/img/recommend/pop_img":"4u","sw/document/img/recommend/topnav":"4v","sw/document/img/search":"50","sw/document/img/security":"51","sw/document/img/storage":"52","sw/document/img/webrio":"53","sw/document/img/yonde_btn":"54","sw/document/include":"55","sw/document/online":"56","sw/document/price":"57","sw/document/seminar":"58","sw/document/software":"59","sw/document/software/koko12":"5a","sw/document/software/koko12/buy_img":"5b","sw/document/software/koko12/coop_img":"5c","sw/document/software/koko12/detail":"5d","sw/document/software/koko12/feature_img":"5e","sw/document/software/koko12/function_img":"5f","sw/document/software/koko12/koko12_common":"5g","sw/document/software/koko12/koko12_common_img":"5h","sw/document/software/koko12/lineup_img":"5i","sw/document/software/koko12/new_img":"5j","sw/document/software/koko12/pdf_img":"5k","sw/document/software/koko12/reason_img":"5l","sw/document/software/koko12/sample_img":"5m","sw/document/software/koko12/scanner_img":"5n","sw/document/software/koko12/storage_img":"5o","sw/document/software/koko12/top_img":"5p","sw/document/software/koko12/trial_img":"5q","sw/document/software/koko12/workings_img":"5r","sw/document/software/products_img":"5s","sw/document/storage":"5t","sw/document/support":"5u","sw/img/header":"5v","sw/printing":"60","sw/printing/060714":"61","sw/printing/img/hikario":"62","sw/printing/java":"63","sw/printing/misc":"64","sw/printing/webmanager":"65","sw/sdk":"66","sw/security":"67","sw/sub":"68"};
var gOET_TARGET_FILE_LIST = {"index.htm":"01","spec.htm":"02","option.htm":"03","size.htm":"04","supply.htm":"05","feat_kousoku.htm":"06","feat_lowcost.htm":"07","feat_useful.htm":"08","feat_network.htm":"09","feat_business.htm":"0a","feat_copy.htm":"0b","feat_kouseisai.htm":"0c","network.htm":"0d","copy.htm":"0e","economy.htm":"0f","fax.htm":"0g","feat.htm":"0h","function.htm":"0i","print.htm":"0j","scan.htm":"0k","index.html":"0l","download.htm":"0m","environment.htm":"0n","ex001.htm":"0o","ex002.htm":"0p","ex003.htm":"0q","ex004.htm":"0r","ex005.htm":"0s","ex006.htm":"0t","feat_compact.htm":"0u","feat_security.htm":"0v","pop01.htm":"10","popup_img01.htm":"11","set.htm":"12","storage.htm":"13","01.htm":"14","02.htm":"15","03.htm":"16","04.htm":"17","05.htm":"18","bbv.htm":"19","bph1.htm":"1a","bpm1.htm":"1b","bpm2.htm":"1c","bpm3.htm":"1d","br01.htm":"1e","br02.htm":"1f","br03.htm":"1g","br04.htm":"1h","br05.htm":"1i","br06.htm":"1j","br07.htm":"1k","br08.htm":"1l","br14.htm":"1m","browser.htm":"1n","bunpu.htm":"1o","cable.htm":"1p","cable_t2.htm":"1q","case.htm":"1r","case_t2.htm":"1s","caution.htm":"1t","circumstance.htm":"1u","color_copies.htm":"1v","company.htm":"20","conference.htm":"21","cooperation.htm":"22","cost.html":"23","csr.htm":"24","detail01.htm":"25","detail02.htm":"26","detail03.htm":"27","detail04.htm":"28","detail05.htm":"29","detail06.htm":"2a","detail07.htm":"2b","detail08.htm":"2c","detail09.htm":"2d","emp-1700.htm":"2e","emp-1705.htm":"2f","emp-1710.htm":"2g","emp-1715.htm":"2h","emp-6100.htm":"2i","emp-750.htm":"2j","emp-755.htm":"2k","emp-760.htm":"2l","emp-765.htm":"2m","emp-7900.htm":"2n","emp-7950.htm":"2o","emp-82.htm":"2p","emp-830.htm":"2q","emp-8300.htm":"2r","emp-835.htm":"2s","emp-S4.htm":"2t","emp_sm2.htm":"2u","ex007.htm":"2v","ex008.htm":"30","ex009.htm":"31","ex010.htm":"32","ex011.htm":"33","feat_quality.htm":"34","feature.htm":"35","feature01.htm":"36","feature02.htm":"37","feature03.htm":"38","feature1.htm":"39","feature2.htm":"3a","file.htm":"3b","flash.htm":"3c","format.htm":"3d","func_temp.html":"3e","high.html":"3f","hikaku.htm":"3g","hikaku5-if.htm":"3h","hikario.htm":"3i","index2.htm":"3j","index_noflash.htm":"3k","index_p.htm":"3l","info.htm":"3m","info_kanagu.htm":"3n","intro.htm":"3o","it1.htm":"3p","it2.htm":"3q","japanese.htm":"3r","kakakukomu.htm":"3s","kanagu.htm":"3t","kanagu_t2.htm":"3u","kyori.htm":"3v","lens.htm":"40","lens_t2.htm":"41","lineup.htm":"42","lp9800cpl.htm":"43","lump.htm":"44","mail.htm":"45","mmv.htm":"46","multi.htm":"47","n_scan.htm":"48","network01.htm":"49","network02.htm":"4a","new.htm":"4b","new_ver10.htm":"4c","new_ver11.htm":"4d","new_ver8.htm":"4e","new_ver9.htm":"4f","news_if.htm":"4g","oc_a_sol1.htm":"4h","oc_a_sol10.htm":"4i","oc_a_sol2.htm":"4j","oc_a_sol3.htm":"4k","oc_a_sol4.htm":"4l","oc_a_sol5.htm":"4m","oc_a_sol6.htm":"4n","oc_a_sol7.htm":"4o","oc_a_sol8.htm":"4p","oc_a_sol9.htm":"4q","oc_m_mfp.htm":"4r","oc_m_offirio.htm":"4s","oc_m_printer.htm":"4t","oc_m_q1.htm":"4u","oc_m_q10.htm":"4v","oc_m_q2.htm":"50","oc_m_q3.htm":"51","oc_m_q4.htm":"52","oc_m_q5.htm":"53","oc_m_q6.htm":"54","oc_m_q7.htm":"55","oc_m_q8.htm":"56","oc_m_q9.htm":"57","oc_m_sol.htm":"58","oc_m_tvcm.htm":"59","oc_p_mfp_item.htm":"5a","oc_p_printer_item.htm":"5b","office01_01.html":"5c","office01_02.html":"5d","office01_03.html":"5e","office01_04.html":"5f","office01_05.html":"5g","office01_top.html":"5h","office02_01.html":"5i","office02_02.html":"5j","office02_03.html":"5k","office02_04.html":"5l","office02_05.html":"5m","office02_top.html":"5n","other.htm":"5o","other_t2.htm":"5p","outline.htm":"5q","owabi.htm":"5r","owabi_051205mfp.htm":"5s","owabi_051205printer.htm":"5t","owabi_051227mfp.htm":"5u","owabi_060706mfp.htm":"5v","owabi_060731printer.htm":"60","p1.htm":"61","p2.htm":"62","p3.htm":"63","p4.htm":"64","p5.htm":"65","p6.htm":"66","p7.htm":"67","pasori.htm":"68","pcfree.htm":"69","pcfree_f.htm":"6a","pop01_1.htm":"6b","pop01_2.htm":"6c","pop02.htm":"6d","pop02_1.htm":"6e","pop02_2.htm":"6f","pop02_3.htm":"6g","pop02_4.htm":"6h","pop02_5.htm":"6i","pop03.htm":"6j","pop03_1.htm":"6k","pop03_2.htm":"6l","pop03_3.htm":"6m","pop03_4.htm":"6n","popup001.htm":"6o","popup001_1.htm":"6p","popup001_2.htm":"6q","popup001_3.htm":"6r","popup002.htm":"6s","popup002_1.htm":"6t","popup002_2.htm":"6u","popup002_3.htm":"6v","popup003.htm":"70","popup003_1.htm":"71","popup003_2.htm":"72","popup003_3.htm":"73","popup004.htm":"74","popup004_1.htm":"75","popup004_2.htm":"76","popup004_3.htm":"77","popup005.htm":"78","popup005_1.htm":"79","popup005_2.htm":"7a","popup005_3.htm":"7b","popup006.htm":"7c","popup006_1.htm":"7d","popup006_2.htm":"7e","popup006_3.htm":"7f","popup007_1.htm":"7g","popup007_2.htm":"7h","popup007_3.htm":"7i","popup008_1.htm":"7j","popup008_2.htm":"7k","popup008_3.htm":"7l","popup009.htm":"7m","popup009_1.htm":"7n","popup009_2.htm":"7o","popup009_3.htm":"7p","popup010_1.htm":"7q","popup010_2.htm":"7r","popup010_3.htm":"7s","popup011_1.htm":"7t","popup011_2.htm":"7u","popup011_3.htm":"7v","printer.htm":"80","proposal.htm":"81","protocol.htm":"82","q1.html":"83","q2.html":"84","question.htm":"85","s_scan.htm":"86","sagyou.html":"87","scanner.htm":"88","screen.htm":"89","sec01.htm":"8a","sec02.htm":"8b","sec03.htm":"8c","security.htm":"8d","server.htm":"8e","service.htm":"8f","shomohin.htm":"8g","shop_01.html":"8h","shop_02.html":"8i","shop_03.html":"8j","shop_04.html":"8k","shop_05.html":"8l","shop_top.html":"8m","sitemap.htm":"8n","soft.htm":"8o","soft01_1.htm":"8p","soft01_2.htm":"8q","soft01_3.htm":"8r","soft02_1.htm":"8s","soft02_2.htm":"8t","soft02_3.htm":"8u","soft03_1.htm":"8v","soft03_2.htm":"90","soft03_3.htm":"91","space.html":"92","spec1700.htm":"93","spec1705.htm":"94","spec1710.htm":"95","spec1715.htm":"96","spec6100.htm":"97","spec750.htm":"98","spec755.htm":"99","spec760.htm":"9a","spec765.htm":"9b","spec7900.htm":"9c","spec7950.htm":"9d","spec82.htm":"9e","spec830.htm":"9f","spec8300.htm":"9g","spec835.htm":"9h","spec_s4.htm":"9i","st01.htm":"9j","st02.htm":"9k","st03.htm":"9l","storagepac.htm":"9m","substitute-if2.htm":"9n","support.htm":"9o","table_b.htm":"9p","table_p.htm":"9q","taiken.htm":"9r","thank.html":"9s","tool01.htm":"9t","tool02.htm":"9u","tool03.htm":"9v","usb.htm":"a0","vision.htm":"a1","wagon.htm":"a2","wagon_t2.htm":"a3","workings.htm":"a4"};

//==================================================
// url data object
//==================================================
function oetUrlData() {
  this.dir  = "";
  this.file = "";
  var oDate = new Date();
  this.time = oDate.getTime();
  this.cookie = "";
}
oetUrlData.prototype.fromCookie = _oetUrlData_fromCookie;
oetUrlData.prototype.setUrl     = _oetUrlData_setUrl;
oetUrlData.prototype.toCookie   = _oetUrlData_toCookie;

//--------------------------------------------------
// method:fromCookie
//--------------------------------------------------
function _oetUrlData_fromCookie(argCookie) {

  this.cookie = argCookie;
  var tmpCookie = argCookie;
  var arrCookie = tmpCookie.split("|");
  for (var i=0; i<arrCookie.length; i++) {
    var nm = arrCookie[i].substr(0,2);
    var vl = arrCookie[i].substr(2);
    if      (nm == "D:") { this.dir  = vl; }
    else if (nm == "F:") { this.file = vl; }
    else if (nm == "T:") { this.time = vl; }
  }

  return this;
}

//--------------------------------------------------
// method:setUrl
//--------------------------------------------------
function _oetUrlData_setUrl(argUrl) {

  // URLを分解
  var spIdx = argUrl.lastIndexOf("/");

  var tgUrlDir, tgUrlFile;
  if (spIdx < 0) {
    // offirio直下
    tgUrlDir  = "";
    tgUrlFile = argUrl;
  } else {
    // サブディレクトリ有り
    tgUrlDir  = argUrl.substr(0,spIdx);
    tgUrlFile = argUrl.substr(spIdx + 1);
  }

  // URLをコード化する
  var zUrlDir = gOET_TARGET_DIR_LIST[tgUrlDir];
  if (zUrlDir) {
    zUrlDir = "$" + zUrlDir;
  } else {
    zUrlDir = tgUrlDir;
  }
  var zUrlFile = gOET_TARGET_FILE_LIST[tgUrlFile];
  if (zUrlFile) {
    zUrlFile = "$" + zUrlFile;
  } else {
    zUrlFile = tgUrlFile;
  }

  this.dir  = zUrlDir;
  this.file = zUrlFile;
  var oDate = new Date();
  this.time = oDate.getTime();
  this.cookie = this.toCookie();

  return this;
}

//--------------------------------------------------
// method:toCookie
//--------------------------------------------------
function _oetUrlData_toCookie() {
  var strCookie = "";

  strCookie += "D:" + this.dir  + "|";
  strCookie += "F:" + this.file + "|";
  strCookie += "T:" + this.time + "|";

  this.cookie = strCookie;
  return strCookie;
}

//--------------------------------------------------
// method:length
//--------------------------------------------------
function _oetUrlData_length() {
  return this.cookie.length;
}

//==================================================
// cookie data object
//==================================================
function oetCookieData() {
  var oDate = new Date();
  this.time = oDate.getTime();
  this.size = 0;
  this.urlData = new Array();

}
oetCookieData.prototype.fromCookie = _oetCookieData_fromCookie;
oetCookieData.prototype.addUrlData = _oetCookieData_addUrlData;
oetCookieData.prototype.toCookie   = _oetCookieData_toCookie;

//--------------------------------------------------
// method:fromCookie
//--------------------------------------------------
function _oetCookieData_fromCookie(argCookie) {

  var tmpCookie = argCookie;
  var arrCookie = tmpCookie.split("@");
  if (arrCookie.length < 2) { return this; }

  var strTime = arrCookie[0];
  var strSize = arrCookie[1];
  if (strSize != arrCookie.length - 3) { return this; }

  var arrUrlData = new Array();
  for (i=2; i<arrCookie.length - 1; i++){
    var oUrlData = new oetUrlData();
    oUrlData.fromCookie(arrCookie[i]);
    arrUrlData[i-2] = oUrlData;
  }

  this.time = strTime;
  this.size = strSize;
  this.urlData = arrUrlData;

  return this;
}

//--------------------------------------------------
// method:addUrlData
//--------------------------------------------------
function _oetCookieData_addUrlData(argUrlData) {

  var newUrlData = new Array();
  var newSize = 0;

  if (this.urlData.length != 0 && argUrlData.dir == this.urlData[0].dir &&  argUrlData.file == this.urlData[0].file ) {
    this.urlData[0].time = argUrlData.time - this.time;
    return this;
  }

  newUrlData[0] = argUrlData;
  newUrlData[0].time -= this.time;
  newSize = argUrlData.cookie.length;
  for (i=0; i<this.urlData.length && i<gOET_MAX_URL_COUNT-1; i++) {
    var aUrlData = this.urlData[i];
    newSize += aUrlData.cookie.length;
    if (newSize > gOET_MAX_URL_SIZE) { break; }
    newUrlData[i+1] = this.urlData[i];
  }

  this.urlData = newUrlData;
  this.size = newUrlData.length;

  return this;
}

//--------------------------------------------------
// method:toCookie
//--------------------------------------------------
function _oetCookieData_toCookie() {
  var strCookie = "";

  strCookie += this.time + "@";
  strCookie += this.urlData.length + "@";
  for (i = 0; i < this.urlData.length; i++) {
    strCookie += this.urlData[i].toCookie() + "@";
  }

  this.cookie = strCookie;
  return strCookie;
}

//==================================================
// misc
//==================================================
function oetIsNumber(argNum) {
  var strNum = "0123456789";
  for (i = 0; i < strNum.length; i++) {
    if (strNum.indexOf(argNum.charAt(i)) < 0) { return false; }
  }
  return true;
}

//==================================================
// main process
//==================================================
function oet_client_main() {

  // 対象URLかどうかのチェック
  var chkUrl = location.href;
  if (chkUrl.substr(0,gOET_TARGET_URL.length) != gOET_TARGET_URL) { return false; }
  var tgUrl = chkUrl.substr(gOET_TARGET_URL.length);

  var oUrlData = new oetUrlData();
  oUrlData.setUrl(tgUrl);

  var oCookieData = new oetCookieData();

  var strCookie = document.cookie;
  var arrCookie = strCookie.split("; ");
  var tgCookie = "";
  for (var i=0; i<arrCookie.length; i++) {
    if (arrCookie[i].substr(0,8) == "oetdata=") {
      tgCookie = arrCookie[i].substr(8);
      break;
    }
  }

  if (tgCookie.length != 0) {
    oCookieData.fromCookie(tgCookie);
  }

  oCookieData.addUrlData(oUrlData);

  strCookie = oCookieData.toCookie();

//  document.cookie = "oetdata=" + strCookie + ";path=" + gOET_COOKIE_PATH;
  ept_set_cookie(oCookieData, null);

  return true;
}

function ept_set_cookie(oetObj, metObj) {
  var oOCookieData = new oetCookieData(); // offirio
  var oMCookieData = new oetCookieData(); // maxart

  var strCookie = document.cookie;
  var arrCookie = strCookie.split("; ");
  var tgOCookie = "";
  var tgMCookie = "";
  for (var i=0; i<arrCookie.length; i++) {
    if (arrCookie[i].substr(0,8) == "oetdata=") {
      tgOCookie = arrCookie[i].substr(8);
      oOCookieData.fromCookie(tgOCookie);
    }
    if (arrCookie[i].substr(0,8) == "metdata=") {
      tgMCookie = arrCookie[i].substr(8);
      oMCookieData.fromCookie(tgMCookie);
    }
  }

  if (oetObj) { oOCookieData = oetObj; }
  if (metObj) { oMCookieData = metObj; }

  var newOUrlData = new Array();
  var newMUrlData = new Array();
  var olen = oOCookieData.urlData.length;
  var mlen = oMCookieData.urlData.length;
  var ai = 0;
  var oi = 0;
  var mi = 0;
  var newSize = 0;
//  alert(olen + mlen);
  for (ai=0; ai<olen+mlen; ai++) {
    // offirio と maxart どちらにもオブジェクトがある場合
    if (oi < olen && mi < mlen) {
      var oOUrlData = oOCookieData.urlData[oi];
      var oMUrlData = oMCookieData.urlData[mi];

      // offirio と maxart どちらが新しいか
      var ot = new Date(parseInt(oOUrlData.time) + parseInt(oOCookieData.time));
      var mt = new Date(parseInt(oMUrlData.time) + parseInt(oMCookieData.time));
      if (ot > mt) {
//        alert('oimi - o '+'['+ot.toLocaleString()+']['+mt.toLocaleString()+']');
        // offirioの方が新しい
        newSize += oOUrlData.cookie.length;
        if (newSize > gOET_MAX_URL_SIZE) { break; }
        newOUrlData[oi] = oOUrlData;
        oi++;
      } else {
//        alert('oimi - m '+'['+ot.toLocaleString()+']['+mt.toLocaleString()+']');
        // maxartの方が新しい
        newSize += oMUrlData.cookie.length;
        if (newSize > gOET_MAX_URL_SIZE) { break; }
        newMUrlData[mi] = oMUrlData;
        mi++;
      }
    } else if (oi >= olen) {
//      alert('mi');
      // offirio のオブジェクトがないので maxart を処理する
      var oMUrlData = oMCookieData.urlData[mi];
      newSize += oMUrlData.cookie.length;
      if (newSize > gOET_MAX_URL_SIZE) { break; }
      newMUrlData[mi] = oMUrlData;
      mi++;
    } else if (mi >= mlen) {
//      alert('oi');
      // maxart のオブジェクトがないので offirio を処理する
      var oOUrlData = oOCookieData.urlData[oi];
      newSize += oOUrlData.cookie.length;
      if (newSize > gOET_MAX_URL_SIZE) { break; }
      newOUrlData[oi] = oOUrlData;
      oi++;
    } else {
//      alert('other');
    }
  }

  oOCookieData.urlData = newOUrlData;
  oOCookieData.size    = newOUrlData.length;
  oMCookieData.urlData = newMUrlData;
  oMCookieData.size    = newMUrlData.length;

  var strOCookie = "";
  var strMCookie = "";

  if (oOCookieData.urlData.length > 0) { strOCookie = oOCookieData.toCookie(); }
  if (oMCookieData.urlData.length > 0) { strMCookie = oMCookieData.toCookie(); }

  if (olen > 0) {
    if (strOCookie.length > 0) {
      document.cookie = "oetdata=" + strOCookie + ";path=" + gOET_COOKIE_PATH;
    } else {
      document.cookie = "oetdata=;expires=Thu, 01-Jan-1970 00:00:00 GMT;path=" + gOET_COOKIE_PATH;;
    }
  }
  if (mlen > 0) {
    if (strMCookie.length > 0) {
      document.cookie = "metdata=" + strMCookie + ";path=" + gOET_COOKIE_PATH;
    } else {
      document.cookie = "metdata=;expires=Thu, 01-Jan-1970 00:00:00 GMT;path=" + gOET_COOKIE_PATH;;
    }
  }
}

//**********************************************************************//
//**********************************************************************//
//**********************************************************************//

//==================================================
// global values (User Access Analysis)
//==================================================
var gOUAA_TARGET_URL = "http://www.epson.jp/products/offirio/";
var gOUAA_SUB_TARGET_URL = new Array('printer/', 'mfp/', 'emp/', 'scanner/', 'sw/');
var gOUAA_COOKIE_PATH = "/";
var gOUAA_MAX_URL_COUNT = 384;
var gOUAA_MAX_URL_SIZE  = 1536;
var gOUAA_HTML_COUNT_BEFOR = "<script type='text/javascript' language='JavaScript' src='http://www.epson.jp/cgi-bin/offirio/200706/count.cgi";
var gOUAA_HTML_COUNT_AFTER = "'></script>";
var gOUAA_SUB_HTML_COUNT_BEFOR = "<script type='text/javascript' language='JavaScript' src='http://www.epson.jp/cgi-bin/offirio/200706/";
var gOUAA_SUB_HTML_COUNT_AFTER = "'></script>";
var gOUAA_TARGET_URL_LIST  = {"kaikae0706/":"001","mfp/lpa500/network.htm":"002","mfp/lpa500/option.htm":"003","mfp/lpm5600/copy.htm":"004","mfp/lpm5600/economy.htm":"005","mfp/lpm5600/fax.htm":"006","mfp/lpm5600/network.htm":"007","mfp/lpm5600/option.htm":"008","mfp/lpm5600/print.htm":"009","mfp/lpm5600/scan.htm":"010","mfp/lpm5600/size.htm":"011","mfp/lpm5600/spec.htm":"012","mfp/lpm5600/supply.htm":"013","mfp/lpm6500/copy.htm":"014","mfp/lpm6500/economy.htm":"015","mfp/lpm6500/fax.htm":"016","mfp/lpm6500/network.htm":"017","mfp/lpm6500/option.htm":"018","mfp/lpm6500/print.htm":"019","mfp/lpm6500/scan.htm":"020","mfp/lpm6500/size.htm":"021","mfp/lpm6500/spec.htm":"022","mfp/lpm6500/supply.htm":"023","mfp/lpm9800/copy.htm":"024","mfp/lpm9800/economy.htm":"025","mfp/lpm9800/fax.htm":"026","mfp/lpm9800/network.htm":"027","mfp/lpm9800/option.htm":"028","mfp/lpm9800/print.htm":"029","mfp/lpm9800/scan.htm":"030","mfp/lpm9800/size.htm":"031","mfp/lpm9800/spec.htm":"032","mfp/lpm9800/supply.htm":"033","mfp/rental/":"034","mfp/":"035","navi/flash.htm":"036","printer/guide/":"037","printer/lp2500/feat_network.htm":"038","printer/lp2500/option.htm":"039","printer/lp7900/feat_network.htm":"040","printer/lp7900/feat_useful.htm":"041","printer/lp7900/option.htm":"042","printer/lp8900/feat_network.htm":"043","printer/lp8900/option.htm":"044","printer/lp9100n/feat_network.htm":"045","printer/lp9100n/option.htm":"046","printer/lp9800c/feat_business.htm":"047","printer/lp9800c/feat_copy.htm":"048","printer/lp9800c/feat_kousoku.htm":"049","printer/lp9800c/feat_lowcost.htm":"050","printer/lp9800c/feat_network.htm":"051","printer/lp9800c/feat_useful.htm":"052","printer/lp9800c/":"053","printer/lp9800c/lp9800cpl.htm":"054","printer/lp9800c/option.htm":"055","printer/lp9800c/size.htm":"056","printer/lp9800c/spec.htm":"057","printer/lp9800c/supply.htm":"058","printer/lps1100/feat_network.htm":"059","printer/lps4000/feat_network.htm":"060","printer/lps4000/feat_security.htm":"061","printer/lps4000/option.htm":"062","printer/lps4000/size.htm":"063","printer/lps4000ps/option.htm":"064","printer/lps4500/feat_network.htm":"065","printer/lps4500/feat_security.htm":"066","printer/lps4500/option.htm":"067","printer/lps5000/feat_business.htm":"068","printer/lps5000/feat_compact.htm":"069","printer/lps5000/feat_kousoku.htm":"070","printer/lps5000/feat_lowcost.htm":"071","printer/lps5000/feat_network.htm":"072","printer/lps5000/feat_security.htm":"073","printer/lps5000/feat_useful.htm":"074","printer/lps5000/":"075","printer/lps5000/option.htm":"076","printer/lps5000/size.htm":"077","printer/lps5000/spec.htm":"078","printer/lps5000/supply.htm":"079","printer/lps6000/feat_business.htm":"080","printer/lps6000/feat_kousoku.htm":"081","printer/lps6000/feat_lowcost.htm":"082","printer/lps6000/feat_network.htm":"083","printer/lps6000/feat_security.htm":"084","printer/lps6000/feat_syouspace.htm":"085","printer/lps6000/feat_useful.htm":"086","printer/lps6000/":"087","printer/lps6000/option.htm":"088","printer/lps6000/size.htm":"089","printer/lps6000/spec.htm":"090","printer/lps6000/supply.htm":"091","printer/lps6500/feat_business.htm":"092","printer/lps6500/feat_compact.htm":"093","printer/lps6500/feat_copy.htm":"094","printer/lps6500/feat_kousoku.htm":"095","printer/lps6500/feat_lowcost.htm":"096","printer/lps6500/feat_network.htm":"097","printer/lps6500/feat_security.htm":"098","printer/lps6500/feat_useful.htm":"099","printer/lps6500/":"100","printer/lps6500/option.htm":"101","printer/lps6500/size.htm":"102","printer/lps6500/spec.htm":"103","printer/lps6500/supply.htm":"104","printer/lps7000/feat_business.htm":"105","printer/lps7000/feat_copy.htm":"106","printer/lps7000/feat_kousoku.htm":"107","printer/lps7000/feat_lowcost.htm":"108","printer/lps7000/feat_network.htm":"109","printer/lps7000/feat_useful.htm":"110","printer/lps7000/":"111","printer/lps7000/option.htm":"112","printer/lps7000/size.htm":"113","printer/lps7000/spec.htm":"114","printer/lps7000/supply.htm":"115","printer/lpv500/feat_business.htm":"116","printer/lpv500/feat_kousoku.htm":"117","printer/lpv500/feat_lowcost.htm":"118","printer/lpv500/feat_network.htm":"119","printer/lpv500/feat_useful.htm":"120","printer/lpv500/":"121","printer/lpv500/option.htm":"122","printer/lpv500/size.htm":"123","printer/lpv500/spec.htm":"124","printer/lpv500/supply.htm":"125","printer/":"126","printer/index2.htm":"127","printer/index_p.htm":"128","scanner/":"129","sw/printing/device.htm":"130","sw/printing/director1.htm":"131","sw/printing/director1_1.htm":"132","sw/printing/director1_2.htm":"133","sw/printing/director1_3.htm":"134","sw/printing/download.htm":"135","sw/printing/":"136","sw/printing/install1.htm":"137","sw/printing/install2.htm":"138","sw/printing/pop03.htm":"139","sw/printing/pop05.htm":"140","sw/printing/pop06.htm":"141","sw/printing/pop07.htm":"142","sw/printing/pop08.htm":"143","sw/printing/support.htm":"144","sw/printing/tool_direct.htm":"145","sw/printing/tool_ipp.htm":"146","sw/printing/tool_ndps.htm":"147","sw/printing/visible.htm":"148","sw/proposal/":"149","sw/sdk/":"150","sw/sdk/sc.htm":"151","sw/security/copy.htm":"152","sw/security/history.htm":"153","sw/security/":"154","sw/security/mistake.htm":"155","sw/security/ninsyo1.htm":"156","sw/security/ninsyo2.htm":"157","sw/security/ninsyo3.htm":"158","sw/security/ninsyo_sys.htm":"159","sw/security/pop01_1.htm":"160","sw/security/pop01_2.htm":"161","sw/security/pop03.htm":"162","sw/security/pop04.htm":"163","sw/security/pop05.htm":"164","sw/security/pop06.htm":"165","sw/security/risk.htm":"166","sw/sub/pasori.htm":"167","sw/":"168","index.htm":"169","information.htm":"170","sitemap.htm":"171","ad/ya11.htm":"172","ad/ya12.htm":"173","ad/ya21.htm":"174","ad/ya22.htm":"175","ad/ya31.htm":"176","ad/ya32.htm":"177","ad/ya41.htm":"178","ad/ya42.htm":"179","ad/ms11.htm":"180","ad/ms12.htm":"181","ad/ms21.htm":"182","ad/ms22.htm":"183","ad/go11.htm":"184","ad/go12.htm":"185","ad/go21.htm":"186","ad/go22.htm":"187","ad/as11.htm":"188","ad/as12.htm":"189","ad/as21.htm":"190","ad/as22.htm":"191","ad/ni11.htm":"192","ad/ni12.htm":"193","ad/ni21.htm":"194","ad/ni22.htm":"195","ad/fd11.htm":"196","ad/fd21.htm":"197","ad/fd31.htm":"198","ad/um11.htm":"199","ad/um21.htm":"200","ad/cy11.htm":"201","ad/cy21.htm":"202","ad/mi11.htm":"203","ad/mi21.htm":"204","ad/so11.htm":"205","ad/so21.htm":"206","ad/de11.htm":"207","ad/de21.htm":"208","ad/fb11.htm":"209","ad/fb21.htm":"210","ad/fb31.htm":"211","ad/it11.htm":"212","ad/it12.htm":"213","ad/im11.htm":"214","ad/im12.htm":"215","ad/cn11.htm":"216","ad/cn12.htm":"217","ad/zd11.htm":"218","ad/zd12.htm":"219","ad/ka11.htm":"220","ad/ke01.htm":"221","ad/ip01.htm":"222","ad/ip02.htm":"223","ad/ip03.htm":"224","ad/ip04.htm":"225","ad/im01.htm":"226","ad/im02.htm":"227","ad/bp13.htm":"228","ad/bp14.htm":"229","ad/bp15.htm":"230","ad/bp16.htm":"231","ad/nikkeipc02.htm":"232","ad/nikkeipc03.htm":"233","ad/nikkeipc04.htm":"234","ad/ad11.htm":"235","ad/ad12.htm":"236","ad/ad13.htm":"237","ad/ad14.htm":"238","ad/ov11.htm":"239","ad/ov12.htm":"240","ad/bp11.htm":"241","ad/googlesearch1.htm":"242","ad/googlesearch2.htm":"243","ad/kakakukomu.htm":"244","ad/nikkeibusiness.htm":"245","ad/nikkeipc.htm":"246","ad/overture1.htm":"247","ad/overture2.htm":"248","oshiete/":"249","oshiete/count/oc_m_offirio.htm":"250","oshiete/count/oc_m_printer.htm":"251","oshiete/count/oc_m_tvcm.htm":"252","oshiete/count/oc_m_sol.htm":"253","oshiete/count/oc_m_q1.htm":"254","oshiete/count/oc_m_q2.htm":"255","oshiete/count/oc_m_q3.htm":"256","oshiete/count/oc_m_q4.htm":"257","oshiete/count/oc_m_q5.htm":"258","oshiete/count/oc_m_q6.htm":"259","oshiete/count/oc_m_q7.htm":"260","oshiete/count/oc_m_q18.htm":"261","oshiete/count/oc_m_q9.htm":"262","oshiete/count/oc_m_q10.htm":"263","js/test.html":"9999"};


//==================================================
// access data object
//==================================================
function ouaaUrlData() {
  this.code    = "";          // URLコード
  this.date    = "";          // 最終アクセス日
  this.revisit = "";          // 再訪問フラグ
  this.session = false;       // セッションフラグ
  this.cookie  = "";          // Cookieデータ
}
ouaaUrlData.prototype.fromCookie      = _ouaaUrlData_fromCookie;
ouaaUrlData.prototype.toCookie        = _ouaaUrlData_toCookie;
ouaaUrlData.prototype.setUrl          = _ouaaUrlData_setUrl;

//--------------------------------------------------
// method:fromCookie
//--------------------------------------------------
function _ouaaUrlData_fromCookie(argCookie) {

  this.cookie = argCookie;
  var tmpCookie = argCookie;
  var arrCookie = tmpCookie.split("|");
  if (arrCookie.length != 3) { return; }

  this.code    = arrCookie[0];
  this.date    = arrCookie[1];
  this.revisit = arrCookie[2];

  return this;
}

//--------------------------------------------------
// method:toCookie
//--------------------------------------------------
function _ouaaUrlData_toCookie() {
  var strCookie = "";

  strCookie = this.code  + "|" + this.date  + "|" + this.revisit;

  this.cookie = strCookie;
  return strCookie;
}

//--------------------------------------------------
// method:setUrl
//--------------------------------------------------
function _ouaaUrlData_setUrl(argUrl) {

  // URLをコード化する
  var zUrlCode = gOUAA_TARGET_URL_LIST[argUrl];
  if (!zUrlCode) {
    zUrlCode = argUrl;  // コード化出来ないためそのまま保存
  }

  // 日付データの作成
  var oDate = new Date();
  var strDate = ("0"  + oDate.getYear()).substr(-1)
    + ("00" + oDate.getMonth()).substr(-2)
    + ("00" + oDate.getDate()).substr(-2);

  this.code    = zUrlCode;
  this.date    = strDate;
  this.revisit = "";
  this.session = true;
  this.cookie  = this.toCookie();

  return this;
}

//==================================================
// cookie data object (User Access Analysis)
//==================================================
function ouaaCookieData() {
  var oDate = new Date();
  this.date    = "";            // 最終アクセス日
  this.revisit = "";            // 再訪問フラグ
  this.size    = 0;             // アクセス履歴数
  this.urlData = new Array();   // アクセス履歴

  this.session = false;         // セッションフラグ

  this.uniqueSiteFlag  = false; // 日別ユニークサイト呼び出しフラグ
  this.uniquePageFlag  = false; // 日別ユニークページ呼び出しフラグ
  this.revisitSiteFlag = false; // 再訪問サイト呼び出しフラグ
  this.revisitPageFlag = false; // 再訪問ページ呼び出しフラグ

  this.cookie  = "";            // Cookieデータ

  this.subdir  = -1;            // subdirフラグ
}
ouaaCookieData.prototype.fromCookie       = _ouaaCookieData_fromCookie;
ouaaCookieData.prototype.toCookie         = _ouaaCookieData_toCookie;
ouaaCookieData.prototype.toSessionCookie  = _ouaaCookieData_toSessionCookie;
ouaaCookieData.prototype.addUrl           = _ouaaCookieData_addUrl;
ouaaCookieData.prototype.getUrlData       = _ouaaCookieData_getUrlData;
ouaaCookieData.prototype.checkUrl         = _ouaaCookieData_checkUrl;
ouaaCookieData.prototype.countUniqueSite  = _ouaaCookieData_countUniqueSite;
ouaaCookieData.prototype.countUniquePage  = _ouaaCookieData_countUniquePage;
ouaaCookieData.prototype.countRevisitSite = _ouaaCookieData_countRevisitSite;
ouaaCookieData.prototype.countRevisitPage = _ouaaCookieData_countRevisitPage;

//--------------------------------------------------
// method:fromCookie
//--------------------------------------------------
function _ouaaCookieData_fromCookie(argCookie, argSessionCookie) {

  this.cookie = argCookie;

  var tmpCookie = argCookie;
  var arrCookie = tmpCookie.split("@");
  if (arrCookie.length < 3) { return this; }

  var strDate    = arrCookie[0];
  var strRevisit = arrCookie[1];
  var strSize    = arrCookie[2];
  if (strSize != arrCookie.length - 4) { return this; }

  var tmpSC = argSessionCookie;
  var arrSC = tmpSC.split("@");

  var arrUrlData = new Array();
  for (i = 3; i < arrCookie.length - 1; i++) {
    var oUrlData = new ouaaUrlData();
    oUrlData.fromCookie(arrCookie[i]);
    for (n = 0; n < arrSC.length - 1; n++) {
      if (arrSC[n] == oUrlData.code) {
        oUrlData.session = true;
        break;
      }
    }
    arrUrlData[i-3] = oUrlData;
  }

  this.date    = strDate;
  this.revisit = strRevisit;
  this.size    = arrUrlData.length;
  this.urlData = arrUrlData;
  if (argSessionCookie != "") {
    this.session = true;
  }

  return this;
}

//--------------------------------------------------
// method:toCookie
//--------------------------------------------------
function _ouaaCookieData_toCookie() {
  var strCookie = "";

  strCookie += this.date + "@";
  strCookie += this.revisit + "@";
  strCookie += this.urlData.length + "@";
  for (i = 0; i < this.urlData.length; i++) {
    strCookie += this.urlData[i].toCookie() + "@";
  }


  this.cookie = strCookie;
  return strCookie;
}

//--------------------------------------------------
// method:toSessionCookie
//--------------------------------------------------
function _ouaaCookieData_toSessionCookie() {
  var strCookie = "";

  for (i = 0; i < this.urlData.length; i++) {
    if (this.urlData[i].session == true) {
      strCookie += this.urlData[i].code + "@";
    }
  }

  return strCookie;
}

//--------------------------------------------------
// method:addUrl
//--------------------------------------------------
function _ouaaCookieData_addUrl(argUrl) {

  // 既にオブジェクトがあれば終了
  if (this.getUrlData(argUrl)) { return; }

  // UrlDataオブジェクトを作成
  var ouUrlData = new ouaaUrlData();
  ouUrlData.setUrl(argUrl);

  this.urlData[this.size] = ouUrlData;
  this.size++;

  return this;
}

//--------------------------------------------------
// method:getUrlData
//--------------------------------------------------
function _ouaaCookieData_getUrlData(argUrl) {

  // URLをコード化する
  var zUrlCode = gOUAA_TARGET_URL_LIST[argUrl];
  if (!zUrlCode) {
    zUrlCode = argUrl;
  }

  for (i = 0; i < this.urlData.length; i++) {
    if (this.urlData[i].code == zUrlCode) {
      return this.urlData[i];
    }
  }

  return;
}

//--------------------------------------------------
// method:checkUrl
//--------------------------------------------------
function _ouaaCookieData_checkUrl(argUrl) {

  // 今日の日付
  var oDate = new Date();
  var strDate = ("0"  + oDate.getYear()).substr(-1)
    + ("00" + oDate.getMonth()).substr(-2)
    + ("00" + oDate.getDate()).substr(-2);

  if (this.session == false) {
    // 初回アクセス

    // 日別ユニーク判断
    if (this.date != strDate) {
      this.uniqueSiteFlag = true;
    }

    // 再訪問判断
    if (this.date != "" && this.revisit == "") {
      this.revisitSiteFlag = true;
      this.revisit = "1";
    }

  }
  // 今日の日付を設定
  this.date = strDate;
  this.session = true;

  // URLオブジェクト
  var ouUrlData = this.getUrlData(argUrl);

  if (!ouUrlData) {
    // 初回アクセス
    this.uniquePageFlag = true;
    this.addUrl(argUrl);

  } else {
    if (ouUrlData.session == false) {

      // 日別ページユニーク判断
      if (ouUrlData.date != strDate) {
        this.uniquePageFlag = true;
      }

      // 再訪問ページ判断
      if (ouUrlData.revisit == "") {
        this.revisitPageFlag = true;
        ouUrlData.revisit = "1";
      }

    }
    ouUrlData.date = strDate;
    ouUrlData.session = true;
  }

}

//--------------------------------------------------
// method:countUniqueSite - 日別ユニーク
//--------------------------------------------------
function _ouaaCookieData_countUniqueSite() {

  if (this.uniqueSiteFlag) {

    // カウンターの呼び出し
    var strParam = "?t=1&u=";
    if (this.subdir < 0) {
      document.write(gOUAA_HTML_COUNT_BEFOR + strParam + gOUAA_HTML_COUNT_AFTER);
    } else {
      document.write(gOUAA_SUB_HTML_COUNT_BEFOR + gOUAA_SUB_TARGET_URL[this.subdir] + "count.cgi" + strParam + gOUAA_SUB_HTML_COUNT_AFTER);
    }

  }

  return true;
}

//--------------------------------------------------
// method:countUniquePage - 日別ユニーク(ページ)
//--------------------------------------------------
function _ouaaCookieData_countUniquePage(argUrl) {

  if (this.uniquePageFlag) {

    // カウンターの呼び出し
    var strUrl = escape(argUrl.replace(/[\/\.]/g, '_'));
    var chkIdx = -1;
    chkIdx = strUrl.indexOf('%');
    if (chkIdx < 0) {
      var strParam = "?t=2&u=" + strUrl;
      document.write(gOUAA_HTML_COUNT_BEFOR + strParam + gOUAA_HTML_COUNT_AFTER);
    }
  }

  return;
}

//--------------------------------------------------
// method:countRevisitSite - 再訪問
//--------------------------------------------------
function _ouaaCookieData_countRevisitSite() {

  if (this.revisitSiteFlag) {

    // カウンターの呼び出し
    var strParam = "?t=3&u=";
    if (this.subdir < 0) {
      document.write(gOUAA_HTML_COUNT_BEFOR + strParam + gOUAA_HTML_COUNT_AFTER);
    } else {
      document.write(gOUAA_SUB_HTML_COUNT_BEFOR + gOUAA_SUB_TARGET_URL[this.subdir] + "count.cgi" + strParam + gOUAA_SUB_HTML_COUNT_AFTER);
    }

  }

  return;
}

//--------------------------------------------------
// method:countRevisitPage - 再訪問(ページ)
//--------------------------------------------------
function _ouaaCookieData_countRevisitPage(argUrl) {

  if (this.revisitPageFlag) {

    // カウンターの呼び出し
    var strUrl = escape(argUrl.replace(/[\/\.]/g, '_'));
    var chkIdx = -1;
    chkIdx = strUrl.indexOf('%');
    if (chkIdx < 0) {
      var strParam = "?t=4&u=" + strUrl;
      document.write(gOUAA_HTML_COUNT_BEFOR + strParam + gOUAA_HTML_COUNT_AFTER);
    }
  }

  return;
}

//==================================================
// main process (User Access Analysis)
//==================================================
function ouaa_client_main() {

  // 対象URLかどうかのチェック
  var chkUrl = location.href;
  if (chkUrl.substr(0,gOUAA_TARGET_URL.length) != gOUAA_TARGET_URL) { return false; }
  var tgUrl = chkUrl.substr(gOUAA_TARGET_URL.length);
  var chkIdx = -1;
  chkIdx = tgUrl.indexOf('?');   if (chkIdx >= 0) { tgUrl = tgUrl.substr(0, chkIdx); }
  chkIdx = tgUrl.indexOf('#');   if (chkIdx >= 0) { tgUrl = tgUrl.substr(0, chkIdx); }
  chkIdx = tgUrl.indexOf('%23'); if (chkIdx >= 0) { tgUrl = tgUrl.substr(0, chkIdx); }
  chkIdx = tgUrl.indexOf('%3f'); if (chkIdx >= 0) { tgUrl = tgUrl.substr(0, chkIdx); }
  chkIdx = tgUrl.indexOf('%3F'); if (chkIdx >= 0) { tgUrl = tgUrl.substr(0, chkIdx); }
  tgUrl = tgUrl.replace(/\/index.htm$/,'/');
  if (tgUrl == "") { tgUrl = "index.htm"; }

  // 操作対象Cookieを取り出す
  var strCookie = document.cookie;
  var arrCookie = strCookie.split(";");
  var tgCookie = "";
  var ssCookie = "";
  for (i=0; i<arrCookie.length; i++) {
    var wkCookie = arrCookie[i].replace(/(^\s+|\s+$)/g,'');
    if (wkCookie.substr(0,9) == "ouaadata=") {
      tgCookie = wkCookie.substr(9);
    }
    if (wkCookie.substr(0,12) == "ouaasession=") {
      ssCookie = wkCookie.substr(12);
    }
  }

  // Cookieからオブジェクトの作成
  var ouCookieData = new ouaaCookieData();
  if (tgCookie.length != 0) {
    ouCookieData.fromCookie(tgCookie, ssCookie);
  }

  // カウンター判断
  ouCookieData.checkUrl(tgUrl);

  // カウンターの呼び出し
  ouCookieData.countUniqueSite();         // 日別ユニーク
  ouCookieData.countUniquePage(tgUrl);    // 日別ユニーク(ページ)
  ouCookieData.countRevisitSite();        // 再訪問
  ouCookieData.countRevisitPage(tgUrl);   // 再訪問(ページ)

  epuaa_set_cookie(ouCookieData, null);

  // アクセスしたURLの情報を更新
//  strCookie = ouCookieData.toCookie();
//  strSessionCookie = ouCookieData.toSessionCookie();

//  var exDate = new Date();
//  exDate.setTime(exDate.getTime() + 30 * 24 * 60 * 60 * 1000);
//  document.cookie = "ouaadata=" + strCookie + "; path=" + gOUAA_COOKIE_PATH + "; expires=" + exDate.toGMTString();
//  document.cookie = "ouaasession=" + strSessionCookie + "; path=" + gOUAA_COOKIE_PATH;

  return true;
}

function epuaa_set_cookie(ouaaObj, muaaObj) {
  var ouOCookieData = new ouaaCookieData();
  var ouMCookieData = new ouaaCookieData();

  // 操作対象Cookieを取り出す
  var strCookie = document.cookie;
  var arrCookie = strCookie.split(";");
  var tgOCookie = "";
  var ssOCookie = "";
  var tgMCookie = "";
  var ssMCookie = "";
  for (i=0; i<arrCookie.length; i++) {
    var wkCookie = arrCookie[i].replace(/(^\s+|\s+$)/g,'');
    if (wkCookie.substr(0,9) == "ouaadata=") {
      tgOCookie = wkCookie.substr(9);
    }
    if (wkCookie.substr(0,12) == "ouaasession=") {
      ssOCookie = wkCookie.substr(12);
    }
    if (wkCookie.substr(0,9) == "muaadata=") {
      tgMCookie = wkCookie.substr(9);
    }
    if (wkCookie.substr(0,12) == "muaasession=") {
      ssMCookie = wkCookie.substr(12);
    }
  }

  // Cookieからオブジェクトの作成
  if (tgOCookie.length != 0) {
    ouOCookieData.fromCookie(tgOCookie, ssOCookie);
  }
  if (tgMCookie.length != 0) {
    ouMCookieData.fromCookie(tgMCookie, ssMCookie);
  }

  if (ouaaObj) { ouOCookieData = ouaaObj; }
  if (muaaObj) { ouMCookieData = muaaObj; }

  var newOUrlData = new Array();
  var newMUrlData = new Array();
  var olen = ouOCookieData.urlData.length;
  var mlen = ouMCookieData.urlData.length;
  var ai = 0;
  var oi = 0;
  var mi = 0;

  strCookie = ouOCookieData.toCookie() + ouOCookieData.toSessionCookie() + ouMCookieData.toCookie() + ouMCookieData.toSessionCookie();

  if (strCookie.length > gOUAA_MAX_URL_SIZE) {
    if (ouOCookieData.urlData.length > 0) {
      for (oi=1;oi<ouOCookieData.urlData.length;oi++) {
        newOUrlData[oi-1] = ouOCookieData.urlData[oi];
      }
    }
    if (ouMCookieData.urlData.length > 0) {
      for (mi=1;mi<ouMCookieData.urlData.length;mi++) {
        newMUrlData[mi-1] = ouMCookieData.urlData[mi];
      }
    }

    ouOCookieData.urlData = newOUrlData;
    ouMCookieData.urlData = newMUrlData;
  }

  var strOCookie = "";
  var strOSessionCookie = "";
  var strMCookie = "";
  var strMSessionCookie = "";

  if (ouOCookieData.urlData.length > 0) {
    strOCookie = ouOCookieData.toCookie();
    strOSessionCookie = ouOCookieData.toSessionCookie();
  }

  if (ouMCookieData.urlData.length > 0) {
    strMCookie = ouMCookieData.toCookie();
    strMSessionCookie = ouMCookieData.toSessionCookie();
  }

  var exDate = new Date();
  exDate.setTime(exDate.getTime() + 30 * 24 * 60 * 60 * 1000);

  if (olen > 0) {
    if (strOCookie.length > 0) {
      document.cookie = "ouaadata=" + strOCookie + "; path=" + gOUAA_COOKIE_PATH + "; expires=" + exDate.toGMTString();
      document.cookie = "ouaasession=" + strOSessionCookie + "; path=" + gOUAA_COOKIE_PATH;
    } else {
      document.cookie = "ouaadata=;expires=Thu, 01-Jan-1970 00:00:00 GMT;path=" + gOUAA_COOKIE_PATH;
      document.cookie = "ouaasession=;expires=Thu, 01-Jan-1970 00:00:00 GMT;path=" + gOUAA_COOKIE_PATH;
    }
  }

  if (mlen > 0) {
    if (strMCookie.length > 0) {
      document.cookie = "muaadata=" + strMCookie + "; path=" + gOUAA_COOKIE_PATH + "; expires=" + exDate.toGMTString();
      document.cookie = "muaasession=" + strMSessionCookie + "; path=" + gOUAA_COOKIE_PATH;
    } else {
      document.cookie = "muaadata=;expires=Thu, 01-Jan-1970 00:00:00 GMT;path=" + gOUAA_COOKIE_PATH;
      document.cookie = "muaasession=;expires=Thu, 01-Jan-1970 00:00:00 GMT;path=" + gOUAA_COOKIE_PATH;
    }
  }

  return;
}

//==================================================
// main process (User Access Analysis) subdir
//==================================================
function ouaa_sub_client_main() {

  // 対象URLかどうかのチェック
  var chkUrl = location.href;
  if (chkUrl.substr(0,gOUAA_TARGET_URL.length) != gOUAA_TARGET_URL) { return false; }
  var tgUrl = chkUrl.substr(gOUAA_TARGET_URL.length);
  var chkIdx = -1;
  chkIdx = tgUrl.indexOf('?');   if (chkIdx >= 0) { tgUrl = tgUrl.substr(0, chkIdx); }
  chkIdx = tgUrl.indexOf('#');   if (chkIdx >= 0) { tgUrl = tgUrl.substr(0, chkIdx); }
  chkIdx = tgUrl.indexOf('%23'); if (chkIdx >= 0) { tgUrl = tgUrl.substr(0, chkIdx); }
  chkIdx = tgUrl.indexOf('%3f'); if (chkIdx >= 0) { tgUrl = tgUrl.substr(0, chkIdx); }
  chkIdx = tgUrl.indexOf('%3F'); if (chkIdx >= 0) { tgUrl = tgUrl.substr(0, chkIdx); }
  tgUrl = tgUrl.replace(/\/index.htm$/,'/');
  if (tgUrl == "") { tgUrl = "index.htm"; }

  var tgSubIdx;
  for (tgSubIdx = 0; tgSubIdx < gOUAA_SUB_TARGET_URL.length; tgSubIdx++) {
    var subChkUrl = gOUAA_SUB_TARGET_URL[tgSubIdx];
    if (tgUrl.substr(0,subChkUrl.length) == subChkUrl) { break; }
  }
  if (tgSubIdx >= gOUAA_SUB_TARGET_URL.length) { return false; }

  // 対象URLをsubdirに限定
	tgUrl = gOUAA_SUB_TARGET_URL[tgSubIdx];

  // 操作対象Cookieを取り出す
  var strCookie = document.cookie;
  var arrCookie = strCookie.split(";");
  var tgCookie = "";
  var ssCookie = "";
	var dataCookieName = "ouaadata_"+tgSubIdx+"=";
  var sessCookieName = "ouaasession_"+tgSubIdx+"=";

  for (i=0; i<arrCookie.length; i++) {
    var wkCookie = arrCookie[i].replace(/(^\s+|\s+$)/g,'');
    if (wkCookie.substr(0,dataCookieName.length) == dataCookieName) {
      tgCookie = wkCookie.substr(dataCookieName.length);
    }
    if (wkCookie.substr(0,sessCookieName.length) == sessCookieName) {
      ssCookie = wkCookie.substr(sessCookieName.length);
    }
  }

  // Cookieからオブジェクトの作成
  var ouSubCookieData = new ouaaCookieData();
  if (tgCookie.length != 0) {
    ouSubCookieData.fromCookie(tgCookie, ssCookie);
  }

  // subdirフラグ
  ouSubCookieData.subdir = tgSubIdx;

  // カウンター判断
  ouSubCookieData.checkUrl(tgUrl);

  // カウンターの呼び出し
  ouSubCookieData.countUniqueSite();         // 日別ユニーク
  ouSubCookieData.countRevisitSite();        // 再訪問

  // アクセスしたURLの情報を更新
  strCookie = ouSubCookieData.toCookie();
  strSessionCookie = ouSubCookieData.toSessionCookie();

  var exDate = new Date();
  exDate.setTime(exDate.getTime() + 30 * 24 * 60 * 60 * 1000);
  document.cookie = dataCookieName + strCookie + "; path=" + gOUAA_COOKIE_PATH + "; expires=" + exDate.toGMTString();
  document.cookie = sessCookieName + strSessionCookie + "; path=" + gOUAA_COOKIE_PATH;

  return true;
}


//==================================================
// call main
//==================================================

oet_client_main();

ouaa_client_main();

ouaa_sub_client_main();

//======================================================================
// EOF
//======================================================================
////////////////////////////////////////////////////////////////////////
// Local Variables:
// tab-width: 2
// End:
////////////////////////////////////////////////////////////////////////
