if(typeof(jQuery) != 'undefined') { var gvPlug = new function() { this.written = false; this.elExists = true; this.jQuery = 0; this.wH = false; this.criteria = 1; this.check = function() { if(!this.written && this.elExists) { var $gvEl = $('.adunit.video'); if($gvEl.length) { if(!this.wH) { this.wH = $(window).height(); } var gr = $gvEl[0].getBoundingClientRect(); switch(this.criteria) { case 1: // almost-there: loads player when it is 300px or less away from becoming visible. if($('document').scrollTop() > (gr.top - this.wH - 300)) { this.write($gvEl); } break; default: case 2: // entirely visible: loads player when its entire bounding box is within the browser window. if(gr.bottom < this.wH) { this.write($gvEl); } break; } } else { this.elExists = false; } } } this.write = function(el) { this.written = true; var jsonMessage = { action: 'start', height: '377px', width: '724px', id: '846398711344853744413187' }; $('.adunit.video iframe')[0].contentWindow.postMessage(JSON.stringify(jsonMessage), '*'); /* var i = document.createElement("iframe"); i.style.height = '377px'; i.style.width = '724px'; i.style.position = 'absolute'; i.style.visibility = 'visible'; i.style.top = '0'; i.style.left = '0'; i.style.backgroundColor = '#000000'; i.scrolling = 'no'; i.style.border = '0 none'; i.src = 'http://www.start.no/includes/ads/goViral/go.php?p=superboard'; el.appendChild(i); jQuery(el).fadeIn(3000); */ } } jQuery(document).ready(function(){ //jQuery(window).scroll(function(){gvPlug.check();}); // loads from jquery.dfp.js when all ads are loaded }); }