/* ===========================================================================   cookies.js	Cookie code for SolarAlmanac Web Site	 jB  F 102706       	from Relationshop/js/cookies.js   jB  Sat 080704     Source: the Netscape JavaScript Guide v. 1.3 =========================================================================== */// Sets cookie values. Expiration date is optional//function setCookie(name, value, expire) {   var	domain = ( window.location.host.indexOf("jebrown.us") == -1 ? "" : "; domain=.jebrown.us" ) ;    document.cookie = name + "=" + escape(value)	   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))	   + domain + "; path=/SolarAlmanac/";    // 120306-A: This doesn't erase the 1st cookie, but sets a 2nd:    document.cookie = name + "=" + escape(value)	   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))	   + "; path=/JEBrown800/SolarAlmanac/"}// Notice the use of escape to encode special characters (semicolons, commas, spaces) in the value string. This function assumes// that cookie names do not have any special characters.// The following function returns a cookie value, given the name of the cookie:function getCookie(Name) {   var search = Name + "="   if (document.cookie.length > 0) { // if there are any cookies      offset = document.cookie.indexOf(search)       if (offset != -1) { // if cookie exists          offset += search.length          // set index of beginning of value         end = document.cookie.indexOf(";", offset)          // set index of end of cookie value         if (end == -1)             end = document.cookie.length         return unescape(document.cookie.substring(offset, end))      }    }}// Notice the use of unescape to decode special characters in the cookie value.// Using Cookies: an Example // // Using the cookie functions defined in the previous section, you can create a simple page users can fill in to "register" when they// visit your page. If they return to your page within a year, they will see a personal greeting. // // You need to define one additional function in the HEAD of the document. This function, register, creates a cookie with the// name TheCoolJavaScriptPage and the value passed to it as an argument.// Author: jB  Sat 080704 //    made from Netscape's register(). function register_for_1_year(name, value) {   var today = new Date()   var expires = new Date()   expires.setTime(today.getTime() + 1000*60*60*24*365)   setCookie(name, value, expires)}// Author: jB  032407 function my_account_url() {	return "http://jebrown.us/SolarAlmanac/private/" + getCookie("SolarAlmanac_ChocolateChip") + ".html" }function im_a_customer() {	if (getCookie("SolarAlmanac_ChocolateChip")) 		return true; 	else 		return false; }// Author: jB  F 110306 function my_account_0(prefix, suffix) {if (im_a_customer()) 	document.writeln(prefix + "<A Href='" + my_account_url() + "' Target='_blank' Title='Your personalized Almanac'>My Account</A>" + suffix); 	// "<A Href='../SolarAlmanac/private/" won't work from other folders. }function my_account() {	my_account_0("", ""); }function my_account_2() {	my_account_0("&middot;<BR>", "<BR>"); }{ // jB 050107 var cname = "YeastBreadYeastBread"; var c = getCookie(cname); register_for_1_year(cname, ( c ? 1 + parseInt(c) : 0 )); }function CatchCheapskates(andgoto) { // jB 122707-A 	var cname = "YeastBreadYeastBread"; 	var c = getCookie(cname); 	var n = ( c ? 1 + parseInt(c) : 0 ); 	if (n > 25) 		location.replace(andgoto); }/* ======================================================================== */