//ログインユーザ名取得
function get_cln(){
	var name = 'UPG_COOKIE_LOGIN_NAME'; // cookie名
	return getCookie(name);
}

//店舗取得(ID、名前、画像パス)
function get_cft(){
	var name = 'UPG_COOKIE_FAVORITE_TENPO'; // cookie名
	var str = getCookie(name);
	arytenpo = new Array();
	if(str != null && str != '') {
		arytenpo = str.split(";");
	}
	return arytenpo;
}

//店舗クッキー登録(ID、名前、画像パス)
function set_cft(tenpo_id, tenpo_name, tenpo_img) {
	var str = "" + tenpo_id + ";" + tenpo_name + ";" + tenpo_img;
	setCookie('UPG_COOKIE_FAVORITE_TENPO', str, 1825);
	alert("お気に入りに登録しました。");
}

//店舗クッキー削除(ID、名前、画像パス)
function del_cft() {
	setCookie('UPG_COOKIE_FAVORITE_TENPO', null, -1);
}

//クッキー取得
function getCookie(key){
	if(_cookie(key))
		return _cookie(key);
	return '';
}

//クッキー登録
function setCookie(key, val, expire) {
	_cookie(key, val, { expires: expire, path: '/'});
}

_cookie = function (key, value, options) {
    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
//        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }
        
        value = String(value);
        
        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

