// sharethis
var switchTo5x=true;
document.write("<script type=\"text/javascript\" src=\"http://w.sharethis.com/button/buttons.js\"></script>");
stLight.options({publisher:'75529278-8a8a-40c8-a56a-e9cfce0dfd7b'});

//open or closed for business
function welcomesign() {
	var today = new Date();
	var hour = today.getHours();
	var dayoweek = today.getDay();
	if(dayoweek == 0 || hour<10 || hour>18) {
		var status = "closed";
	} else {
		var status = "open";
	}
	var contents = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"94\">" +
	"<img src=\"images/" + status + ".jpg\" width=\"90\" height=\"47\" align=\"left\" id=\"openorclosed\" />" + 
	"</td><td width=\"86\" valign=\"bottom\">HOURS:<br />10-7 Mon - Sat </td></tr></table>";
	document.getElementById("openorclosed").innerHTML = contents;
}

//validate catering form
function validateForm()
{
	var t=document.forms["cateringform"]["eventmonth"].value;
	var u=document.forms["cateringform"]["eventday"].value;
	var v=document.forms["cateringform"]["eventyear"].value;
	var x=document.forms["cateringform"]["requester"].value;
	var y=document.forms["cateringform"]["e-mail"].value;
	var z=document.forms["cateringform"]["phone"].value;
	
	if (x==null || x=="")
	  {
		  alert("Please tell us your name");
		  window.location = "#contact";
		  return false;
	  }
	
	var atpos=y.indexOf("@");
	var dotpos=y.lastIndexOf(".");
	if (atpos<1 || dotpos<atpos+2 || dotpos+2>=y.length)
	  {
		  alert("Not a valid e-mail address");
		  window.location = "#contact";
		  return false;
	  }
	
	if (z==null || z=="")
	  {
		  alert("Please give us your phone number");
		  window.location = "#contact";
		  return false;
	  }
	if (t==null || t=="")
	  {
		  alert("Please specify the month of the event");
		  window.location = "#event";
		  return false;
	  }
	
	if (u==null || u=="")
	  {
		  alert("Please specify the date of the event");
		  window.location = "#event";
		  return false;
	  }
	
	if (v==null || v=="")
	  {
		  alert("Please specify the year of the event");
		  window.location = "#event";
		  return false;
	  }
		  
    //this calculates the event date vs +3 business days before accepting
	var today = new Date;
	var deadline = new Date();
	var eventDate = new Date();
	var dow = today.getDay();
	switch(dow) {
		case 6:
			dayno = 4;
			break;
		case 5:
			dayno = 5;
			break;
		case 4:
			dayno = 5;
			break;
		case 3:
			dayno = 5;
			break;
		default:
		  dayno = 3;
	}
	deadline.setDate(today.getDate()+dayno);
	eventDate.setMonth(document.cateringform.eventmonth.value - 1);
	eventDate.setDate(document.cateringform.eventday.value);
	eventDate.setYear(document.cateringform.eventyear.value);
	if(eventDate < today) {
		alert("Oops. Hog Heaven's time machine is out of order! Please change your event date to sometime in the future.");
		window.location = "#event";
		return false;
	}
	if(eventDate - deadline >= 0) {
		return true
	} else {
		alert("We're Sorry. To place an order or get a quote for this Event Date, you will need to call Hog Heaven @ 615-329-1234 for assistance.");
		window.location = "#event";
		return false;
	}
}


function validateContactForm()
{
	var x=document.forms["contactform"]["fromname"].value;
	var y=document.forms["contactform"]["e-mail"].value;
	var z=document.forms["contactform"]["phone"].value;
	if (x==null || x=="")
	  {
		  alert("Please tell us your name");
		  return false;
	  }
	
	var atpos=y.indexOf("@");
	var dotpos=y.lastIndexOf(".");
	if (atpos<1 || dotpos<atpos+2 || dotpos+2>=y.length)
	  {
		  alert("Not a valid e-mail address");
		  return false;
	  }
	
	if (z==null || z=="")
	  {
		  alert("Please give us your phone number");
		  return false;
	  }
}
