/*▼初期設定*/
var _gaq = _gaq || [];
if (typeof console === 'undefined') console = { log: function () { return null; } }

/*ビルトインオブジェクトの拡張*/
var YOUBI = ['日', '月', '火', '水', '木', '金', '土'];
Date.prototype.AddMinutes = function (addMinutes) {
    this.setMinutes(this.getMinutes() + addMinutes);
};
Date.prototype.AddHours = function (addHours) {
    this.setHours(this.getHours() + addHours);
};
Date.prototype.AddDays = function (addDays) {
    this.setDate(this.getDate() + addDays);
};
Date.prototype.AddMonths = function (addMonths) {
    var d = this.getDate();
    var m = this.getMonth();
    var test = new Date(this.getTime());
    test.setMonth(m + addMonths);
    if (d === test.getDate()) {
        this.setMonth(m + addMonths);
    } else {
        this.setMonth(m + addMonths);
        this.setDate(0);
    }
};
Date.prototype.AddYears = function (addYears) {
    var d = this.getDate();
    var y = this.getFullYear();
    var test = new Date(this.getTime());
    test.setFullYear(y + addYears);
    if (d === test.getDate()) {
        this.setFullYear(y + addYears);
    } else {
        this.setFullYear(y + addYears);
        this.setDate(0);
    }
};
Date.prototype.format = function (separator) {
    var y = this.getFullYear();
    var m = this.getMonth() + 1;
    if (10 > m) m = '0' + m;
    var d = this.getDate();
    if (10 > d) d = '0' + d;
    var day = this.getDay();
    var hh = this.getHours();
    var mm = this.getMinutes()
    var ss = this.getSeconds()
    var ms = this.getMilliseconds()
    if (separator == 'cookie') {
        return y * 100000000 + m * 1000000 + d * 10000 + hh * 100 + mm * 1;
    } else if (separator == 'jp') {
        return m + '/' + d + '(' + YOUBI[day] + ')';
    } else {
        return y + separator + m + separator + d;
    }
};

/*Cookie取得*/
var $_COOKIE = (function (cookieStr) {
    var _temp = {};
    for (var i = 0; cookieStr.length > i; i++) {
        var _cookieItem = cookieStr[i].split("=");
        try {
            _temp[_cookieItem[0]] = decodeURIComponent(_cookieItem[1]);
        } catch (e) {
            _temp[_cookieItem[0]] = _cookieItem[1];
        }
    }
    return _temp;
})(document.cookie.toString().replace(/ /ig, '').split(';'));

var $__utmb = false;
var $_COOKIE_SN = (function (SN_cookie) {
    var _temp = {};
    try {
        _temp = eval('(' + SN_cookie + ')');
        for (var i in _temp) {
            (function (_item) {
                try {
                    _temp[i][0] = decodeURIComponent(_item[0]);
                } catch (e) {
                    console.log(i + " : " + e);
                    _temp[i][0] = _item[0];
                }
                var _expires = (_item[1] + "0000").substr(0, 12).replace(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/, '$1/$2/$3 $4:$5');
                _temp[i][1] = new Date(_expires);
            })(_temp[i]);
        }
    } catch (e) {
        console.log(e);
    }
    return _temp;
})($_COOKIE.SN_COOKIE);

var delCookie = function () {
    var nowtime = new Date().getTime();
    var limit = new Date(nowtime + (60 * 60 * 24 * 1000 * -1));
    var expires = limit.toGMTString();
    document.cookie = key + '=; expires=' + expires + '; path=/';
};

if ($_COOKIE['SESSIONID']) {
    _gaq.push(
		['_setCustomVar', 2, 'login_visitor', 'login', 1],
		['_setCustomVar', 4, 'login_session', 'login', 2],
		['_setCustomVar', 5, 'login_page', 'login', 3]
	);
} else {
    _gaq.push(['_setCustomVar', 5, 'login_page', 'logout', 3]);
}

if ($_COOKIE['userId']) {
    _gaq.push(['_setCustomVar', 1, 'userid', $_COOKIE['userId'], 1]);
}

if ($_COOKIE['__utmb']) {
    $__utmb = true;
} else if ($_COOKIE['SESSIONID']) {
    _gaq.push(['_setCustomVar', 3, 'login_landing', 'login', 2]);
} else {
    _gaq.push(['_setCustomVar', 3, 'login_landing', 'logout', 2]);
}

function setCookie(key, value, period) {
    var nowtime = new Date().getTime();
    var limit = new Date(nowtime + (60 * 60 * 24 * 1000 * period));
    var expires = limit.toGMTString();
    // クッキーの発行（書き込み）
    document.cookie = key + "=" + encodeURIComponent(value) + "; expires=" + expires + ";path=/";
}


/*URL Query取得*/
var urlOption = (function () {
    var temp = {};
    if (mySearch = window.location.search.toString().replace(/^\?/, '').split('&')) {
        for (var _i = 0; mySearch.length > _i; _i++) {
            if (mySearch[_i].split("=")) {
                temp[mySearch[_i].split("=")[0]] = decodeURIComponent(mySearch[_i].split("=")[1]);
            }
        }
    }
    return temp;
})();
var URLargument = urlOption;

var oft_infoBox_var = 0;
var oftTop = "-100px";
var oft_Period = 0;

if (TimeCheck(2012091800, 2012092323)) {
    innerPopup_overBox
    oft_infoBox_var = 1;
    oft_Period = 1;
    oftTop = 0;
}


/*▲初期設定*/

/*ログインチェック*/
var login = {
    "API": 0,
    "loginStatas": 0,
    "IsChowari": 0,
    "IsSgm": 0
}
function LoginStatasCallback(LoginStatas) {
    if (LoginStatas.LoginStatasResponse.ActivationResult * 1) {
        login.API = 1;
    } else {
        login = {
            "API": true,
            "loginStatas": (LoginStatas.LoginStatasResponse.loginStatas * 1 > 0),
            "IsChowari": (LoginStatas.LoginStatasResponse.superDiscount * 1 > 0),
            "IsSgm": (LoginStatas.LoginStatasResponse.IsSgm * 1 > 0)
        }
    }
}

