// JavaScript Document

var CurrentPage;
var date = new Date();
var day = date.getDate();
var month = date.getMonth();

function Load() //
{
	if (document.title === "Welcome to Baeten's Nursery!")
	{
		document.getElementById("Nav1").setAttribute("class", "Selected");
		document.getElementById("BNav1").setAttribute("class", "SelectedBottom");
		
		CurrentPage = "Nav1";
	}
	else if (document.title ==="Gallery")
	{
		document.getElementById("Nav7").setAttribute("class", "Selected");
		document.getElementById("BNav7").setAttribute("class", "SelectedBottom");
		
		CurrentPage = "Nav7";
	}
	else if (document.title ==="Baeten's Nursery Events")
	{
		document.getElementById("Nav3").setAttribute("class", "Selected");
		document.getElementById("BNav3").setAttribute("class", "SelectedBottom");
		
		CurrentPage = "Nav3";
	}
	else if (document.title ==="Earl Baeten's Tips for Growing")
	{
		document.getElementById("Nav6").setAttribute("class", "Selected");
		document.getElementById("BNav6").setAttribute("class", "SelectedBottom");
		
		CurrentPage = "Nav6";
	}
	else if (document.title ==="Baeten's Seasonal Plants for Water and Japanese Gardens")
	{
		document.getElementById("Nav2").setAttribute("class", "Selected");
		document.getElementById("BNav2").setAttribute("class", "SelectedBottom");
		
		CurrentPage = "Nav2";
	}
	else if (document.title ==="Information Links from Baeten's Nursery")
	{
		document.getElementById("Nav4").setAttribute("class", "Selected");
		document.getElementById("BNav4").setAttribute("class", "SelectedBottom");
		
		CurrentPage = "Nav4";
	}
	else if (document.title ==="Baeten's Landscaping Services")
	{
		document.getElementById("Nav5").setAttribute("class", "Selected");
		document.getElementById("BNav5").setAttribute("class", "SelectedBottom");
		
		CurrentPage = "Nav5";
	}
	else if (document.title ==="Baeten's Nursery & Greenhouses Store Information")
	{
		document.getElementById("Nav8").setAttribute("class", "Selected");
		document.getElementById("BNav8").setAttribute("class", "SelectedBottom");
		
		CurrentPage = "Nav8";
	}
	
	
	document.getElementById("Nav1").firstChild.href = "index.html";
	document.getElementById("BNav1").href = "index.htm";
	document.getElementById("Nav2").firstChild.href = "seasonal.html";
	document.getElementById("BNav2").href = "seasonal.html";
	document.getElementById("Nav3").firstChild.href = "Events.html";
	document.getElementById("BNav3").href = "Events.html";
	document.getElementById("Nav4").firstChild.href = "links.html";
	document.getElementById("BNav4").href = "links.html";
	document.getElementById("Nav5").firstChild.href = "landscaping.html";
	document.getElementById("BNav5").href = "landscaping.html";
	document.getElementById("Nav6").firstChild.href = "Tips.html";
	document.getElementById("BNav6").href = "Tips.html";
	document.getElementById("Nav7").firstChild.href = "Gallery.html";
	document.getElementById("BNav7").href = "Gallery.html";
	document.getElementById("Nav8").firstChild.href = "store_info.html";
	document.getElementById("BNav8").href = "store_info.html";	
	
	
	/* Code for changing the date object. If the date is between 4/11 and 6/18 it will change to the spring hours */
	/* Make not that January is 0 so subtract one from the month's number to ensure it's the right date i.e. August is the 7th month not the 8th */
		if (month >= 3 && month <=5)	
		{
			if (month == 3 && day >= 11 || month == 4 || month == 5 && day <= 18) //Spring Hours		
				document.getElementById("Hours").innerHTML = '<span class="BoldInfo">New Spring Hours:</span><br>(Effective 4/11-6/18)<br><b>Monday - Friday</b><br>8:00 AM - 7:00 PM<br><b>Saturday</b><br>8:00 AM - 4:30 PM<br><b>Sunday</b><br>10:30 AM - 4:00 PM';
		}
			
		else if (month == 5 && day >= 20 || month == 6 || month == 7 && day <= 16)	// Summer Hours	
			document.getElementById("Hours").innerHTML = '<span class="BoldInfo">Fall Hours:</span><br>(Effective now)<br><b>Monday - Friday</b><br>8:00 AM - 5:00 PM<br><b>Saturday</b><br>8:00 AM - 4:30 PM<br><b>Sunday</b><br>Closed';
	
		else if (month == 7 && day >= 17 || month == 8 || month == 9 && day <= 31)	// Fall Hours	
			document.getElementById("Hours").innerHTML = '<span class="BoldInfo">Fall Hours:</span><br>(Effective 8/15-10/31)<br><b>Monday - Friday</b><br>8:00 AM - 5:00 PM<br><b>Saturday</b><br>8:00 AM - 4:30 PM<br><b>Sunday</b><br>Closed';
		
//IE fixes
browser_type = navigator.appName;
if (browser_type == "Microsoft Internet Explorer")
document.getElementById("liContainer").setAttribute("id", "liContainerIE");

}

function Highlight(Element)
{
	if (Element.charAt(0) != "B")
	{
		//document.getElementById(Element).style.backgroundColor = "#104D23";
		document.getElementById(Element).firstChild.style.textDecoration = "underline";
	}
	else
		document.getElementById(Element).style.textDecoration = "underline";
}

function Deselect(Element)
{
	if (Element.charAt(0) != "B")
	{
		//document.getElementById(Element).style.backgroundColor = "#669966";
			
			document.getElementById(Element).firstChild.style.textDecoration = "none";
	}
	else
	{		
		if (Element != "B" + CurrentPage)	
			document.getElementById(Element).style.textDecoration = "none";
	}
}

function validate_email(field,alerttxt)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  if (apos<1||dotpos-apos<2)
    {alert(alerttxt);return false;}
  else {return true;}
  }
}

function validate_form(thisform)
{
with (thisform)
  {
  if (validate_email(EMAIL,"Please input a valid Email address") == false)
    {EMAIL.focus();return false;}
  }
  if (validate_email(EMAIL,"Please input a valid Email address") == true)
  	document.getElementById("botprotection").setAttribute("action","_gdForm/webformmailer.asp");
}


