function openBrWindow(flashurl) 
{
	eval("window.open(flashurl,'Win1','scrollbars=no,resizable=yes,width=1014,height=700,left=0,top=0')");
}

function getCookie ( name ) 
	{ 
		cookie_name = name + "="; 
		cookie_length = document.cookie.length; 
		cookie_begin = 0; 
		while (cookie_begin < cookie_length) 
		{ 
			value_begin = cookie_begin + cookie_name.length; 
			if (document.cookie.substring(cookie_begin, value_begin) == cookie_name) 
			{ 
				var value_end = document.cookie.indexOf ( ";", value_begin); 
				if (value_end == -1) 
				{ 
					value_end = cookie_length; 
				} 
				return unescape(document.cookie.substring(value_begin, value_end)); 
			} 
			cookie_begin = document.cookie.indexOf ( " ", cookie_begin) + 1; 
			if (cookie_begin == 0) 
			{ 
				return null;  
			} 
		} 
	} 
		
	function addShopCookie(shopId, type) {
		var key = 'compare_restaurants';
		if ( type == '2' ) {
			key = 'compare_shops';
		} else if ( type == '3') {
			key = 'compare_enterprises';
		}
		var arrayStrTemp =getCookie(key);
		if (arrayStrTemp != null) {
			var arrayStr = arrayStrTemp.split("|");
			var hasShop = '0';
			for (var i=0; i<arrayStr.length; i++) {
				if (arrayStr[i] == shopId) {
					hasShop = '1';
					break;
				}
			}
			if (hasShop == '0') {
				arrayStr[arrayStr.length]=shopId;
			}
			var shops = arrayStr[0];
			for (var i=1; i<arrayStr.length; i++) {
				shops += '|' +  arrayStr[i];
			}
			document.cookie=key+"="+shops+"; path=/";
		} else {
			arrayStr = new Array();
			arrayStr[0] = shopId;
			document.cookie=key+"="+arrayStr+"; path=/";
		}
	}
	function delShopCookie(shopId, type) {
		var key = 'compare_restaurants';
		if ( type == '2' ) {
			key = 'compare_shops';
		} else if ( type == '3') {
			key = 'compare_enterprises';
		}
		var arrayStrTemp = getCookie(key);
		if (arrayStrTemp != null) {
			var arrayStr = arrayStrTemp.split("|");
			for (var i=0; i<arrayStr.length; i++) {
				if (arrayStr[i] == shopId) {
					arrayStr[i] = arrayStr[arrayStr.length-1];
					arrayStr.pop(i);
					break;
				}
			}
			var shops = '';
			if (arrayStr.length > 0) {
				shops = arrayStr[0];
				for (var i=1; i<arrayStr.length; i++) {
					shops += '|' +  arrayStr[i];
				}
			}
			document.cookie=key+"="+shops+"; path=/";
		}
		window.location.reload();
	}
	
function userRead(chinaSite, japanSite) {
	var cookieCountry = getCookie('digitalbook');
	if (cookieCountry == null) {
		window.open('http://www.chainavi.jp/mag/popup.htm?'+chinaSite+'?'+japanSite,'','width=360,height=200');
	} else if (cookieCountry=='CHINA') {
		openBrWindow(chinaSite);
	} else if (cookieCountry=='JAPAN') {
		openBrWindow(japanSite);
	}
}