// Init js object
var FPWebForm = new Object();
FPWebForm.sc2 = null;
FPWebForm.scwebform = null;
FPWebForm.ifr = null;
FPWebForm.hasData = false;
FPWebForm.url = 'http://www.futurespress.net/webform/Render.aspx?id=';
//FPWebForm.url = 'http://localhost/FPCorporateSite/webform/Render.aspx?id=';

FPWebForm.sourceType = '';
FPWebForm.verifyLeads = '';
FPWebForm.affiliateId = '';
FPWebForm.teaser = '';
FPWebForm.market = '';
FPWebForm.commodity = '';
FPWebForm.title = '';
FPWebForm.titleColor = '';
FPWebForm.teaserColor = '';
FPWebForm.borderColor = '';
FPWebForm.backgroundColor = '';
FPWebForm.imageUrl = '';

FPWebForm.loadJQueryInteralId = 2;

FPWebForm.call = function(ws) {
    // Remove tag script scriptData
    if (this.sc2)
        this.sc2.parentNode.removeChild(this.sc2);   
    this.sc2 = document.createElement('SCRIPT');
    this.sc2.id = 'sc2';
    this.sc2.type = 'text/javascript';
    this.sc2.src = ws;

    // Append script tag
    try {
        document.getElementsByTagName('head')[0].appendChild(this.sc2);
    }
    catch (ex) {
        document.body.appendChild(this.sc2);
    }
}
FPWebForm.runScript = function() {
    this.loadJQueryInteralId = setInterval("FPWebForm.includeScript()", 200);
}
FPWebForm.includeScript = function() {
    document.getElementById('FP_WebForm_SourceType').value = FPWebForm.sourceType;
    document.getElementById('FP_WebForm_VerifyLeads').value = FPWebForm.verifyLeads;

    if (FPWebForm.getHexOrDefault(FP_WebForm_CustomBorderColor, FPWebForm.borderColor) != '') {
        document.getElementById('FP_WebForm_Container').style.border = 'solid 2px ' + FPWebForm.getHexOrDefault(FP_WebForm_CustomBorderColor, FPWebForm.borderColor);
    }

    document.getElementById('FP_WebForm_Container').style.backgroundColor = FPWebForm.getHexOrDefault(FP_WebForm_CustomBackgroundColor, FPWebForm.backgroundColor);

    if (FPWebForm.imageUrl != '') {
        document.getElementById('FP_WebForm_ImageUrl').src = FPWebForm.imageUrl;
        document.getElementById('FP_WebForm_ImageUrl').style.display = 'block';
    }
    var customStr = '';

    document.getElementById('FP_WebForm_Title').innerHTML = FPWebForm.title;
    document.getElementById('FP_WebForm_Title').style.color = FPWebForm.getHexOrDefault(FP_WebForm_CustomTitleColor, FPWebForm.titleColor);
    document.getElementById('FP_WebForm_Teaser').innerHTML = FPWebForm.teaser;
    document.getElementById('FP_WebForm_Teaser').style.color = FPWebForm.getHexOrDefault(FP_WebForm_CustomTeaserColor, FPWebForm.teaserColor);

    document.forms['fp_webform_frminfs'].Contact0Company.value = FPWebForm.market;
    document.forms['fp_webform_frminfs'].Contact0JobTitle.value = FPWebForm.commodity;
    document.forms['fp_webform_frminfs'].Contact0AffiliateID.value = FPWebForm.affiliateId;

    FPWebForm.hasData = true;
    clearInterval(this.loadJQueryInteralId);
}
FPWebForm.getHexOrDefault = function(hexColor, defaultColor) {
    if (hexColor.indexOf('#') != 0) hexColor = '#' + hexColor;
    return (FP_WebForm_CustomColors && hexColor.match('^#[a-fA-F0-9]{6}$')) ? hexColor : defaultColor;
}

