$( function(){	
	var message_container = $( ".form_error" );
	$( "#mail_list_form" ).validate( {
		rules: {
			'name' : { required: true },
			'email' : { required: true, email: true }
		},
		messages:{
			'name' : 'Name field is required.',
			'email' : 'Email field is required.'
		},
		errorLabelContainer: message_container
	} );
	
	$( "#submit_button" ).click( function(){

		if( $( "#mail_list_form" ).valid() ){
			$( ".loader_container" ).addClass( 'loading' );
			$( "#mail_list_form" ).ajaxSubmit ({
				dataType: 'json',
				success: function( data ){ 
					$( ".loader_container" ).removeClass( 'loading' );
					if( data ){
						
						if( data.status == 'ok' ){
							
							$( ".form_confirm" ).html( data.message );							
							document.forms['mail_list_form'].reset();
							
							setTimeout( '$(".form_confirm" ).html("")', 3000 ); 
							
						}else{
							$( ".form_error" ).html( data.message );														
						}
					}
				}
			} );
		}

	});

	if( !$.browser.msie ){
		$( ".fade_on_hover" ).hover( 
		function(){
			$( this ).animate( { opacity: 0.5 }, 'fast' );
		}, 
		function(){
			$( this ).animate( { opacity: 1 }, 'fast' );			
		} );
	}
	
	var d = new Date();
	var curr_year = d.getFullYear()
	$( "#year" ).html( curr_year );
} );
