function getCookie(Name){
	var search = Name + "=";
	if (document.cookie.length > 0) {
		offset = document.cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if (end == -1)	end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
	}
	return '';
}

function WindowOnFocus()
{
	var shoppingCartPrice = document.getElementById('ShoppingCart_total');
	var shoppingCartItems = document.getElementById('ShoppingCart_items');	
	
	var price = getCookie('shopping_cart_price');
	var items = getCookie('shopping_cart_items');

	
	if(shoppingCartPrice) {
		price = parseFloat(price);
		price = isNaN(price) ? 0 : price;
		price = price.toString();
		price = price.replace(/(\d)(\d{3}([.]\d)*)$/, '$1,$2');
		price = price.replace(/(\d)(\d{3},\d{3}([.]\d)*)$/, '$1,$2');
		shoppingCartPrice.innerHTML = price + ' baht';
	}

	if(shoppingCartItems) {
		items = parseInt(items, 10);
		items = isNaN(items) ? 0 : items;
		shoppingCartItems.innerHTML = items.toString() + ' item(s)';
	}
}
//WindowOnFocus();
//window.onfocus=WindowOnFocus;

//add timer for update price every 5 sec.
setInterval("WindowOnFocus( )", 5000);