// Lib Name:	API_JS_domain.js
// Author:	Fareeda Mallick
// Version:	1.0
// Created:	13/6/2001
// Purpose:	This library contains a number of procedures which are used to set and get the value in the CUSTOMER_TYPE
// cookie.


//setCookie 
// Description: Called from setCustomerType and sets the CUSTOMER_TYPE cookie to the parameters as passed.

function setCookie(name,contents, pathName, domainName) 
{
	var expDate = new Date();
	//var pathName = "/btinternet/pop/"
    expDate.setTime(expDate.getTime() + (1 * 24 * 60 * 60 * 1000 * 365))
    expDate = expDate.toGMTString();
    document.cookie = name + '=' + escape(contents) + ";expires=" + expDate +
	 ";path=" +pathName +
	 ";domain=" +domainName +
	 ";"
}

//getCookie 
// Description: Retrieves the value stored in the CUSTOMER_TYPE cookie

function getCookie(cookieName) 
{
	var allcookies = document.cookie;
	var pos = allcookies.indexOf(cookieName + "=");
	if(pos != -1) {
		var start = pos+ (cookieName.length+1);
		var end = allcookies.indexOf(";", start);
		if(end == -1) end= allcookies.length;
		var value = allcookies.substring(start,end);
		return unescape(value);
	} else {
		return "nothing";
	}
}


//setCustomerType 
// Description: Passes the custType which can be one of:
// CUSTOMER, CUSTOMER_LOG, BUSINESS, UNKNOWN.
// and the domain of the cookie is passed from the getDomain API to setCookie.
 
function setCustomerType (custType, domain)

{
	setCookie("CUSTOMER_TYPE", custType, "/", domain);

}

//getCustomerType 
// Description: returns the value of the CUSTOMER_TYPE cookie
// Values returned could be: CUSTOMER, CUSTOMER_LOG, BUSINESS, UNKNOWN, nothing 

function getCustomerType ()

{
	var value=getCookie("CUSTOMER_TYPE");
	return value;
}
