if (typeof window.vs_get_rnd_num === 'undefined') { window.vs_get_rnd_num = function() { return Math.floor(Math.random()*(1000000-1+1)+1); } } var vs_widget_width = '500px'; var vs_hash = window.location.hash; var vs_ref = encodeURIComponent(document.referrer); var vs_rnd_num = vs_get_rnd_num(); var vs_default_email = ''; var vs_default_fname = ''; var vs_default_lname = ''; var vs_default_phone = ''; if (typeof vs_email!='undefined') { vs_default_email = vs_email; } if (typeof vs_first_name!='undefined') { vs_default_fname = vs_first_name; } if (typeof vs_last_name!='undefined') { vs_default_lname = vs_last_name; } if (typeof vs_phone!='undefined') { vs_default_phone = vs_phone; } function vs_scroll_to(eleID) { var sp = document.documentElement.scrollTop || document.body.scrollTop; var e = document.getElementById(eleID); var st = e.scrollTop; if (sp<=st) { return false; } if (!!e && e.scrollIntoView) { e.scrollIntoView(); } } document.write(''); var vs_get_distance = function ( elem ) { var location = 0; if (elem.offsetParent) { do { location += elem.offsetTop; elem = elem.offsetParent; } while (elem); } return location >= 0 ? location : 0; }; function vs_in_iframe() { try { return window.self !== window.top; } catch (e) { return true; } } document.addEventListener('scroll', function (event) { if (vs_in_iframe()) { var top = 0; var location = 0; } else { var doc = document.documentElement, body = document.body; var top = (doc && doc.scrollTop || body && body.scrollTop || 0); var elem = document.querySelector('#vs_widget_frame_vs_38462_' + vs_rnd_num); var location = vs_get_distance( elem ); } var json = {"parent_top": top, "parent_position": location}; if (elem!=null) elem.contentWindow.postMessage(json, "*"); }); var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent"; var eventer = window[eventMethod]; var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message"; eventer(messageEvent, function (e) { if( e.origin == 'https://app.viralsweep.com' || e.origin == 'http://app.viralsweep.com') { var obj = e.data; if(obj !== null && typeof obj === 'object') { if(("height" in obj) && ("id" in obj) && ("rnd" in obj)) { var h = obj.height; var code_id = obj.id; var rnd = obj.rnd var frame_id = 'vs_widget_frame_vs_'+code_id+'_'+rnd; var el = document.getElementById(frame_id); if (typeof(el) != 'undefined' && el != null) { el.style.height = h; } } if(("entry" in obj) && ("id" in obj) && ("rnd" in obj)) { var code_id = obj.id; var rnd = obj.rnd var frame_id = 'vs_widget_frame_vs_'+code_id+'_'+rnd; vs_scroll_to(frame_id); } } } // Do whatever you want to do with the data got from IFrame in Parent form. }, false);