jQuery(document).ready(function($){

//////////////////
//DROP-DOWN MENU
//////////////////
var ddm = {

	init : function() {

		$('#nav').find('a').removeAttr('title')  //remove title attributes
			.end().find('li').has('ul')
			.each(function() {
				var $ul = $(this).find('ul:first');
				$(this).hover(
					function(){
						$ul.stop().css({'overflow':'hidden', 'height':'auto', 'display':'none'}).slideDown(250, function(){
							$ul.css({'display':'block', 'overflow':'visible', 'height':'auto', 'opacity':0.9});
						});
					},
					function(){
						$ul.stop().slideUp(250, function(){
							$ul.css({'overflow':'hidden', 'display':'none'});
						});
					}
				);
			});
	}

};
ddm.init();





//////////////////
//FORMS
//////////////////
var xForm = {

	init : function() {

	$('.x-form').show().submit(function() {
		var form = $(this);
		var str = $(this).serialize();
		$(this).prev('.form-alert').fadeIn(400).html('Sending...');
		$('.submit', this).attr('disabled', 'disabled');
		$.ajax({
			type: 'POST',
			url: xjax.url,
			data: 'action=xform&'+str,
			dataType: 'json',
			success: function(json) {
				if(json.status == 'sent') {
					$(form).prev('.form-alert').html(json.reply);
					$(form).animate({'height':'0px'},function(){
						$(form).hide();
					});
				}
				else {
					$(form).prev('.form-alert').html(json.reply);
				}
				$('.submit', form).removeAttr('disabled');
			}
		});
		return false;
    });

	}

};
xForm.init();




//////////////////
//SCROLL TO TOP
//////////////////
	$('a.top').click(function(){
		$('html, body').animate({scrollTop:0}, 750);
		return false;
	});



});
