function EnableGuestBookForm (theform)
{
    CForm (theform).Init ();
    StoreCaret (theform.name);
}

function GuestbookConfirmDelete ()
{
    return (window.confirm ("Möchtest Du diesen Gästebucheintrag löschen?") ? undefined : false);
}

function GuestbookPreview (thebutton, theprefix)
{
    var xmlhttpreq = new CXMLHttpRequest ();
    if (xmlhttpreq.xmlhttpreq !== null) {
        var showpreview = function (therequest) {
            CHtml.SetInnerHTML (document.getElementById ("guestbooknewpreview"), therequest.responseText);
        }
        var showerror = function (therequest) {
            document.getElementById ("guestbooknewerror").style.display = "block";
            CHtml.SetInnerHTML (document.getElementById ("guestbooknewerror"), therequest.statusText);
        }
        var cleanup = function (therequest) {
            document.getElementById ("guestbooknewpreview").style.display = "block";
            thebutton.disabled = false;
            document.getElementById ("text").focus ();
        }
        document.getElementById ("guestbooknewerror").style.display = "none";
        thebutton.disabled = true;
        var property = theprefix + "[xmlhttprequest]";
        var addvalues = new Object;
        addvalues [property] = ["1"];
        xmlhttpreq.MakeRequest (thebutton.form.action, showpreview, showerror, cleanup, CForm (thebutton.form).CollectValues (thebutton.id).Serialize (addvalues, encodeURIComponent), "POST");
        return (false);
    }
    return (true);
}

function ResetGuestbookForm ()
{
    window.document.getElementById ("guestbookform").reset ();
    CForm (window.document.getElementById ("name")).Init ();
    return (false);
}

function ValidateGuestBookForm ()
{
    var elems = [
        new CFormValidator ("name"                                 , true , null                              , null, "Bitte gib Deinen Namen ein."                                                   ),
        new CFormValidator ("email"                                , false, CFormValidator.IsValidEMailAddress, null, "Bitte lasse das Feld \"E-Mail\" leer oder gib eine gültige E-Mail-Adresse ein."),
        new CFormValidator ("text"                                 , true , null                              , null, "Bitte gib eine Nachricht ein."                                                 ),
        new CFormValidator ("user_juguestbook_pi1_captcha_response", true , null                              , null, "Bitte gib den Code aus dem linken Bild ein."                                   )
    ];
    return (CForm.Validate (elems));

}

