/* 2009-04-04 */

(function($) {

        $(function () {
                var prevEmail = $('#Email').val();

                $('input[type="text"]').each(function() {
                        $(this).toggleValue($(this).val());
            	});

				$('.tooltip').simpletooltip();

				$('#box-newsletter a').click(function(event) {
						$('#form-newsletter').slideToggle('slow');
						event.preventDefault();
				});

				$('#form-newsletter').submit(function () {
				        $('#nl-error').remove();
                        $.post($(this).attr('action'), $(this).serialize(), function (data) {
                                if (data.error == '1') {
                                        $('#form-newsletter').before('<p id="nl-error" style="display: none;">' + data.msg + '</p>');
                                        $('#Email').focus();
                                        $('#nl-error').fadeIn().animate({ opacity: 1 }, 3000, '', function () {
                                                $(this).fadeOut('normal', function () {
                                                        $(this).remove();
                                                });
                                        });
                                }
                                else {
                                        $('#form-newsletter').slideToggle('slow', function () {
                                                $('#Email').val(prevEmail);
                                        });
                                        $('#form-newsletter').before('<p id="nl-success" style="display: none;">' + data.msg + '</p>');
                                        $('#nl-success').fadeIn().animate({ opacity: 1 }, 2000, '', function () {
                                                $(this).fadeOut('normal', function () {
                                                        $(this).remove();
                                                });
                                        });

                                }
                        }, 'json');
                        return false;
				});

        });

})(jQuery);
