/*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 iframe = this.frame; var doc = iframe.contentDocument ? iframe.contentDocument : (iframe.contentWindow.document || iframe.document); doc.open(); doc.write(""); } catch (err) { this.frame.src= "javascript:void((function(){document.open();document.domain=\'"+ this.getBaseDomain()+"\';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\"><\ cr'+'ipt="">', 'gim'), 'src="http://api.recaptcha.net/js/recaptcha_ajax.js"><'+'div id="recaptcha_div"><'+' iv="">'+ '<'+'style>#recaptcha_logo{ display:none;} #recaptcha_tagline{display:none;} #recaptcha_table{border:none !important;} .recaptchatable .recaptcha_image_cell, #recaptcha_table{ background-color:transparent !important; } <'+' tyle="">'+ '<'+'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"); }}})'+ ' }<'+' cript="">'); string = string.replace(/(type="text\/javascript">)\s+(validate\(\"[^"]*"\);)/, '$1 jTime = setInterval(function(){if("validate" in window){$2clearTimeout(jTime);}}, 1000);'); var iframe = this.frame; var doc = iframe.contentDocument ? iframe.contentDocument : (iframe.contentWindow.document || iframe.document); doc.open(); doc.write(string); setTimeout( function(){ doc.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.getBaseDomain = function(){ var thn = window.location.hostname; var cc = 0; var buff = ""; for(var i=0; i< thn.length;i++){="" var="" chr="thn.charAt(i);" if(chr="=" "."){="" cc++;="" }="" if(cc="=" 0){="" buff+="chr;" }="" }="" if(cc="=" 2){="" thn="thn.replace(buff+".","");" }="" return="" thn;="" }="" this.changeheight="function" (){="" var="" actualheight="this.getBodyHeight();" var="" currentheight="this.getViewPortHeight();" if(actualheight="==" undefined){="" this.frame.style.height="this.frameHeight;" 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.frameHeight = 0; 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){ } this.frameHeight = height; 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 i20955429037356 = new FrameBuilder("20955429037356", false, "", "\n
\n\n\n\n