var lb_scriptTagForm = true; // Flag used to check from other js files whether this is a script tag form
var lb_headTag = document.getElementsByTagName("head")[0];
var lb_scriptTag = document.getElementById("LB_FormTag");
var lb_parentNode = lb_scriptTag.parentNode; // Container element for the form

// Function to build HTML elements to add to the DOM
function buildTag(tagObject)
{
     var element;
     if( tagObject.tag ) element = document.createElement(tagObject.tag);
     for (pty in tagObject)
     {
            element[pty] = tagObject[pty];
     } 
     return element;
}

// Function to add HTML elements to the DOM
function addTag(element, p)
{
    p.appendChild(element);
}

var lb_formBuilderURL = "https://forms.leadbay.co.uk/scripttag/scripttag.aspx?"
lb_formBuilderURL += 'formType=' + ((typeof(lb_formType) == 'undefined')?'':lb_formType);
lb_formBuilderURL += '&qs=' + ((typeof(lb_formPrefillQueryStringParameters) == 'undefined')?'':'true');
lb_formBuilderURL += ((typeof(lb_affiliateId) == lb_affiliateId)?'':'&aid=' + lb_affiliateId);

addTag(buildTag({tag: 'script', type: 'text/javascript', src: lb_formBuilderURL}), lb_parentNode);
