$(document).ready(function() {
	
	Cufon.set('fontFamily', 'Century Gothic').replace('h2');
	Cufon.set('fontFamily', 'Century Gothic').replace('#footer p', { hover: true });
	Cufon.set('fontFamily', 'Century Gothic').replace('#footer ul a', { hover: true });
	Cufon.set('fontFamily', 'Century Gothic').replace('.download', { hover: true });
	Cufon.set('fontFamily', 'Century Gothic').replace('#header .social a', { hover: true });
	Cufon.set('fontFamily', 'Century Gothic').replace('.newsletter h3');
	Cufon.set('fontFamily', 'Century Gothic').replace('.main-menu a', { hover: true });
	
	/* Main Menu */
	
	$('.main-menu li').each(function(i, el) {
		if($(el).find('ul:first').length > 0) {
			$(el).find('a:first').attr('href', 'javascript:;');
			$(el).click(function() {
				if($(this).hasClass('hover')) {
					$(this).removeClass('hover');
					$(this).find('ul:first').slideUp(300);
				} else {
					$(this).addClass('hover');
					$(this).find('ul:first').slideDown(500);
				}
			});
		}
	});
	
	$('form.subscribe').append('<div class="error-msg"></div>');
	
	$('form.subscribe').submit(function() {
		$.ajax({
			type: 'POST',
			url: ( $(this).attr('action') != '' ? $(this).attr('action') : document.location.href ),
			data: $(this).serialize(),
			cache: false,
			success: function( message ) {
				if(message != '' && message.search('jquery') == -1) {
					$('form.subscribe').find('input[name="ne"]').removeClass('done');
					$('.error-msg').html(message).fadeIn();
				} else {
					$('.error-msg').hide();
					$('form.subscribe').find('input[name="ne"]').addClass('done');
				}
				return;
			}
		});
		
		return false;
	});
	
	// Init Auto Clear for Text Fields
	$('input:text').focus(function() { if($(this).val() == $(this).attr('title')) { $(this).val(''); } });
	$('input:text').blur(function() { if($(this).val() == '') { $(this).val($(this).attr('title')); } });
	
}); 
