﻿$(function($) {
    //(new Connector()).Post("AllQuestions", {});    
    toggle();

    function Connector() {
        var post = this.Post = function(method, data, callback) {
            function _callback(response) {
                if (response.error) {
                    waiting.dialog("close");
                    error.text(response.error).show();
                } else if (response.IsLogged === false) {
                    document.location = response.RedirectUrl;
                } else {
                    callback(response);
                }
            }

            if (method !== undefined) {
                this.method = method;
                this.data = data;
                this.callback = callback;
            }

            $.post("Handlers/JSonHandler.ashx/faq/" + this.method, $.toJSON(this.data), _callback, "json");
        };
    }

    function toggle() {
        $(".questionboxclosed").toggle(
			function() {
			    this.className = "questionboxopened";
			    $(".answer", this).slideDown();
			},
			function() {
			    var elm = this;
			    $(".answer", elm).slideUp(function() {
			        elm.className = "questionboxclosed";
			    });
			}
		);
    }
});
