﻿
/// <reference path="jquery-1.4.1-vsdoc.js" />


var contentType;
var cmsLoaded;
jQuery(document).ready(function () {


    if (cmsLoaded != true) {

        initEditContentDialog();

        cmsLoaded = true;
    }



});



function initEditContentDialog() {



    jQuery("#editContentDialog").dialog({
        bgiframe: true, autoOpen: false, modal: true, width: 420, buttons: {

            'Speichern': function () {


                
                if (contentType == "HTML") {


                

                    var data = { editFormValue: escape($("#editFormValue").htmlarea("toHtmlString")), editFormField: $("#editFormField").attr("value") };

                } else {
                    var data = { editFormValue: escape($("#editFormValue").attr("value")), editFormField: $("#editFormField").attr("value") };
                }
                $.post($("#editForm").attr("action"), data, function (obj) {

                    $("#editForm").dialog("close");


                    location.reload();

                });






            }

        }
    });




    return true;
}


function editHtmlField(username, field, value) {

    contentType = "HTML";

    //set the form action to the right controller



    $("#editForm").attr("action", "/Doctor/UpdateProfile/" + username);




    // set the field to the right value

    $("#editFormValue").attr("value", unescape(value));

    $("#editFormField").attr("value", field);


    // open the dialog
    $("#editContentDialog").dialog("option", "title", field);


    jQuery("#editContentDialog").dialog("open");



    $("#editFormValue").htmlarea("dispose");


    $("#editFormValue").htmlarea();

    return false;
}



function editTextField(username, field, value) {

    contentType = "Text";

    $("#editForm").attr("action", "/Doctor/UpdateProfile/" + username);

    $("#editFormValue").attr("value", unescape(value));

    $("#editFormField").attr("value", field);

    $("#editContentDialog").dialog("option", "title", field);


    jQuery("#editContentDialog").dialog("open");



    return false;
}


