	/*
	|==========================================================
	| Doors Opening
	|----------------------------------------------------------
	| Copyright (c) 2006, metro55
	|----------------------------------------------------------
	| File: /htdocs/public/javascript/calendar.js
	|----------------------------------------------------------
	| Purpose: Javascript functions for public calendar
	|==========================================================
	*/
	
	function setCalendarRows() {
		if (!document.getElementsByTagName) return false;
		var trs = document.getElementsByTagName('tr');
		for (var i=0;i<trs.length;i++) {
			
			if (trs[i].className=='row' || trs[i].className=='row alt') {
				
				trs[i].rowBelow = trs[i+1];
				var a = trs[i].getElementsByTagName('a')[0];
				
				a.onclick = function() {
					var rowBelow = this.parentNode.parentNode.rowBelow;
					/*
						this = the a link
						this.parentNode = table cell the link is in
						this.parentNode.parentNode = the table row that the cell is in which contains the a link
						this.parentNode.parentNode.rowBelow = the variable we assigned to the the table row that the cell is in which contains the a link
						NB: The variable is the HTML Table Row Collection of the row below the one with the a link in
					
					*/
					/* Tell me this is a hack to detect I.E. This needs to be done becuse you cant set i.e. display type to table-row. It returns an error. (But inline works for i.e. */
					
					var agt	= navigator.userAgent.toLowerCase();
					var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
					
					if (is_ie) {
						var displayType	= 'inline';
					} else {
						var displayType	= 'table-row';
					};
					/* http://www.webexperiments.org/hide_table_rows/index.html */
					/*
					if(rowBelow.style.display == 'none') {
						try {
							rowBelow.style.display = 'table-row';
						} catch(e) {
							rowBelow.style.display = 'block';
						};
							
					} else {
						rowBelow.style.display = 'none'	
					};
					return false;
					*/
					if (rowBelow.style.display!=displayType) {
						rowBelow.style.display			= displayType;
					} else {
						rowBelow.style.display			= 'none';
					};
					return false;
				};
			};
		};
	}
	
	addLoadEvent(setCalendarRows);