   var OSEC = OSEC || {};

    (function ($) {
        function Feedbacktab() {
            var $feedbackForm = $('#feedbackForm form');
            var $result = $('#feedbackForm .result');
            var $loader = $('#feedbackForm .loader');

            $('#feedbackTab a').click(function () {
                return false;
            });

            $(document).bind('tbloaded', function (){
                if($('#TB_window #feedbackForm').length > 0) {
                    $('#TB_window').addClass('hasBorder');
                }
            });

            $(document).bind('tbunload', function (){
                $('#TB_window').removeClass('hasBorder');
                $feedbackForm.show();
                $result.hide();
                $loader.hide();
            });

             var form_post = function () {

                $.ajax({
                	data : $feedbackForm.serialize(),
                    type : $feedbackForm.attr('method'),
                    url : $feedbackForm.attr('action'),
                    beforeSend : function () {
                        $feedbackForm.hide();
                        $loader.show();
                    },
                    success : function () {
                        $result.show();
                    },

                    complete : function () {
                        $loader.hide();
                        $('#closeFeedbackForm').click(function () {
                            tb_remove();
                        });
                    }

                });

            };

            $feedbackForm.submit(function (){
                return false;
            });
            
            $feedbackForm.validate({
                    errorClass: "invalid",
                    errorElement: "span",
                    errorPlacement: function(error, element) {
                        error.appendTo( element.parents().filter('.contentFormWrapper') );
                    },
                    submitHandler : function () {
                        form_post();
                    }
                }
            );
        }

        OSEC.Feedbacktab = Feedbacktab
    }(jQuery));

    jQuery(document).ready(function () {
        ft = new OSEC.Feedbacktab;
      });
    
    
    (function () {
    	Spamcalculator = function (max) {
    
	        var a = 0,
	            b = 0,
	            c = 0;
	           
	        this.generate = function () {
	        	
	        	a = parseInt(Math.random() * max, 10);
	        	b = parseInt(Math.random() * max, 10);
	        	c = a + b;
	        	
	        }
	        
	        this.get_a = function () {
	        	return a;
	        };
	        
	        this.get_b = function () {
	        	return b;
	        };
	        
	        this.get_c = function () {
	        	return c;
	        }
    	
    	}
    	
    	OSEC.Spamcalculator = Spamcalculator;
    	
    }());
