/* 
	Comments
*/

var win = null;
function popup(n,w,h){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,toolbar=no,resizable=no';
	win = window.open("",n,settings);
}
function popupScroll(n,w,h){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,toolbar=no,resizable=no';
	win = window.open("",n,settings);
}

function greeting() {

	var currentTime = new Date();
	var thehour = currentTime.getHours();
	var theday = currentTime.getDay();
	var theminute = currentTime.getMinutes();

	// Greeting

	if (thehour >= 18) display = "Good Evening";
	else if (thehour >= 12) display = "Good Afternoon, thought about dinner yet?";
	else display = "Good Morning, have you thought about lunch yet?";

	// Day of week (0=Sun - 6=Sat)

	if (theday == 0) thedayDisp = "";
	else if (theday == 1) thedayDisp = ""
	else if (theday == 2) thedayDisp = "";
	else if (theday == 3) thedayDisp = "";
	else if (theday == 4) thedayDisp = "";
	else if (theday == 5) thedayDisp = "";
	else thedayDisp = "";

	// Extra conditions

	if ((theday == 5) && (thehour >= 17)) extra = "";
	else extra = "";

	// Write the greeting

	var greetingText = (thedayDisp + " " + display + " " + extra);

	document.write(greetingText);

}

function toggle_nutritionals() {
	if (!Element.hasClassName('ni', 'on')) {
		Effect.BlindDown('nutritionalpanel', {duration: .25});
		Effect.Appear('nutritionalpanel', {duration: .75});
		Element.addClassName('ni', 'on');
	} else {
		Effect.BlindUp('nutritionalpanel', {duration: .25});
		Effect.Fade('nutritionalpanel', {duration: .3});
		Element.removeClassName('ni', 'on');
	}
}

function validateSponsorship() {

	var themessage = "Please note:\nYou are required to complete the following fields: \n\n";

	if ((document.enquiryForm.firstName.value == "" || document.enquiryForm.firstName.value == " "))
		{
			themessage = themessage + " - First Name\n";
		}
	if ((document.enquiryForm.lastName.value == "") || (document.enquiryForm.lastName.value == " "))
		{
			themessage = themessage + " - Last Name\n";
		}
	if (((document.enquiryForm.phone1.value == "") || (document.enquiryForm.phone1.value == " ")) &&
		  ((document.enquiryForm.email.value == "") || (document.enquiryForm.email.value == " ")))
		{
			themessage = themessage + " - Phone or Email Address\n";
		}
	if ((document.enquiryForm.regarding.value == "") || (document.enquiryForm.regarding.value == " "))
		{
			themessage = themessage + " - Subject\n";
		}
	if ((document.enquiryForm.comments.value == "") || (document.enquiryForm.comments.value == " "))
		{
			themessage = themessage + " - Email\n";
		}
	if (document.enquiryForm.email.value != document.enquiryForm.emailchk.value)
		{
			themessage = themessage + " - Correct Email Address\n";
		}
	if (themessage == "Please note:\nYou are required to complete the following fields: \n\n")
		{
			document.enquiryForm.submit();
		}
	else
		{
			alert(themessage);
			return false;
		}
}

function validateRecEmail() {

	var themessage = "Please note:\nYou are required to complete the following fields: \n\n";

	if ((document.emailForm.yname.value == "" || document.emailForm.yname.value == " "))
		{
			themessage = themessage + " - Your Name\n";
		}
	if ((document.emailForm.yemail.value == "" || document.emailForm.yemail.value == " "))
		{
			themessage = themessage + " - Your Email Address\n";
		}
	if ((document.emailForm.fname.value == "" || document.emailForm.fname.value == " "))
		{
			themessage = themessage + " - Friend's Name\n";
		}
	if ((document.emailForm.femail.value == "" || document.emailForm.femail.value == " "))
		{
			themessage = themessage + " - Friend's Email Address\n";
		}
	if (themessage == "Please note:\nYou are required to complete the following fields: \n\n")
		{
			document.emailForm.submit();
		}
	else
		{
			alert(themessage);
			return false;
		}
}

function validateRecComment() {

	var themessage = "Please note:\nYou are required to complete the following fields: \n\n";

	if ((document.commentForm.name.value == "" || document.commentForm.name.value == " "))
		{
			themessage = themessage + " - Your Name\n";
		}
	if ((document.commentForm.email.value == "" || document.commentForm.email.value == " "))
		{
			themessage = themessage + " - Your Email Address\n";
		}
	if (themessage == "Please note:\nYou are required to complete the following fields: \n\n")
		{
			document.commentForm.submit();
		}
	else
		{
			alert(themessage);
			return false;
		}
}

function validateRecPost() {

	var themessage = "Please note:\nYou are required to complete the following fields: \n\n";

	if ((document.recipePost.name.value == "" || document.recipePost.name.value == " "))
		{
			themessage = themessage + " - Your Name\n";
		}
	if ((document.recipePost.email.value == "" || document.recipePost.email.value == " "))
		{
			themessage = themessage + " - Your Email Address\n";
		}
	if (themessage == "Please note:\nYou are required to complete the following fields: \n\n")
		{
			document.enquiryForm.submit();
		}
	else
		{
			alert(themessage);
			return false;
		}
}
function submitform()
{
  document.commentFormLink.submit();
}
