/** Author Keishi Takashima**/
document.observe("dom:loaded", function() {				
	$$('.input-box', '.textarea-box').invoke('observe', 'focus', clearText );
	var valid = new Validation('contact-form' , {onSubmit:false});	
	$('send').observe('click', function(){
    	var result = valid.validate();
		if( result )
			sendMail();
	});
});

function sendMail(){
	$('contact-form').request({
		onLoading: function(){
			$('loading').show();
		},
		onSuccess: function(transport){ 
			var response = transport.responseText.evalJSON();
			if(response.success){
				$('contact-form').setStyle({'visibility':'hidden'});
				$('contact-form').disable();
				$('response').setStyle({'color':'#000'});
				new Effect.BlindDown('response', {duration : .75 });
			}
			$('response').update(response.message);
			$('loading').hide();
		}
	})
}

function clearText(event){
	var thefield = event.element();
	if (thefield.defaultValue==thefield.value)
		thefield.value = ""
	thefield.setStyle({'color':'#000'});
}