/**
 * Includes a Form with javascript
 * @param {Object} formId
 * @param {Object} initialHeight
 * @param {Object} iframeCode
 */
function FrameBuilder (formId, initialHeight, iframeCode){
    this.formId = formId;
    this.initialHeight = initialHeight;
    this.iframeCode = iframeCode;
    this.frame = null;
    this.timeInterval= 200;
    
    // initialize function for object
    this.init = function(){
        this.createFrame();
        this.addFrameContent(this.iframeCode);
    };
    
    // Create the frame
    this.createFrame = function(){
        var htmlCode = "<"+"iframe src=\"\" allowtransparency=\"true\" frameborder=\"0\" name=\""+this.formId+"\" id=\""+this.formId+"\" style=\"width:100%; height:"+this.initialHeight+"px; border:none;\" scrolling=\"no\"></if"+"rame>";
        document.write(htmlCode);
        // also get the frame for future use.
        this.frame = document.getElementById(this.formId);
        // set the time on the on load event of the frame
        this.addEvent (this.frame, 'load', this.bindMethod(this.setTimer, this));
    };
    
    // add event function for different browsers
    this.addEvent = function( obj, type, fn ) {
        if ( obj.attachEvent ) {
            obj["e"+type+fn] = fn;
            obj[type+fn] = function() { obj["e"+type+fn]( window.event ); };
            obj.attachEvent( "on"+type, obj[type+fn] );
        }
        else{
            obj.addEventListener( type, fn, false );   
        }
    };
    
    this.addFrameContent = function (string){
        string = string.replace(new RegExp('src\=\"[^"]*captcha.php\"><\/scr'+'ipt>', 'gim'), 'src="http://api.recaptcha.net/js/recaptcha_ajax.js"></scr'+'ipt><'+'div id="recaptcha_div"><'+'/div>'+
                '<'+'style>#recaptcha_logo{ display:none;} #recaptcha_tagline{display:none;} #recaptcha_table{border:none !important;} .recaptchatable .recaptcha_image_cell, #recaptcha_table{ background-color:transparent !important; } <'+'/style>'+
                '<'+'script defer="defer"> window.onload = function(){ Recaptcha.create("6Ld9UAgAAAAAAMon8zjt30tEZiGQZ4IIuWXLt1ky", "recaptcha_div", {theme: "clean",tabindex: 0,callback: function (){'+
                'if (document.getElementById("uword")) { document.getElementById("uword").parentNode.removeChild(document.getElementById("uword")); } if (window["validate"] !== undefined) { if (document.getElementById("recaptcha_response_field")){ document.getElementById("recaptcha_response_field").onblur = function(){ validate(document.getElementById("recaptcha_response_field"), "Required"); } } } if (document.getElementById("recaptcha_response_field")){ document.getElementsByName("recaptcha_challenge_field")[0].setAttribute("name", "anum"); } if (document.getElementById("recaptcha_response_field")){ document.getElementsByName("recaptcha_response_field")[0].setAttribute("name", "qCap"); }}})'+
                ' }<'+'/script>');
        string = string.replace(/(type="text\/javascript">)\s+(validate\(\"[^"]*"\);)/, '$1 jTime = setInterval(function(){if("validate" in window){$2clearTimeout(jTime);}}, 1000);');
        var frameDocument = (this.frame.contentWindow) ? this.frame.contentWindow : (this.frame.contentDocument.document) ? this.frame.contentDocument.document : this.frame.contentDocument;
        frameDocument.document.open();
        frameDocument.document.write(string);
        setTimeout( function(){frameDocument.document.close();},200);
    };
    
    this.setTimer = function(){
        var self = this;
        this.interval = setTimeout(function(){self.changeHeight();},this.timeInterval);
    };
    
    this.changeHeight = function (){
        var actualHeight = this.getBodyHeight();
        var currentHeight = this.getViewPortHeight();
        if(actualHeight === undefined){
            this.frame.style.height = "100%";
            this.frame.style.minHeight = "300px";
        }else if  (Math.abs(actualHeight - currentHeight) > 18){
            this.frame.style.height = (actualHeight)+"px";
        }
        this.setTimer();
    };
    
    this.bindMethod = function(method, scope) {
        return function() {
            method.apply(scope,arguments);
        };
    };
    
    this.getBodyHeight = function (){
        var height;
        var scrollHeight;
        var offsetHeight;
        try{  // Prevent IE from throw errors
            if (this.frame.contentWindow.document.height){
                
                height = this.frame.contentWindow.document.height;
                
            } else if (this.frame.contentWindow.document.body){
                
                if (this.frame.contentWindow.document.body.scrollHeight){
                    height = scrollHeight = this.frame.contentWindow.document.body.scrollHeight;
                }
                
                if (this.frame.contentWindow.document.body.offsetHeight){
                    height = offsetHeight = this.frame.contentWindow.document.body.offsetHeight;
                }
                
                if (scrollHeight && offsetHeight){
                    height = Math.max(scrollHeight, offsetHeight);
                }
            }            
        }catch(e){ }
        return height;
    };
    
    this.getViewPortHeight = function(){
        var height = 0;
        try{ // Prevent IE from throw errors
            if (this.frame.contentWindow.window.innerHeight)
            {
                height = this.frame.contentWindow.window.innerHeight - 18;
            }
            else if ((this.frame.contentWindow.document.documentElement)
                && (this.frame.contentWindow.document.documentElement.clientHeight))
            {
                height = this.frame.contentWindow.document.documentElement.clientHeight;
            }
            else if ((this.frame.contentWindow.document.body)
                && (this.frame.contentWindow.document.body.clientHeight))
            {
                height = this.frame.contentWindow.document.body.clientHeight;
            }            
        }catch(e){ }
        return height;
    };
    
    this.init();
}
FrameBuilder.get = [];
var i81863102461 = new FrameBuilder("81863102461" ,"", "<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/strict.dtd\">\n<html><head>\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/>\n<meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;\" \/>\n<meta name=\"HandheldFriendly\" content=\"true\" \/>\n<title>Form<\/title>\n<link type=\"text\/css\" rel=\"stylesheet\" href=\"https:\/\/forms.wcm.cargill.com\/php\/forms\/static\/formCss.css?undefined\"\/>\n<link type=\"text\/css\" media=\"print\" rel=\"stylesheet\" href=\"https:\/\/forms.wcm.cargill.com\/php\/forms\/css\/printForm.css?undefined\"\/>\n<style type=\"text\/css\">\n    .form-label{\n        width:150px !important;\n    }\n    .form-label-left{\n        width:150px !important;\n    }\n    .form-line{\n        padding:10px;\n    }\n    .form-label-right{\n        width:150px !important;\n    }\n    body, html{\n        margin:0;\n        padding:0;\n        background:false;\n    }\n\n    .form-all{\n        margin:0px auto;\n        padding-top:20px;\n        width:690px;\n        color:Black !important;\n        font-family:Verdana;\n        font-size:12px;\n    }\n<\/style>\n\n<style type=\"text\/css\" id=\"form-designer-style\">\n    \/* Injected CSS Code *\/\n@import url(https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/font-awesome\/4.6.3\/css\/font-awesome.css);@import url(https:\/\/cloud.typography.com\/7595216\/6135192\/css\/fonts.css);@import url(\/\/fonts.googleapis.com\/css?family=Libre+Baskerville:400i|Montserrat:400,500,700);body\n{\nmargin:0px;\nbackground: #60d1e0;\n}\n.form-header-group\n{\npadding-left:0px;\n}\n.form-line\n{\npadding:5px !important;\nwidth: 100%;\n}.form-input {\ndisplay: block;\n}\n.form-all\n{\nmax-width:100%;\nwidth: 100%;\n}\n@media screen and (max-width: 765px) {\n.form-textarea {\nwidth:100%;\n}\n}\n.form-header-group {\nbackground-color: #60d1e0;\nborder: none; }.form-header {\nfont-size: 18px;\nline-height: 1.4em;\ndisplay: none; }.form-subHeader {\nborder: none;\nfont-size: 14px;\nfont-style: normal;\nline-height: 1.4em; }.form-required {\nfont-size: 15px;\nmargin-left: -2px; }.form-error-message {\ndisplay: none; }.form-line-error {\nborder: none;\nbackground: transparent; }\n.form-line-error input:not(#coupon-input), .form-line-error select, .form-line-error textarea, .form-line-error .form-validation-error {\nbox-shadow: none; }\n.form-line-error input:not(#coupon-input):active, .form-line-error input:not(#coupon-input):focus, .form-line-error select:active, .form-line-error select:focus, .form-line-error textarea:active, .form-line-error textarea:focus, .form-line-error .form-validation-error:active, .form-line-error .form-validation-error:focus {\n}\n.form-line-error input:not(#coupon-input):hover, .form-line-error select:hover, .form-line-error textarea:hover, .form-line-error .form-validation-error:hover {\nborder: none;\nbox-shadow: 0 0 3px black; }\n.form-line-error .form-input {\nposition: relative; }\n.form-line-error .form-input::after {\ncontent: 'f00d';\ncolor: red;\nfont-size: 1.8em;\nfont-family: FontAwesome;\nheight: 20px;\nposition: absolute;\nright: -23px;\ntop: 5px;\nwidth: 20px; }.form-description {\nbackground: #d9edf8;\nborder: 2px solid #bce8f1;\nborder-radius: 0;\nbox-shadow: none;\ncolor: #317091; }\n.form-description .form-description-content {\npadding: 5px 10px;\ncolor: #317091;\nheight: 16px;\nline-height: 16px; }\n.form-description .form-description-arrow {\nborder-width: 15px;\nborder-style: solid;\nborder-color: transparent #bce8f1 transparent transparent;\nleft: -32px;\ntop: -2px;\nwidth: 0px;\nheight: 0px;\nposition: absolute; }\n.form-description .form-description-arrow-small {\nborder-width: 13px;\nborder-style: solid;\nborder-color: transparent #d9edf6 transparent transparent;\nleft: -26px;\ntop: 0px; }.form-label-left {\npadding: 10px 10px 0 0; }.form-label, .form-textbox {\nfont-size: .75rem;\nfont-weight: 300;\ncolor: #002b58;\ndisplay: block;\nfloat:none;\n}.form-sub-label-container {\ndisplay: block;\nmargin:0px;\nwidth: 49.5%;\nfloat: left;\n}.form-sub-label {\nfont-size: 11px;\npadding-left: 0;\nmargin-top: 0.25em;\ncolor: #002b58;\nfont-weight: 300;\n}.form-grading-label {\nmargin-left: 0.5em; }.form-line-column {\nwhite-space: normal;\nline-height: 1.5em; }[data-type=\"control_radio\"] input[type=\"radio\"] {\ndisplay: none; }\n[data-type=\"control_radio\"] input[type=\"radio\"] + label {\nposition: relative;\npadding: 2px 0 5px 25px;\ndisplay: inline-block; }\n[data-type=\"control_radio\"] input[type=\"radio\"] + label:before {\nbackground: #fff;\ncontent: \" \";\ndisplay: inline-block;\nheight: 13px;\nwidth: 13px;\nborder-radius: 13px;\nposition: absolute;\nleft: 3px;\ntop: 3px; }\n[data-type=\"control_radio\"] input[type=\"radio\"] + label:after {\nborder: 1px #000 solid;\ncontent: \" \";\ndisplay: inline-block;\nheight: 17px;\nwidth: 17px;\nborder-radius: 17px;\nposition: absolute;\npointer-events: none;\nleft: 0;\ntop: 0; }\n[data-type=\"control_radio\"] input[type=\"radio\"]:checked + label:before {\nbackground: #000; }input.form-textbox, select.form-dropdown {\npadding-left: 0.7em;\npadding-right: 0.25em;\nheight: 2.9em !important;\nwidth: 100%;display: block;\nborder: 1px solid #002b58 !important; }.form-textarea-limit span {\ndisplay: block;\n}input.form-textbox:link, input.form-textbox:visited, input.form-textbox:active, input.form-textbox:hover, input.form-textbox:focus, input.form-textarea:link, input.form-textarea:visited, input.form-textarea:active, input.form-textarea:hover, input.form-textarea:focus {\noutline: none; }input.form-textbox:active, input.form-textbox:focus, input.form-textarea:active, input.form-textarea:focus {\n}input.form-textbox:hover, input.form-textarea:hover {\nborder: none;\nbox-shadow: 0 0 3px black; }input[type|=\"number\"].form-textbox {\nborder: 0 !important; }input[type|=\"number\"].form-textbox.form-number-input {\nborder: 1px solid #000 !important; }\ninput[type|=\"number\"].form-textbox.form-number-input:active, input[type|=\"number\"].form-textbox.form-number-input:focus {\n}\ninput[type|=\"number\"].form-textbox.form-number-input:hover {\nborder: none;\nbox-shadow: 0 0 3px black; }.form-line {\nbackground: transparent; }table.form-textbox {\nborder: none;\noutline: none;\nbox-shadow: none; }\ntable.form-textbox:link, table.form-textbox:visited, table.form-textbox:active, table.form-textbox:hover, table.form-textbox:focus {\noutline: none;\nborder: none;\nbox-shadow: none; }[data-type=\"control_textbox\"]:not(.form-line-column) {\noverflow: hidden; }\n[data-type=\"control_textbox\"]:not(.form-line-column) .form-input {\nfloat: left; }\n[data-type=\"control_textbox\"]:not(.form-line-column) .form-description {\ndisplay: inline-block;\nleft: 40px;\nright: inherit;\ntop: 2px;\nposition: relative;\nfloat: left; }[data-type=\"control_textbox\"].form-line-column .form-description {\ntop: 35px; }.form-textarea {\nborder: 1px solid #000; }.form-checkbox-item {\nmargin: 0;\nline-height: normal; }input[type=\"checkbox\"] {\ndisplay: none; }\ninput[type=\"checkbox\"] + label {\ndisplay: inline-block;\npadding: 8px 0 8px 27px;\nposition: relative; }\ninput[type=\"checkbox\"] + label:before {\ncontent: ' ';\nborder: 1px solid #000;\ndisplay: inline-block;\nheight: 18px;\nwidth: 18px;\nposition: absolute;\nleft: 0;\ntop: 5px; }\ninput[type=\"checkbox\"]:checked + label:after {\ncontent: \"f00c\";\nfont-family: \"FontAwesome\";\nfont-size: 22px;\nposition: absolute;\nleft: -1px;\ntop: 4px; }select {\n-webkit-appearance: none;\n-moz-appearance: none;\nappearance: none;\npadding-right: 2.7em; }\nselect::-ms-expand {\ndisplay: none; }\nselect.form-dropdown {\nborder-radius: 0 !important;\nbackground: transparent;\npadding-left: 0.7em;\npadding-right: 0.7em;\nheight: 2.9em;\nborder: 1px solid #000 !important; }\nselect.form-dropdown:link, select.form-dropdown:visited, select.form-dropdown:active, select.form-dropdown:hover, select.form-dropdown:focus {\noutline: none; }\nselect.form-dropdown:hover {\nborder: none;\nbox-shadow: 0 0 3px black; }[data-type=\"control_dropdown\"] [class^=\"form-input\"] {\ndisplay: inline-block;\nposition: relative; }\n[data-type=\"control_dropdown\"] [class^=\"form-input\"]:after {\nfont-family: \"FontAwesome\";\ncontent: \"f0d7\";\nfont-size: 16px;\npointer-events: none;\nposition: absolute;\nright: 18px;\ntop: 9px; }.form-sub-label-container select.form-dropdown {\npadding-right: 1.7em; }\n.form-sub-label-container select.form-dropdown + label {\nposition: relative; }\n.form-sub-label-container select.form-dropdown + label:after {\nfont-family: \"FontAwesome\";\ncontent: \"f0d7\";\ncolor: #000;\nfont-size: 16px;\nposition: absolute;\nright: 8px;\ntop: -28px; }.form-spinner {\nborder: 1px #000 solid !important; }\n.form-spinner .form-spinner-input-td {\npadding: 0 !important; }\n.form-spinner .form-spinner-up, .form-spinner .form-spinner-down {\nborder: 1px #000 solid !important; }\n.form-spinner .form-spinner-up img, .form-spinner .form-spinner-down img {\nfloat: none;\nmargin: 0px;\npadding-right: 1px; }input[type=\"number\"] {\npadding: 0 5px !important; }table.form-spinner {\noutline: none; }.form-matrix-table tr {\npadding-left: 0.7em;\npadding-right: 0.25em;\nheight: 2.9em !important; }.form-all {\nfont-family: 'Gotham A', 'Gotham B','Montserrat', sans-serif;}.form-buttons-wrapper {\nmargin: 0px !important;\n}.form-pagebreak-next,\n.form-pagebreak-back,\n.form-submit-button,\nbutton {\nbackground-color: #002b58;\ncolor: #4dcbda;\n-webkit-appearance: none;\noutline: none;\ncursor: pointer;\nfont-size: 12px;\nfont-family: Arial, Helvetica, sans-serif;\nborder-radius: 0px;\nheight: 35px;\npadding-left: 1em;\npadding-right: 1em; }\n.form-pagebreak-next:hover,\n.form-pagebreak-back:hover,\n.form-submit-button:hover,\nbutton:hover {\n-webkit-appearance: none; }.form-pagebreak {\nbackground-color: transparent; }.form-grading-item {\nmargin-bottom: 0.5em; }input[type=\"text\"],\ninput[type=\"email\"],\ninput[type=\"search\"],\ninput[type=\"number\"],\ninput[type=\"tel\"],\ntextarea, button {\nborder: 1px solid #002b58;\nbackground: transparent;\nheight: 30px !important;\npadding: 10px;\nbox-shadow: none !important;\nfont-family: 'Libre Baskerville', serif;\nfont-weight: 300;\ndisplay: inline-block;\n-webkit-appearance: none;\nborder-radius: 0;\n}input[type=\"text\"],\ninput[type=\"email\"],\ninput[type=\"search\"],\ninput[type=\"number\"],\ninput[type=\"tel\"],\ntextarea {\nwidth: 93% !important;\n}textarea {\nheight: 100px;\n}input[type=\"text\"] {\nfont-family: $secondary-font-family;\n}\ninput[type=\"submit\"],\nbutton,\n#wpsl-search-btn {\nbackground: #002b58;\ncolor: #4dcbda;\nborder: none;\nfont-weight: 700;\nfont-size: .6875rem;\ntext-transform: uppercase !important;\npadding: 7px 20px;\nheight: 40px;\n}input::placeholder {\nfont-family: 'Libre Baskerville', serif;\ncolor: rgba(0,43,88,.65);\nopacity: .75;\n}button[type=\"submit\"] {\ndisplay: block;\nmargin: auto;\n}\nlabel {\nfont-weight: 500;\nfont-size: .75rem;\ntext-transform: uppercase;\n}\n    \/* Injected CSS Code *\/\n<\/style>\n\n<script src=\"https:\/\/forms.wcm.cargill.com\/php\/forms\/static\/prototype.forms.js\" type=\"text\/javascript\"><\/script>\n<script src=\"https:\/\/forms.wcm.cargill.com\/php\/forms\/static\/jotform.forms.js?undefined\" type=\"text\/javascript\"><\/script>\n<script type=\"text\/javascript\">\n var jsTime = setInterval(function(){try{\n   JotForm.jsForm = true;\n\n   JotForm.init(function(){\n      $('input_3').hint('myname@example.com');\n   });\n\n   clearInterval(jsTime);\n }catch(e){}}, 1000);\n<\/script>\n<\/head>\n<body>\n<form class=\"jotform-form\" action=\"https:\/\/forms.wcm.cargill.com\/php\/forms\/submit.php\" method=\"post\" name=\"form_81863102461\" id=\"81863102461\" accept-charset=\"utf-8\">\n    <input type=\"hidden\" name=\"formID\" value=\"81863102461\" \/>\n    <div class=\"form-all\">\n        <ul class=\"form-section\">\n            <li class=\"form-line\" id=\"id_6\">\n                <label class=\"form-label-left\" id=\"label_6\" for=\"input_6\"> First Name <\/label>\n                <div id=\"cid_6\" class=\"form-input\">\n                    <input type=\"text\" class=\"form-textbox\" id=\"input_6\" name=\"q6_firstName\" size=\"30\" \/>\n                <\/div>\n            <\/li>\n            <li class=\"form-line\" id=\"id_7\">\n                <label class=\"form-label-left\" id=\"label_7\" for=\"input_7\"> Last Name <\/label>\n                <div id=\"cid_7\" class=\"form-input\">\n                    <input type=\"text\" class=\"form-textbox\" id=\"input_7\" name=\"q7_lastName\" size=\"30\" \/>\n                <\/div>\n            <\/li>\n            <li class=\"form-line\" id=\"id_3\">\n                <label class=\"form-label-left\" id=\"label_3\" for=\"input_3\"> Email <\/label>\n                <div id=\"cid_3\" class=\"form-input\">\n                    <input type=\"email\" class=\"form-textbox validate[Email]\" id=\"input_3\" name=\"q3_email\" size=\"30\" \/>\n                <\/div>\n            <\/li>\n            <li class=\"form-line\" id=\"id_4\">\n                <label class=\"form-label-left\" id=\"label_4\" for=\"input_4\"> Zip Code <\/label>\n                <div id=\"cid_4\" class=\"form-input\">\n                    <input type=\"text\" class=\"form-textbox validate[AlphaNumeric]\" id=\"input_4\" name=\"q4_zipCode\" size=\"30\" \/>\n                <\/div>\n            <\/li>\n            <li class=\"form-line\" id=\"id_5\">\n                <label class=\"form-label-left\" id=\"label_5\" for=\"input_5\"> Comments <\/label>\n                <div id=\"cid_5\" class=\"form-input\">\n                    <textarea id=\"input_5\" class=\"form-textarea\" name=\"q5_comments\" cols=\"40\" rows=\"6\"><\/textarea>\n                <\/div>\n            <\/li>\n            <li class=\"form-line\" id=\"id_2\">\n                <div id=\"cid_2\" class=\"form-input-wide\">\n                    <div style=\"margin-left:156px\" class=\"form-buttons-wrapper\">\n                        <button id=\"input_2\" type=\"submit\" class=\"form-submit-button\">\n                            Submit\n                        <\/button>\n                    <\/div>\n                <\/div>\n            <\/li>\n            <li style=\"display:none\">\n                Should be Empty:\n                <input type=\"text\" name=\"website\" value=\"\" \/>\n            <\/li>\n        <\/ul>\n    <\/div>\n    <input type=\"hidden\" id=\"simple_spc\" name=\"simple_spc\" value=\"81863102461\" \/>\n    <script type=\"text\/javascript\">\n        document.getElementById(\"si\" + \"mple\" + \"_spc\").value = \"81863102461-81863102461\";\n    <\/script>\n    <input type=\"hidden\" class=\"form-hidden\" value=\"ProElite\" id=\"input_8\" name=\"q8_clickTo\" \/>\n    <input type=\"hidden\" class=\"form-hidden\" value=\"proelitecontactus\" id=\"input_9\" name=\"q9_clickTo9\" \/>\n<\/form><\/body>\n<\/html>\n");
