﻿// doExternalPost:for form post to aweber, infusion
function doExternalPost(targetUrl, theForm) {
    theForm.__VIEWSTATE.value = "";
    theForm.encoding = "application/x-www-form-urlencoded";
    theForm.action = targetUrl;
    theForm.target = '_new';
    theForm.submit();
}
//end external post function

//doExternalPostWithTarget:for form post to aweber, infusion
function doExternalPostWithTarget(targetUrl, theForm, target) {
    theForm.__VIEWSTATE.value = "";
    theForm.encoding = "application/x-www-form-urlencoded";
    theForm.action = targetUrl;
    theForm.target = target;
    theForm.submit();
}
//end external post function

// doExternalPostWithTargetVS:for form post to aweber, infusion
function doExternalPostWithTargetVS(targetUrl, theForm, target) {
    theForm.encoding = "application/x-www-form-urlencoded";
    theForm.action = targetUrl;
    theForm.target = target;
    theForm.submit();
}
//end external post function

// doExternalPostWithTargetPurl:for form post to aweber, infusion
function doExternalPostWithTargetPurl(targetUrl, theForm, target, arNameField, arEmailField, extDomain, arRedirectId) {
    theForm.__VIEWSTATE.value = "";
    theForm.encoding = "application/x-www-form-urlencoded";
    theForm.action = targetUrl;
    theForm.target = target;

    if (extDomain == true) {
        //external domain cant use cookies so...
        //external domain so set the querystring of the
        //redirect hidden field and we use that to get the
        //name and email purl data
        document.getElementById(arRedirectId).value = document.getElementById(arRedirectId).value + '?fname=' + document.getElementById(arNameField).value + '&email=' + document.getElementById(arEmailField).value;
    }
    else {
        //siteBOSS domain so use cookies
        document.cookie = "arName=" + document.getElementById(arNameField).value;
        document.cookie = "arEmail=" + document.getElementById(arEmailField).value;
    }
    theForm.submit();
}
//end external post function

// for form post to 1shoppingCart with getSurveyAnswers()
function doExternalPostSurvey(targetUrl, theForm) {
    if (validateSurvey() == true) {
        theForm.__VIEWSTATE.value = "";
        theForm.encoding = "application/x-www-form-urlencoded";
        theForm.action = targetUrl;
        theForm.target = '_new';
        document.getElementById('field10').value = document.getElementById('field10').value + "\r\n\r\n" + document.getElementById('WHY').value + "\r\n\r\n" + document.getElementById('DELIGHT').value;
        theForm.submit();
        document.getElementById('field10').value = "";
        document.getElementById('WHY').value = "";
        document.getElementById('DELIGHT').value = "";
        return true;
    }
    return false;
}

function validateSurvey() {
    if (document.getElementById('field10').value.length == 0) {
        alert("Please enter all required data...");
        return false;
    }

    if (document.getElementById('WHY').value.length == 0) {
        alert("Please enter all required data...");
        return false;
    }

    if (document.getElementById('DELIGHT').value.length == 0) {
        alert("Please enter all required data...");
        return false;
    }
    return true;
}
//end survey function
