function addResCartItem(res_id, res_name, res_guid, res_city, res_baseline) {	
	//add a new restaurant to the cookie
	var info = [];
	info[0] = res_name;
	info[1] = res_city;
	info[2] = res_baseline;
	info[3] = res_guid;
	$.cookie('res_' + res_id, info.join(';'), {path : '/'});	
	//update cart list
	var res_carts = getResCartList();	
	res_carts.push(res_id);
	updateResCartList(res_carts);
}

function getResCartList() {
	var res_carts = $.cookie('res_cartlist');	
	if( res_carts == null )
		return [];
	else
		return res_carts.split(',');
}

function getResCartItem(res_id) {
	var info = $.cookie('res_' + res_id);
	if( info != null )
		return info.split(';');
	return [];
}

function updateResCartList(newCarts) {
	$.cookie('res_cartlist', newCarts.join(','), {path : '/'});
}

function removeResCartItem(res_id,myfav,city,kitchentype,keyword,region) {
	var res_carts = getResCartList();
	//var index = $.inArray(res_id, res_carts);
	var index = -1;
	
	for (i=0; i < res_carts.length; i++)
	{
		if(res_carts[i] == res_id)
			index = i;
	}
	
	if( index != -1 ) {		
		res_carts.splice( index, 1 );
		updateResCartList(res_carts);
	}
	$.cookie('res_' + res_id, null);

	ajaxListLoad(myfav,'true',city,kitchentype,keyword,region);
}

function checkDuplication(res_id) {
	var res_carts = getResCartList();	
	return $.inArray(res_id, res_carts);
}
