


 

/********************************************************************/
//	  Function to return the value of the cookie specified by "name".
//	  name - String object containing the cookie name.
//	  returns - String object containing the cookie value, or empty 
//	  string if the cookie does not exist.
/********************************************************************/
function getCookie(name) { // use: getCookie("name");
	var re = new RegExp(name + "=([^;]+)");
	var value = re.exec(document.cookie);
	return (value != null) ? unescape(value[1]) : "";
}

/********************************************************************/
//	  Function to create or update a cookie.
//	  name - String object containing the cookie name.
//	  value	  - String object containing the cookie value.	May contain
//				  any valid string characters.
//	  [expires]   - Date object containing the expiration data of the cookie.  If
//				  omitted or null, expires the cookie at the end of the current session.
//	  [path]	  - String object indicating the path for which the cookie is valid.
//				  If omitted or null, uses the path of the calling document.
//	  [domain]	  - String object indicating the domain for which the cookie is
//				  valid.	If omitted or null, uses the domain of the calling document.
//	  [secure]	  - Boolean (true/false) value indicating whether cookie transmission
//				requires a secure channel (HTTPS).	
//	The first two parameters are required.	The others, if supplied, must
//	be passed in the order listed above.  To omit an unused optional field,
//	use null as a place holder.  For example, to call setCookie using name,
//	value and path, you would code:
//
//		setCookie ("myCookieName", "myCookieValue", null, "/");
//
//	Note that trailing omitted parameters do not require a placeholder.
//
//	To set a secure cookie for path "/myPath", that expires after the
//	current session, you might code:
//
//		setCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
/********************************************************************/
function setCookie (name, value, expires, path, domain, secure) {// use: setCookie("name", value);
	document.cookie = name + "=" + escape (value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "");
}

/********************************************************************/
//	  Function to check if the browser support using cookies
//	  returns - true if cookies are enable 
/********************************************************************/
function testCookie() {
    setCookie("test","true");
	if (getCookie("test")!="true"){
       	unescapeAlert("Cookies are disabled in your browser. You will have to enable cookies in order to use our site");
		return false;
	}
	return true
}


function unescapeAlert(str) {
	alert (unescape(str));
}
