﻿function stripHTML() {
    // Strip HTML Tags (form) script- By JavaScriptKit.com (http://www.javascriptkit.com)
    // For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
    // This notice must stay intact for use
    var re = /<\S[^><]*>/g;
    for (i = 0; i < arguments.length; i++) {
        arguments[i].value = arguments[i].value.replace(re, '');
    }
}

function setClassValue(val) {
    scv = document.getElementById("selclassvalue");
    scv.value = val;
}

function setLocationValue(val) {
    scv = document.getElementById("sellocationvalue");
    scv.value = val;
}

function handlePrint() {
    if (!validatePage())
        return;
    window.print();
}

function handlePay() {
    if (!validatePage())
        return;
    submitData();
}

function finishApplication(val) {
    hideDiv('blocker');
    hideDiv('ccinfo');
    if (val == true)
        window.location = "http://www.lakeside.edu";
}

function validatePage() {
    if (isEmpty("sellocationvalue", "value for location")) {
        document.getElementsByName("location")[0].focus();
        return false;
    }
    if (isEmpty("selclassvalue", "value for class selection")) {
        document.getElementsByName("class")[0].focus();
        return false;
    }
    if (isEmpty(s_name, "value for Full Name"))
        return false;
    if (isEmpty(s_address1, "value for Address 1"))
        return false;
    if (isEmpty(s_city, "value for City"))
        return false;
    if (getSelectFieldValue(state) == 0) {
        alert("State is a required field");
        document.getElementById(state).focus();
        return false;
    }
    if (isEmpty(s_zip, "value for Zip"))
        return false;
    if (!checkZip(s_zip, "Zip Code")) {
        document.getElementById(s_zip).focus();
        return false;
    }
    if (isEmpty(s_phone, "value for Home Phone"))
        return false;
    if (isEmpty(s_email, "value for E-mail Address"))
        return false;
    if (!isSetRadio(employment, "value for Employment"))
        return false;
    if (isEmpty(date_of_birth, "value for Date of Birth"))
        return false;
    if (isEmpty(age, "value for Age"))
        return false;
    if (!isSetRadio(gender, "value for Gender"))
        return false;
    if (!isSetRadio(veteransbenefits, "value for Veterans Benefits"))
        return false;
    return true;
}


