//---------------------slide the send details out

window.addEvent('domready', function() {

//sort out the slide out window for sending options
var SendSlider = new Fx.Slide('send');
SendSlider.hide();

$('send_open').addEvent('click', function(e){
	duration:'short'
	SendSlider.toggle();
});

//sort out the share out window
var ShareSlider = new Fx.Slide('share');
ShareSlider.hide();

$('share_open').addEvent('click', function(e){
	duration:'short'
	ShareSlider.toggle();
});

//ajax for the send button
var SendButton = $('btnSend');

SendButton.addEvent('click', function(event) {
									  
	//turn off the text elements
	$('formSend').getElements('input[type=text]').setStyle("background-color","#eeeeee");
	
	//prevent the page from changing
	event.stop();
	
	//make the ajax call, replace text
	var req = new Request({
		method: 'get',
		url: "sendemail.php",
		data: { 
			'senderName' : $('txtYourname').get('value'),
			'recpName' : $('txtRecipientname').get('value'),
			'recpEMail' : $('txtRecipientemail').get('value'),
			'ajax' : 1
		},
		onRequest: function() { 
			var morphObject = new Fx.Morph($('statusMessage'));
			morphObject.start({
				'height': 20,
				'background-color': "#fffdd6",
				'color':"#5c5708"
			});
			$('statusMessage').set('text','Sending e-mail');
		},
		onSuccess: function(svrResponse) {
			//turn on the text elements
			$('formSend').getElements('input[type=text]').setStyle("background-color","#ffffff");
			$('formSend').getElements('input[type=text]').set("value","");
			var morphObject = new Fx.Morph($('statusMessage'));
			morphObject.start({
				'height': 20,
				'background-color': "#406a9a",
				'color':"#ffffff"
			});
			$('statusMessage').set('text','E-mail sent, thank you');
		},
		onFailure: function() { 
			$('formSend').getElements('input[type=text]').setStyle("background-color","#ffffff");
			var morphObject = new Fx.Morph($('statusMessage'));
			morphObject.start({
				'height': 20,
				'background-color': "#9a4040",
				'color':"#ffffff"
			});
			$('statusMessage').set('text','Sending failed, please check the details and try again');
		}
	}).send();

});

});