var isIE=(navigator.appVersion.indexOf("MSIE")!=-1)?true:false;var isWin=(navigator.appVersion.toLowerCase().indexOf("win")!=-1)?true:false;var isOpera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;function SC_ControlVersion(){var version;var axo;var e;try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");version=axo.GetVariable("$version")}catch(e){}if(!version){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version="WIN 6,0,21,0";axo.AllowScriptAccess="always";version=axo.GetVariable("$version")}catch(e){}}if(!version){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");version=axo.GetVariable("$version")}catch(e){}}if(!version){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");version="WIN 3,0,18,0"}catch(e){}}if(!version){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");version="WIN 2,0,0,11"}catch(e){version=-1}}return version}function SC_GetSwfVer(){var flashVer=-1;if(navigator.plugins!=null&&navigator.plugins.length>0){if(navigator.plugins["Shockwave Flash 2.0"]||navigator.plugins["Shockwave Flash"]){var swVer2=navigator.plugins["Shockwave Flash 2.0"]?" 2.0":"";var flashDescription=navigator.plugins["Shockwave Flash"+swVer2].description;var descArray=flashDescription.split(" ");var tempArrayMajor=descArray[2].split(".");var versionMajor=tempArrayMajor[0];var versionMinor=tempArrayMajor[1];var versionRevision=descArray[3];if(versionRevision==""){versionRevision=descArray[4]}if(versionRevision[0]=="d"){versionRevision=versionRevision.substring(1)}else if(versionRevision[0]=="r"){versionRevision=versionRevision.substring(1);if(versionRevision.indexOf("d")>0){versionRevision=versionRevision.substring(0,versionRevision.indexOf("d"))}}var flashVer=versionMajor+"."+versionMinor+"."+versionRevision}}else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.6")!=-1)flashVer=4;else if(navigator.userAgent.toLowerCase().indexOf("webtv/2.5")!=-1)flashVer=3;else if(navigator.userAgent.toLowerCase().indexOf("webtv")!=-1)flashVer=2;else if(isIE&&isWin&&!isOpera){flashVer=SC_ControlVersion()}return flashVer}function SC_DetectFlashVer(reqMajorVer,reqMinorVer,reqRevision){versionStr=SC_GetSwfVer();if(versionStr==-1){return false}else if(versionStr!=0){if(isIE&&isWin&&!isOpera){tempArray=versionStr.split(" ");tempString=tempArray[1];versionArray=tempString.split(",")}else{versionArray=versionStr.split(".")}var versionMajor=versionArray[0];var versionMinor=versionArray[1];var versionRevision=versionArray[2];if(versionMajor>parseFloat(reqMajorVer)){return true}else if(versionMajor==parseFloat(reqMajorVer)){if(versionMinor>parseFloat(reqMinorVer))return true;else if(versionMinor==parseFloat(reqMinorVer)){if(versionRevision>=parseFloat(reqRevision))return true}}return false}}
var hasFlash = SC_DetectFlashVer(9, 0, 0);
var objectHTML;
if( hasFlash) {
  objectHTML = ("<script type=\"text/javascript\">\n  var url = \"http://analytics.spongecell.com/widgets/138493?action_type=JS_IMPRESSION\";\n  url = url + \"&placement_id=\" + ((window.spongecellParams || {}).placementId || \'\');\n  url = url + \"&anticache=\" + new Date().getTime();\n  if(window.spongecellParams && !window.spongecellParams.trackingDisabled) {\n  document.write(\"<div style=\\\"position:absolute;left:0px;top:0px;visibility: hidden;\\\">\");\n  document.write(\"<img width=\\\"0\\\" height=\\\"0\\\" style=\\\"width:0px;height:0px;\\\" alt=\\\"\\\" src=\\\"\" + url + \"\\\"/>\");\n  document.write(\"</div>\");\n  }\n</script>\n<script type=\"text/javascript\">\n  window.spongecellParams = window.spongecellParams || {};\n  if(window.spongecellParams && !window.spongecellParams.trackingDisabled && window.spongecellParams.trackingPixel && window.spongecellParams.trackingPixel.toLowerCase().indexOf(\'http\')==0 && window.spongecellParams.trackingPixel != \'SPONGECELL_TRACKING_PIXEL\') {\n  document.write(\"<div style=\\\"position:absolute;left:0px;top:0px;visibility: hidden;\\\">\");\n  document.write(\"<img width=\\\"0\\\" height=\\\"0\\\" style=\\\"width:0px;height:0px;\\\" alt=\\\"\\\" src=\\\"\" + ((window.spongecellParams || {}).trackingPixel || \'\').replace(\'[rand]\',Math.floor(Math.random()*100000000)).replace(\'[timestamp]\',new Date().getTime()) + \"\\\"/>\");\n  document.write(\"</div>\");\n  }\n</script>\n<div style=\"text-align:center; width: 300px; height: 250px; display:inline;\">\n  <object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" height=\"250\" id=\"spongecellWidget138493\" width=\"300\">\n    <param name=\"movie\" value=\"http://%widget_resource_host%/ministryofsound/summer/v2q/bin/RectangleGrid.swf?%anticache%\" />\n    <param name=\"flashvars\" value=\"%tracking_disabled%placementId=%placement%&amp;%cdn_disabled%clickthroughUrl=http%3A%2F%2Fwww.ministryofsound.com%2Fmagazine%2Fsummersessions.aspx%3Fns_campaign%3Ddigital_summer_sessions%26ns_mchannel%3Ddisplay%26ns_source%3Ddigital%26ns_linkname%3Dsummer_sessions_dl%26ns_fee%3D1&amp;actionsType=Rectangle&amp;hostBaseUrl=spongecell.com&amp;creativeSwfUrl=..%2Fassets%2F300x250.swf&amp;subMenuType=Pop&amp;menuType=Grid&amp;widgetId=138493&amp;trackImpressions=0&amp;menuSkin=Gradient&amp;linkPrefixDecoded=SPONGECELL_CLICK_TAG&amp;%click_tag_multi%\" />\n    <param name=\"allowScriptAccess\" value=\"always\" />\n    <param name=\"allowNetworking\" value=\"all\" />\n    <param name=\"allowFullScreen\" value=\"true\" />\n    <param name=\"wmode\" value=\"opaque\" />\n    <param name=\"quality\" value=\"high\" />\n    <param name=\"salign\" value=\"tl\" />\n    <param name=\"base\" value=\".\" />\n    <!--[if !IE]>-->\n    <object allowFullScreen=\"true\" allowNetworking=\"all\" allowScriptAccess=\"always\" base=\".\" data=\"http://%widget_resource_host%/ministryofsound/summer/v2q/bin/RectangleGrid.swf?%anticache%%tracking_disabled%placementId=%placement%&amp;%cdn_disabled%clickthroughUrl=http%3A%2F%2Fwww.ministryofsound.com%2Fmagazine%2Fsummersessions.aspx%3Fns_campaign%3Ddigital_summer_sessions%26ns_mchannel%3Ddisplay%26ns_source%3Ddigital%26ns_linkname%3Dsummer_sessions_dl%26ns_fee%3D1&amp;actionsType=Rectangle&amp;hostBaseUrl=spongecell.com&amp;creativeSwfUrl=..%2Fassets%2F300x250.swf&amp;subMenuType=Pop&amp;menuType=Grid&amp;widgetId=138493&amp;trackImpressions=0&amp;menuSkin=Gradient&amp;linkPrefixDecoded=SPONGECELL_CLICK_TAG&amp;%click_tag_multi%\" height=\"250\" quality=\"high\" salign=\"tl\" type=\"application/x-shockwave-flash\" width=\"300\" wmode=\"opaque\">\n      <!--<![endif]-->\n      <p>Please Install Flash Player</p>\n      <!--[if !IE]>-->\n    </object>\n    <!--<![endif]-->\n  </object>\n</div>\n");
} else {
  objectHTML = "\074p\076Please Install Flash Player\074/p\076\n\074div style=\"position:absolute;left:0px;top:0px;visibility: hidden;\"\076\n  \074img alt=\"\" height=\"0\" src=\"http://analytics.spongecell.com/widgets/138493?action_type=JS_IMPRESSION&amp;anticache=[rand]&amp;noflash=true&amp;placement_id=%placement%\" style=\"width:0px;height:0px;\" width=\"0\" /\076\n\074/div\076\n";
}
function spongecellIsHttp(s) { return s && s.toLowerCase().indexOf('http') == 0; }
// If the spongecellClickTag is real URL, replace the linkPrefixDecoded value
var spongecellClickTag = window.spongecellClickTag || '';
var spongecellParams = window.spongecellParams || {};
spongecellParams.clickTag = spongecellParams.clickTag || spongecellClickTag;
if (spongecellIsHttp(spongecellParams.clickTag)) {
  // replaces linkPrefixDecoded=SPONGECELL_CLICK_TAG with the click tag if it starts with http
  objectHTML = objectHTML.replace(/&(amp;)?linkPrefixDecoded=.*?(?=['&"])/g, '&linkPrefixDecoded=' + spongecellParams.clickTag);
}
var spongecellLandingPages = {"": "http://www.ministryofsound.com/magazine/summersessions.aspx?ns_campaign=digital_summer_sessions&ns_mchannel=display&ns_source=digital&ns_linkname=summer_sessions_dl&ns_fee=1"};
var spongecellClickTagMulti = "";
for (var key in spongecellParams) {
  if (key && key.indexOf("clickTag") == 0 ) {
    spongecellClickTagMulti += key + "=";
    if (spongecellIsHttp(spongecellParams[key])) { spongecellClickTagMulti += spongecellParams[key]; }
    var landingPageKey = key.replace("clickTag","");
    if( spongecellLandingPages[landingPageKey] ) {
      spongecellClickTagMulti += escape(spongecellLandingPages[landingPageKey]);
    }
    spongecellLandingPages[landingPageKey] = null;
    spongecellClickTagMulti += "&";
  }
}
for (var key in spongecellLandingPages) {
  if (key && spongecellLandingPages[key] && spongecellLandingPages[key].length > 0) {
    spongecellClickTagMulti += "clickTag" + key + "=" + escape(spongecellLandingPages[key]) + "&";
  }
}
if (spongecellParams.placementId == 'SPONGECELL_PLACEMENT_ID') {spongecellParams.placementId = '';}
if (spongecellParams.clickTag == 'SPONGECELL_CLICK_TAG' || !spongecellIsHttp(spongecellParams.clickTag)) {spongecellParams.clickTag = '';}
objectHTML = objectHTML.replace(/%placement%/g, spongecellParams.placementId || '');
objectHTML = objectHTML.replace(/%click_tag%/g, spongecellParams.clickTag || '');
objectHTML = objectHTML.replace(/%click_tag_multi%/g, spongecellClickTagMulti);
objectHTML = objectHTML.replace(/%tracking_disabled%/g, spongecellParams.trackingDisabled ? "trackingDisabled=1&" : "");
objectHTML = objectHTML.replace(/%anticache%/g, spongecellParams.cdnDisabled ? ("anticache="+Math.floor(Math.random()*10000)+"&") : "");
objectHTML = objectHTML.replace(/%cdn_disabled%/g, spongecellParams.cdnDisabled ? "cdnDisabled=1&" : "");
objectHTML = objectHTML.replace(/%widget_resource_host%/g, spongecellParams.resourceHost || 'cdn.statics.live.spongecell.com');
document.write(objectHTML);

// Focus Flash when the mouse enters it
var outerObject = document.getElementById('spongecellWidget138493');
if( outerObject ) {
  outerObject.onmouseover = function() {
    var innerObject = outerObject.getElementsByTagName('object')[0];
    (innerObject || outerObject).focus();
  }
}

// Listen for the page load and set a variable for Flash to check
var spongecellOnload = function(evt) { spongecellParams.pageLoaded = true; }
if (typeof window.addEventListener != "undefined") {
  window.addEventListener("load", spongecellOnload, false);
} else if (typeof document.addEventListener != "undefined") {
  document.addEventListener("load", spongecellOnload, false);
} else if (typeof window.attachEvent != "undefined") {
  window.attachEvent("onload", spongecellOnload);
}
