//Start: Previously was M3_zones_topgear.js. Defines the zones for the site
var M3_n = new Array('b48acde1','b8acde75c','b91fac3e','ba914def','b9bc1de5');
var M3_zoneIds = new Array('2','5','14','4','3');
var M3_zoneNames = new Array('banner','button','hidden','MPU','skyscraper');
var M3_w = new Array('468','120','0','200','120');
var M3_h = new Array('60','60','0','200','600');
//End: Previously was M3_zones_topgear.js
//Start: Previously was M3_core.js
var M3_http = (location.protocol == 'https:') ? 'https:' : 'http:';
var M3_source = 'bbc/' + document.Category;
var M3_noLoad = Array(M3_zoneNames.length);

document.context = '';
document.phpAds_used = '';

function M3_findPosX(obj) {
    origObj = obj;
	var curleft = 0;
	if (obj.offsetParent) {
	    while (obj.offsetParent) {
		curleft += obj.offsetLeft;
		obj = obj.offsetParent;
	    }
	} else if (obj.x) {
		curleft += obj.x;
    }
    if(!curleft) {
        return origObj.offsetLeft;
    }
	return curleft;
}
function M3_findPosY(obj) {
    origObj = obj;
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop;
	    obj = obj.offsetParent;
         }
    } else if (obj.y) {
		curtop += obj.y;
    }
    if(!curtop) {
        return origObj.offsetTop;
    }
	return curtop;
}
function M3_getHeight(elm) {
    var height = 0;
    if (elm.offsetHeight) {
        height = elm.offsetHeight;
    } else if (elm.clip && elm.clip.height) {
        height = elm.clip.height;
    } else if (elm.style && elm.style.pixelHeight) {
        height = elm.style.pixelHeight;
    }
    return height;
}
function M3_getWidth(elm) {
    if (elm.offsetWidth) { 
        width = elm.offsetWidth;
    } else if (elm.clip && elm.clip.width) {
        width = elm.clip.width;
    } else if (elm.style && elm.style.pixelWidth) {
        width = elm.style.pixelWidth;
    } else {
        width=0;
    }
    return width;
}
function M3_prepTarget(sourceObj, targetObj, key) {
    var width = M3_w[key];
    var height = M3_h[key];
    if (M3_w[key] == '*') { width = M3_getWidth(sourceObj); }
    if (M3_h[key] == '*') { height = M3_getHeight(sourceObj); }
    if (width == 24 && height == 24) {
        return false;
    }
    targetObj.style.width = parseInt(width) + 'px';
    targetObj.style.height = parseInt(height) + "px";
    return true;
}
function M3_moveAbove(sourceObj,targetObj) {
    var left = M3_findPosX(targetObj);
    var top = M3_findPosY(targetObj);
    sourceObj.style.left = parseInt(left) + "px";
    sourceObj.style.top = parseInt(top) + "px";
}
function M3_writeAds(idName) {
    var M3_zoneCount = M3_zoneNames.length;
    for (var i = 0; i < M3_zoneCount; i++) {
        if (idName == M3_zoneNames[i]) {
            if (document.all) {
                if (document.all[M3_zoneNames[i]]) {
                    M3_writeTag(i)
                } 
            } else {
                if (document.getElementById(M3_zoneNames[i])) {
                    M3_writeTag(i)
                }
            }
        }
    }
}
function M3_writeTag(key) {
    var az = '';
    az += "<" + "script language='JavaScript' type='text/javascript' src='" + M3_http + "//d.ak.m3.net/adjs.php";
    az += "?n=" + M3_n[key] + "&zoneid=" + M3_zoneIds[key] + "&source={derive}&exclude=" + document.phpAds_used;
    az += "&context=" + document.context + "&r=" + Math.floor(Math.random()*999999999999);
    if (window.location) az += "&loc=" + escape(window.location);
    if (document.referrer) az += "&referer=" + escape(document.referrer);
    az += "'><" + "/script>";
    document.write(az);
}
function M3_positionDivs() {
    var M3_zoneCount = M3_zoneNames.length;
    M3_prep_targets(M3_zoneCount);
    M3_move_source(M3_zoneCount);
}
function M3_prep_targets(M3_zoneCount) {
    for (var i = 0; i < M3_zoneCount; i++) {
        var zoneContentContainer = 'M3ad_' + M3_zoneIds[i];
        if (window[zoneContentContainer] != '' && window[zoneContentContainer] != 'undefined') {
            var hiddenZoneName = M3_zoneNames[i] + 'Hidden';
            if (document.getElementById) {
                if (document.getElementById(M3_zoneNames[i])) {
                    var zoneElm = document.getElementById(M3_zoneNames[i]);
                    var hideElm = document.getElementById(hiddenZoneName);
                    if (M3_prepTarget(hideElm, zoneElm, i) === true) {
                        M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] = 0;
                    } else {
                        M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] = 1;
                    }
                }            
            } else {
                if (document.all[M3_zoneNames[i]]) {
                    var zoneElm = document.all[M3_zoneNames[i]];
                    var hideElm = document.all[hiddenZoneName];
                    if (M3_prepTarget(hideElm, zoneElm, i) === true) {
                        M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] = 0;
                    } else {
                        M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] = 1;
                    }
                }
            }
        } else {
            M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] = 1;
        }
    }
}
function M3_move_source(M3_zoneCount) {
    for (var i = 0; i < M3_zoneCount; i++) {
        var zoneContentContainer = 'M3ad_' + M3_zoneIds[i];
        if (window[zoneContentContainer] != '' && window[zoneContentContainer] != 'undefined') {
            var hiddenZoneName = M3_zoneNames[i] + 'Hidden';
            if (document.getElementById) {
                if (document.getElementById(M3_zoneNames[i])) {
                    var zoneElm = document.getElementById(M3_zoneNames[i]);
                    var hideElm = document.getElementById(hiddenZoneName);
                    if(M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] == 1) {
                        if (M3_prepTarget(hideElm, zoneElm, i) === false) {
                            M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] = 1;
                        }
                    }
                    if(M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] == 0) {
                        M3_moveAbove(hideElm, zoneElm);
                    }
                }
            } else {
                if (document.all[M3_zoneNames[i]]) {
                    var zoneElm = document.all[M3_zoneNames[i]];
                    var hideElm = document.all[hiddenZoneName];
                    if(M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] == 1) {
                        if (M3_prepTarget(hideElm, zoneElm, i) === false) {
                            M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] = 1;
                        }
                    }
                    if(M3_noLoad['M3ad_noLoad' + M3_zoneIds[i]] == 0) {
                        M3_moveAbove(hideElm, zoneElm);
                    }
                }
            }
        }
    }
}
//End: Previously was M3_core.js
//Start: Previously was M3_core_inline.js
/*var M3_http = (location.protocol == 'https:') ? 'https:' : 'http:';
var M3_source = 'bbc/' + document.Category;
document.context = '';
document.phpAds_used = '';*/

function M3_GetIndex(name)
{
    var index = -1;
    if (typeof(name) != 'undefined') {
        for (var i=0; i<M3_zoneNames.length; i++) {
            if (M3_zoneNames[i] == name ) {
                index = i;
                break;
            }
        }
    }
    return index;
}

function M3_writeAds(name)
{
    var index = M3_GetIndex(name);
    if (index > -1) {
        var az = '';
        az += "<" + "script language='JavaScript' type='text/javascript' src='" + M3_http + "//d.ak.m3.net/adjs.php";
        az += "?n=" + M3_n[index] + "&zoneid=" + M3_zoneIds[index] + "&source={derive}&exclude=" + document.phpAds_used;
        az += "&context=" + document.context + "&r=" + Math.floor(Math.random()*999999999999);
        if (window.location) az += "&loc=" + escape(window.location);
        if (document.referrer) az += "&referer=" + escape(document.referrer);
        az += "'><" + "/script>";
        document.write(az);
    }
}

//End: Previously was M3_core_inline.js

