
//------------------------------------------------
// Function for generating standard page navigation header:

function pagehead(bcolor) {

	// Specify nav elements here:
	var navmenu = new Array(
		"<a href='index.html'>Home</a>",
		"<a href='about.html'>About</a>",
		"<a href='food.html'>Food</a>",
		"<a href='wine.html'>Wine &amp; Spirits</a>",
		"<a href='express/'>Express</a>",
		"<a href='services.html'>Facilities &amp; Services</a>",
		"<a href='whatsnew.html'>What's New</a>",
		"<a href='contact.html'>Contact</a>",
		"<a href='https://app.quicksizzle.com/survey.aspx?sfid=13024'>Subscribe</a>",
		"<a href='contents.html'>Contents</a>"
	);
	var navtext = navmenu.join(" | "); // Join all nav menu elements
	
	var c = "images/logotype_small.gif"; // Page head graphic, default
	var c2 = "images/logotype_smG.gif"; // Page head graphic, color 2
	var img = "images/band_rough.jpg"; // Page head image band
	
	if (bcolor == "green") { c = c2 } // Change the title graphic color
	
	// Write HTML code:
	document.write("<div id='navtop'>")
	document.write("<a href='index.html' title='Paolo&rsquo;s Home'><img height='40' width='207' src='" + c + "' alt='Paolo\'s'></a>");
	document.write("<p>" + navtext + "</p>");
	document.write("<img id='titleband' src='" + img + "' alt=''>");
	document.write("</div>")
}


//------------------------------------------------
// Function for generating menu page navigation header:

function menuhead() {
	
	// Write HTML code:
	document.write("<div id='menubar'>");
	document.write("<div id='menulinks'>");
	document.write("<p><img src='images/sub_menus2.gif' alt='' style='vertical-align: middle; border-right: 1px white solid; margin: 0'><a class='menulink' href='Menu_Lunch_Paolos.pdf'>Lunch</a><a href='Menu_Dinner_Paolos.pdf'>Dinner</a><a href='Menu_Dessert_Paolos.pdf'>Dessert</a><a href='Menu_Express_Paolos.pdf'>Paolo's Express</a><a href='express/calendar.html'>Express Daily Specials</a></p>");
	document.write("</div>");
	document.write("</div>");
}


//------------------------------------------------
// Functions for Contact page:

function checkmsg() {
	var warn = new Array; // Warning collected in this array
	if (document.MsgForm.MsgText.value.length == 0) { warn = warn.concat('- Message field is empty.') }; // Check that message field is not empty
	if (!checkmail(document.MsgForm.MsgEmail.value)) { warn = warn.concat('- Email address improperly formatted.') }; // Check that email address is valid format
	// If there is a warning about either field, show an alert:
	if (warn.length != 0) {
		alert("Please correct problems with your message input:\n\n" + warn.join("\n"));
		return false;
	}
	return true;
}
// Function for checking format of email address:
function checkmail(mymail) {
	var pattern = /^\S+@\S+\.\w{2,4}$/; // The email pattern match
	if (!mymail) { return true } // Return true if field is blank (since it's optional)
	if (pattern.test(mymail)) { return (true) }
	else { return false }
}



//------------------------------------------------
// Function for new picture window:

function picwindow(url, x, y) {
	if (!x) { x = 500 } // default width
	if (!y) { y = 600 } // default height
	var w = window.open(url, '', "scrollbars,width=" + x + ",height=" + y);
}


//------------------------------------------------
// Function to pre-load two images for a rollover
// Required pre-declared object 'rollimage'
function loadimage(x) {
	var d = 'images'; // The directory of default images
	var d_over = 'images_over'; // The directory of rollover images

	var n = x + '0'; // Name of default image
	var n_over = x + '1'; // Name of rollover image

	var i = d + '/' + x + '.gif'; // Location of default image
	var i_over = d_over + '/' + x + '.gif'; // Location of rollover image

	rollimage[n] = new Image;
	rollimage[n].src = i;
	rollimage[n_over] = new Image;
	rollimage[n_over].src = i_over;
}


//------------------------------------------------
// Function for changing rollover images
// Required pre-declared object 'rollimage'
function changeimage(n, x) {
	var img = n + x;
	i[n].src = rollimage[img].src;
}

