function delCart(no){
	var ctlname="sumicart_" + no;

	if(!$(ctlname)) return false;
    if($(ctlname).style.display == 'none'){
		return false;
    }
    var ajax = new Ajax.Request("/cart/?no=" + no + "&del=del", {onComplete: _addCart});

	return false;
}
function addCart(no){
	var ctlname="sumicart_" + no;

	if(!$(ctlname)) return false;
    if($(ctlname).style.display == 'block'){
		return false;
    }
    var ajax = new Ajax.Request("/cart/?no=" + no, {onComplete: _addCart});

	return false;
}
function _addCart(){
	checkCart();
}

function checkCart(){
    var ajax = new Ajax.Request("/cart/check2.php", {onComplete: _chkCart});
    if( !$('count_cart')) return;
    var ajax2 = new Ajax.Request("/cart/count.php", {onComplete: _updateCart});
}
function _chkCart(res){
    eval('var data = ' + res.responseText);
	nos.each(function(no){
		sumi_top = 'sumicart_' + no.toString();
		addcart_top = 'addcart_' + no.toString();
		sumi_bottom = 'sumicart_' + no.toString() + '_bottom';
		addcart_bottom = 'addcart_' + no.toString() + '_bottom';
                sumi_midle = 'sumicart_' + no.toString() + '_midle';
                addcart_midle = 'addcart_' + no.toString() + '_midle';
		chk_kousha = 'chk_kousha_' + no.toString();
		data_flg = false
		if( data["cart"] && data["cart"][no] ) {
			data_flg = true;
		}
		if($(sumi_top)) $(sumi_top).style.display = ( data_flg ) ? 'block' : 'none';
		if($(addcart_top)) $(addcart_top).style.display = ( data_flg ) ? 'none' : 'block';
		if($(sumi_bottom)) $(sumi_bottom).style.display = ( data_flg ) ? 'block' : 'none';
		if($(addcart_bottom)) $(addcart_bottom).style.display = ( data_flg ) ? 'none' : 'block';
                if($(sumi_midle)) $(sumi_midle).style.display = ( data_flg ) ? 'block' : 'none';
                if($(addcart_midle)) $(addcart_midle).style.display = ( data_flg ) ? 'none' : 'block';

		if($(chk_kousha) && data_flg ) {
			$(chk_kousha).className = "a_cl01_on_checked";
		}else{
			$(chk_kousha).className = "a_cl01_of";
		}
	});
}

function _updateCart(res){
	$('count_cart').innerHTML = res.responseText;
        if( !$('count_cart_bottom')) return;
	$('count_cart_bottom').innerHTML = res.responseText;
	return;
}




function k_delCart(pref_cd, no){
	var ctlname="k_sumicart_" + no;

	if(!$(ctlname)) return false;
    if($(ctlname).style.display == 'none'){
		return false;
    }
    var ajax = new Ajax.Request("/cart/?pref_cd=" + pref_cd +   "&k_no=" + no  + "&del=del", {onComplete: _k_addCart});

	return false;
}
function k_addCart(pref_cd, no){
	var ctlname="k_sumicart_" + no;

	if(!$(ctlname)) return false;
    if($(ctlname).style.display == 'block'){
		return false;
    }
    var ajax = new Ajax.Request("/cart/?pref_cd=" + pref_cd +  "&k_no=" + no, {onComplete: _k_addCart});

	return false;
}
function _k_addCart(){
	k_checkCart();
}

function k_checkCart(){
    var ajax = new Ajax.Request("/cart/check2.php", {onComplete: _k_chkCart});
    if( !$('count_cart')) return;
    var ajax2 = new Ajax.Request("/cart/count.php", {onComplete: _k_updateCart});
}
function _k_chkCart(res){
    eval('var data = ' + res.responseText);
	k_nos.each(function(no){
		sumi_top = 'k_sumicart_' + no.toString();
		addcart_top = 'k_addcart_' + no.toString();
		sumi_bottom = 'k_sumicart_' + no.toString() + '_bottom';
		addcart_bottom = 'k_addcart_' + no.toString() + '_bottom';
                sumi_midle = 'k_sumicart_' + no.toString() + '_midle';
                addcart_midle = 'k_addcart_' + no.toString() + '_midle';

		chk_kousha = 'k_chk_kousha_' + no.toString();
		data_flg = false
		if( data["k_cart"] && data["k_cart"][no] ) {
			data_flg = true;
		}
		if($(sumi_top)) $(sumi_top).style.display = ( data_flg ) ? 'block' : 'none';
		if($(addcart_top)) $(addcart_top).style.display = ( data_flg ) ? 'none' : 'block';
                if($(sumi_midle)) $(sumi_midle).style.display = ( data_flg ) ? 'block' : 'none';
                if($(addcart_midle)) $(addcart_midle).style.display = ( data_flg ) ? 'none' : 'block';
		if($(sumi_bottom)) $(sumi_bottom).style.display = ( data_flg ) ? 'block' : 'none';
		if($(addcart_bottom)) $(addcart_bottom).style.display = ( data_flg ) ? 'none' : 'block';
		if($(chk_kousha) && data_flg ) {
			$(chk_kousha).className = "a_cl01_on_checked";
		}else{
			$(chk_kousha).className = "a_cl01_of";
		}
	});
}

function _k_updateCart(res){
	$('count_cart').innerHTML = res.responseText;
        if( !$('count_cart_bottom')) return;
	$('count_cart_bottom').innerHTML = res.responseText;
	return;
}



