// JavaScript Document
// this is for the postcomment effects
window.addEvent('domready', function() {
	var mySlide = new Fx.Slide('postcomment',{mode: 'vertical'});
	mySlide.hide();
	new Fx.Slide('weddingdate', {duration: 700,mode: 'vertical', transition:Fx.Transitions.Back.easeOut}).hide().slideIn();
//	new Fx.Styles('left-bar', {duration: 300, transition:Fx.Transitions.linear}).start({'opacity': [0,1]});
	$('togglepostcomment').addEvent('click', function(e){
		e = new Event(e);
		mySlide.toggle();
		e.stop();
	});

	$('frm-comment').addEvent('submit', function(e) {
		/**
		 * Prevent the submit event
		 */
		new Event(e).stop();
		/**
		 * This empties the log and shows the spinning indicator
		 */
		if (!validate(this))
			return;
		
		var log = $('log_res').addClass('ajax-loading');
		var gc = $('guestcomments');
	 
		/**
		 * send takes care of encoding and returns the Ajax instance.
		 * onComplete removes the spinner from the log.
		 */
		this.send({
			update: log,
			onComplete: function() {
				log.removeClass('ajax-loading');
				gc.innerHTML = log.innerHTML + gc.innerHTML;
				log.empty();
				var myEffect = gc.effect('background-color', {duration: 1000,transition: Fx.Transitions.linear});
				myEffect.start('#ffe7e7', '#ffffff');
			}
		});
	});
	
	$('allcomment').addEvent('click', function(e){
		e = new Event(e).stop();
		return;
		var log = $('log_res').addClass('ajax-loading');
		var gc = $('guestcomments');
		
		new Ajax('http://ow.amudanhani.com/include/postcomment.php?type=showallcomment', 
							  {method: 'post',
							  update: log,
							  onComplete: function() {
									log.removeClass('ajax-loading');
									gc.innerHTML = log.innerHTML + gc.innerHTML;
									log.empty();
									var myEffect = gc.effect('background-color', {duration: 1000,transition: Fx.Transitions.linear});
									myEffect.start('#ffe7e7', '#ffffff');
									}
								}).request();
	});
});
