if (!(typeof(addEvent)=='function')) {
  function addEvent(name,obj,f) {
    if (window.attachEvent) {
      obj.attachEvent("on"+name,f);
    } else if (window.addEventListener) {
      obj.addEventListener(name,f,false);
    }
  }
}

addEvent('load',window,function() {
	var tables=document.getElementsByTagName('table');
	var found=false;
	var i=0;
	while ((i<tables.length) && !found) {
		if (tables[i].className=='availability') {
			found=true;
		} else {
			i++;
		}
	}

	if (!found) return;
	var table=tables[i];

	var thead=(table.getElementsByTagName('thead'))[0];
	var ths=thead.getElementsByTagName('th');
	var gridlines=[];
	for (i=0;i<ths.length;i++) {
		var div=document.createElement('div');
		div.style.opacity=0.17;
		div.style.filter='alpha(opacity=17)';
		div.style.position='absolute';
		div.style.backgroundColor='black';
		div.style.width='1px';
		document.body.appendChild(div);
		gridlines.push(div);
	}

	function findPos(obj) {
		var curleft=curtop=0;
		if (obj.offsetParent) {
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj=obj.offsetParent);
		}
		return [curleft,curtop];
	}

	function placeGridlines() {
		var tableheight=table.offsetHeight-2;
		for (var i=0;i<gridlines.length;i++) {
			var coords=findPos(ths[i]);
			var curheight=ths[i].offsetHeight;
			gridlines[i].style.height=''+(tableheight-curheight)+'px';
			gridlines[i].style.top=''+(coords[1]+curheight)+'px';
			gridlines[i].style.left=''+coords[0]+'px';
		}
	}

	placeGridlines();
	addEvent('resize',window,placeGridlines);
});