<!--

////////////////
// image preload
////////////////
function preloadimages() {

	if (document.images)
	{
	
		home_button_on = new Image(106, 22);
		home_button_on.src = "images/buttons/home_on.jpg";
		
		lunch_menu_button_on = new Image(106, 22);
		lunch_menu_button_on.src = "images/buttons/lunch_menu_on.jpg";
	
		dinner_menu_button_on = new Image(106, 22);
		dinner_menu_button_on.src = "images/buttons/dinner_menu_on.jpg";

		wine_list_button_on = new Image(106, 22);
		wine_list_button_on.src = "images/buttons/wine_list_on.jpg";

		banquet_menus_button_on = new Image(106, 22);
		banquet_menus_button_on.src = "images/buttons/banquet_menus_on.jpg";

		catering_button_on = new Image(106, 22);
		catering_button_on.src = "images/buttons/catering_on.jpg";

		virtual_tour_button_on = new Image(106, 22);
		virtual_tour_button_on.src = "images/buttons/virtual_tour_on.jpg";
	
		reviews_button_on = new Image(106, 22);
		reviews_button_on.src = "images/buttons/reviews_on.jpg";

		about_a_bellagio_button_on = new Image(106, 22);
		about_a_bellagio_button_on.src = "images/buttons/about_a_bellagio_on.jpg";
		
		directions_button_on = new Image(106, 22);
		directions_button_on.src = "images/buttons/directions_on.jpg";
				
		contact_us_button_on = new Image(106, 22);
		contact_us_button_on.src = "images/buttons/contact_us_on.jpg";

		la_pizzeria_button_on = new Image(177, 64);
		la_pizzeria_button_on.src = "images/buttons/la_pizzeria_on.jpg";

		cafe_campbell_button_on = new Image(148, 64);
		cafe_campbell_button_on.src = "images/buttons/cafe_campbell_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 contactUsPhoneNumber = document.getElementById('contact_us_phone_number').value;
	var contactUsSubject = document.getElementById('contact_us_subject').value;
	var contactUsComments = document.getElementById('contact_us_comments').value;
	var errorResponse = "The following error(s) were found during your submission:";
	var errorFlag = 0;
	var elems;


	var somethingIsCheckedFlag = 0;
	var areaOfInterest = "";

	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(contactUsPhoneNumber);
	alert(contactUsSubject);
	alert(contactUsComments);*/

	if(contactUsName == ""){
		errorResponse = errorResponse + "\r- Full Name is missing";
		errorFlag = 1;
	}
	
	if(!isValidEmail(contactUsEmail)){
		errorResponse = errorResponse + "\r- Email Address is invalid";
		errorFlag = 1;
	}

	if(contactUsPhoneNumber == ""){
		errorResponse = errorResponse + "\r- Phone Number is missing";
		errorFlag = 1;
	}

	if(contactUsSubject == ""){
		errorResponse = errorResponse + "\r- Subject is missing";
		errorFlag = 1;
	}
		
	if(contactUsComments == ""){
		errorResponse = errorResponse + "\r- Comments are missing";
		errorFlag = 1;
	}


	for(z = 0; z < theForm.length; z++){
		
		if(theForm[z].type == 'checkbox' && theForm[z].checked && theForm[z].name != 'checkall'){
			
			if (somethingIsCheckedFlag != 0){
				areaOfInterest = areaOfInterest + ", ";
			}

			somethingIsCheckedFlag = 1;
			areaOfInterest = areaOfInterest + theForm[z].name;
			
			//alert(theForm[z].name);
			//alert(theForm[z].id);
			//alert(theForm[z].checked);
			//alert(areaOfInterest);

		} // end if
	} // end for

	//alert(areaOfInterest);

	if(somethingIsCheckedFlag == 0){
		errorResponse = errorResponse + "\r- Areas of Interest is not selected";
		errorFlag = 1;

	}
		
	if(errorFlag == 0){

		contactUsBody = "Full Name: " + contactUsName + "\r\rEmail Address: " + contactUsEmail + "\r\rPhone Number: " + contactUsPhoneNumber + "\r\rSubject: " + contactUsSubject + "\r\rComments: " + contactUsComments + "\r\rAreas of Interest: " + areaOfInterest; 

		//alert(contactUsBody);
		
		/*alert(contactUsName);
		alert(contactUsEmail);
		alert(contactUsPhoneNumber);
		alert(contactUsSubject);
		alert(contactUsComments);*/

	  // build URL to connect to
	  url = "send.php?type=contact_us&name=" + escape(contactUsName) + "&email=" + escape(contactUsEmail) + "&body=" + escape(contactUsBody) + "&subject=" + escape(contactUsSubject);
		//alert("before open" + url);
		
	  // open a connection to the server
	  //alert(url);
	  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);

	} else {
		alert(errorResponse);
		
	}
	
	
	function getSendState() {
			
	
		  if (xmlHttp.readyState == 4) {

				 // if "OK"
				if (xmlHttp.status != 200)
				{
					alert("Problem sending.")

				} else {
	
			    response = xmlHttp.responseText;
			    //alert(response);

					alert("Thank you for contacting us.");
					document.getElementById('contact_us_name').value = "";
					document.getElementById('contact_us_email').value = "";
					document.getElementById('contact_us_phone_number').value = "";
					document.getElementById('contact_us_subject').value = "";
					document.getElementById('contact_us_comments').value = "";
					uncheckAll(theElement);
	
				} // end status check
	    
		  } // end readyState check
	
		} // end getSubscribeState()	
	
}


function checkUncheckAll(theElement) {
	
	var theForm = theElement.form, z = 0;

	for(z=0; z < theForm.length; z++){
		
		if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
			theForm[z].checked = theElement.checked;
		}
	}
}

function uncheckAll(theElement) {
	
	var theForm = theElement.form, z = 0;

	for(z=0; z < theForm.length; z++){
		
		if(theForm[z].type == 'checkbox'){
			theForm[z].checked = false;
		}
	}
}




//-->