function sForm() {
	document.getElementById("leftbody").innerHTML="<div style='width: 200px; height: 100px; text-align: center; margin-left: auto; margin-right: auto; background-color: transparent;'><img src='./images/ajax-loader.gif' style='margin-top: 30px;'><br /><p style='font-weight: bold;'>LOADING...</p></div>";
	new Ajax.Updater('leftbody', 'submit.html', {
		method: 'post'
	});
}

function rForm() {
	document.getElementById("tfl").innerHTML="<div style='margin-top: 200px; width: 200px; height: 100px; text-align: center; margin-left: auto; margin-right: auto; background-color: transparent;'><img src='./images/ajax-loader.gif' style='margin-top: 30px;'><br /><p style='font-weight: bold;'>LOADING...</p></div>";
	setTimeout ( "oForm()", 2000 );
}

function oForm() {
	document.getElementById("tfl").innerHTML="<h1>Contact Us at Castaway Restaurant</h1><p><span class='bodybold'>Whether you want to inquire</span> about reservations, plan your perfect event, need some information not found on our website, or would just like to leave feedback, contact us here at Castaway Restaurant in Burbank.</p><p>Use our convenient web form below for all your communication needs. We look forward to hearing from you!</p><div id='loadajax'></div><div id='formLayout' style='width: auto;'><form action='#' onsubmit='return false;' name='contactus' method='post'><input type='hidden' class='inputbox' name='category' value='inquiry' /><table><tr><th style='text-align: left;'>Name:</th><td><input type='text' class='inputbox' name='fname' value='' /></td></tr><tr><th style='text-align: left;'>Telephone:</th><td><input type='text' class='inputbox' name='tphone' value='' /></td></tr><tr><th style='text-align: left;'>Email:</th><td><input type='text' class='inputbox' id='fromEmail' name='email' value='(required)' onfocus='clearMe(this)' /></td></tr></table><div style='font-weight: bold; font-size: .8; margin-top: 10px;'><input type='checkbox' id='market' value='yes' name='market[]' /> Send me news &amp; information!</div><h1>Questions or Comments:</h1><textarea class='textbox' name='fcomments' style='width: 420px;' rows='7' maxlength='10' /></textarea><table style='width: 400px;'><tr><td style='text-align: right;'><p><input name='submit' type='submit' onclick='ssForm();' value='Submit!' /> <input name='reset' onclick='rForm();' type='reset' value='Reset!' /></p></td></tr></table></form></div>";
}

var xmlHttp

function ssForm() {
	var name = document.contactus.fname.value;
	var phone = document.contactus.tphone.value;
	var email = document.contactus.email.value;
	if(document.contactus.market.checked) {
		var market = 'yes';
	} else {
		var market = 'no';
	}
	var cmt = document.contactus.fcomments.value;
	document.getElementById("tfl").innerHTML="<div style='width: 200px; height: 100px; text-align: center; margin-left: auto; margin-right: auto; background-color: transparent;'><img src='./images/ajax-loader.gif' style='margin-top: 30px;'><br /><p style='font-weight: bold;'>LOADING...</p></div>";
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	var url="submit.html";
	var cat = 'inquiry';
	var tform = 'category='+cat+'&fname='+name+'&tphone='+phone+'&email='+email+'&market='+market+'&fcomments='+cmt;
	xmlHttp.onreadystatechange=bodyChanged;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
	xmlHttp.send(tform);
} 

function bodyChanged() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("tfl").innerHTML=xmlHttp.responseText;
		/*pageTracker._trackPageview("/submit.html");*/
	}
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function clearMe(formfield){
	if (formfield.defaultValue==formfield.value) {
		formfield.value = "";
	}
}

function clearForm() {
	document.contactus.fname.value = "";
	document.contactus.tphone.value = "";
	document.contactus.email.value = "";
	document.contactus.fcomments.value = "";
}