
function showHiddenElement (strId) {
  $("#" +strId).show("slow");
}

function hideShowenElement (strId) {
  $("#" +strId).hide();
}

function showHideElement (strId) {
    if (document.getElementById(strId).style.display == "inline") {
        hideShowenElement (strId);
    } else {
        showHiddenElement (strId);
    }
}

function loadHeadline (strJsConfig, strAction) {

    $.get ("index.php", { ajax: "applic|modules|headline|headline.base.php", strJsConfig: strJsConfig, strAction: strAction }, function (data) { $("#area_headline").html (data); }  );

}

function loadUserImage () {

    $.get ("index.php", { ajax: "applic|modules|profile|profile.base.php", ac: "reloadUserimage" }, function (data) {

            var arrTemp = data.split ('|');

            $("#tblUserImage").attr ("width", arrTemp[0]);
            $("#tblUserImage").attr ("height", arrTemp[1]);
            $("#tblUserImage").attr ("background", arrTemp[2]);

        }
    );

}

function splitConfig (strConfig) {
    var arrConfig = strConfig.split("|");
    return arrConfig;
}

function setBlogSearchAction () {

    var strValue = $("#strSearch").val();

    $.get ("index.php", { ajax: "applic|modules|blogsearch|blogsearch.base.php", strValue: strValue }, function (data) {

            if (data != "") {

                location.href = data;

            }
        }
    );
}

function handleSearch(evt) {
    evt = (evt) ? evt : ((event) ? event : null);
    if (evt) {
        key = evt.keyCode;
        if (evt.charCode) {
            key = evt.charCode;
        }
        if (key && (key == 13)) setBlogSearchAction();
    }
}

function handleFriendship (intToUser, strAction, strDesignPath) {

    $.get ("index.php", { ajax: "applic|modules|friend|friend.base.php", ac: "friend.handle", intToUser: intToUser, strAction: strAction}, function (data) {

            if (strAction == "accept") {
                if (document.getElementById("friend_accept_"+intToUser)) {
                    $("#friend_pending_"+intToUser).attr ("src", strDesignPath+"images/icons/friend_yes.gif");
                    $("#friend_pending_"+intToUser).attr ("onClick", "");
                    $("#friend_pending_"+intToUser).attr ("style", "");
                    $("#friend_pending_"+intToUser).attr ("title", "");
                }
                if (document.getElementById("friend_cancle_"+intToUser)) {
                    $("#friend_cancle_"+intToUser).attr ("src", strDesignPath+"images/x.gif");
                    $("#friend_cancle_"+intToUser).attr ("onClick", "");
                    $("#friend_cancle_"+intToUser).attr ("style", "");
                    $("#friend_cancle_"+intToUser).attr ("title", "");
                    $("#friend_cancle_"+intToUser).attr ("height", "1");
                    $("#friend_cancle_"+intToUser).attr ("width", "1");
                }
                if (document.getElementById("friend_pending_"+intToUser)) {
                    $("#friend_accept_"+intToUser).attr ("src", strDesignPath+"images/x.gif");
                    $("#friend_accept_"+intToUser).attr ("onClick", "");
                    $("#friend_accept_"+intToUser).attr ("style", "");
                    $("#friend_accept_"+intToUser).attr ("title", "");
                    $("#friend_accept_"+intToUser).attr ("height", "1");
                    $("#friend_accept_"+intToUser).attr ("width", "1");
                }

            }

            if (strAction == "decline") {
                if (document.getElementById("friend_accept_"+intToUser)) {
                    $("#friend_pending_"+intToUser).attr ("src", strDesignPath+"images/icons/friend_no.gif");
                    $("#friend_pending_"+intToUser).attr ("onClick", "");
                    $("#friend_pending_"+intToUser).attr ("style", "");
                    $("#friend_pending_"+intToUser).attr ("title", "");
                }
                if (document.getElementById("friend_cancle_"+intToUser)) {
                    $("#friend_cancle_"+intToUser).attr ("src", strDesignPath+"images/x.gif");
                    $("#friend_cancle_"+intToUser).attr ("onClick", "");
                    $("#friend_cancle_"+intToUser).attr ("style", "");
                    $("#friend_cancle_"+intToUser).attr ("title", "");
                    $("#friend_cancle_"+intToUser).attr ("height", "1");
                    $("#friend_cancle_"+intToUser).attr ("width", "1");
                }
                if (document.getElementById("friend_pending_"+intToUser)) {
                    $("#friend_accept_"+intToUser).attr ("src", strDesignPath+"images/x.gif");
                    $("#friend_accept_"+intToUser).attr ("onClick", "");
                    $("#friend_accept_"+intToUser).attr ("style", "");
                    $("#friend_accept_"+intToUser).attr ("title", "");
                    $("#friend_accept_"+intToUser).attr ("height", "1");
                    $("#friend_accept_"+intToUser).attr ("width", "1");
                }
            }

            if (strAction == "cancle") {
                if (document.getElementById("friend_active_"+intToUser)) {
                    $("#friend_active_"+intToUser).attr ("src", strDesignPath+"images/x.gif");
                    $("#friend_active_"+intToUser).attr ("onClick", "");
                    $("#friend_active_"+intToUser).attr ("style", "");
                    $("#friend_active_"+intToUser).attr ("title", "");
                    $("#friend_active_"+intToUser).attr ("height", "1");
                    $("#friend_active_"+intToUser).attr ("width", "1");
                }
                if (document.getElementById("friend_cancle_"+intToUser)) {
                    $("#friend_cancle_"+intToUser).attr ("src", strDesignPath+"images/x.gif");
                    $("#friend_cancle_"+intToUser).attr ("onClick", "");
                    $("#friend_cancle_"+intToUser).attr ("style", "");
                    $("#friend_cancle_"+intToUser).attr ("title", "");
                    $("#friend_cancle_"+intToUser).attr ("height", "1");
                    $("#friend_cancle_"+intToUser).attr ("width", "1");
                }
            }

            if (data != "") {

                if (document.getElementById('friendshipResultInfo')) {

                    $("#friendshipResultInfo").html(data);

                }

            }

        }
    );

}

