function check_fields()
{
	name = $('name').value;
	email = $('email').value;

	v_name = validate_name('name',name);
	v_email = validate_email('email',email);
	
	if (v_name && v_email){send_form();}
	
	
	
}


function send_form() {

	   		var params = Form.serialize($('signup')); // Serialize the form data
     		Element.hide('submit');
			Element.show('loading');
	 new Ajax.Updater('updates', '/leads/signup', {asynchronous:true, parameters:params, onComplete: function() {Element.hide('loading');
         }
	 });
	 }
	 
	 	

function validate_email(field,theValue)
{
	theValue = trim(theValue);
	var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
	
	if (email.test(theValue))
	{
		$('e_' + field).hide();
		return true;
	}
	else{$('e_' + field).show();return false;}
	
	
	
}

function validate_name(field,theValue)
{
	if (theValue != '' && theValue.length > 1)
	{
		$('e_' + field).hide();
		return true;
	}
	else{$('e_' + field).show();return false;}

}

function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}


function show_photo_tour()
{
	newwindow=window.open('photo-tour.html','name','height=400,width=510,left=100,top=100,resizable=yes,scrollbars=no,toolbar=no,status=no');
	
}
