function init(pErrorMsg) {
    if (pErrorMsg != "") {
        document.getElementById("formError").style.display = "block";
        document.getElementById("formError").innerHTML = pErrorMsg;
    } else {
        document.getElementById("formError").style.display = "none";
    }
}


function validate(pForm) {
    l_strWarning = ""

    if(pForm.txtFromName.value.trim() == '') l_strWarning += "<li><strong>Your First Name:</strong> Cannot be empty.</li>";
    if(!isAlpha(pForm.txtFromName.value)) l_strWarning += "<li><strong>Your First Name:</strong> Must contain alphabetic characters.</li>";

	var l_strEmailWarning = '';
    l_strEmailWarning = emailCheck(pForm.txtFromEmail.value, l_strEmailWarning);
    if (l_strEmailWarning != "") l_strWarning += "<li><strong>Your Email:</strong>" + l_strEmailWarning;


    if(pForm.txtToName.value.trim() == '') l_strWarning += "<li><strong>Friend's First Name:</strong> Cannot be empty.</li>";
    if(!isAlpha(pForm.txtToName.value)) l_strWarning += "<li><strong>Friend's First Name:</strong> Must contain alphabetic characters.</li>";

	var l_strEmailWarning = '';
    l_strEmailWarning = emailCheck(pForm.txtToEmail.value, l_strEmailWarning);
    if (l_strEmailWarning != "") l_strWarning += "<li><strong>Friend's Email:</strong>" + l_strEmailWarning;


    if (l_strWarning != "") {
        document.getElementById("formError").style.display = "block";
        document.getElementById("formError").innerHTML= "<strong>The form cannot be submitted because\nthe following fields are invalid/incomplete:</strong><ul>" + l_strWarning + "</ul>";
        return false;
    } else {
		return true;
        //pForm.submit();
		//makeRequest()
    }
}

function textLimit(field, maxlen) {
	if (field.value.length > maxlen + 1) alert('Your message must be 250 characters or fewer.');
	if (field.value.length > maxlen) field.value = field.value.substring(0, maxlen);
}

function makeRequest(loc) {

	window.location = "/kisses/downloads/index.asp?id=" + loc;

    }

    function alertContents(httpRequest) {

        if (httpRequest.readyState == 4) {
            if (httpRequest.status == 200) {
               //alert(httpRequest.responseText);
			   document.getElementById("ecard-content").innerHTML = httpRequest.responseText
            } else {
                alert('There was a problem with the request.');
            }
        }

    }