document.write('');
<!--

// Function to check if str is numeric.
function isNumeric(number) {
  if ((number >= 0)||(number < 0)){
    return true;
  } else {
    return false;
  }
}

// Function to return the sectionID of the page.
function getSectionID(pathname,type){

  // If type=0 return JUST the first part of the path as this is the siteID
  // If type=1 return upto four levels of description
  // pathname starts with slash, so first string in array element 1
  
  var section = pathname.split("/");
  var output = section[1];

  if(type==1 && section[2] && !isNumeric(section[2])){
    output += "/" + section[2];
  }

  if(type==1 && section[3] && !isNumeric(section[3])){
    output += "/" + section[3];
  }

  if(type==1 && section[4] && !isNumeric(section[4])){
    output += "/" + section[4];
  }

  if(pathname=="/"){
    output = "portal";
  }
  
  return output;
}

// 

tmgads = new Array();

if(typeof(window['mpusitename']) != "undefined"){
 tmgads['site']    = mpusitename;
 tmgads['section'] = mpupageclass;
} else {
 tmgads['site']    = getSectionID(window.location.pathname,0);
 tmgads['section'] = getSectionID(window.location.pathname,1);
}

// Firefox/Netscape/Safari/Opera
if (window.innerWidth) {
  tmgads['bw']=window.innerWidth;
  tmgads['bh']=window.innerHeight;
}  

if (document.body.clientWidth) {
  if (document.compatMode && document.compatMode != "BackCompat"){
    // from http://www.quirksmode.org/js/doctypes.html
    tmgads['bw']=document.documentElement.clientWidth;
    tmgads['bh']=document.documentElement.clientHeight;
  } else {
    tmgads['bw']=document.body.clientWidth;
    tmgads['bh']=document.body.clientHeight;
  }
}


tmgads['ord']     = "2008.8.8.23.6.17.0";
tmgads['view']    = "";
tmgads['pt']      = "";
tmgads['search']  = "";
tmgads['adw']  =  300; // width of adunit
tmgads['adh']  =  600; // height of adunit
tmgads['sw']   = 986; // Site Width
tmgads['gutr'] =    5; // gutter between site and ad
tmgads['posy'] =  120; // position down from top of browser.
tmgads['posx'] = ((tmgads['bw']-tmgads['sw'])/2)+tmgads['sw']+tmgads['gutr']; // position from left of browser

var uA = navigator.userAgent;
tmgads['browser'] = "unknown";
// Disover which browser and amend placement accordingly.
if (uA.indexOf("Opera") > -1) {
  tmgads['browser'] = "Opera";
} else if (uA.indexOf("Safari") > -1) {
  tmgads['browser']= "Safari";
} else if (uA.indexOf("Konqueror") > -1) {
  tmgads['browser']= "Konqueror";
} else if (uA.indexOf("Gecko") > -1) {
  tmgads['browser']= "Mozilla";
} else if (uA.indexOf("MSIE") > -1) {
  tmgads['browser']= "Internet Explorer";
}

// Amend values if on new eScenic
if(tmgads['site']=="news" || tmgads['site']=="travel" || tmgads['site']=="sport" || tmgads['site']=="portal"){
  tmgads['sw']   = tmgads['sw']   + 15; 	// Site Width on eScenic
  tmgads['posy'] = tmgads['posy'] + 42; 	// Site Width on eScenic
  tmgads['posx'] = tmgads['posx'] - 12; 	// Site Width on eScenic
  if(tmgads['browser']=="Internet Explorer"){
    tmgads['posy'] = tmgads['posy'] + 11;
  }
  if(tmgads['browser']=="Mozilla"){
    tmgads['posy'] = tmgads['posy'] + 12;
  }
}





if(tmgads['bw']>=1500 & tmgads['bh']>=400){

  tmgads['adtag'] = 'http://ads.telegraph.co.uk/html.ng/site='+tmgads['site']+'&spaceid=sidebar&sz=330x850&sz=300x600&transactionID='+tmgads['ord']+'&Section='+tmgads['section']+'&view='+tmgads['view'];

  document.write('<div id=\"sidebar\" style=\"position:absolute;top:'+tmgads['posy']+'px;left:'+tmgads['posx']+'px;text-align:center;font-size:10px;font-family:tahoma\">\n');
  document.write('<ifr'+'ame src="'+tmgads['adtag']+'" WIDTH="'+tmgads['adw']+'" HEIGHT="'+tmgads['adh']+'" MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#CCCCCC" BGCOLOR="#CCCCCC"></ifra'+'ame>');
  document.write('</div>\n');
  //alert(" bw:"+tmgads['bw']+"\n bh:"+tmgads['bh']+"\n posx:"+tmgads['posx']+"\n posy:"+tmgads['posy']+"\n gutr:"+tmgads['gutr']+"\n sw:"+tmgads['sw']+"\n site:"+tmgads['site']+"\n section:"+tmgads['section']+"\n browser:"+tmgads['browser'])
}

//-->
document.write('');
