<!--

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}

function buildCalendar(calendarForm) {
	document.calendarForm.img0.value=getCookie("Jan");
	document.calendarForm.img1.value=getCookie("Feb");
	document.calendarForm.img2.value=getCookie("Mar");
	document.calendarForm.img3.value=getCookie("Apr");
	document.calendarForm.img4.value=getCookie("May");
	document.calendarForm.img5.value=getCookie("Jun");
	document.calendarForm.img6.value=getCookie("Jul");
	document.calendarForm.img7.value=getCookie("Aug");
	document.calendarForm.img8.value=getCookie("Sep");
	document.calendarForm.img9.value=getCookie("Oct");
	document.calendarForm.img10.value=getCookie("Nov");
	document.calendarForm.img11.value=getCookie("Dec");
	calendarForm.submit();
}

function listCookies() {
	alert('Jan '+getCookie("Jan"));
	alert('Feb '+getCookie("Feb"));
	alert('Mar '+getCookie("Mar"));
}

function setQuiltMonth(message,form) {
    var selectedMonth="---";
	var now = new Date();
	fixDate(now);
	now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
	currentQuilt=form.quiltNumber.value;

	if      (form.month[0].selected)  { selectedMonth="Jan"; }
	else if (form.month[1].selected)  { selectedMonth="Feb"; }
	else if (form.month[2].selected)  { selectedMonth="Mar"; }
	else if (form.month[3].selected)  { selectedMonth="Apr"; }
	else if (form.month[4].selected)  { selectedMonth="May"; }
	else if (form.month[5].selected)  { selectedMonth="Jun"; }
	else if (form.month[6].selected)  { selectedMonth="Jul"; }
	else if (form.month[7].selected)  { selectedMonth="Aug"; }
	else if (form.month[8].selected)  { selectedMonth="Sep"; }
	else if (form.month[9].selected)  { selectedMonth="Oct"; }
	else if (form.month[10].selected) { selectedMonth="Nov"; }
	else if (form.month[11].selected) { selectedMonth="Dec"; }

	setCookie(selectedMonth, currentQuilt, now, '/');
	//alert(message+' '+currentQuilt+' added to calendar for '+selectedMonth);
	//WriteMonthStatus2 () ;
	
	location.reload();
}

function WriteMonthStatus () {
	var cookievalue;
	var spacer = "&nbsp;&nbsp;|&nbsp;&nbsp;"
//	var unassigned = "<b style=\"background:#E9E9E9\">--</b>";
//	var unassigned = "&nbsp;&nbsp;&nbsp;";
	var unassigned = "___";
//	var assignedstart = "<b style=\"background:#D9FFD9\">";
	var assignedstart = "<b>";
	var assignedend = "</b>"

	cookievalue = getCookie("Jan");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Jan: " + cookievalue + spacer);

	cookievalue = getCookie("Feb");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Feb: " + cookievalue + spacer);

	cookievalue = getCookie("Mar");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Mar: " + cookievalue + spacer);

	cookievalue = getCookie("Apr");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Apr: " + cookievalue + spacer);

	cookievalue = getCookie("May");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("May: " + cookievalue + spacer);

	cookievalue = getCookie("Jun");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Jun: " + cookievalue + spacer);

	cookievalue = getCookie("Jul");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Jul: " + cookievalue + spacer);

	cookievalue = getCookie("Aug");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Aug: " + cookievalue + spacer);

	cookievalue = getCookie("Sep");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Sep: " + cookievalue + spacer);

	cookievalue = getCookie("Oct");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Oct: " + cookievalue + spacer);

	cookievalue = getCookie("Nov");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Nov: " + cookievalue + spacer);

	cookievalue = getCookie("Dec");
	if (cookievalue == null) { cookievalue = unassigned; } else { cookievalue = assignedstart + cookievalue + assignedend; }
	document.write ("Dec: " + cookievalue);

}

// -->