/*Stringクラスを拡張*/
String.prototype.replaceAll = function (org, dest) {
    return this.split(org).join(dest);
}
String.prototype.note = function (arg) {
    var arg = (arg) ? arg : {};
    var HTML = new String();
    try {
        var attention = this;
        var atText = [];
        var nowTime = slashDobj(time.toString().replace(/(\d{4})(\d{2})(\d{2})\d{2}/, '$1/$2/$3'));
        var tempAttention = attention.replace(/\|\|/ig, '|').replace(/\n|｜/ig, '|');
        tempAttention = tempAttention.replace(/￥”/ig, '\"');
        tempAttention = tempAttention.split('|');
        for (var h = 0; tempAttention.length > h; h++) {
            var _tObj = tempAttention[h].match(/\(\(\d{4}\/\d{2}\/\d{2}\)\)/);
            if (_tObj) {
                var tObj = slashDobj(_tObj.toString().match(/\d{4}\/\d{2}\/\d{2}/));
                var sabun = (tObj.getTime() - nowTime.getTime()) / (24 * 60 * 60 * 1000);
                if (sabun > 0) {
                    var naiyou = tempAttention[h].replace(/\(\(\d{4}\/\d{2}\/\d{2}\)\)/ig, '');
                    atText.push(naiyou);
                }
            } else {
                if (tempAttention[h]) {
                    atText.push(tempAttention[h]);
                }
            }
        }
        if (atText.length) {
            if (arg.myClass == 'kome') {
                HTML = '<p class="kome">※' + atText.join('</p><p class="kome">※') + '</p>';
            } else {
                HTML = '<p>' + atText.join('</p><p>') + '</p>';
            }
        }
    } catch (e) {
    }
    return HTML.replace(/※※/ig, '※');
}

/*曜日配列*/
var youbi = ['日', '月', '火', '水', '木', '金', '土'];

function mAlert(str) {
    if (window.location.host.match(/origin/ig)) { alert(str + '\nこのメッセージはテストURLでのみ表示されます') };
}
function tAlert(STR) {
    if (w.search.match(/chk/)) { alert(STR); }
}
/*DOM操作用*/
function $(ID) {
    return document.getElementById(ID);
}
function $$(tagName) {
    return document.getElementsByTagName(tagName);
}

function removeChild(_element) {
    if (_element.hasChildNodes()) {
        while (_element.childNodes.length > 0) {
            _element.removeChild(_element.firstChild)
        }
    }
}

var mobileHTML = null;
function printMobileHTML(str) {
    /*
    document.write(str);
    */
}

/*****************************************************
割引券告知チェック
******************************************************/
function oftChk() {
    var temp = false;
    if (oft_infoBox_var) {
        if (login.loginStatas) {
            temp = 'login';
        } else {
            temp = 'logout';
        }
    }
    return temp;
}

