function cleared(info) {
    document.getElementById(info).value = "";
    if (info == "fmail1" || info == "fmail2" || info == "fmail3" || info == "fmail4") {
        document.getElementById('fmail1').value = "";
        document.getElementById('fmail2').value = "";
        document.getElementById('fmail3').value = "";
        document.getElementById('fmail4').value = "";
    }
        
}

function closed() {
    $("#stf").fadeOut("slow");
}

function redo(info) {
    switch(info) {
        case 'name':
            if (document.getElementById(info).value == "") {
                document.getElementById(info).value = "Your Name";
            }
            break;
        case 'email':
            if (document.getElementById(info).value == "") {
                document.getElementById(info).value = "Your Email";
            }
            break;
        case 'message':
            if (document.getElementById(info).value == "") {
                document.getElementById(info).value = "Your Message";
            }
            break;
        case 'fmail1':
            if (document.getElementById(info).value == "") {
                document.getElementById('fmail1').value = "Friend Email 1";
            }
            break;
        
    }
}

 function stf() {
   intLeft = window.innerWidth / 2 - 210;
   intTop = (window.innerHeight / 2) + window.pageYOffset - 127;
       
    var book = document.getElementById('book');
    var overlay = document.createElement('div');
    overlay.setAttribute('id', 'stf');
    overlay.style.width = "419px";
    overlay.style.position = "absolute";
    overlay.style.left = intLeft + "px";
    overlay.style.top = intTop + "px";
    overlay.style.zIndex = "100";
    document.body.appendChild(overlay);
    overlay.style.display = "none";
    $.post("stf.html", {},
        function (data) {
            document.getElementById("stf").innerHTML = data;
            $("#stf").fadeIn("slow");
    });
}

$(document).ready(function() {
    $("#mfstf").click(function() {
        stf();
    });
});

$(document).keyup(function(event){
    if (event.keyCode == 27) {
        $("#stf").fadeOut("slow");
    }
});

function friendClear() {
                
    if (document.getElementById('txtFriend1').value == "Friend Email 1") {
        document.getElementById('txtFriend1').value = "";
    }
    if (document.getElementById('txtFriend2').value == "Friend Email 2") {
        document.getElementById('txtFriend2').value = "";
    }
    if (document.getElementById('txtFriend3').value == "Friend Email 3") {
        document.getElementById('txtFriend3').value = "";
    }
    if (document.getElementById('txtFriend4').value == "Friend Email 4") {
        document.getElementById('txtFriend4').value = "";
    }
}

function close() {
    $("#stf").fadeOut("slow");
}

function send() {
            var txtName = $("#txtStfName").val();
            var txtEmail = $("#txtStfEmail").val();
            var txtMessage = document.getElementById("txtStfMessage").value;
            var txtFriend1 = document.getElementById("txtFriend1").value;
            var txtFriend2 = document.getElementById("txtFriend2").value;
            var txtFriend3 = document.getElementById("txtFriend3").value;
            var txtFriend4 = document.getElementById("txtFriend4").value;
                $.post("stf.php", 
                { 
                    txtName: txtName,
                    txtEmail: txtEmail,
                    txtMessage: txtMessage,
                    txtFriend1: txtFriend1,
                    txtFriend2: txtFriend2,
                    txtFriend3: txtFriend3,
                    txtFriend4: txtFriend4
                },
                function (data) {
                    $("#stfcontain").fadeOut("slow", function() {
                        document.getElementById("stfcontain").innerHTML = data;
                        $("#stfcontain").fadeIn("slow");
                    });
                });
            }