function sendSendContent () {

    $("#sendContentButton").attr ("disabled", true);

    $.get ("index.php", { ajax: "applic|modules|sendcontent|sendcontent.base.php", ac: "sendcontent.save",
            strLink: $("#strLink").val(),
            strRecipientName: $("#strRecipientName").val(),
            strRecipientMail: $("#strRecipientMail").val(),
            strMessage: $("#strMessage").val() },

            function (data) {

                if (data != "1") {

                    $("#sendContentError").html (data);
                    $("#sendContentButton").attr ("disabled", false);

                } else {

                    $("#comment_add_container").slideUp();
                    $("#comment_add_container").html("");

                }

            }
    )

}

function sendContentInput (intReferenceId, strReferenceType) {

    var strHtml = $("#comment_add_container").html();
    var trainingContainer = 'container_' +intReferenceId;
    var strDropDownBox = 'strTrainingWeek_' +intReferenceId;

    var objTrainingContainer = document.getElementById (trainingContainer);
    var objDropDownBox = document.getElementById (strDropDownBox);

    if (strHtml.length < 2) {

        $.get ("index.php", { ajax: "applic|modules|sendcontent|sendcontent.base.php", ac: "sendcontent.input",
            intReferenceId: intReferenceId,
            strReferenceType: strReferenceType },

            function (data) {

                if (objTrainingContainer) {
                    if (objDropDownBox) {
                        objDropDownBox.options[0].selected = true;
                    }
                    $("#"+trainingContainer).html ("");
                }
                $("#comment_add_container").html (data);
                $("#comment_add_container").slideDown();

            }

        );

        location.href = "#actionAnchor";

    } else {

        $("#comment_add_container").slideUp();
        $("#comment_add_container").html("");

    }

}