// submit data to the credit card page.
function submitData() {
    fLocation = getFieldValue("sellocationvalue");
    fClass = getFieldValue("selclassvalue");
    fName = getFieldValue(s_name);
    fAddress1 = getFieldValue(s_address1);
    fAddress2 = getFieldValue(s_address2);
    fCity = getFieldValue(s_city);
    fState = getSelectFieldValue(state);
    fZip = getFieldValue(s_zip);
    fCellPhone = getFieldValue(s_cellphone);
    fPhone = getFieldValue(s_phone);
    //fWorkPhone = getFieldValue(s_workphone);
    fEmail = getFieldValue(s_email);
    fEmployment = getRadioFieldValue(employment);
    fOccupation = getFieldValue(occupation);
    fDOB = getFieldValue(date_of_birth);
    fAge = getFieldValue(age);
    fGender = getRadioFieldValue(gender);
    fVetBenefits = getRadioFieldValue(veteransbenefits);
    fHighSchool = getFieldValue(high_school);
    fSchoolSummary = getTinyMceFieldValue(school_summary);
    fHCLAD = getFieldValue(health_care_license_application_denied);
    fHCL = getFieldValue(health_care_litigation);
    fFelony = getFieldValue(felony);
    fHealthProbs = getFieldValue(health_problems);
    fPhysLimits = getFieldValue(physical_limitations);
    fLearnDis = getFieldValue(learning_disabilities);
    fAllergies = getFieldValue(allergies);
    fStateLicense = getFieldValue(state_license);
    fWIStateLicense = getFieldValue(wi_state_license);
    fEducationSummary = getTinyMceFieldValue(education_summary);
    fWorkSummary = getFieldValue(work_summary);
    fInterestedInCarpool = getCheckedFieldValue(interested_in_carpool);
    fNotInterestedInCarpool = getCheckedFieldValue(not_interested_in_carpool);
    fWhereHeard = getFieldValue(first_heard_of_lakeside);

    strs = "fLocation=" + escape(fLocation) + "&fClass=" + escape(fClass) +
               "&fName=" + escape(fName) + "&fAddress1=" + escape(fAddress1) +
               "&fAddress2=" + escape(fAddress2) + "&fCity=" + escape(fCity) +
               "&fState=" + escape(fState) + "&fZip=" + escape(fZip) +
               "&fPhone=" + escape(fPhone) + 
               "&fWorkPhone=" + 
               "&fEmail=" + escape(fEmail) + "&fEmployment=" + escape(fEmployment) +
               "&fOccupation=" + escape(fOccupation) + "&fDOB=" + escape(fDOB) +
               "&fAge=" + escape(fAge) + "&fGender=" + escape(fGender) +
               "&fVetBenefits=" + escape(fVetBenefits) +
               "&fHighSchool=" + escape(fHighSchool) + 
               "&fSchoolSummary=" + encodeURIComponent(fSchoolSummary) +
               "&fHCLAD=" + escape(fHCLAD) + "&fHCL=" + escape(fHCL) +
               "&fFelony=" + escape(fFelony) + "&fHealthProbs=" + escape(fHealthProbs) +
               "&fPhysLimits=" + escape(fPhysLimits) + "&fLearnDis=" + escape(fLearnDis) +
               "&fAllergies=" + escape(fAllergies) + 
               "&fCellPhone=" + escape(fCellPhone) +
               "&fWIStateLicense=" + escape(fWIStateLicense) +
               "&fStateLicense=" + escape(fStateLicense) +
               "&fEducationSummary=" + encodeURIComponent(fEducationSummary) +
               "&fWorkSummary=" + escape(fWorkSummary) +
               "&fInterestedInCarpool=" + escape(fInterestedInCarpool) +
               "&fNotInterestedInCarpool=" + escape(fNotInterestedInCarpool) +
               "&fWhereHeard=" + escape(fWhereHeard);
    showCC(strs);
}


function showCC(str) {
    /**
    getWindowSize();
        
    var h = 410, w = 440;
    var div = document.getElementById( "ccinfo" );
    var blockerdiv = document.getElementById( "blocker" );
        
    div.style.width = w + 'px';
    div.style.height = h + 'px';
        
    if( document.documentElement )
    {
    offs_top = document.documentElement.scrollTop;
    offs_left = document.documentElement.scrollLeft;
    }
    else if( document.body )
    {
    offs_top = document.body.scrollTop;
    offs_left = document.body.scrollLeft;
    }

        div.style.left = offs_left + (( wWidth - w ) / 2 ) + 'px';
    div.style.top = offs_top + (( wHeight - h ) / 2 ) + 'px';
    div.style.zIndex = 10000;
        
    blockerdiv.style.zIndex = 9999;
     
    blockerdiv.style.height = bHeight + 'px';
    blockerdiv.style.width = bWidth + 'px';
    */
    // Jump to the secure page.
    secureLoc = Lakeside.controls.learn_about_our_programs.massage_therapy_application.getSecureLocation().value;
    /*
    div.innerHTML = "<iframe width='100%' height='100%' src='" + secureLoc + "showCC.aspx?" + str + "'></iframe>";
    showDiv( "ccinfo" );
    showDiv( "blocker" );
    */

    window.open(secureLoc + "showCC.aspx?" + str, "CCInfo", "height=410,width=440,status=no,toolbar=no,menubar=no,location=no", true);
}

function validate_email(obj, value) {
    if (Lakeside.controls.learn_about_our_programs.massage_therapy_application.isEmailUsed(value).value == true) {
        alert("The e-mail address '" + value + "' is already in our database.\n" +
                   "Please use another e-mail address or contact greta@lakeside.edu");
        obj.focus();
    }
}