var invalidColor = '#FAA';  														var requiredColor = '#FFA';
var successText = '<p><strong class="contact_thank_you">THANK YOU</strong></p> <p>Your inquiry has been submitted.  A member of our staff will respond to you shortly.</p>';

function highlightFields(type,array)
{
//    (type == 'required') ? color = requiredColor : color = invalidColor;
	for(var i in array)
	{
		sDebug(i+' = '+array[i]);
		$(i).setStyle('background-color',invalidColor);
		$(i).setProperty('title',array[i]);
		$(i).addEvent('change', function(){
			this.setStyle('background-color','#FFF');
			this.removeProperties('onchange', 'title');
		});
	}
}

function submitContactForm(form)
{
	switch(form)
	{
		case 'contact':
			var container = 'vert';
			var response_container = 'contact_form';
			var postJSON = JSON.encode({
				'contact_name:alpha': $('contact_name:alpha').value,
				'contact_email:email': $('contact_email:email').value,
				'contact_location:dropdown': $('contact_location:dropdown').value,
				'contact_subject:dropdown': $('contact_subject:dropdown').value,
				'contact_info:safe_text': $('contact_info:safe_text').value
			});
		break;
		case 'pvtdining':
			var container = 'sub';
			var response_container = 'private_dining_form';
			var postJSON = JSON.encode({
				'contact_name:alpha': $('contact_name:alpha').value,
				'contact_email:email': $('contact_email:email').value,
				'contact_phone:us_phone': $('contact_phone:us_phone').value,
				'contact_start_date:date': $('contact_start_date:date').value,
				'contact_end_date:date': $('contact_end_date:date').value,
				'contact_event:alphanum': $('contact_event:alphanum').value,
				'contact_guest_count:integer': $('contact_guest_count:integer').value,
				'contact_comments:safe_text': $('contact_comments:safe_text').value
			});
		break;
	}
	var jsonRequest = new Request.JSON({
		url: "services/mailService.php",
		onSuccess: function(response){
			if (typeof(response.errors) != 'undefined' && typeof(response.errors.invalid) != 'undefined')
			{
				highlightFields('invalid',response.errors.invalid);
			}
			if (typeof(response.errors) != 'undefined' && typeof(response.errors.required) != 'undefined')
			{
				highlightFields('required',response.errors.required);
			}
			sDebug(response);
			if (response.success == true)
			{
				sDebug('mailed form');
				//$(response_container).innerHTML = '<div class="tcenter">' + successText + '</div>';
				$(container + '_box_content').getElements('.success').setStyle('display','block');
				ScrollReload(container + '_box_content');
			}
		}
	}).post({'form':form,'json':postJSON,'default_location':window.loc});
}
