/**
 * Called when the user submits the "Learn More" form. We format an email
 * with the contents of the form and send it.
 */
function submitLearnMoreForm()
{
    var name = "postmaster";
    var dom = "stfrancissoupkitchen";
    var t = "org"
    var CRLF = '%0d%0a';

    var form = $( "#form1" );
    var u = 'm' + 'a' + 'i' + 'l' + 't' + 'o' + ':' + name + '@' + dom + '.' + t;

    var firstName = form.find( "#firstName" ).val();
    var lastName = form.find( "#lastName" ).val();
    var name;

    if (!! firstName)
    {
        name = firstName;
        if (!! lastName)
        {
            name += " " + lastName;
        }
    }
    else
    {
        name = lastName;
    }
//    u += "?subject=St. Francis Learn More About form";
//    u += ("&body=" +
//            "name %3d " + name + CRLF +
//            "address %3d " + form.find( "#address1" ).val() + CRLF +
//            "address2 %3d " + form.find( "#streetTwo" ).val() + CRLF +
//            "city %3d " + form.find( "#city" ).val() + CRLF +
//            "state %3d " + form.find( "#state" ).val() + CRLF +
//            "zip %3d " + form.find( "#zip" ).val() + CRLF +
//            "email %3d " + form.find( "#emailAddress" ).val() + CRLF +
//            "telephone %3d " + form.find( "#telephone" ).val() + CRLF +
//            "newsletter %3d " + (form.find( "#newsletter" )[0].checked ? "yes" : "no") + CRLF);
//
//    form.attr( "action", u.replace( /\ /g, "%20" ) );
    u += "?subject=I would like to help";
    u += ("&body=" +
            "Thank you for your interest in learning more about our kitchen and mission" + CRLF +
            "to the poor and hungry of our area. Please feel free to add any additional" + CRLF +
            "information or comments below, then click \"Send\" in your email application." + CRLF +
            CRLF + CRLF + CRLF +
            "Thank you," + CRLF +
            "The St. Francis Soup Kitchen family" + CRLF + CRLF +
            "name %3d " + name + CRLF +
            "address %3d " + form.find( "#address1" ).val() + CRLF +
            "address2 %3d " + form.find( "#streetTwo" ).val() + CRLF +
            "city %3d " + form.find( "#city" ).val() + CRLF +
            "state %3d " + form.find( "#state" ).val() + CRLF +
            "zip %3d " + form.find( "#zip" ).val() + CRLF +
            "email %3d " + form.find( "#emailAddress" ).val() + CRLF +
            "telephone %3d " + form.find( "#telephone" ).val() + CRLF +
            "newsletter %3d " + (form.find( "#newsletter" )[0].checked ? "yes" : "no") + CRLF);

    window.location = u.replace( /\ /g, "%20" );

    form.find( "#firstName" ).val( "" );
    form.find( "#lastName" ).val( "" );
    form.find( "#streetTwo" ).val( "" )
    form.find( "#city" ).val( "" )
    form.find( "#state" ).val( "" )
    form.find( "#emailAddress" ).val( "" )
    form.find( "#telephone" ).val( "" )

    return false;

}

function indexImageLoaded()
{
    var headerImage = $( ".headerImage" );
    var headerImageBuffer = $( ".headerImageBuffer" );

    headerImage[0].onload = null;

    slideShow = new SlideShow(
        ".headerImage", ".headerImageBuffer",
        [
            "images/rotate/index/jmjSign.jpg",
            "images/rotate/index/kitchenSign.jpg",
            "images/rotate/index/threeChildren.jpg",
            "images/rotate/index/stiringThePot.jpg",
            "images/rotate/index/stfrancisstatue.jpg"
        ]
    );
    slideShow.start();

    // Stop after one minute.
    setTimeout(
        function()
        {
            slideShow.stop();
        },
        60 * 1000
    );
}


function howToHelpImageLoaded()
{
    var headerImage = $( ".headerImage" );
    var headerImageBuffer = $( ".headerImageBuffer" );

    headerImage[0].onload = null;

    slideShow = new SlideShow(
        ".headerImage", ".headerImageBuffer",
        [
            "images/rotate/how-to-help/gardenrotate.jpg",
            "images/rotate/how-to-help/jmjrotate.jpg",
            "images/rotate/how-to-help/ukrainevolunteers.jpg",
            "images/rotate/how-to-help/serving.jpg"
        ]
    );
    slideShow.start();

    // Stop after one minute.
    setTimeout(
        function()
        {
            slideShow.stop();
        },
        60 * 1000
    );
}


