function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();


var a = null;
var week1 = null;
var week2 = null;
var week3 = null;
var week4 = null;
var details = new Array();
for(var d=1;d<=7;d++) {
	details[d] = null;
}
var currentWeek = 1;

function leftScroll() {
	if (a == null) {
		var curr = parseInt(week1.style.left);
		if (curr > -600) {
			var dest = curr - 200;
			currentWeek++;

			a = new Accelimation(week1.style, "left", dest, 600, .8, "px");
			a.onend = onend;
			a.onframe = slideframe;
			a.start();
			for(n=1;n<=7;n++) {
				document.getElementById("detail_" + n + "_" + (currentWeek - 1)).style.visibility = "hidden";
				document.getElementById("detail_" + n + "_" + currentWeek).style.visibility = "visible";
			}
			document.getElementById("weekTitle_" + (currentWeek - 1)).style.visibility = "hidden";
			document.getElementById("weekTitle_" + currentWeek).style.visibility = "visible";
		}
	}
}

function rightScroll() {
	if (a == null) {
		var curr = parseInt(week1.style.left);
		if (curr < 0) {
			var dest = curr + 200;
			currentWeek--;

			a = new Accelimation(week1.style, "left", dest, 600, .8, "px");
			a.onend = onend;
			a.onframe = slideframe;
			a.start();
			for(n=1;n<=7;n++) {
				document.getElementById("detail_" + n + "_" + (currentWeek + 1)).style.visibility = "hidden";
				document.getElementById("detail_" + n + "_" + currentWeek).style.visibility = "visible";
			}
			document.getElementById("weekTitle_" + (currentWeek + 1)).style.visibility = "hidden";
			document.getElementById("weekTitle_" + currentWeek).style.visibility = "visible";
		}
	}
}

function slideframe(x) {
	week1.style.left = x + "px";
	week2.style.left = (x + 200) + "px";
	week3.style.left = (x + 400) + "px";
	week4.style.left = (x + 600) + "px";
}

function onend() {
	a.stop();
	a = null;
}

function detailsSlideOut(theDiv) {
	if(details[theDiv] != null) {
		details[theDiv].stop();
		details[theDiv] = null;
	} else {
		//if (document.getElementById("slideContainer").style.width == "0px") {
			document.getElementById("slideContainer").style.width = "250px";
		//}
	}
	outDiv = document.getElementById("detail_" + theDiv);
		
	details[theDiv] = new Accelimation(outDiv.style, "left", 0, 500, .8, "px");
	details[theDiv].onend = new Function("details[" + theDiv + "].stop;details[" + theDiv + "] = null;");
	details[theDiv].onframe = new Function("x","document.getElementById('detail_" + theDiv + "').style.left = x + 'px'");
//	details[theDiv].onframe = eval("details" + theDiv);
	details[theDiv].start();
}

function details1(x) {
	document.getElementById("detail_1").style.left = x + 'px';
}

function detailsSlideIn(theDiv) {
	if(details[theDiv] != null) {
		details[theDiv].stop();
		details[theDiv] = null;
	}

	inDiv = document.getElementById("detail_" + theDiv);
		
	details[theDiv] = new Accelimation(inDiv.style, "left", 250, 400, .8, "px");
	details[theDiv].onend = new Function("details[" + theDiv + "].stop;details[" + theDiv + "] = null;checkCover();");
	details[theDiv].onframe =  new Function("x","document.getElementById('detail_" + theDiv + "').style.left = x + 'px'");
	details[theDiv].start();

}

function checkCover() {
	var blah = true;
	for(var d=1;d<=7;d++) {
		if (details[d] != null) {
			blah = false;
		}
	}
	if (blah) {
		document.getElementById("slideContainer").style.width = "0px";
	}
}

function init() {
	week1 = document.getElementById("week_1");
	week2 = document.getElementById("week_2");
	week3 = document.getElementById("week_3");
	week4 = document.getElementById("week_4");

	// emailsignup.php form
	if(document.f && document.f.process) document.f.process.value = "1";
}
function sizeColumns() {
	var n = document.getElementById("heightDiv").offsetHeight;
	//alert(n);
	if (n < 493) {
		document.getElementById("maincontent").innerHTML += "<br><br><br>";
		sizeColumns();
	} else {
		document.getElementById("rightcontent").style.height = n + "px";
		document.getElementById("leftcontent").style.height = n + "px";
	}
}

