//---------------------slide the send details out

window.addEvent('domready', function() {

var myMenu = new MenuMatic();
//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",
		noCache : true,
		data: { 
			'senderName' : $('txtYourname').get('value'),
			'recpName' : $('txtRecipientname').get('value'),
			'recpEMail' : $('txtRecipientemail').get('value'),
			'hdnUrl' : $('hdnUrl').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"
			});
			if (svrResponse == 'Sent'){
				$('statusMessage').set('text','E-mail sent, thank you.');
			} else {
				$('statusMessage').set('text',svrResponse);
			}
		},
		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':"#5c5708"
			});
			$('statusMessage').set('text','Sending failed, please check the details and try again');
		}
	}).send();

});

//calendar
$$('.calavailable').addEvent('click',function(el){
	window.location = "makebooking.html";
});

//timeline (Where applicable)

/*	if ($('lstTimeline')){
		var timeline = new MooTimeline ({
			timeline:'lstTimeline',
			start:2001.8,
			end:2007.6,
			timelineheight:245,
			displaytitles: true,
			parsevalue: 'date',
			interval:1,
			tooltip:'title',
			autoadjustheight:true,
			shownextprev:true,
			onClick:function(data){
				element = this.timelinetext;
				var myFx = new Fx.Scroll(window, {
					duration:1000
				}).toElement(element);
			},
			onEntryAdd:function(data){
				element = data.element;
				tempentry = timelineentries[data.index];
				if (tempentry.get('html').trim() != tempentry.get('title').trim()){
					infosymbol = new Element('div', 
						{	
							'class':'timelineinfo',
							'styles':{
								'position':	'absolute',
								'top': element.getStyle('top').toInt() - 2,
								'left': (element.getStyle('left').toInt() + element.getStyle('width').toInt() - 2)
							}					
						}
					)
					infosymbol.inject(this.timelineview);
					//element.highlight();
				}
			}
			
		});
		
	};*/	

});

