//jQuery Production scripts //Scripts for European MPU dynamic functionality /* ---- detection functions ---- */ // Flash Player Version Detection - Rev 1.6 // Detect Client Browser type // Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved. var isIE = (navigator.appVersion.indexOf("MSIE") > -1); var isWin = (navigator.appVersion.toLowerCase().indexOf("win") > -1); var isOpera = (navigator.userAgent.indexOf("Opera") > -1); function ControlVersion() { var version; var axo; var e; // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry try { // version will be set for 7.X or greater players axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); version = axo.GetVariable("$version"); } catch (e) { } if (!version) { try { // version will be set for 6.X players only axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); // installed player is some revision of 6.0 // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, // so we have to be careful. // default to the first public version version = "WIN 6,0,21,0"; // throws if AllowScripAccess does not exist (introduced in 6.0r47) axo.AllowScriptAccess = "always"; // safe to call for 6.0r47 or greater version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 4.X or 5.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = axo.GetVariable("$version"); } catch (e) { } } if (!version) { try { // version will be set for 3.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = "WIN 3,0,18,0"; } catch (e) { } } if (!version) { try { // version will be set for 2.X player axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); version = "WIN 2,0,0,11"; } catch (e) { version = -1; } } //alert(version); return version; } // JavaScript helper required to detect Flash Player PlugIn version information function GetSwfVer(){ // NS/Opera version >= 3 check for Flash plugin in plugin array 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")); } } flashVer = versionMajor + "." + versionMinor + "." + versionRevision; //alert("flashVer="+flashVer); } } // MSN/WebTV 2.6 supports Flash 4 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; // WebTV 2.5 supports Flash 3 else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; // older WebTV supports Flash 2 else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; else if ( isIE && isWin && !isOpera ) { flashVer = ControlVersion(); } return flashVer; } // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { versionStr = GetSwfVer(); if (versionStr == -1 ) { return false; } else if (versionStr !== 0) { if(isIE && isWin && !isOpera) { // Given "WIN 2,0,0,11" tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] tempString = tempArray[1]; // "2,0,0,11" versionArray = tempString.split(","); // ['2', '0', '0', '11'] } else { versionArray = versionStr.split("."); } var versionMajor = versionArray[0]; var versionMinor = versionArray[1]; var versionRevision = versionArray[2]; // is the major.revision >= requested major.revision AND the minor version >= requested minor 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 detectFlash = function(){ FlashCanPlay = DetectFlashVer(6,0,0); return; }; var buildIEFlashObject = function(path, width, height, areaid){ return ''; }; var buildMozFlashEmbed = function(path, width, height, areaid){ return ''; }; function getFlashMovieObject(movieName) { if (window.document[movieName]) { return window.document[movieName]; } if (navigator.appName.indexOf("Microsoft Internet")==-1) { if (document.embeds && document.embeds[movieName]) return document.embeds[movieName]; } else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) { return document.getElementById(movieName); } } var europeanMPU = function(mpuData, areaid){ /*var start = (new Date).getTime(); console.log('start'+start);*/ var timer = null; var bannerIndex = 0; var bannerRotInt = 6000; //default if (typeof areaid == 'undefined'){ var areaid = '';} if (typeof mpuData.interval !== 'undefined'){ bannerRotInt = parseInt(mpuData.interval);} var lastDisplayed = null; //index of the last item displayed var imgHeight = parseInt(document.getElementById('bannerViewer'+areaid).style.height, 10); var imgWidth = parseInt(document.getElementById('bannerViewer'+areaid).style.width, 10); if (isNaN(imgHeight)){ imgHeight = 250;} if (isNaN(imgWidth)){ imgWidth = 250;} detectFlash(); var preloadImages = function() { for (var i=0;i -1); mpuData[i].flash = mpuData[i].imgSrc; mpuData[i].img = new Image(); mpuData[i].img.width = imgWidth; mpuData[i].img.height = imgHeight; mpuData[i].img.border = '0'; mpuData[i].img.id = "bannerItem"+areaid+i; if(mpuData[i].isFlash === true){ mpuData[i].img.src = mpuData[i].flashReplaceImage; mpuData[i].flashObj = {}; mpuData[i].flashObj.src = mpuData[i].imgSrc; if (isIE){ mpuData[i].flashObj.html = buildIEFlashObject(mpuData[i].imgSrc, imgWidth, imgHeight, areaid);} else{ mpuData[i].flashObj.html = buildMozFlashEmbed(mpuData[i].imgSrc, imgWidth, imgHeight, areaid);} } else{ mpuData[i].img.src = mpuData[i].imgSrc; } mpuData[i].isImageEmpty = (mpuData[i].img.src.length === 0); mpuData[i].isFlashEmpty = (mpuData[i].flash.length === 0); if(!mpuData[i].isFlash && mpuData[i].isImageEmpty){ mpuData[i].img.src = mpuData[i].imgSrc; mpuData[i].img.height = imgHeight; mpuData[i].img.width = imgWidth; } } //for }; //preloadImages preloadImages(); var display = function(bannerItem){ /*var diff = (new Date).getTime() - start; console.log('display() called:'+diff); */ var bannerItemLinkElement = document.getElementById('bannerItemLink'+areaid), //DOM Element bannerItemO = jQuery('#bannerItem'+areaid), //jQ Object bannerItemObjectO = jQuery('#bannerItemObject'+areaid); //jQ Object if (bannerItem.isFlash && FlashCanPlay) { bannerItemObjectO.replaceWith(bannerItem.flashObj.html); var movie = getFlashMovieObject('bannerItemObject'+areaid); movie.onReadyStateChange = function () { bannerItemO.hide(); bannerItemObjectO.show(); }; }else{ //console.log('img comp: '+bannerItem.img.complete); var displayImg = function() { bannerItemO.empty(); bannerItemO.append(bannerItem.img); bannerItemObjectO.hide(); bannerItemO.show(); } if (!bannerItem.img.complete) { bannerItem.img.onload = displayImg;//if img is not complete, attach function to its onload event } else { displayImg(); } } //common for both flash and image bannerItemLinkElement.href = bannerItem.target; bannerItemLinkElement.title = bannerItem.title; var checkHref = jQuery(bannerItemLinkElement).attr('href'); if(checkHref == '#'){ bannerItemLinkElement.style.cursor = 'default'; } else{ bannerItemLinkElement.style.cursor = 'pointer'; } setTimer(); jQuery('#bannerContainer'+areaid).show(); }; //display() jQuery('#bannerItemLink'+areaid).click(function(){document.location=this.href}); var setTimer = function(){ if(mpuData.length > 1){ /*var diff = (new Date).getTime() - start; console.log('setTimer() timer set:'+diff);*/ timer = setTimeout(nextBanner, bannerRotInt); } }; //not used var previousBanner = function(){ clearTimeout(timer); if (bannerIndex === 0){ bannerIndex = mpuData.length-1; } else { bannerIndex--; } if (typeof mpuData[bannerIndex] == "undefined"){ prevBanner(); return; } if (typeof mpuData[bannerIndex].skip != "undefined"){ if (mpuData[bannerIndex].skip === true){ prevBanner(); return; } } if (lastDisplayed != bannerIndex){ lastDisplayed = bannerIndex; display(mpuData[bannerIndex]); } }; var nextBanner = function(){ /*var diff = (new Date).getTime() - start; console.log('nextBanner() index:'+ bannerIndex+' called:'+diff); */ if(bannerIndex == (mpuData.length-1)){ clearTimeout(timer); bannerIndex = 0; } else{ bannerIndex++; } if (typeof mpuData[bannerIndex] == "undefined"){ nextBanner(); return; } if (typeof mpuData[bannerIndex].skip != "undefined"){ if (mpuData[bannerIndex].skip === true){ nextBanner(); return; } } if (lastDisplayed != bannerIndex){ lastDisplayed = bannerIndex; display(mpuData[bannerIndex]); } }; bannerIndex=-1; /*var diff = (new Date).getTime() - start; console.log('time:'+diff);*/ nextBanner(); //setup first item }; //europenMPU //End of scripts for European MPU dynamic functionality //Start of scripts for dynamic dropdowns of various types powered by jquery //Start of script for basic dynamic dropdowns jQuery(function(){ jQuery("div[id*='jqddDiv']").hide();//hide all divs with ids containing the string 'jqddDiv' to ensure all divs hidden when page is first displayed jQuery('.jqddClosebutton').click(function() {//acts when any button of class jqddClosebutton is clicked jQuery("div[id*='jqddDiv']").slideUp('fast', function() {});//hides any div with an id containing the string 'jqddDiv' }); jQuery("a[id*='jqddLink']").click(function() {//acts on any anchor with an id containing the string 'jqddLink' var clickId = jQuery(this).attr('id');//gets id of the link var clickId2 = clickId.split("k");//splits id at the letter k of the word Link so 'jqddLink1' is split to 'jqddLink' and '1' var clickId3 = "#" + "jqddDiv" + clickId2[1];//works out id of the div associated with the link so e.g. '#jqddDiv1' jQuery("div[id*='jqddDiv']").hide();//hides any div with an id containing the string 'jqddDiv' jQuery(clickId3).slideDown('fast', function() {//displays the div in question }); }); jQuery("div[id*='jqddNestDiv']").hide();////hides any div with an id containing the string 'jqddNestDiv'. This is for any nested divs within divs jQuery('.jqddNestClosebutton').click(function() {//acts when any button of class jqddNestClosebutton is clicked. This is for any nested divs within divs jQuery("div[id*='jqddNestDiv']").slideUp('fast', function() {});//hides any div with an id containing the string 'jqddNestDiv' }); jQuery("a[id*='jqddNestLink']").click(function() {//acts on any anchor with an id containing the string 'jqddNestLink' var clickId = jQuery(this).attr('id');//gets id of the link var clickId2 = clickId.split("k");//splits id at the letter k of the word Link so 'jqddNestLink1' is split to 'jqddNestLink' and '1' var clickId3 = "#" + "jqddNestDiv" + clickId2[1];//works out id of the div associated with the link so e.g. '#jqddNestDiv1' jQuery("div[id*='jqddNestDiv']").hide();//hides any div with an id containing the string 'jqddNestDiv' jQuery(clickId3).slideDown('fast', function() {//displays the div in question }); }); }); //End of script for basic dynamic dropdowns //Start of script for plus and minus dynamic dropdown functionality jQuery(document).ready(function(){ jQuery("a[id*='pmLink']").click(function() {//acts on any anchor with an id containing the string "pmLink' var pmLinkId = '#' + jQuery(this).attr('id'); //gets id of the link var pmLinkIdArray = pmLinkId.split('k'); //splits id at the letter k of the word Link so 'pmLink1' is split to 'pmLink' and '1' var pmDivId = '#' + 'pmDiv' + pmLinkIdArray[1]; //works out id of the div associated with the link so e.g. '#pmDiv1' var pmLinkImg = '#' + 'pmLinkImg' + pmLinkIdArray[1];//works out id of the img associated with the div so e.g. '#pmLinkImg1' var divOpen = jQuery(pmDivId).css('display');//gets display style of the div so 'none' if div is hidden or 'block' if it is not hidden if (divOpen == 'none'){//if div is hidden then open it jQuery(pmDivId).show(); jQuery(pmLinkImg).attr("src", "/content/images/ie/jQuery/minusBlue.gif");//change img from plus to minus as div is now open } else{//if div is not hidden then hide it jQuery(pmDivId).hide(); jQuery(pmLinkImg).attr("src", "/content/images/ie/jQuery/plusBlue.gif");//change img from minus to plus as div is now closed } }); }); //End of script for plus and minus dynamic dropdown functionality //End of scripts for dynamic dropdowns of various types powered by jquery /* Functions for cookied rotating MPU functionality */ function updateRImg(arrIndex,rImgArray) { var imgE = document.getElementById(rImgArray.imgElement), imgLink = document.getElementById(rImgArray.imgLink); if (imgE == null) { return; } imgE.src = rImgArray[arrIndex].imgSrc; imgE.title = rImgArray[arrIndex].title; imgE.alt = rImgArray[arrIndex].alt; //set mouseover and mouseout jQuery(imgE).hover(function(){this.src=rImgArray[arrIndex].onmouseover}, function() {this.src= rImgArray[arrIndex].imgSrc}); if (imgLink != null) { imgLink.href = rImgArray[arrIndex].target; } jQuery.aaCookie.set(rImgArray.cookieName, arrIndex, 1, "/"); } function handleRImg(rImgArray) { var ck = jQuery.aaCookie.get(rImgArray.cookieName); //cookied value if ((rImgArray.active === true) && (ck !== null)) { ckNext = parseInt(ck,10) + 1; //convert to int, to be sure if (typeof rImgArray[ckNext] == 'undefined') { ckNext = 0; //set to first if there's no next (i.e. loop) } } else{ ckNext = 0; } //preload required images rImgArray[ckNext].imgObjA = new Image(); rImgArray[ckNext].imgObjA.src = rImgArray[ckNext].imgSrc; rImgArray[ckNext].imgObjB = new Image(); rImgArray[ckNext].imgObjB.src = rImgArray[ckNext].onmouseover; if (typeof window.handlerFunctions == 'undefined') { window.handlerFunctions = []; //create global object } //update DOM with function put in a global object window.handlerFunctions[rImgArray.imgElement] = function(){updateRImg(ckNext,rImgArray);}; } /* End of functions for cookied rotating MPU functionality */