if (typeof Event == 'undefined') Event = new Object();
DOM = {
ready: function(fn) {
if (DOM.loaded) return fn();
var readyList = DOM.readyList;
if (!readyList) readyList = DOM.readyList = [];
readyList[readyList.length] = fn;
if (DOM.callback) return;
DOM.callback = function() {
if (DOM.loaded) return;
DOM.loaded = true;
if (DOM.timer) {
clearInterval(DOM.timer);
DOM.timer = null;
}
var readyList = DOM.readyList;
for (var i = 0, length = readyList.length; i < length; i++) {
var fn = readyList[i];
readyList[i] = null;
fn();
}
DOM.callback = DOM.readyList = null;
};
var ie = !!(window.attachEvent && !window.opera);
if (document.readyState && navigator.userAgent.match(/webkit|safari|khtml/i)) {
DOM.timer = setInterval(function() {
if (document.readyState.match(/loaded|complete/)) {
DOM.callback();
}
}, 50);
}
else if (document.readyState && ie) {
var src = (window.location.protocol == 'https:') ? '://0' : 'javascript:void(0)';
document.write(
'<script type="text/javascript" defer="defer" src="' + src + '" ' +
'onreadystatechange="if (this.readyState == \'complete\') DOM.callback();"' +
'><\/script>');
}
else {
if (window.addEventListener) {
document.addEventListener("DOMContentLoaded", DOM.callback, false);
window.addEventListener("load", DOM.callback, false);
}
else if (window.attachEvent) {
window.attachEvent('onload', DOM.callback);
}
else {
var fn = window.onload;
window.onload = function() {
DOM.callback();
if (fn) fn();
}
}
}
}
}
var RakutoraCookie = function(name, options) {
this.expires = '';
this.path    = '/';
this.domain  = 'travel.rakuten.co.jp';
this.secure  = '';
this.cache   = 'true';
this.prefix  = '';
this.debug   = 'false';
this.setOptions(this, options, true);
this.cookieName = this.prefix + name;
this.cookieValue = '';
};
RakutoraCookie.prototype.setOptions = function(obj, optionsObj, ignoreUndefined) {
if (!optionsObj)
return;
for (var optionName in optionsObj) {
if (ignoreUndefined && optionsObj[optionName] == undefined)
continue;
obj[optionName] = optionsObj[optionName];
}
};
RakutoraCookie.prototype.set = function(key, value) {
if (this.cookieValue != '')
this.cookieValue = this.cookieValue + '|';
if (key != '') {
if (key == 'f_teikei' && value.substring(0,4) == ':pl_') {
this.cookieValue = this.cookieValue + '"' + key + '"=""';
}
else {
this.cookieValue = this.cookieValue + '"' + key + '"="' + value + '"';
if (key == 'f_teikei') {
this.cookieValue = this.cookieValue + '|"cdAffiliate"="' + value + '"';
}
}
}
else {
this.cookieValue = this.cookieValue + value;
}
};
RakutoraCookie.prototype.setCookie = function() {
var expires = '';
if (this.expires && (typeof this.expires == 'number' || this.expires.toUTCString)) {
var date;
if (typeof this.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (this.expires * 24 * 60 * 60 * 1000));
}
else {
date = this.expires;
}
expires = '; expires=' + date.toUTCString();
}
var path   = this.path   ? '; path='   + (this.path)   : '';
var domain = this.domain ? '; domain=' + (this.domain) : '';
var secure = this.secure ? '; secure'                  : '';
document.cookie = [this.cookieName, '=', encodeURIComponent(this.cookieValue), expires, path, domain, secure].join('');
};
RakutoraCookie.prototype.getCookie = function() {
var cookieHash  = new Array();
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].replace(/^\s+|\s+$/g, "");
if (cookie.substring(0, this.cookieName.length + 1) == (this.cookieName + '=')) {
var cookieValue = decodeURIComponent(cookie.substring(this.cookieName.length + 1)).replace(/^"|"$/g, "");
var tmp1 = cookieValue.split('"|"');
for (var j = 0; j < tmp1.length; j++) {
var tmp2 = tmp1[j].split('"="');
if (cookieHash[tmp2[0]] == undefined) {
var cookieArray = new Array();
cookieArray.push(tmp2[1]);
if (tmp2[0] == 'f_ptn') {
cookieHash[tmp2[0]] = 'tiku';
}
else {
cookieHash[tmp2[0]] = cookieArray;
}
}
else {
cookieHash[tmp2[0]].push(tmp2[1]);
}
}
break;
}
}
}
return cookieHash;
};

