////////////////////////////////////////////
function getCookie(NameOfCookie) {

// First we check if there is a cookie stored at all.
// Otherwise the length of document.cookie would be zero.

  if (document.cookie.length > 0) { 

// Second we check if the cookies name is stored in the
// "document.cookie"-object for the page.

// Since more than just one cookie can be set on a
// single page it is possible that our cookie
// is not present, even though the "document.cookie"-object
// is not just an empty text.
// If our cookiename is not present the value -1 is stored
// in the variable called "begin".

    begin = document.cookie.indexOf(NameOfCookie+"="); 
    if (begin != -1) { 

// Our cookie was set. 
// The value stored in the cookie is returned from the function.

		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;  
}
////////////////////////////////////////////