/*jslint nomen:false, debug:true, evil:true, vars:false, browser:true, forin:true, undef:false, white:false */ /** * Includes a Form with javascript * @param {Object} formId * @param {Object} initialHeight * @param {Object} iframeCode */ function FrameBuilder (formId, appendTo, initialHeight, iframeCode){ this.formId = formId; this.initialHeight = initialHeight; this.iframeCode = iframeCode; this.frame = null; this.timeInterval= 200; this.appendTo = appendTo || false; this.formSubmitted = 0; // initialize function for object this.init = function(){ this.createFrame(); this.addFrameContent(this.iframeCode); }; // Create the frame // Create the frame this.createFrame = function(){ var tmp_is_ie = !!window.ActiveXObject; //IE detection 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(this.appendTo === false){ document.write(htmlCode); }else{ var tmp = document.createElement('div'); tmp.innerHTML = htmlCode; var a = this.appendTo; document.getElementById(a).appendChild(tmp.firstChild); //var form = document.getElementById() } // also get the frame for future use. this.frame = document.getElementById(this.formId); //correct fix to IE security bugfix if(tmp_is_ie === true){ try { //check for security bug ahead! If bug occurs then parent frame's document.domain was set, if it does not then do not apply fix!!! var tmptmptmp = (this.frame.contentWindow) ? this.frame.contentWindow : (this.frame.contentDocument.document) ? this.frame.contentDocument.document : this.frame.contentDocument; tmptmptmp.document.open(); tmptmptmp.document.write(""); } catch (err) { this.frame.src= "javascript:void((function(){document.open();document.domain=\'"+ window.location.hostname.replace('www.', '')+"\';document.close();})())"; } } // set the time on the on load event of the frame this.addEvent(this.frame, 'load', this.bindMethod(this.setTimer, this)); var self = this; //on chrome to suppress unsafe attempt error this codes break setHeight-time interval loop if(window.chrome!==undefined){ this.frame.onload = function(){ try{ var doc = this.contentWindow.document; var _jotform = this.contentWindow.JotForm; if(doc!==undefined){ var form = doc.getElementById(""+self.formId); self.addEvent(form, "submit", function(){ if(_jotform.validateAll()){ self.formSubmitted=1; } }); } } catch(e){ } } } }; // 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"><'+'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(); try{ if('JotFormFrameLoaded' in window){ JotFormFrameLoaded(); } }catch(e){} },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%"; if(!this.frame.style.minHeight){ 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 (){ if(this.formSubmitted===1){ return; } var height; var scrollHeight; var offsetHeight; try{ // Prevent IE from throw errors if (this.frame.contentWindow.document.height){ height = this.frame.contentWindow.document.height; //Emre: to prevent "iframe height" problem (61059) 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; } } 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(){ if(this.formSubmitted===1){ return; } 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 i23463562342350 = new FrameBuilder("23463562342350", false, "", "\n
\n\n\n\n