FPWebForm.renderForm = function() {
    // attach stylesheet
    var styleBasic = document.createElement('LINK');
    styleBasic.type = 'text/css';
    styleBasic.rel = 'stylesheet';
    styleBasic.href = 'http://www.futurespress.net/webform/basic.css';
//    styleBasic.href = 'http://localhost/FPCorporateSite/webform/basic.css';

    // Attach basic.css tag
    try {
        document.getElementsByTagName('head')[0].appendChild(styleBasic);
    }
    catch (ex) {
        document.body.appendChild(styleBasic);
    }

    // append web form
    var html = '<div id="FP_WebForm_Container" class="fp_webform">\
                    <div class="fp_webform_imageurl" align="center"><img id="FP_WebForm_ImageUrl" alt="" style="display:none;"/></div>\
                    <div class="fp_webform_title">\
                        <b id="FP_WebForm_Title"></b>\
                        <div style="height: 1px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>\
                    </div>\
                    <div class="fp_webform_teaser"><span id="FP_WebForm_Teaser"></span></div>\
                    <div style="padding-bottom: 7px; padding-left: 7px; padding-right: 7px; padding-top: 7px; color:red;" id="sperr" class="errmsg"></div>\
                    <form id="fp_webform_frminfs" onsubmit="return l_validateForm();" method="post" name="frmleftsignup2" action="https://dynamic.infusionsoft.com/AddForms/processForm.jsp">\
                        <input id="formid" value="287" type="hidden" name="formid"/>\
                        <input id="type" value="CustomFormWeb" type="hidden" name="type"/>\
                        \
                        <div class="fp_webform_fields">\
                            <table style="border-collapse: collapse" border="0" cellspacing="0" cellpadding="3">\
                                <tbody>\
                                    <tr>\
                                        <td>\
                                            <input name="Contact0FirstName" type="text" value="First Name:*" />\
                                        </td>\
                                    </tr>\
                                    <tr>\
                                        <td>\
                                            <input name="Contact0LastName" type="text" value="Last Name:*" />\
                                        </td>\
                                    </tr>\
                                    <tr>\
                                        <td>\
                                            <input name="Contact0Email" id="sgnEmail" type="text" value="Email:*" />\
                                        </td>\
                                    </tr>\
                                    <tr>\
                                        <td>\
                                            <input name="Contact0Phone1" id="fonenb" type="text" value="Daytime Phone:*" />\
                                        </td>\
                                    </tr>\
                                    <tr>\
                                        <td class="fp_webform_fields_btn">\
                                            <input type="submit" value="Submit" />\
                                        </td>\
                                    </tr>\
                                </tbody>\
                            </table>\
                        </div>\
                        <input value="" type="hidden" name="Contact0_ipaddress" />\
                        <input value="" type="hidden" name="Contact0_ipbrowser" />\
                        <input value="" type="hidden" name="Contact0_ipreferrerurl" />\
                        <input value="" type="hidden" name="Contact0_IpState" />\
                        <input value="" type="hidden" name="Contact0_IPCity" />\
                        <input value="" type="hidden" name="Contact0_ipcountry" />\
                        <input value="" type="hidden" name="Contact0_ipinternetprovider" />\
                        \
                        <input id="FP_WebForm_SourceType" value="" type="hidden" name="Contact0_SourceType"/>\
                        <input id="FP_WebForm_VerifyLeads" value="" type="hidden" name="Contact0_VerifyLeads"/>\
                        \
                        <input name="Contact0Country" type="hidden" />\
                        <input name="Contact0State" type="hidden" />\
                        \
                        <input name="Contact0Company" type="hidden" />\
                        <input name="Contact0JobTitle" type="hidden" />\
                        <input name="Contact0AffiliateID" type="hidden" />\
                    </form>\
                    <script type="text/javascript" src="http://www.futurespress.net/webform/funcs.js"></script>\
                </div>';
    //<script id="DWSIpDetail" formId="fp_webform_frminfs" type="text/javascript" src="http://76.12.3.132/IP_Tracking/App_Resource/DWSIpDetail.js"></script>\
    //<script type="text/javascript" src="http://localhost:18826/FPCorporateSite/webform/funcs.js"></script>\
    document.open();
    document.write(html);
    document.close();
}

FPWebForm.execute = function() {
    // On Loading...
    var ws = this.url + FP_WebForm_Id + '&rand=' + Math.random();
    if (typeof FP_WebForm_AffCode != 'undefined')
        ws += '&AffCode=' + FP_WebForm_AffCode;
    this.call(ws);
}
FPWebForm.callBack = function() {
    FPWebForm.runScript();
}

FPWebForm.renderForm();
FPWebForm.execute();

