// create id string for today
// change style of row with that ID to .today
function afterLoad() {

	var mydate= new Date();
	var dayOfMonth = mydate.getDate();
	var M = mydate.getMonth();
	M++;
	var Y = mydate.getYear() + 1900;
	var ord=1;
	
	dayOfMonth = pad(dayOfMonth, "0", 2)
	M = pad (M, "0", 2)
	
	do {
		xid = "tr"+Y+""+M+""+dayOfMonth+""+ord
		x = document.getElementById(xid)
	
		if (x) {
			x.className="today";
		}
	
		ord++;
	} while (x);
	
	initialize();
}

function initialize() {

	var calendarEmail = "";
	// read cookie
	theCookie = document.cookie;
	cookieKey = "uemail";

	// if no e-mail, ask for it
	if (theCookie.length >0 && theCookie.indexOf(cookieKey) >= 0) {
    	 i = theCookie.indexOf(cookieKey)
	     i += cookieKey.length +1
	     j = theCookie.indexOf(";",i-1)
	     if (j>1) { len = j-i } else { len = 1000 }
	     calendarEmail = theCookie.substr(i,len)
	}

	if (calendarEmail != "" ) {

	     var popurl="http://www.moviehabit.com/calendar/getreminders.php"
	     popurl += "?email=" + escape(calendarEmail);

		winpops=window.open(popurl,"moviehabitpop","width=100,height=100,scrollbars,resizable,")
	}
}

function setCheck(idString) {
	var elms = document.form1.elements;
	for (var i=0; i<elms.length; i++ ) {
		if (elms[i].id==idString) {
			elms[i].checked=true;
			break;
		}
	}
	// eval ("document.form1." + idString + ".checked = true");
}

function pad (strToPad, strWith, finalLen) {
	strToPad = strToPad + "";	// force numbers to be strings
	if (strToPad.length >= finalLen) { return strToPad }
	while (strToPad.length < finalLen) {
		strToPad = strWith.concat(strToPad)
	}
	return strToPad
}

addLoadEvent(afterLoad); 