function weekRollIn(e) {
	e.className = (e.className == "weekday_today") ? "weekday_today" : "weekday_over";
}
function weekRollOut(e) {
	e.className = (e.className == "weekday_today") ? "weekday_today" : "weekday";
}

//shadow stuff
function drawSmallShadow(w,h,x,y,z) {
	if (browser.isIE) {
		return smallShadowIE(w,h,x,y,z);
	} else {
		return smallShadow(w,h,x,y,z);
	}	
}

function smallShadow(w,h,x,y,z) {
	$output = "<div style=\"position:absolute;width:" + w + "px;height:" + h + "px;left:" + x + "px;top:" + y + "px;z-index:" + z + "\">";
	$output += "<table cellpadding=\"0\" cellspacing=\"0\" width=\"" + w + "\" height=\"" + h + "\">";
	$output += "<tr><td style=\"background-image:url(images/shadow/small_1.png);width:8px;height:8px;\"></td>";
	$output += "<td style=\"background-image:url(images/shadow/small_2.png);width:" + (w - 16) + "px;height:8px;\"></td>";
	$output += "<td style=\"background-image:url(images/shadow/small_3.png);width:8px;height:8px;\"></td></tr>";
	$output += "<tr><td style=\"background-image:url(images/shadow/small_4.png);width:8px;height:" + (h - 16) + "px;\"></td>";
	$output += "<td style=\"background-image:url(images/shadow/small_5.png);width:" + (w - 16) + "px;height:" + (h - 16) + "px\"></td>";
	$output += "<td style=\"background-image:url(images/shadow/small_6.png);width:8px;height:" + (h - 16) + "px\"></td></tr>";
	$output += "<tr><td style=\"background-image:url(images/shadow/small_7.png);width:8px;height:8px;\"></td>";
	$output += "<td style=\"background-image:url(images/shadow/small_8.png);width:" + (w - 16) + ";height:8px;\"></td>";
	$output += "<td style=\"background-image:url(images/shadow/small_9.png);width:8px;height:8px;\"></td></tr></table></div>";
	return $output;
}

function smallShadowIE(w,h,x,y,z) {
	$output = "<div style=\"position:absolute;width:" + w + "px;height:" + h + "px;left:" + x + "px;top:" + y + "px;z-index:" + z + "\">";
	$output += "<table cellpadding=\"0\" cellspacing=\"0\" width=\"" + w + "\" height=\"" + h + "\">";
	$output += "<tr><td style=\"background-image:url(images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/shadow/small_1.png',sizingMethod='scale');width:8px;height:8px;\"></td>";
	$output += "<td style=\"background-image:url(images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/shadow/small_2.png',sizingMethod='scale');width:" + (w - 16) + "px;height:8px;\"></td>";
	$output += "<td style=\"background-image:url(images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/shadow/small_3.png',sizingMethod='scale');width:8px;height:8px;\"></td></tr>";
	$output += "<tr><td style=\"background-image:url(images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/shadow/small_4.png',sizingMethod='scale');width:8px;height:" + (h - 16) + "px;\"></td>";
	$output += "<td style=\"background-image:url(images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/shadow/small_5.png',sizingMethod='scale');width:" + (w - 16) + "px;height:" + (h - 16) + "px\"></td>";
	$output += "<td style=\"background-image:url(images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/shadow/small_6.png',sizingMethod='scale');width:8px;height:" + (h - 16) + "px\"></td></tr>";
	$output += "<tr><td style=\"background-image:url(images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/shadow/small_7.png',sizingMethod='scale');width:8px;height:8px;\"></td>";
	$output += "<td style=\"background-image:url(images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/shadow/small_8.png',sizingMethod='scale');width:" + (w - 16) + ";height:8px;\"></td>";
	$output += "<td style=\"background-image:url(images/spacer.gif);filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/shadow/small_9.png',sizingMethod='scale');width:8px;height:8px;\"></td></tr></table></div>";
	return $output;
}

