
d = (new Date()).getTime();
document.write(unescape('%3Cscript type="text/javascript" src="http://www.cuoca.com/library/common/js/jquery.cookie.js?date='+d+'"%3E%3C/script%3E'));

// JavaScript Document
jQuery.noConflict();
var j$ = jQuery;
//url
var host_name="www.cuoca.com";
var protocol = ( (host_name == "www.cuoca.com" || "https:" == document.location.protocol) ? 'https://' : 'http://' );
var url_customer = protocol+host_name+"/api/customer.php?jsonp=?";
var url_cart = protocol+host_name+"/api/cart.php?jsonp=?";

//クッキー取得
//mycuoca
j$(function (){
	ULID = j$.cookie('ULID');
	UPID = j$.cookie('UPID');
	if(ULID && UPID){
		var ntime = (new Date()).getTime();
        j$.ajaxSetup({scriptCharset:'utf-8'});
		j$.getJSON(url_customer,{type:'json',cust_id:ULID,passwd:UPID,ntime:ntime},callbackGetCustomerData);
	}
	else{
		showUnlogin();
	}
});
//
//smartcart
j$(function (){
	//UCRT = j$.cookie('UCRT');
	//CSD = j$.cookie('CSD');
	//if(UCRT && CSD){
	var ntime = (new Date()).getTime();
	j$.getJSON(url_cart,{type:'json',ntime:ntime},callBackCartUpDate);
	//}
	//else{
	//}
});

//mycuoca表示
function callbackGetCustomerData(data, status) {
	//j$.dump(data,status);
	if(data.result == "OK"){
		j$("#sidemycuoca-name").html("ようこそ、"+data.customer.last_name + data.customer.first_name+"さん");
		j$("#sidemycuoca-point").html('クオカポイント&nbsp;<strong>' + data.customer.point + 'pt</strong>');
		j$("#sidemycuoca-navi0 a").text('マイクオカ');
		j$("#sidemycuoca-navi0 a").attr('href','https://mycuoca.cuoca.com/index.html');
		j$("#sidemycuoca-navi1 a").text('ご注文履歴から注文');
		j$("#sidemycuoca-navi1 a").attr('href','https://mycuoca.cuoca.com/myhistory.php');
        j$("#sidemycuoca-navi2 a").text('お気に入り商品リスト');
        j$("#sidemycuoca-navi2 a").attr('href','https://mycuoca.cuoca.com/myfavorite.php');
		//j$("#sidemycuoca-r").html('<a href="https://mycuoca.cuoca.com/login.php?mode=logout&ref=/index.html">ログアウト</a>');
	}
	else{
		showUnlogin();
	}
}

//smartCart表示
function callBackCartUpDate(data,status){
	//j$.dump(data,true);
	var lv = data.last_viewing;
	var count = lv.length;
	var a = '';
	if(count > 0){
		j$("#last_viewing").css("display","block");
		for(i=0;i<count;i++){
		a+= '<dd class="check_goods clearfix">';
        a+= '<a href="'+lv[i].url+'"><img src="http://www.cuoca.com'+lv[i].image+'"';
        a+= ' alt="'+lv[i].name+'" width="65" />'+lv[i].name+'</a></dd>';
		}
		j$("#last_viewing").after(a);
	}
	//カートの中身
	if(data.item_count > 0){
		j$(".cart_title,.cart_in,.cart").css("display","block");
		j$("#com_data_publish_count_all_sum").html(data.item_count);
		j$("#com_data_publish_price_all_sum").html(data.price_sum);
		j$("#com_data_publish_carry_sum").html(data.soryo_sum);
		j$("#com_data_publish_soryo_alert_sum").html(data.soryo_alert);
	}
}

//未ログイン時の表示
function showUnlogin(){
	j$("#sidemycuoca-name").html("ようこそ、ゲストさん");
	j$("#sidemycuoca-point").css('display','none');
	j$("#sidemycuoca-navi0 a").text('初めての方へ');
	j$("#sidemycuoca-navi0 a").attr('href','http://www.cuoca.com/library/about/welcome/index.html');
	j$("#sidemycuoca-navi0 a").after('&nbsp;<img alt="初めての方へ" src="http://www.cuoca.com/image/template/side/icn_mark.gif">');
	j$("#sidemycuoca-navi1 a").text('送料・支払い方法など');
	j$("#sidemycuoca-navi1 a").attr('href','javascript:void(0)');
	j$("#sidemycuoca-navi1 a").attr('onclick','openWindow("http://www.cuoca.com/library/howto/")');
	j$("#sidemycuoca-navi2 a").text('お買い物ガイド');
	j$("#sidemycuoca-navi2 a").attr('href','javascript:void(0)');
	j$("#sidemycuoca-navi2 a").attr('onclick','openWindow("http://www.cuoca.com/library/howto/")');
		//j$("#sidemycuoca-r").html('<a href="https://mycuoca.cuoca.com/index.html?mode=login">ログイン</a>');
		//送料無料コメント(2/2)
		//j$("#header").after('<div style="background-color:#f7e657; padding:5px;width:890px;margin-bottom:5px;"><img src="http://www.cuoca.com/library/common/parts/0yen_icon.gif" style="vertical-align:-3px;" /><font color="#e42424"><b><span style="font-size:14px;">【初回送料無料キャンペーン】 クオカで初めてご購入のお客様に限り送料無料！6月25日まで ※Webでご注文3,000円以上</span></b></font></div>');
}