/*****************************************************
ポップアップ
open_window(uri,[width,height])
uri		= 表示URL（必須）
width	= Window幅
height	= Window高さ
******************************************************/
function open_window(uri, width, height) {
    if (window.nwin) {
        window.nwin.close();
    }
    var width = width || 720;
    var height = height || 540;
    nwin = window.open(uri, "nwin", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,WIDTH=" + width + ",HEIGHT=" + height);
    window.nwin.focus();
}
/*****************************************************
ページ内ポップアップ
modal_window(uri,[width,height])
uri		= 表示URL（必須）
width	= Window幅
height	= Window高さ
******************************************************/
function modal_window(uri, width, height) {
    var width = (width) ? width : 600;
    var height = (height) ? height : 400;

    var windowWidth = (function () {
        if (window.innerWidth) {
            return window.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientWidth != 0) {
            return document.documentElement.clientWidth;
        } else if (document.body) {
            return document.body.clientWidth;
        }
        return 800;
    })();
    var windowHeight = (function () {
        if (window.innerWidth) {
            return window.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight != 0) {
            return document.documentElement.clientHeight;
        } else if (document.body) {
            return document.body.clientHeight;
        }
        return 600;
    })();

    height = (windowHeight * 0.8 > height) ? height : Math.ceil(windowHeight * 0.8);
    width = (windowWidth * 0.8 > width) ? width : Math.ceil(windowWidth * 0.8);

    var userAgent = window.navigator.userAgent.toLowerCase();
    var appVersion = window.navigator.appVersion.toLowerCase();


    if (userAgent.indexOf("msie") >= 0 && appVersion.indexOf("msie 6.") >= 0) {
        if (uri) {
            var nwin = window.open(uri, 'nwin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,WIDTH=' + width + ',HEIGHT=' + height);
            nwin.focus();
        }
    } else if (userAgent.indexOf("iphone") >= 0 || userAgent.indexOf("ipod") >= 0 || userAgent.indexOf("android") >= 0) {
        if (uri) {
            var nwin = window.open(uri, 'nwin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,WIDTH=' + width + ',HEIGHT=' + height);
            nwin.focus();
        }
    } else if (uri) {
        var innerPopup_CloseBtn = {
            "TAG": "img",
            "src": "/~/media/Images/Common/innerPopup/close",
            "width": "75",
            "height": "30",
            "alt": "閉じる"
        }
        var innerPopup_OpenBtn = {
            "TAG": "img",
            "src": "/~/media/Images/Common/innerPopup/open",
            "width": "145",
            "height": "30",
            "alt": "別ウィンドウで開く"
        }

        var innerPopup_topBAR = {
            "TAG": "div",
            "id": "innerPopup_topBAR"
        }
        var innerPopup_topBARbox = {
            "TAG": "div",
            "id": "innerPopup_topBARbox"
        }

        var innerPopup_BoxTBL = {
            "TAG": "table",
            "id": "innerPopup_base",
            "cellpadding": "0",
            "cellspacing": "0"
        };
        var innerPopup_BoxTbody = {
            "TAG": "tbody"
        }
        var innerPopup_BoxTR = {
            "TAG": "tr"
        };
        var innerPopup_BoxTD = {
            "TAG": "td",
            "id": "innerPopup_BoxTD",
            "vAlign": "middle",
            "align": "center"
        };
        var innerPopup_FrameBox = {
            "TAG": "div",
            "id": "innerPopup_FrameBox"
        }
        var innerPopup_FrameDiv = {
            "TAG": "div",
            "id": "innerPopup_FrameDiv"
        }
        var innerPopup_Frame = {
            "TAG": "iframe",
            "id": "innerPopup_Frame",
            "width": "100%",
            "height": "100%",
            "frameborder": "0",
            "framespacing": "0",
            "allowtransparency": "false",
            "hspace": "0",
            "vspace": "0",
            "marginheight": "0",
            "marginwidth": "0"
        };

        var elm_innerPopup_BoxTBL = makeDOM(innerPopup_BoxTBL);
        var elm_innerPopup_BoxTbody = makeDOM(innerPopup_BoxTbody);
        var elm_innerPopup_BoxTR = makeDOM(innerPopup_BoxTR);
        var elm_innerPopup_BoxTD = makeDOM(innerPopup_BoxTD);

        var elementBody = document.getElementsByTagName('body')[0];

        elm_innerPopup_BoxTBL.appendChild(elm_innerPopup_BoxTbody);
        elm_innerPopup_BoxTbody.appendChild(elm_innerPopup_BoxTR);
        elm_innerPopup_BoxTR.appendChild(elm_innerPopup_BoxTD);

        var elm_innerPopup_FrameBox = makeDOM(innerPopup_FrameBox);
        var elm_innerPopup_FrameDiv = makeDOM(innerPopup_FrameDiv);
        var elm_innerPopup_Frame = makeDOM(innerPopup_Frame);

        elm_innerPopup_FrameBox.style.width = width + "px";
        elm_innerPopup_FrameBox.style.height = height + "px";

        elm_innerPopup_Frame.src = uri;
        elm_innerPopup_Frame.border = 0;
        elm_innerPopup_Frame.frameborder = 0;
        elm_innerPopup_Frame.sandbox = 'allow-forms allow-scripts allow-top-navigation allow-same-origin';

        var elm_closeBtn = makeDOM(innerPopup_CloseBtn);
        var elm_openBtn = makeDOM(innerPopup_OpenBtn);
        var elm_innerPopup_topBAR = makeDOM(innerPopup_topBAR);
        var elm_innerPopup_topBARbox = makeDOM(innerPopup_topBARbox);

        elm_innerPopup_topBARbox.appendChild(elm_openBtn);
        elm_innerPopup_topBARbox.appendChild(elm_closeBtn);
        elm_innerPopup_topBAR.appendChild(elm_innerPopup_topBARbox);

        elm_innerPopup_FrameDiv.appendChild(elm_innerPopup_Frame);
        elm_innerPopup_FrameBox.appendChild(elm_innerPopup_topBAR);
        elm_innerPopup_FrameBox.appendChild(elm_innerPopup_FrameDiv);
        elm_innerPopup_BoxTD.appendChild(elm_innerPopup_FrameBox);

        elementBody.appendChild(elm_innerPopup_BoxTBL);

        elm_innerPopup_BoxTBL.onclick = function () {
            elementBody.removeChild(elm_innerPopup_BoxTBL);
        }
        elm_closeBtn.onclick = function () {
            elementBody.removeChild(elm_innerPopup_BoxTBL);
        }
        elm_openBtn.onclick = function () {
            elementBody.removeChild(elm_innerPopup_BoxTBL);
            var nwin = window.open(uri, 'nwin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,WIDTH=' + width + ',HEIGHT=' + height);
            nwin.focus();
        }

        elm_closeBtn.onmouseout = function () {
            this.src = "/~/media/Images/Common/innerPopup/close";
        }
        elm_closeBtn.onmouseover = function () {
            this.src = "/~/media/Images/Common/innerPopup/close_on";
        }
        elm_openBtn.onmouseout = function () {
            this.src = "/~/media/Images/Common/innerPopup/open";
        }
        elm_openBtn.onmouseover = function () {
            this.src = "/~/media/Images/Common/innerPopup/open_on";
        }

    }
}


/*****************************************************
ダウンロードサイズ
open_window(size(num))
******************************************************/
function sizeWindow(num) {
    if (num) {
        open_window("/dl/simulation.html?" + num, 465, 360);
    } else {
        open_window("/dl/simulation.html", 465, 360);
    }
}


/*****************************************************
/連想配列の添字をカウント
hash_len(hash)

入力された連想配列の添字をカウント
hash		：連想配列
*****************************************************/
function hash_len(hash) {
    var num = new Number();
    for (var i in hash) {
        num++
    }
    return num;
}

/********************************************/
/*	getElementPosition( _element)			*/
/*	_element:DOMエレメント					*/
/********************************************/
function getElementPosition(_element) {
    var _target = _element;
    var _pos = new function () { this.x = 0; this.y = 0; }
    while (_target) {
        _pos.x += _target.offsetLeft;
        _pos.y += _target.offsetTop;
        _target = _target.offsetParent;
    }
    _element._x = _pos.x;
    _element._y = _pos.y;
    return _element;
}
function getScrollPosition() {
    var _obj = new Object();
    _obj._x = document.documentElement.scrollLeft || document.body.scrollLeft;
    _obj._y = document.documentElement.scrollTop || document.body.scrollTop;
    return _obj;
}

/*****************************************************
ミニWindowを開く
openwin(url,winname)
url		：開くURL
winname	：Window名
width	:開くWindoの幅（デフォルト640）
height	:開くWindoの高さ（デフォルト640）
******************************************************/
var miniWindow = {};
function openwin(url, winname, width, height) {
    var width = (width) ? width : 640;
    var height = (height) ? height : 640;
    miniWindow['win1'] = open(url, winname, 'width=' + width + ',height=' + height + ',toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1');
    miniWindow['win1'].focus();
}

/*****************************************************
時間制限メッセージ
TimeMessage(start,end,str,ID)

start以上end未満の間　メッセ時を出力する
start	：開始日時　yyyymmddhh
end		：終了日時　yyyymmddhh
str		：表示文字列
ID		：DOM　ID
******************************************************/
function TimeCheck(start, end) {
    var start = (typeof (start) == 'number') ? start : 0;
    var end = (typeof (end) == 'number') ? end : 9999999999;
    var mytime = (urlOption.time) ? urlOption.time : time;
    try {
        if (mytime.indexOf(":") >= 0) {
            mytime = mytime.replace(/%20/, ' ');
            var mytimeAr = mytime.split(":");
            mytime = mytimeAr[0].replace(/[^0-9]/ig, '');
        }
    } catch (e) {
    }
    return (start <= mytime && end > mytime) ? 1 : 0;
}
function TimeMessage(start, end, str, ID) {
    if (TimeCheck(start, end)) {
        if (ID) {
            if (typeof ID == "object") {
                ID.innerHTML = str;
            } else if (ID == "return") {
                return str;
            } else {
                $(ID).innerHTML = str;
            }
        } else {
            document.write(str);
        }
    } else {
        if (ID == "return") {
            return '';
        }
    }
}
/*****************************************************
折りたたみ
exMenu(ID)

入力されたID属性の表示非表示を変更する。
該当するIDが存在しない場合は「IDが存在しません」とアラートをたてる。

ID		: CSS ID属性値（必須）
******************************************************/
/*
function exMenu(ID){
var	elementObj =0;
if(typeof ID == "object"){
elementObj	= ID;
}else if($(ID)){
elementObj	= $(ID);
}
if(elementObj){
elementObj.style.display = (elementObj.style.display == 'block') ? 'none' : 'block';
}
}
*/
function exMenu(ID) {
    var elementObj = 0;
    if (typeof ID == "object") {
        elementObj = ID;
    } else if ($(ID)) {
        elementObj = $(ID);
    }
    if (elementObj) {
        var myStyle = elementObj.currentStyle || document.defaultView.getComputedStyle(elementObj, '');
        var returnText = [];
        returnText.push("--element--\n");
        returnText.push(
			'overflow : ' + elementObj.style.overflow + '\n' +
			'display : ' + elementObj.style.display + '\n' +
			'height : ' + elementObj.style.height + '\n'
		)
        returnText.push("--myStyle--\n");
        returnText.push(
			'overflow : ' + myStyle.overflow + '\n' +
			'display : ' + myStyle.display + '\n' +
			'height : ' + myStyle.height + '\n'
		);

        if (myStyle.display === 'none') {
            elementObj.style.overflow = 'visible';
            elementObj.style.display = 'block';
            elementObj.style.height = 'auto';
        } else if (myStyle.height === '0px' || myStyle.height === '1px') {
            returnText.push("--close now--\n");
            elementObj.style.overflow = 'visible';
            elementObj.style.height = 'auto';
        } else {
            returnText.push("--open now--\n");
            elementObj.style.overflow = 'hidden';
            elementObj.style.height = 0;
        }
        returnText.push("--element--\n");
        returnText.push(
			'overflow : ' + elementObj.style.overflow + '\n' +
			'display : ' + elementObj.style.display + '\n' +
			'height : ' + elementObj.style.height + '\n'
		)
        returnText.push("--myStyle--\n");
        returnText.push(
			'overflow : ' + myStyle.overflow + '\n' +
			'display : ' + myStyle.display + '\n' +
			'height : ' + myStyle.height + '\n'
		);
        //alert(returnText.join("\n"));
    }
}
/*****************************************************
桁とり
ketatori(num)

入力された値を桁とり（3桁ごとに「,」を挿入）して返す
該当する値が存在しない場合は「num」そのままを返す。

num		: 数値（必須）
******************************************************/
function ketatori(num) {
    if (num) {
        if (isNaN(num)) {
            return num;
        } else {
            var temp = num.toString().split('.');
            temp[0] = temp[0].toString().replace(/([0-9]+?)(?=(?:[0-9]{3})+$)/g, '$1,')
            return temp.join('.');
        }
    } else {
        return num;
    }
}
/*****************************************************
エクセルから出力された数列を日付に変換
getDateEX(num)

num	：数列
*****************************************************/
function getDateEX(num) {
    var retDate = false
    if (isNaN(num)) {
    } else {
        retDate = (function () {
            var date = new Date(1899, 11, 30);
            var dObj = new Date();
            dObj.setTime(date.getTime() + (num * 24 * 3600 * 1000));
            return dObj;
        })();
    }
    return retDate;
}
/*****************************************************
/日付オブジェクトを/区切りの日付フォーマットに変換
slDobj(date)

区切りの日付をSOURCENEXTフォーマットに変換

date		：スラッシュ区切りの日にち
*****************************************************/
function slDobj(dObj) {
    if (dObj) {
        var yy = dObj.getYear();
        var mm = dObj.getMonth() + 1;
        var dd = dObj.getDate();
        mm = (mm < 10) ? "0" + mm : mm;
        dd = (dd < 10) ? "0" + dd : dd;
        yy = (yy < 2000) ? yy + 1900 : yy;
        yy = (yy > 3000) ? yy - 1900 : yy;

        return (yy + "/" + mm + "/" + dd);
    } else {
        return false;
    }
}


/*****************************************************
/区切りの日付をSOURCENEXTフォーマットに変換
SNdObj(date)

区切りの日付をSOURCENEXTフォーマットに変換

date		：スラッシュ区切りの日にち
*****************************************************/
function SNdObj(date, _tgl) {
    if (date) {
        var d0 = date.split('/');
        var d = new Date(date + ' 0:0:0');
        if (_tgl) {
            return (d0[0] * 1) + '年' + (d0[1] * 1) + '月' + (d0[2] * 1) + '日（' + youbi[d.getDay()] + '）';
        } else {
            return (d0[1] * 1) + '月' + (d0[2] * 1) + '日（' + youbi[d.getDay()] + '）';
        }
    }
    return false;
}
/*****************************************************
/区切りの日付を日付オブジェクトに変換
slashDobj(date)

区切りの日付をSOURCENEXTフォーマットに変換

date		：スラッシュ区切りの日にち
*****************************************************/
function slashDobj(date) {
    if (date) {
        var d = new Date(date + ' 0:0:0');
        return d;
    }
    return false;
}
/*****************************************************
任意のIDに差込
reWrite(ID,str)

指定IDのタグ内にstrの値を書き込む。

ID		：書き込むタグのID※必須
str		：書き込む内容
*****************************************************/
function reWrite(ID, str) {
    if (typeof ID == "object") {
        ID.innerHTML = str;
    } else {
        try {
            $(ID).innerHTML = str;
        } catch (e) {
        }
    }
}

/********************************************/
/*           	　フキダシ                　*/
/********************************************/
function fukidashiBOX(element, popupBOX, popupCenter, elmCenter) {
    var elm = getElementPosition(element);
    var offsetY = 0;
    var offsetX = 0;
    var elmH = elm.offsetHeight;
    var elmW = elm.scrollWidth;
    var BOXH = popupBOX.offsetHeight;
    var BOXW = popupBOX.scrollWidth;

    switch (elmCenter) {
        case 'TL':
            break;
        case 'TC':
            offsetX = (elmW / 2);
            break;
        case 'TR':
            offsetX = elmW;
            break;
        case 'CL':
            offsetY = (elmH / 2);
            break;
        case 'CC':
            offsetY = (elmH / 2);
            offsetX = (elmW / 2);
            break;
        case 'CR':
            offsetY = (elmH / 2);
            offsetX = elmW;
            break;
        case 'BL':
            offsetY = elmH;
            break;
        case 'BC':
            offsetY = elmH;
            offsetX = (elmW / 2);
            break;
        case 'BR':
            offsetY = elmH;
            offsetX = elmW;
            break;
        default:
            break;
    }

    switch (popupCenter) {
        case 'TL':
            break;
        case 'TC':
            offsetX -= (BOXW / 2);
            break;
        case 'TR':
            offsetX -= BOXW;
            break;
        case 'CL':
            offsetY -= (BOXH / 2);
            break;
        case 'CC':
            offsetY -= (BOXH / 2);
            offsetX -= (BOXW / 2);
            break;
        case 'CR':
            offsetY -= (BOXH / 2);
            offsetX -= BOXW;
            break;
        case 'BL':
            offsetY -= BOXH;
            break;
        case 'BC':
            offsetY -= BOXH;
            offsetX -= (BOXW / 2);
            break;
        case 'BR':
            offsetY -= BOXH;
            offsetX -= BOXW;
            break;
        default:
            break;
    }

    popupBOX.style.top = offsetY + elm._y + 'px';
    popupBOX.style.left = offsetX + elm._x + 'px';
}

/********************************************/
/*		   	イメージ拡大				*/
/********************************************/
function popUp_IMG(element, tgl, img, offsetX, offsetY) {
    $img = img;
    $elm = element;
    var offset = $elm.offset();
    var _x = -(($img.outerWidth() - $elm.outerWidth()) * 0.5 - (offsetX || 0));
    var _y = -(($img.outerHeight() - $elm.outerHeight()) * 0.5 - (offsetY || 0));
    var _pos = (tgl) ? {
        "x": offset.left + _x + "px",
        "y": offset.top + _y + "px"
    } : {
        "x": "-999px",
        "y": "-990px"
    };
    $img.css({
        top: _pos.y,
        left: _pos.x,
        zIndex: 1000000000000
    });
}
/********************************************/
/*           	イメージ拡大                */
/********************************************/
function _imgPOPUP() {
    var _ID = new Number();
    return function (element) {
        element.id = 'IMG_x' + _ID;
        var _IMG = document.createElement('img');
        _IMG.src = element.src;
        _IMG.id = 'IMG_p' + _ID;
        $('popupIMG_TMP').appendChild(_IMG);

        var _child = document.createElement('div');
        _child.style.backgroundImage = 'url(' + element.src + ')';
        _child.id = 'x' + _ID;
        _child.onmouseout = function () {
            popUp_IMG(this, false, this);
        }
        $('popupIMG_TMP').appendChild(_child);
        if (mobile) {
        } else if (element.className.match(/nopopup/)) {
        } else {
            element.style.cursor = 'pointer';
            element.onmousemove = function () {
                var popObj = $(element.id.replace(/IMG_/, ''));
                popObj.style.width = $(element.id.replace(/IMG_x/, 'IMG_p')).width + 'px';
                popObj.style.height = $(element.id.replace(/IMG_x/, 'IMG_p')).height + 'px';
                if (typeof jQuery != 'undefined') {
                    popUp_IMG(jQuery('#' + element.id), true, jQuery('#' + popObj.id));
                }
            }
        }
        _ID++;
    };
}
var imgPOPUP = _imgPOPUP();

/*****************************************************
「画像」ポップアップ
popup(URL)
URLに画像を指定することで、画像表示用のポップアップWindowが
開く。Windowのサイズは画像に最適化される。
******************************************************/
/*「動作環境」「FAQ」「ユー声」読み込み*/
function popup(url, width, height) {
    open_window(url + "?w=800&h=600&bc=ffffff&as=0", (width) ? width : 840, (height) ? height : 630);
    /*
    if(window.nwin){
    window.nwin.close();
    }
    window.open('http://www.sourcenext.com/img/popup.html?URL=http://www.sourcenext.com/'+url,"nwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,WIDTH=100,HEIGHT=100");
    window.nwin.focus();
    */
}

/**XML操作系**/
/*****************************************************
ファイルのインポート
importFile(PATH)

与えられたパスに存在するファイルを読み込んで表示する。


PATH		: 呼び出すファイルのパス
******************************************************/
function importFile(URI, ID, callback) {

    if (ID) {
    } else {
        var ID = 'ID' + (Math.ceil(Math.random() * 1000000 + 10000000))
        document.write('<ins style=" text-decoration:none;" id="' + ID + '"></ins>');
    }
    var callback = (callback) ? callback : false;
    requestFile(URI, 'import', ID, false, callback);
}
function func_import(xml, ID, obj, callback) {
    var sHost = (document.location.protocol == 'https:') ? "https://" : "http://";
    var txt = xml.responseText;

    txt = txt.replaceAll('http://', sHost);

    txt = txt.replace(/https:\/\/www\.sourcenext\.info\//ig, 'http://www.sourcenext.info/');
    txt = txt.replace(/https:\/\/www\.ichibel\.com\//ig, 'http://www.ichibel.com/');
    txt = txt.replace(/https:\/\/sourcenext\.force\.com\//ig, 'http://sourcenext.force.com/');
    txt = txt.replace(/https:\/\/a1763\.g\.akamai\.net\//ig, 'http://a1763.g.akamai.net/');
    txt = txt.replace(/%7E\/media\//ig, '/%7E/media/');
    txt = txt.replace(/~\/media\//ig, '/%7E/media/');
    txt = txt.replace(/\/\/%7E\/media\//ig, '/%7E/media/');
    txt = txt.replace(/https:\/\/windows\.microsoft\.com\//ig, 'http://windows.microsoft.com/');


    reWrite(ID, txt.toString().replace(/<!--.+?-->/ig, ''))
    if (ID == 'js_sysPage') {
        var _myName = txt.match(/<!--：.+?：.+?：.+?：.+?：-->/);
        var myName = _myName.toString().split('：')
        reWrite('js_pName', myName[4]);
    }
    if (callback) {
        try {
            eval(callback)();
        } catch (e) {
        }
    }
}

/*****************************************************
ファイルのインポート（ぺろんぺろん）
importFile(PATH)

与えられたパスに存在するファイルを読み込んで表示する。


PATH		: 呼び出すファイルのパス
******************************************************/
function importFilePero(URI, ID) {
    if (ID) {
        var ID = null;
    } else {
        var ID = 'ID' + (Math.ceil(Math.random() * 1000000 + 10000000))
        document.write('<ins style=" text-decoration:none;" id="' + ID + '"></ins>');
    }
    requestFile(URI, 'importPero', ID);
}
function func_importPero(xml, ID) {
    var txt = xml.responseText;
    var chk = txt.match(/<!--：次回確認日：\d{8}：.*?：.*?：-->/);
    if (chk) {
        var cArray = chk.toString().split('：');
    }
    var mongon = (chk) ? cArray[4] : '詳細'
    txt = '<p ID="' + ID + '_c1" onClick="exMenu(\'' + ID + '_o\');exMenu(\'' + ID + '_c1\');exMenu(\'' + ID + '_c2\');exMenu(\'' + ID + '_body\');" style="font-size:80%; display:none; cursor:pointer; display:none"><span style=" color:#f90">▲</span>閉じる</p>\n<p ID="' + ID + '_o" onClick="exMenu(\'' + ID + '_o\');exMenu(\'' + ID + '_c1\');exMenu(\'' + ID + '_c2\');exMenu(\'' + ID + '_body\');" style="font-size:80%; cursor:pointer; display:block"><span style=" color:#f90">▼</span>' + mongon + 'を見る</p>\n<div ID="' + ID + '_body" style="display:none;">' + txt + '</div>\n';
    txt += '<p ID="' + ID + '_c2" onClick="exMenu(\'' + ID + '_o\');exMenu(\'' + ID + '_c1\');exMenu(\'' + ID + '_c2\');exMenu(\'' + ID + '_body\');" style="font-size:80%; display:none; cursor:pointer; display:none"><span style=" color:#f90">▲</span>閉じる</p>\n';
    reWrite(ID, txt)
}
/*****************************************************
XML取得
requestFile(fileName,ID,[myID,obj,callbackFaunction])
******************************************************/
/*XML読み込み*/
function requestFile(fileName, ID, myID, obj, callback) {
    var xmlObj = createXMLHttp();
    if (xmlObj) {
        xmlObj.onreadystatechange = function () {
            if (xmlObj.readyState == 4) {
                if (xmlObj.status == 200) {
                    eval('func_' + ID)(xmlObj, myID, obj, callback);
                } else if (xmlObj.status != 200) {
                    if (window.location.host.match(/origin/ig)) {
                        window.status = '「' + fileName + '」\n' + xmlObj.status + '\n' + alertMsg[xmlObj.status];
                    }
                }
            }
        }
        var rndHead = (fileName.match(/\?/)) ? '&rnd=' : '?rnd=';
        var file = fileName + rndHead + Math.ceil(Math.random() * 10000);
        xmlObj.open('GET', file, true);
        xmlObj.send(null);
    } else {
        mAlert("XMLHttpRequest非対応のブラウザです。");
    }
}
/*****************************************************
XMLオブジェクト作成
createXMLHttp()

XMLオブジェクトを作成する
XMLオブジェクトが作成できない場合は「false」を返す。
******************************************************/
function createXMLHttp() {
    if (window.XMLHttpRequest) {
        return (new XMLHttpRequest());
    } else if (window.ActiveXObject) {
        try {
            return (new ActiveXObject("Msxml2.XMLHTTP"));
        } catch (e) {
            return (new ActiveXObject("Microsoft.XMLHTTP"));
        }
    } else {
        return (false);
    }
}

/*****************************************************
同期確認
confirmation(obj)

足並みを確認する。
足並み確認用Objectを入力し、全てのプロパティを確認し
全て真だった場合、真を返す。
******************************************************/
function confirmation(obj) {
    var n = new Number()
    for (var i in obj) {
        n += (obj[i]) ? 0 : 1;
    }
    return (n == 0) ? true : false;
}

/*****************************************************
DOM作成
makeDOM(obj)
obj = {
"TAG":"タグ",		//省略時DIVタグ
"ID":"ID",			//ID　省略可
"myClass":"CLASS",	//Class　省略可
"myClass":"text",	//テキスト（HTML不可）
"****":"hoge"		//****で属性を作成し、値をその属性に入れる。
}
******************************************************/
function makeDOM(obj) {
    if (obj.TAG == "clear") {
        obj.TAG = 'div';
        obj.myClass = 'clear';
    }
    var myTAG = (obj.TAG) ? obj.TAG : "div";
    var temp = document.createElement(obj.TAG);
    for (var arg in obj) {
        if (arg == 'TAG') {
        } else if (arg == 'ID') {
            temp.setAttribute("id", obj.id);
        } else if (arg == 'id') {
            temp.setAttribute("id", obj.id);
        } else if (arg == 'myClass') {
            if (document.all) {
                temp.setAttribute("className", obj.myClass);
                temp.setAttribute("class", obj.myClass);
            } else {
                temp.setAttribute("class", obj.myClass);
            }
        } else if (arg == 'text') {
            var txtNode = document.createTextNode(obj.text);
            temp.appendChild(txtNode);
        } else {
            if (obj[arg]) {
                temp.setAttribute(arg, obj[arg]);
            }
        }
    }
    return temp;
}
/**/

/*XML操作系*/
/*****************************************************
XMLから任意の情報を抽出する
xmlTag(XMLObject,tagName[,nodeNumber,Attribute])

指定されたXMLオブジェクトの指定されたタグの内容を返す
該当する値が存在しない場合は「false」を返す。

XMLObject		: XMLオブジェクトを指定※必須
tagName			: タグを指定※必須
nodeNumber		: ノードを数値で指定※省略可（省略時は一番先頭のノードが読み込まれる）
Attribute		: アトリビュート※省略可（省略時は指定ノードの情報が出力される）
******************************************************/

function xmlTag(xmlObj, tag, num, Attribute) {
    var num = (num > 0) ? num : 0;
    try {
        var t = xmlObj.getElementsByTagName(tag);
    } catch (e) {
        var t = false;
    }
    if (t) {
        var temp = t[num]
        if (!Attribute) {
            try {
                return temp.firstChild.nodeValue.replace(/\n/ig, '<br />');
            } catch (e) {
                return false;
            }
        } else {
            try {
                var t = temp.getAttribute(Attribute);
                return (t != null) ? t : false;
            } catch (e) {
                return false;
            }
        }
    } else {
        return false;
    }
}


function xml2obj(xmlObj, tag) {
    var t = false;
    var _array = false;
    try {
        t = xmlObj.getElementsByTagName(tag);
    } catch (e) { }
    if (t) {
        _array = new Array();
        for (var _i = 0; t.length > _i; _i++) {
            var temp = t[_i];
            _array[_i] = new Object();
            try {
                _array[_i].value = temp.firstChild.nodeValue.toString().replace(/\n/ig, '<br />');
                _array[_i]._value = temp.firstChild.nodeValue;
            } catch (e) {
                _array[_i].value = false;
                _array[_i]._value = false;
            }
            for (var _j = 0; temp.attributes.length > _j; _j++) {
                var _name = temp.attributes.item(_j).name;
                var _value = temp.getAttributeNode(_name).value;
                try {
                    _array[_i][_name] = _value.toString().replace(/\n/ig, '<br />');
                    _array[_i]['_' + _name] = _value;
                } catch (e) {
                }
            }
        }
    } else { }
    return _array;
}

/*****************************************************
ログインチェック
confirmation(obj)
******************************************************/
loginBOX = new function () {
    this.clearForm = function () {
        if (window.document.loginform.userID.value.match(/[^\x01-\x7E]/)) {
            window.document.loginform.userID.value = '';
        } else {
        }
    }

    this.makeLoginForm = (function () {
        var _RETURN_URL = '/';
        var _SIZE = 230;
        var _HTML = '<FORM name="loginform" method="post" action="https://www.sourcenext.com/users/action/login">\
		<INPUT type="hidden" name="location" value="@@/returnURL/@@" />\
		<INPUT type="hidden" name="mail" value="" />\
		<INPUT type="hidden" name="head" value="" />\
		<INPUT type="hidden" name="tail" value="" />\
		<INPUT type="hidden" name="backflg" value="" />\
		<INPUT type="hidden" name="zenrinId" value="" />\
		<div><input type="text" ID="userID" name="userID" maxlength="128" value="" style="width:@@/SIZE/@@px; margin:5px auto;" onclick="void(loginBOX.chkLoginForm1(true));" onfocus="loginBOX.chkLoginForm1(true)" onblur="loginBOX.chkLoginForm1()" /></div>\
		<div><INPUT type="password" ID="passwd" name="passwd" maxlength="16" style="width:@@/SIZE/@@px; margin:5px auto; display:none;" onblur="loginBOX.setPass(false);" />\
		<INPUT type="text" ID="_passwd_" name="_passwd_" maxlength="16" style="width:@@/SIZE/@@px; margin:5px auto; color:#999" value="パスワード（英数半角4～16文字）" onfocus="loginBOX.setPass(true);" onclick="loginBOX.setPass(true);" /></div>\
		<!--p class="kome">※メールアドレスもユーザーIDとしてご使用いただけます。 </p-->\
		<div onClick="loginBOX.clearForm();">@@/BTN/@@</div>\
		</FORM>';
        var _BTN = '<INPUT type="IMAGE" name="" src="/img/common/btn_mylogin.gif" width="110" height="28" border="0" alt="ログイン" title="ログイン" />';
        return function (_returnURL, _btn, _method, size) {
            _RETURN_URL = (_returnURL) ? _returnURL : _RETURN_URL;
            _SIZE = (size) ? size : _SIZE;
            _BTN = (_btn) ? _btn : _BTN;
            _HTML = _HTML.replace(/@@\/returnURL\/@@/g, _RETURN_URL);
            _HTML = _HTML.replace(/@@\/BTN\/@@/g, _BTN);
            _HTML = _HTML.replace(/@@\/SIZE\/@@/g, _SIZE);
            if (_method == 'return') {
                return _HTML;
            } else {
                document.write(_HTML);
                this.chkLoginForm1();
            }
            this.chkLoginForm1();
        };
    })();

    this.chkLoginForm1 = (function () {
        var _userID = 'メールアドレス（ユーザーID）';
        var _colorOFF = '#999';
        var _colorON = '#000';
        return function (_chk, _obj) {
            if (_chk) {
                if ($('userID').value == '' || $('userID').value == _userID) {
                    $('userID').value = '';
                    $('userID').style.color = _colorON;
                }
            } else {
                if ($('userID').value == '' || $('userID').value == _userID) {
                    $('userID').value = _userID;
                    $('userID').style.color = _colorOFF;
                } else {
                    $('userID').style.color = _colorON;
                }
            }
        };
    })();

    this.setPass = (function () {
        return function (tgl) {
            if (tgl) {
                $('_passwd_').style.display = 'none';
                $('passwd').style.display = 'inline';
                $('passwd').focus();
            } else {
                if ($('passwd').value == "") {
                    $('_passwd_').style.display = 'inline';
                    $('passwd').style.display = 'none';
                }
            }
        };
    })();
}

/////////////EC//////////////////////////////////
/*ログインポップアップ*/
function ww() {
    if (document.all) {
        var b = document.getElementsByTagName('BODY');
        var w = b[0].clientWidth;
    } else if (document.layers || document.getElementById) {
        var w = window.innerWidth;
    }
    return (w / 2 - 210)
}
var cpURL = new String();
function loginCHK(URL, elm, offset_y, offset_x, pos, align) {
    var bgImg = '/eshop/img/login/popbox_top.png'
    var offset = false;
    if (align) {
        if (align == 'left') {
            bgImg = '/eshop/img/login/popbox_left.png'
            offset = true;
        } else if (align == 'right') {
            bgImg = '/eshop/img/login/popbox_right.png'
            offset = true;
        }
        $('EC_LOGIN_POP_HEAD').style.height = '40px';
    } else {
    }
    $('EC_LOGIN_POP_HEAD').style.backgroundImage = 'url(' + bgImg + ')';
    $('EC_LOGIN_POP_BODY').style.background = 'url(' + bgImg + ') center center';
    $('EC_LOGIN_POP_FOOT').style.backgroundImage = 'url(' + bgImg + ')';
    if (typeof _gaq === 'undefined') {
    } else {
        _gaq.push(['_trackEvent', 'LOGIN_' + ga_ini.category, 'loginCHK', ga_ini.opt_label]);
    }

    var place = { "TOP": "ecgt_bb", "BOTTOM": "ecgt_sb" }
    var URL = URL + "?i=" + place[pos];

    if (login.loginStatas) {
        if (URL.match(/http/)) {
        } else {
            URL = 'http://www.sourcenext.com' + URL;
        }
        window.location.href = URL;
    } else {
        if (URL) {
            var __URL = URL.split('?');
            if (__URL[1]) {
                var _URL = __URL[1].split('&');
                _URL.push('loginCHK=LOGIN_ECGT');
                var URL = __URL[0] + '?' + _URL.join('&');
            } else {
                var URL = __URL[0] + '?loginCHK=LOGIN_ECGT';
            }
        } else {
            var URL = '/eshop/';
        }
        if (URL.match(/http/)) {
        } else {
            URL = 'http://www.sourcenext.com' + URL;
        }
        window.document.loginform.location.value = URL;
        loginBOX_PopUp(elm, offset_y, offset_x, offset);
    }
}
var loginBOX_PopUp_tgl = false;
window.document.onclick = function () {
    if ($('EC_LOGIN_POP_BOX')) {
        var popObj = $('EC_LOGIN_POP_BOX');
        if (loginBOX_PopUp_tgl) {

        } else {
            try {
                popObj.style.top = '-500px';
            } catch (e) {
            }
        }
    }
}
function loginBOX_PopUp(elm, offset_y, offset_x, offset) {
    var offset_x = (offset_x) ? offset_x : -10;
    var offset_y = (offset_y) ? offset_y : 20;
    var boxObj = getElementPosition(elm);
    var popObj = $('EC_LOGIN_POP_BOX');
    //	alert(boxObj);
    if (offset) {
        offset = 0;
    } else {
        offset = popObj.offsetHeight
    }
    popObj.style.top = (boxObj._y - offset + offset_y) + 'px';
    popObj.style.left = (boxObj._x + offset_x) + 'px';
}
mY = new Number();
mX = new Number();
function setPosition() {
    window.document.onmousemove = function (e) {
        mX = getMousePosition(e).x;
        mY = getMousePosition(e).y;
    }
}

function getMousePosition(e) {
    var obj = new Object();
    if (e) {
        obj.x = e.pageX;
        obj.y = e.pageY;
    } else {
        obj.x = event.x + document.body.scrollLeft;
        obj.y = event.y + document.body.scrollTop;
    }
    return obj;
}


function close_pop(obj) {
    if ($('POP').style.top == '-1000px') {
        fukidashiBOX(obj, $('POP'), 'TR', 'CL');
    } else {
        $('POP').style.top = '-1000px'
    }
}

/*****************************************************
割引券ポップアップ
******************************************************/
function pop_oft_infoBox(view) {
    if (view) {
        var myCookie = {};
        var cookieStr = document.cookie.toString().replace(/ /ig, '').split(';');
        for (var i = 0; cookieStr.length > i; i++) {
            var temp = cookieStr[i].split("=");
            myCookie[temp[0]] = temp[1];
        }
        if (myCookie.pyon) {
        } else {
            if (login.loginStatas) {
                if (oft_infoBox_var) {
                    if ($('oft_infoBox')) {
                        $('oft_infoBox').style.top = oftTop;
                    }
                }
            }
        }
    } else {
        $('oft_infoBox').style.top = "-100px";
    }
}
function setNyon(h) {
    document.cookie = "pyon=1;path=/";
    pop_oft_infoBox(0);
}

/*****************************************************
スマホ対策 動画swfプレーヤー
mp4_iPhone(ID,URL,サムネール,横幅,縦幅,音声の有無)
******************************************************/

function mp4_iPhone(IDname, url, bg, xw, yh, se) {

    var HTML = new String();
    HTML = "<div style='width:" + xw + "; background:url(" + bg + ") center top no-repeat;'><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" + xw + "' height='" + (yh + 24) + "' id='mov' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='%7E/media/Files/common/mov_size.swf?movie_file=" + url + "&se=" + se + "&xw=" + xw + "&yh=" + yh + "' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='~/media/Files/common/mov_size.swf?movie_file=" + url + "&se=" + se + "&xw=" + xw + "&yh=" + yh + "' quality='high' wmode='transparent' bgcolor='#ffffff' width='" + xw + "' height='" + (yh + 24) + "' name='mov' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object></div>";

    var HTML_i = new String();
    HTML_i = "<p><EMBED SRC='" + bg + "' HREF='" + url + "' TYPE='video/x-m4v' TARGET='myself' SCALE='1' width='" + xw + "' height='" + yh + "'></p>";

    /*HTML_i = '<div class="img_c"><video src="'+url+'" poster="'+bg+'" preload="none" onclick="this.play()" controls></video></div>';*/

    if (mobile == 1) {
        if (navigator.userAgent.indexOf('Android') > 0) {
            reWrite(IDname, HTML);
        } else {
            reWrite(IDname, HTML_i);
        }
    } else {
        reWrite(IDname, HTML);
    }

}
function ticketlists() {
}

var set_soldout_kamo_btn_num = 0;
function set_soldout_kamo_btn() {
    if (!window['jQuery']) {
    } else {
        if (jQuery('.cartKamoBtn').length > 0) {
            jQuery('.cartKamoBtn').each(function () {
                $this = jQuery(this);
                $this.click(function () {
                    $this = jQuery(this);
                    var GroupCode = $this.attr('data-pgcode');
                    jQuery.getJSON(
						'/sc/module/wish_reg.aspx?do=add&progroup=' + GroupCode + '&callback=?',
						function (result) {
						    if (!jQuery('#kamoToolTip').size()) {
						        jQuery("body").append('<div id="kamoToolTip" class="" style="border-color: rgb(255, 153, 0); background-color: rgb(255, 255, 204); "><p></p></div>');
						    }
						    if (result.StautsText == 'success') {
						        var nowX = ($this.offset().left) + 25;
						        var nowY = ($this.offset().top) - 10;
						        jQuery("p", '#kamoToolTip').replaceWith("<p>「気になるかも」に<br />登録しました</p>");
						        nowY -= jQuery('#kamoToolTip').height();
						        jQuery('#kamoToolTip').css({ left: nowX, top: nowY });
						        jQuery('#kamoToolTip').animate({ opacity: "show" }, 200);
						        setTimeout(function () {
						            jQuery('#kamoToolTip').hide().css({ left: -600, top: -600 });
						            jQuery("p", '#kamoToolTip').replaceWith("<p></p>");
						        }, 3000);
						        jQuery('#kamoToolTip').click(function () {
						            jQuery('#kamoToolTip').hide().css({ left: -600, top: -600 });
						            jQuery("p", '#kamoToolTip').replaceWith("<p></p>");
						        });
						    } else {
						        window.open('https://www.sourcenext.com/sc/campaign/wish', 'newWindow');
						    }

						}
					);
                });
            })
			.mouseover(function () {
			    $this = jQuery(this);
			    $this.attr('src', '/~/media/Images/eshop/btn/btn_nyuukakamo_o');
			})
			.mouseout(function () {
			    $this = jQuery(this);
			    $this.attr('src', '/~/media/Images/eshop/btn/btn_nyuukakamo');
			})
			.css({ 'cursor': 'pointer' })
			;
        } else {
            set_soldout_kamo_btn_num++;
            if (set_soldout_kamo_btn_num != 10) {
                setTimeout("set_soldout_kamo_btn()", 1000);
            }
        }
    }
};

/*
for (var i in $_COOKIE_SN) {
console.log(i + ' : \n\tvalue : ' + $_COOKIE_SN[i][0] + '\n\texpires : ' + $_COOKIE_SN[i][1] + '\n\tpriority : ' + $_COOKIE_SN[i][2]);
}
*/
var setSnCookie = function (options) {
    var __COOKIE_SN = {};
    var _temp = [];
    var _json = [];
    var _size = 0;
    var _now = new Date();
    if (typeof options.key === 'undefined' || typeof options.value === 'undefined') {
        console.log('入力されたフォーマットが正しくありません。\n{key:呼び出し名,Value:値[,priority:0～99,expires:YYYY/MM/DD HH:mm]}で入力してください');
        return null;
    }
    if (options.key.match(/[^0-9a-zA-Z_]+/)) {
        console.log('Keyに指定されている値が無効です\n半角英数字のみ利用できます');
        return null;
    }
    var _key = options.key;
    var _value = encodeURIComponent(options.value);
    var _priority = (function (priority) {
        if (typeof priority === 'undefined') return 99;
        var _priority = parseInt(priority);
        if (typeof _priority != 'number' || isNaN(_priority)) return 99;
        if (0 > _priority) {
            return 0;
        }
        return (_priority >= 100) ? 99 : _priority;
    })(options.priority);
    var _expires = (function (expires) {
        var _return = new Date();
        _return.AddHours(12);
        if (typeof expires !== 'undefined') {
            try {
                _return = new Date(expires);
            } catch (e) {
            }
        }
        return _return;
    })(options.expires);

    if (_expires >= _now) {
        _temp.push({ 'key': _key, 'value': _value, 'expires': _expires, 'priority': _priority, 'json': '"' + _key + '":["' + _value + '",' + _expires.format('cookie') + ',' + _priority + ']' });
        __COOKIE_SN[_key] = [_value, _expires, _priority];
    }
    for (var i in $_COOKIE_SN) {
        var _date = $_COOKIE_SN[i][1];

        if (_now >= _date) continue;
        (function (_insertKey) {
            var _key = i;
            var _value = $_COOKIE_SN[i][0];
            var _expires = $_COOKIE_SN[i][1];
            var _priority = $_COOKIE_SN[i][2];
            var _json = '"' + _key + '":["' + encodeURIComponent(_value) + '",' + _expires.format('cookie') + ',' + _priority + ']';
            if (_insertKey != _key) {
                _temp.push({ 'key': _key, 'value': _value, 'expires': _expires, 'priority': _priority, 'json': _json });
                __COOKIE_SN[_key] = [_value, _expires, _priority];
            }
        })(_key);
    }
    $_COOKIE_SN = {};
    $_COOKIE_SN = __COOKIE_SN;
    _temp.sort(function (a, b) {
        return (a.priority < b.priority) ? -1 : 1;
    });
    for (var i = 0; _temp.length > i; i++) {
        var _item = _temp[i];
        if (typeof _item === 'undefined') continue;
        if (_size + _item.json.length > 1024) continue;
        if (_size + _item.json.length > 1000) break;
        _size += _item.json.length;
        _json.push(_item.json);
    }
    var JSON = '{' + _json.join(',') + '}';
    (function (value) {
        if (value) {
            var nowtime = new Date().getTime();
            var limit = new Date(nowtime + (60 * 60 * 24 * 1000 * 365 * 3));
            var expires = limit.toGMTString();
            var insCookie = 'SN_COOKIE=' + value + '; expires=' + expires + '; path=/';
            document.cookie = insCookie;
        }
    })(JSON);
    return JSON;
};
