<!--

////////////////
// image preload
////////////////
function preloadimages() {

	if (document.images)
	{
	
		home_button_on = new Image();
		home_button_on.src = "images/buttons/home_on.jpg";
		
		about_lucio_button_on = new Image();
		about_lucio_button_on.src = "images/buttons/about_lucio_on.jpg";
	
		lunch_menu_button_on = new Image();
		lunch_menu_button_on.src = "images/buttons/lunch_menu_on.jpg";
	
		dinner_menu_button_on = new Image();
		dinner_menu_button_on.src = "images/buttons/dinner_menu_on.jpg";
	
		pizza_menu_button_on = new Image();
		pizza_menu_button_on.src = "images/buttons/pizza_menu_on.jpg";

		wine_menu_button_on = new Image();
		wine_menu_button_on.src = "images/buttons/wine_menu_on.jpg";
	
		virtual_tour_button_on = new Image();
		virtual_tour_button_on.src = "images/buttons/virtual_tour_on.jpg";
	
		photo_gallery_button_on = new Image();
		photo_gallery_button_on.src = "images/buttons/photo_gallery_on.jpg";
	
		reviews_button_on = new Image();
		reviews_button_on.src = "images/buttons/reviews_on.jpg";
	
		contact_us_button_on = new Image();
		contact_us_button_on.src = "images/buttons/contact_us_on.jpg";
	}

}


/////////////
// image swap
/////////////
function changer(from, to) {
	if(document.images) {
		document.images[from].src = "images/buttons/" + from + "_" + to + ".jpg";
	}
}


// General
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}


// Send contact_us form
function sendContactUs(theElement){

	var theForm = theElement.form, z = 0;
	var contactUsName = document.getElementById('contact_us_name').value;
	var contactUsEmail = document.getElementById('contact_us_email').value;
	var contactUsBody = document.getElementById('contact_us_body').value;
		
	var errorFlag = 0;
	var elems;

	var url;
	var response;
	
	// creates a new XMLHttpRequest object to talk to the web server
	var xmlHttp = false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try {
	  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	  try {
	    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (e2) {
	    xmlHttp = false;
	  }
	}
	@end @*/

	if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
	  xmlHttp = new XMLHttpRequest();
	}


	//alert(contactUsName);
	//alert(contactUsEmail);
	//alert(contactUsBody);
	
	if(contactUsName == ""){
		alert("Name is missing. Please enter a valid name.");
		errorFlag = 1;
	}

	if(!isValidEmail(contactUsEmail)){
		alert("Invalid email address. Please enter a valid email address.");
		errorFlag = 1;
	}
	
	if(contactUsBody == ""){
		alert("Body of the message is missing. Please enter a valid message.");
		errorFlag = 1;
	}
		
	if(errorFlag == 0){

	  // build URL to connect to
	  url = "send.php?type=contact_us&name=" + escape(contactUsName) + "&email=" + escape(contactUsEmail) + "&body=" + escape(contactUsBody);
		//alert("before open" + url);
		
	  // open a connection to the server
	  xmlHttp.open("POST", url, true);
	
		//alert("before status: " + url);
		
	  // setup a function for the server to run when it is done
	  xmlHttp.onreadystatechange = getSendState;

		//alert("after status: " + url);

	  // send the request
	  xmlHttp.send(null);
	
		alert("Thank you for contacting us.");
		document.getElementById('contact_us_name').value = "";
		document.getElementById('contact_us_email').value = "";
		document.getElementById('contact_us_body').value = "";

	}
	
	
	function getSendState() {
			
	
		  if (xmlHttp.readyState == 4) {

				 // if "OK"
				if (xmlHttp.status != 200)
				{
					alert("Problem updating.")
				} else {
	
			    response = xmlHttp.responseText;
			    //alert(response);
	
				} // end status check
	    
		  } // end readyState check
	
		} // end getSubscribeState()	
	
}


//-->