function Set_Cookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) 
					+ ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) 
					+ ( ( path ) ? ";path=" + path : "" ) 
					+ ( ( domain ) ? ";domain=" + domain : "" ) 
					+ ( ( secure ) ? ";secure" : "" );
}

	function getCookie(NameOfCookie)
	{
		if (document.cookie.length > 0)
		{
			begin = document.cookie.indexOf(NameOfCookie+"=");
			if (begin != -1)
			{
				begin += NameOfCookie.length+1;
				end = document.cookie.indexOf(";", begin);
				if (end == -1) end = document.cookie.length;
				return unescape(document.cookie.substring(begin, end));
			}
		}
		return null;
	}

function Get_Cookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ ) {
		a_temp_cookie = a_all_cookies[i].split( '=' );
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
		if ( cookie_name == check_name ) {
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 ) {
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) {
		return null;
	}
}				
function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie(name) ) {
		document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
}
function resetLogoutCookie() {
	
	Delete_Cookie('tcp_firstname', '/', '');
	Delete_Cookie('tcp_emailaddress', '/', '');
	Delete_Cookie('tcp_isregistered', '/', '');
	
	//delete minicart ..
	delete_cookie('minicartcookie', '/', '');
	delete_cookie('numOfItems', '/', '');
	delete_cookie('cmEmailCookie', '/', '');
	
}

function resetCookie() {
	
	Delete_Cookie('tcp_firstname', '/', '');
	Delete_Cookie('tcp_emailaddress', '/', '');
	Delete_Cookie('tcp_isregistered', '/', '');
	
}

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function getNumOfItems() {
	var numOfItems;
	numOfItems = 0;
	if ( Get_Cookie('numOfItems') ) {
		numOfItems = Get_Cookie('numOfItems');
		return numOfItems;
	} else {
		return 0;
	}
}
function getTotalAmt() {
	var totalAmt = '$0.00';
	if ( Get_Cookie('totalAmt') ) {
		totalAmt = Get_Cookie('totalAmt');
	}
	if (totalAmt == null) {
		return '$0.00';
	} else {
		return totalAmt;
	}
}

function setNumOfItems(numOfItems) {
	Set_Cookie('numOfItems', numOfItems, null);
}
function setTotalAmt(totalAmt) {
	Set_Cookie('totalAmt', totalAmt, null);
}

<!-- Added for Shopping Cart Limitation bug - Checkout possible with more than 15 SKUs for single item -->
function setOrderItemsQtyList(orderItemsQtyList)
{
	Set_Cookie('orderItemsQtyList', orderItemsQtyList, null);
}

<!-- Added for Shopping Cart Limitation bug - Checkout possible with more than 15 SKUs for single item -->
function getOrderItemsQtyList()
{
	var orderItems = null;
	if (Get_Cookie('orderItemsQtyList')) 
	{
		orderItems = Get_Cookie('orderItemsQtyList');
	}
	return orderItems;
}

