strLocation = window.location.toString().toLowerCase();
if (strLocation.search(/webdevp/) >= 0) {
	document.domain="mingpao.com";
} else {
	document.domain="mpfinance.com";
}

function setStockCookie(code)
{¡@
	var stocksList = '';
	var limit, strRegExp;
	var refresh = false;

	if (isNaN(code)) code = code.substr(code.length-6);
	if (!isNaN(code)) {
		code = parseInt(code,10);
		strRegExp = new RegExp(',' + code + ',', 'i');
		limit = 5;
		stocksList = getFinanceCookie('yourstockslist');
		if (!stocksList) {
			stocksList = 'yourstockslist=' + code;
			setFinanceCookie(stocksList);
			refresh = true;
		} else {
			temp = ',' + stocksList + ',';
			if (temp.search(strRegExp)<0) {
				oldStockList = stocksList.split(',');
				stocksList = 'yourstockslist=' + code;
				for (i=0;i<oldStockList.length;i++) {
					stocksList = stocksList + ',' + oldStockList[i];
					if (i>=(limit-2)) break;
				}
				setFinanceCookie(stocksList);
				refresh = true;
			}
		}
		if (refresh && window.opener && window.opener.displayQuoteHistory) window.opener.displayQuoteHistory();
	}
}

function setFinanceCookie(cookieValue)
{
	var now;
	now = new Date();
	now.setTime(now.getTime() + 1000 * 60 * 60 * 12);
	strLocation = window.location.toString().toLowerCase();
	if (strLocation.search(/webdevp/) >= 0) {
		document.cookie = cookieValue + ';expires=' + now.toGMTString() + ';path=/';
	} else {
		document.cookie = cookieValue + ';expires=' + now.toGMTString() + ';path=/;domain=mpfinance.com';
	}
}

function getFinanceCookie(checkname)
{
	var mpfcookies = document.cookie.split(';');
	var tempCookies, cookieName, cookieValue, bFound;
	for (i=0;i<mpfcookies.length;i++)
	{
		tempCookies = mpfcookies[i].split( '=' );
		cookieName = tempCookies[0].replace(/^\s+|\s+$/g, '');
		if (cookieName==checkname)
		{
			bFound = true;
			if (tempCookies.length>1) cookieValue = unescape(tempCookies[1].replace(/^\s+|\s+$/g, ''));
			return cookieValue;
			break;
		}
		tempCookies = null;
		cookieName = '';
	}
	if (!bFound) return null;
}
