(function() { var config = { scriptPath: '/embedjs/555b835861646d0672070000/video/5786bbc2776f721430000a20.js?autoplay=1', playerBaseUrl: '//player-backend.cnevids.com', embedPath: '/embed/5786bbc2776f721430000a20/555b835861646d0672070000' }; var embedLoader = { // Check for Head Parent // // Performs a check to ensure the script tag is located within // the source page's document body and not within its head. checkForHeadParent: function(element) { var elementParent, headFound; headFound = false; elementParent = element.parentNode; while (elementParent.tagName.toUpperCase() !== 'HTML') { headFound = elementParent.tagName.toUpperCase() === 'HEAD'; if (headFound) { break; } elementParent = elementParent.parentNode; } if (headFound) { throw 'EmbedLoaderError: Script tag found in head. Tag must be in doucment body.'; } return headFound; }, // Find and Insert findAndInsert: function(embedCode, iframePayload) { var iframe, queries, scriptTag; scriptTag = this.findMyself(); this.checkForHeadParent(scriptTag); scriptTag.parentNode.insertBefore(embedCode, scriptTag.nextSibling); embedCode.className += ' cne-player-container' embedCode.className = embedCode.className.trim(); queries = config.scriptPath.split('?')[1]; if ( typeof queries !== 'undefined' ) { queriesArray = queries.split('&'); for (var i = 0, len = queriesArray.length; i < len; i++) { splitQuery = queriesArray[i].split('='); splitQuery[0] = splitQuery[0].replace(/-([\da-z])/gi, function(match, letter) { return (letter).toUpperCase(); }); embedCode.dataset[splitQuery[0]] = splitQuery[1]; } } iframe = embedCode.getElementsByTagName('iframe')[0]; try { // Try writing the iframe payload directly from the string... var doc = iframe.contentDocument; doc.open(); doc.write(iframePayload); doc.close(); } catch(e) { // ... otherwise, we have no choice but to hit the server again. // This method is used in IE9/10. iframe.src = config.playerBaseUrl + config.embedPath } }, // Find Myself // // Locates