function getCookieValue(cookieName){

	var cookieValue = document.cookie;
	var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");

	if (cookieStartsAt == -1){
		cookieStartsAt = cookieValue.indexOf(cookieName + "=");
	}

	if (cookieStartsAt == -1){
		cookieValue = null;
	}
	else{
		cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1;
		var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
		if (cookieEndsAt == -1){
			cookieEndsAt = cookieValue.length;
		}
		cookieValue = unescape(cookieValue.substring(cookieStartsAt,cookieEndsAt));
	}

	return cookieValue;

}

function setCookie(cookieName, cookieValue, cookiePath, cookieExpires){

	cookieValue = escape(cookieValue);

	if (cookieExpires == ""){
		var nowDate = new Date();
		nowDate.setMonth(nowDate.getMonth() + 1);
		cookieExpires = nowDate.toGMTString();
	}

	if (cookiePath != ""){
		cookiePath = ";Path=" + cookiePath;
	}

	document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires + cookiePath;

}

function wipeCookies(){
	setCookie("youreap","","/","");	setCookie("healthcare","","/","");
	location.reload();
}	

function wipeCookiesNoReload(){
	setCookie("youreap","","/","");	setCookie("healthcare","","/","");
}

function setHealthcareCookies(){	setCookie("healthcare","","/","");
	setCookie("youreap","","/","");
	setCookie("healthcare",strCompany,"/","");
}

function setEAPCookies(){
	setCookie("youreap","","/","");	setCookie("healthcare","","/","");
	setCookie("youreap",strCompany,"/","");
}
	
function checkLoginHealthcare(){

	if (getCookieValue("healthcare")!=strCompany){
		//alert("Unauthorised Access: " + strCompany);
		location.href="../healthcare.html";
	}
	else {
		setCookie("youreap","","/","");
		//alert("Access Granted: " + strCompany);
		location.href=("../healthcare/" + strCompany + ".html");
	}
}	

function checkLoginEAP(){

	if (getCookieValue("youreap")!=strCompany){
		//alert("Unauthorised Access: " + strCompany);
		location.href="../youreap.html";
	}
	else {	setCookie("healthcare","","/","");
		//alert("Access Granted: " + strCompany);
		location.href=("../users/" + strCompany + ".html");
	} 
}	