function onLoadAdLaunchBarrier() {
onLoadBarrier--;
if (onLoadBarrier <= 0) launchAd();
}

function importScripts(scripts) {
onLoadBarrier = scripts.length + 1;  //  +1 because window.onload also uses the launch barrier.
if (scripts.length == 0) return;
mbrixAppendNewScript.apply(window, scripts[0]);
}

function mbrixAppendNewScript(src, id){
var script = document.createElement("script");
script.id = id;
script.src = src;
script.onload = function() {
scripts.splice(0,1);
if (scripts.length > 0) mbrixAppendNewScript.apply(window, scripts[0]);
onLoadAdLaunchBarrier();
}
var head = document.getElementsByTagName("head")[0];
head.appendChild(script);
}

var scripts = [];

scripts.push(["http://mediabrix.vo.llnwd.net/o38/mobile/mjs/jquery.min.js", "jquery"]);
if (os != 'windows phone') scripts.push(["http://mediabrix.vo.llnwd.net/o38/mobile/js/mdos_mobile.js", "mdos_mobile"]);
scripts.push(["http://www.mediabrix.com/dev/ads/js/bridge_mobile-1.5.8.js", "bridge_mobile"]);
if (os != 'windows phone') scripts.push(["http://mediabrix.vo.llnwd.net/o38/mobile/js/facebook_mobile.js","facebook_mobile"]);
scripts.push(["http://mediabrix.vo.llnwd.net/o38/rewards/mobile/js/CSSPlugin.min.js", "cssplugin"]);
scripts.push(["http://mediabrix.vo.llnwd.net/o38/rewards/mobile/js/TweenLite.min.js", "tweenlite"]);
scripts.push(["http://mediabrix.vo.llnwd.net/o38/mobile/js/mediabrix_mobile.js", "mediabrix_mobile"]);

importScripts(scripts);