function getPage(url,subj) {
	//alert(url);
	window.location.href = url+subj;
}

				
function findEvents(sbase,s,d) {
	s = document.getElementById(s).value
	d = document.getElementById(d).value
	
	var ext = "sample_events_list&subject=" + s + "&requestdate=" + d;
 	window.location = sbase + ext;
	//alert(sbase + ext);
}

// HOMEPAGE FLASH STUFF
var seasons;
var flashProxy;

// let Flash do a JS alert
function sendAlert(str) {
	alert(str);
}

function setupFlash() {
	if (flashIsReady==1) {
		var lcId = new Date().getTime();
		flashProxy = new FlashProxy(lcId, "flash/JavaScriptFlashGateway.swf");
		var flashTag = new FlashTag("flash/home2.swf", 547, 498, "7,0,14,0");
		flashTag.setPlay(false);
		flashTag.setFlashvars("lcId=" + lcId);
		document.getElementById("divFlash").innerHTML = flashTag.toString();
	}
}

// Season structure
function Season(title,name)
{
	this.title = title;
	this.name = name;
	this.page = "";
	this.eventhtml = "";
	this.images = new Array();
}


// see that Flash can send the object back to us
function sendMsg(items) {

	for (key in items) {
		var item = items[key];
		alert("key:"+key);
		alert("name:"+item.name);
		alert("title:"+item.title);
		alert("page:"+item.page);
		alert("html:"+item.eventhtml);
		for (var i = 0; 0<item[key].images.length; i++) {
			alert(item[key].images[i]);
		}
	}
}

// Flash tells us what season user selected
function styleSwap(newstyle) {
	setActiveStyleSheet(newstyle);
}

// SEASON SELECTOR STUFF
function startDropdowns() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" over";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" over\\b"), "");
		}
	}
}

if (document.getElementById("nav")) {
	if (window.attachEvent) window.attachEvent("onload", startDropdowns);
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
  //alert(title);
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if (a.getAttribute("rel").indexOf("style") != -1 
	&& a.getAttribute("rel").indexOf("alt") == -1 
	&& a.getAttribute("title")) {
		return a.getAttribute("title");
	}
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
 	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function readCookies() {
	var title;
	//var fontsize;
	var theSeason;
	var cookie;
	
	/*
	cookie = readCookie("lwg_size");
	if (cookie) {
		fontsize = cookie
	} else {
		fontsize = "60%";
	}
	changeSize(fontsize);
	*/
	  
	cookie = readCookie("lwg_style");
	if (!cookie) {
		title = getPreferredStyleSheet();
	} else {
		title = cookie;
	}
	setActiveStyleSheet(title);
	
	cookie = readCookie("lwg_season");
	if (!cookie) {
		theSeason = getPreferredStyleSheet();
	} else {
		theSeason = cookie
	}
	
	//alert(theSeason);
}

function tossCookies() {
  //var fontsize = document.body.style.fontSize;
  //createCookie("lwg_size", fontsize, 365);

  var title = getActiveStyleSheet();
  createCookie("lwg_style", title, 0);
  
  var flashStyle = getActiveStyleSheet();
  createCookie("lwg_season", flashStyle, 0);
}

function changeSize(val)
{
  document.body.style.fontSize = val;
}

function checkEvents(h,l) {
	if(document.getElementById(l).innerHTML=="") {
		document.getElementById(h).className = "HideIt";
	}
}





