// $Date: 2007/03/23 10:41:39 $
// $Name: ukconcept_v1_r37 $
// $Revision: 1.96.2.3 $
// $State: Exp $


function Rotator() {
	
      this.framecount = 0;
      this.frames = new Array();
      this.timer;
	  this.running = true;
	  
      this.init = function(){
		  	this.data = document.getElementById('rotator_data_'+this.id);
			this.target = document.getElementById('rotator_main_'+this.id);
			this.tools = document.getElementById('rotator_tools_'+this.id);
			
		  for(var i = 0;i<=this.data.childNodes.length-1;i++) {
			  if(this.data.childNodes[i].nodeType==1) {
					this.framecount++;
					this.frames[this.frames.length] = this.data.childNodes[i].innerHTML;
			  }
		  }
	  }

      this.currentFrame = 0;
	  this.start = function(){
		  this.running = true;
		  this.run();
	  }

      this.run = function() {

		  if (this.running)
		  {		  
			  if (this.maxFrames > 0)
			  {
			  
				this.currentFrame++;
				if(this.currentFrame>this.maxFrames) {
					  this.currentFrame = 1;
				}
				this.target.innerHTML = this.frames[this.currentFrame-1];
				this.buildTools();
				this.timer = setTimeout('rotator'+this.id+'.run()',this.interval);
			  }
		  }
      }
	  this.stop = function(){
		  this.running = false;
	  }
 
      this.forward = function() {
           clearTimeout(this.timer);
           this.run();
           return false;
      }

      this.back = function() {
            clearTimeout(this.timer);
            this.currentFrame--;
            this.move();
            return false;
      }

      this.move = function() {
           if(this.currentFrame>this.maxFrames) {
               this.currentFrame = 1;
           } else if(this.currentFrame==0) {
               this.currentFrame = this.maxFrames;
           }
           this.target.innerHTML = this.frames[this.currentFrame-1];
           this.buildTools();
      }
  
     this.jump = function(i) {

           clearTimeout(this.timer);
           if(this.currentFrame<i) {
                this.currentFrame = i-1;
                this.run();
           } else {
                this.currentFrame = i;
                this.move();
           }
           return false;
     }
	 
      this.BACK_TEXT = "<span class='arrows'>&lt;</span> Back";
	  this.FORWARD_TEXT = "Next <span class='arrows'>&gt;</span>";
	  this.pageNavArray = new Array();
	  this.jumpEvent = function(ev){stopDefaultAction(ev);return ev.currentTarget.rotator.jump(ev.currentTarget.numberIndex)}

      this.buildTools = function() {
		  
		this.toolsContainerElem = document.createElement("p");
		this.toolsContainerElem.className = 'module_body';

		this.toolsBackSpanElem = document.createElement("span");
		this.toolsBackSpanElem.className = 'back';

		this.toolsBackLinkElem = document.createElement("a");
		this.toolsBackLinkElem.href = '#';
		this.toolsBackLinkElem.innerHTML = this.BACK_TEXT;
		this.toolsBackLinkElem.rotator  = this;
		addEvent(this.toolsBackLinkElem, "mouseup", function(ev){stopDefaultAction(ev);return ev.currentTarget.rotator.back()}, false);

		this.toolsNumbersSpanElem = document.createElement("span");
		this.toolsNumbersSpanElem.className = 'item_numbers';
		
		for (var i in this.pageNavArray){this.pageNavArray[i].rotator = null; this.pageNavArray[i] = null;}
		this.pageNavArray = new Array();

		for(var i = 0;i<=this.maxFrames-1;i++) {
			var frameIndex = i+1;
			if(frameIndex==this.currentFrame) {
			  this.pageNavArray[i] = document.createElement("span");
			  this.pageNavArray[i].innerHTML = frameIndex;
			  this.pageNavArray[i].numberIndex = frameIndex;
			} else {
			  this.pageNavArray[i] = document.createElement("a");
			  this.pageNavArray[i].href="#";
			  this.pageNavArray[i].numberIndex = frameIndex;
			  this.pageNavArray[i].rotator  = this;
			  addEvent(this.pageNavArray[i], "click", this.jumpEvent, false);
			  this.pageNavArray[i].innerHTML = frameIndex;
			}
			this.toolsNumbersSpanElem.appendChild(this.pageNavArray[i]);
        }

		this.toolsForwardSpanElem = document.createElement("span");
		this.toolsForwardSpanElem.className = 'forward';

		this.toolsForwardLinkElem = document.createElement("a");
		this.toolsForwardLinkElem.href = '#';
		this.toolsForwardLinkElem.innerHTML = this.FORWARD_TEXT;
		this.toolsForwardLinkElem.rotator  = this;
		
		addEvent(this.toolsForwardLinkElem, "mouseup", function(ev){stopDefaultAction(ev); return ev.currentTarget.rotator.forward()}, false);
		
		//add dummy functions for Safari to cancel default onclick
		addEvent(this.toolsBackLinkElem, "click", function(ev){stopDefaultAction(ev); return false;});
		addEvent(this.toolsForwardLinkElem, "click", function(ev){stopDefaultAction(ev); return false;});
		
		this.toolsBackSpanElem.appendChild(this.toolsBackLinkElem);
		this.toolsForwardSpanElem.appendChild(this.toolsForwardLinkElem);

		this.toolsContainerElem.appendChild(this.toolsBackSpanElem);
		this.toolsContainerElem.appendChild(this.toolsNumbersSpanElem);
		this.toolsContainerElem.appendChild(this.toolsForwardSpanElem);

		this.tools.innerHTML = '';
		this.tools.appendChild(this.toolsContainerElem);
       }
}


function openWindow (url) {
    window.open(url);
}

function openPhoto (url) {
    options = 'width=340,height=500,scrollbars=yes';
    window.open(url,'',options);
}

function openGallery (url) {
    options = 'width=235,height=429';
    window.open(url,'',options);
}

function openVideo (url) {
    options = 'width=320,height=300';
    window.open(url,'',options);
}

function openAudio (url) {
    options = 'width=192,height=36';
    window.open(url,'',options);
}

function openItem (url, options) {
    window.open(url, '', options)
}

function closeWindow () {
    window.close();
}

function interceptLinks () {
    txt = 'This area is only available within the AOL client.';
    for (i = 0; i < document.links.length; i++) {
        url = document.links[i].href;
        if (url.substring(0,3) == 'aol') {
            document.links[i].href = 'javascript: alert("'+txt+'");';
        }
    }
}

function openEnhancedGallery (channel,id) { // resizePopup
    options = "width=500;height=500";
    window.open('/' + channel + "/enhPhotoGallery.adp?id=" + id,'',options);
}
function returnUrlWithNoParameters(){
    var new_location_href=window.location.href;
	var urlArray = new_location_href.split('?');
    return urlArray[0];
}

// return popup gallery url 
function EnhPhotoGalleryPollPopupUrl (galleryid) {
    var articleid="";
	var beginOfArticle = "";
	var wholeUrl = window.location.href;
    var urlParamArray = wholeUrl.split('?');
    var pageUrl = urlParamArray [0] 
	var urlArray = pageUrl.split('/');
	var article = "";
	var newPageUrl= "";
	if (urlArray[(urlArray.length-2)]=="article")
    {       	
        articleid=urlArray[(urlArray.length-1)];
	    var urlArray = pageUrl.split('/');
	    for (i=0;i<(urlArray.length-3);i++)
	    {
		   newPageUrl+=urlArray[i]+"/";
	    }
		galleryUrl = newPageUrl + "enhPhotoGalleryPollPopup.adp?popupgalleryid=" + galleryid + "&articleID=" + articleid;
    } else {
		if (urlArray[(urlArray.length)-1])
		{
			pageUrl=pageUrl+"/";
		}
		galleryUrl = pageUrl + "enhPhotoGalleryPollPopup.adp?popupgalleryid=" + galleryid;

	}
    return galleryUrl;
}



// Open Popup Gallery

function openEnhPhotoGalleryPollPopup (galleryid,x,y) { // resizePopup
    var galleryUrl ="";
    galleryUrl = EnhPhotoGalleryPollPopupUrl(galleryid);
     // X and Y are optional but in order to pass Y you need to pass a X first
	if (x)
	{   
		options ="";
		options = options+ "width=" + x;
		 if (y)
		{
		options = options+",height=" + y;
		} 
	
	}else {
       options = "width=740,height=584";
	}


	options =  options + ",location=0,resizable = 0,status =0,scrollbars=0";
	
	window.open(galleryUrl,'',options);
}


// generic onload procedure support:

var Onload = new Object();
Onload.runnables = new Array();
Onload.register = function ( obj ) { Onload.runnables[Onload.runnables.length] = obj;}
Onload.run = function () {
  for (var i = 0 ; i < Onload.runnables.length ; i++) Onload.runnables[i].onload();
  }


// CONTROL MY SEARCH TABS IN THE HEADER

// TODO: Rename as can't be used generically

var getSearchElement = function(classname,tagname) {
  if (tagname === undefined) {
    tagname = "div";
  }

	var parent= document.getElementById('gSearch_'+currentSearch);
	if (!parent)
	{
		parent= document.getElementById('headerSearch');		
	}
	
	var elements=getElementsByClassName(classname,parent,tagname);
	return elements[0];
}

function getElement(id) {
 var element=document.getElementById?document.getElementById(id):(document.all?document.all(id):null)
 return element;
}



// New search tab switcher 27-11-06 Will Jackson
function getSearchItem (classname,tagname) {
  if (tagname === undefined) {
    tagname = "div";
  }
	var parent = eval("document.getElementById('gSearch_"+currentSearch+"')");
	var elements=getElementsByClassName(classname,parent,tagname);
	return elements[0];
}

function getObject( obj ) {
  if ( document.getElementById ) {
    obj = document.getElementById( obj );
  } else if ( document.all ) {
    obj = document.all.item( obj );
  } else {
    obj = null;
  }
  return obj;
}

// Prevent default action for links so that they perform onclick event but don't follow the link
// Needed in addition to 'return false' in <a> tag to work around Safari bug
function dontFollowLinks (classname, parent) {
  // only for newer browsers
  if (document.getElementById) {
    // get parent and links
    var parent = document.getElementById(parent);
    var links = getElementsByClassName(classname,parent,"a");
    
    // loop through each link and prevent default action
    for (var i=0; i <links.length; i++) {
      links[i].addEventListener('click',function (e) { e.preventDefault(); },false);
    }
  }
}
dontFollowLinks("search_tab_link", "gSearch_"+currentSearch);

var searchTabs = new Array('search_tab_web','search_tab_shopping','search_tab_image','search_tab_audio','search_tab_video');
var searchTabClasses = new Array('dsTbOff','dsTbOn');
var actionArrayPortal = new Array('http://search.aol.co.uk/web','http://search.aol.co.uk/image','http://search.aol.co.uk/audio','http://aolsearch.aol.co.uk/video', 'http://aolcouk.uk.shopping.com/xFS');
var actionArrayClient = new Array('http://aolsearch.aol.co.uk/web','http://aolsearch.aol.co.uk/image','http://aolsearch.aol.co.uk/audio','http://aolsearch.aol.co.uk/video','http://aolcouk.uk.shopping.com/xFS');

var qb_init=true;
var fromShop=false;
var fromMusic=false;
var currentSearch='header';

function showDS(id,formName,dsQuery,searchURL,caller,tabs) {
	// Default to 5 tabs if not specified
	if (tabs == null){
    tabs = 5;
  }
  
	// Use JS variable to persist current search object
	currentSearch = caller;
	
	// change tab class
  for(var i=1; i<=tabs; i++) {
	  if (i == id) {
			var newClass=searchTabClasses[1];
			var oldClass=searchTabClasses[0];
		}
		else {
			var newClass=searchTabClasses[0];
			var oldClass=searchTabClasses[1];
		}
		elem=getSearchItem('search_tab' + i);
		currentClass=elem.className;
		classValue=currentClass.replace(oldClass,newClass);
	  elem.className=classValue;
  }
  
  // tab dividers
  for (var i=1; i<tabs; i++){
	  elem = getObject('search_divider'+i)
	  elem.style.display = "";
  }
  if (id==1) {
		getObject('search_divider1').style.display = "none";
  }
  else if (id==tabs) {
	  getObject('search_divider'+(id-1)).style.display  = "none";
  }
  else {
	  getObject('search_divider'+id).style.display = "none";
	  getObject('search_divider'+(id-1)).style.display = "none";
  }
    
  // powered by logos
  if(id==3 || id==4) {
    getSearchItem('powered_by_google').style.visibility = "hidden";
    getSearchItem('powered_by_shopping').style.visibility = "hidden";
  } else {
    getSearchItem('powered_by_google').style.visibility = "visible";
    getSearchItem('powered_by_shopping').style.visibility = "visible";
  }

  // search where options (only for web tab)
  var elem = getSearchItem('search_tab' + id);
  var isWeb = elem.className.indexOf('search_tab_web') == 0;
	if(isWeb) {
		getSearchItem('search_where').style.visibility = "visible";
	} else {
		getSearchItem('search_where').style.visibility = "hidden";
	}

  /*if (searchURL == 'http://search.aol.co.uk') {
      getSearchItem(formName,'form').action=actionArrayPortal[id-1];
  } else {
      getSearchItem(formName,'form').action=actionArrayClient[id-1];
  }*/
  getSearchItem(formName,'form').action=searchURL;

	
  getSearchItem('googleInput','input').name=dsQuery;

	if(id==3){
		getSearchItem('avtype','input').value="1";
	}else if (id==4){
		getSearchItem('avtype','input').value="3";
	}else{
		getSearchItem('avtype','input').value="";
	}
	
}

function switchShop(which,caller,panes) {
	// Default panes to 2 if not specified
	if (panes == null) {
		panes = 2;
	}
	
	searchPanes = new Array('search_pane_main','search_pane_shopping','search_pane_music');
	fromShop = (NN4) ? getSearchItem(searchPanes[1],'div').display != 'none' : getSearchItem(searchPanes[1],'div').style.display != 'none';
	if(panes > 2) {
		fromMusic = (NN4) ? getSearchItem(searchPanes[2],'div').display != 'none' : getSearchItem(searchPanes[2],'div').style.display != 'none';
	}
	
	currentSearch=caller;
	persistSearchQuery(which);
	
  for(var i = 0; i < panes; i++ ) {
    if(NN4) eval("getSearchItem(searchPanes[i],'div').display='none'")
    if(IE5) eval("getSearchItem(searchPanes[i],'div').style.display='none'")
    if(NN6) eval("getSearchItem(searchPanes[i],'div').style.display='none'") 
  }

  if(NN4) eval("getSearchItem(searchPanes[which],'div').display='block'")
  if(IE5) eval("getSearchItem(searchPanes[which],'div').style.display='block'")
  if(NN6) eval("getSearchItem(searchPanes[which],'div').style.display='block'")
}

function persistSearchQuery(type){
	qb=getSearchItem('googleInput','input');
	sb=getSearchItem('shoppingInput','input');
	ms=getSearchItem('musicInput','input');
	// Makes search term persist across different forms
	if (type==1){
		// Keep term for shopping
		if(fromMusic){
			if (ms.value != "" && ms.value.indexOf('search') == -1){
				sb.value=ms.value;
			}
		} else {
        sb.value=qb.value;
  }
  fromMusic=false;
  fromShop=true;
	} else if (type==2) {
		// Keep term for music
		if(fromShop){
			if (sb.value != "" && sb.value.indexOf('search') == -1){
				ms.value=sb.value;
			}
		} else {
            ms.value=qb.value;
        }
        fromShop=false;
        fromMusic=true;
    } else {
		// Keep term from music
		if(fromMusic){
			if (ms.value != "" && ms.value.indexOf('search') == -1){
				qb.value=ms.value;
			}
		} else if(fromShop){
		// Keep term from shopping
			if (sb.value != "" && sb.value.indexOf('search') == -1){
				qb.value=sb.value;
			}
		}
    fromShop=false;
    fromMusic=false;
	}
}
// End new search tab switcher

// CONTROL SWITCH FUNCTION IN THE HEADER FOR SHOP
ggSearch=2
IE5=NN4=NN6=false
if (document.all)IE5=true
else if(document.layers)NN4=true
else if(document.getElementById)NN6=true

function persistQuery(type){
	qb=getSearchElement('dsQuery','input');
	sb=getSearchElement('shopQuery','input');
	ms=getSearchElement('musicQuery','input');
	// Makes search term persist across different forms
	if (type==1){
		// Keep term for shopping
		if(fromMusic){
			if (ms.value != "" && ms.value.indexOf('search') == -1){
				sb.value=ms.value;
			}
		} else {
            sb.value=qb.value;
        }
        fromMusic=false;
        fromShop=true;
	} else if (type==2) {
		// Keep term for music
		if(fromShop){
			if (sb.value != "" && sb.value.indexOf('search') == -1){
				ms.value=sb.value;
			}
		} else {
            ms.value=qb.value;
        }
        fromShop=false;
        fromMusic=true;
    } else {
		// Keep term from music
		if(fromMusic){
			if (ms.value != "" && ms.value.indexOf('search') == -1){
				qb.value=ms.value;
			}
		} else if(fromShop){
		// Keep term from shopping
			if (sb.value != "" && sb.value.indexOf('search') == -1){
				qb.value=sb.value;
			}
		}
        fromShop=false;
        fromMusic=false;
	}
}



//
// Send To A Friend link function.
//

function mailToFriend(sSubject,sBody) {
	var linkURL = window.location.href;
	var bodyText = escape(sBody + linkURL);
	var subject = escape(sSubject);
	var mailto = 'mailto:?subject='+subject+'&body='+bodyText;
	window.location.href = mailto;
}


//
// Cookie Stubs
//

function getCookie () {
    return "";
}

function setCookie () {
    return true;
}

//
// Flexiad Code
//

var fai_status = false;
var adTop = 0;
var nMainAdH = 0;
var adH = 0;
var nATH = 0;

// Define the fai_call Class
var fai_call = function(w,h,bP) {
    this.oR = this.getObj("rhc");
    if(!fai_status) {
        var j = 0;
        this.w = w;
        this.h = h;
        
        //Get Ad Spot
        this.oT = this.getObj("flexiad");
        this.oA = this.getObj("lateAd");
        this.oCB = this.getObj("chBlock");
        
        this.oA.style.visibility = "hidden";

        switch(w) {
            case 300:
                this.oT.style.width = "300px"; this.oT.style.height = "250px"; this.oT.style.marginRight = "10px";
                nMainAdH = 250;
                adH = 0;
                break;
            case 180:
                if (!bP)
                {
                    for (j=0;j<(aMagicNums.length -1);j++) writeAdCall(aMagicNums[j],aSizes[j]);
                    var oTHeight = (((j * 155) + 150) + "px");
                    adH = (j * 155);
                } else {
                    var oTHeight = "150px";
                    adH = 0;
                }
                this.oT.style.width = "310px"; this.oA.style.display = "inline"; this.oT.style.height = oTHeight; this.oCB.style.height = oTHeight; 
                nMainAdH = 150;
                break;
            case 160:
                if (!bP)
                {
                    for (j=0;j<(aMagicNums.length -1);j++) writeAdCall(aMagicNums[j],aSizes[j]);
                } else {
                    var oTHeight = "600px";
                    this.oT.style.height = oTHeight;  
                }
                var oRWidth = this.oR.scrollWidth;
                oRWidth = oRWidth + 10 + "px";
                this.oT.style.width = "160px";  
                this.oR.style.width = oRWidth; 
                nMainAdH = 600;
                adH = 0;
                break;
            case 120: 
                if (!bP)
                {
                    for (j=0;j<(aMagicNums.length -1);j++) writeAdCall(aMagicNums[j],aSizes[j]);
                    var oTHeight = (((j * 65) + h) + "px");
                    adH = (j * 65);
                } else {
                    var oTHeight = "600px";
                    adH = 0;
                }
                this.oT.style.width = "120px"; this.oT.style.height = oTHeight; this.oT.style.marginRight = "30px"; 
                nMainAdH = 600;
                break;
            default: 
                this.oT.style.width = "0px"; this.oT.style.height = "0px";
        }
        if (w > 1) {
            this.oT.style.display = "inline";
            this.oCB.style.display = "none";
            var r = this.getXY(this.oT);
			// check that the ad is further left than the rhc
	        var rhc = this.getXY(this.oR);
			if (rhc[0] > r[0]) {
				r[0] = r[0] + 160;
                this.oT.style.position = 'relative';
                this.moveObj(this.oT,r[0],r[1]);
			}
            if (w != 180) r[1] = r[1] + adH;

            this.moveObj(this.oA,r[0],r[1]);
            adTop = r[1];
            this.oA.style.width = w+"px";
            if (w == 180) h = h + adH;
            if (h != 60) {
                this.oA.style.height = h+"px";
				
            } else {
                this.oA.style.visibility = "hidden";
            }
            this.oA.style.display = "block";
            if (w=="180") {
                var adW = w+140;
                this.oA.style.width = adW + 'px';
                this.oCB.style.display = "inline";
                this.oCB.style.marginRight = "0px";
                this.oCB.style.borderRight = "10px solid white";
            }
            if (bP) this.oA.style.backgroundColor = "#ccc";
        } else {
            this.oT.style.display = "none";
        }
    } else {
        this.oR.style.visibility = "visible";
    }
    fai_status = true;
}

fai_call.prototype.getXY = function(obj) {
    var objX = 0;
    var objY = 0;    
    if(obj.offsetParent) {
        while(obj.offsetParent) {
            objX = objX + obj.offsetLeft;
            objY = objY + obj.offsetTop;
            obj = obj.offsetParent;
        }
    }
    return [objX,objY];
};

fai_call.prototype.getObj = function(objID) {
    try {
        var obj = document.getElementById(objID);
    } catch(err) {
        var obj = "";
    }
    return obj;
};

fai_call.prototype.moveObj = function(obj,x,y) {
    obj.style.top = y+"px";
    obj.style.left = x+"px";
    return true;
};

function getXY(obj) {
    var objX = 0;
    var objY = 0;    
    if(obj.offsetParent) {
        while(obj.offsetParent) {
            objX = objX + obj.offsetLeft;
            objY = objY + obj.offsetTop;
            obj = obj.offsetParent;
        }
    }
    return [objX,objY];
}

function moveObj(obj,x,y) {
    obj.style.top = y+"px";
    obj.style.left = x+"px";
    return true;
}

function moveAd() {
    var oT = document.getElementById('flexiad');
    var oA = document.getElementById('lateAd');
    var r = getXY(oT);
    r[1] = r[1] + nATH;
    moveObj(oA,r[0],r[1]);
    return true;
}

function fai_check() {
    var fai_timer = setTimeout("new fai_call(0,0);",5000);
}

function fai_create() {
    var ad = new fai_call(0,0);
}

function adTechSetSize(w, h) {
    var ad1 = new fai_call(w, h);
}

function fnStartInit(bTrue) {
    if ((document.readyState=="complete") || (bTrue))
    {
        getATs();
        document.getElementById('lateAd').style.visibility = "visible";
        document.getElementById('rhc').style.visibility = "visible";
    }

    if (window.addEventListener) {
    	window.addEventListener("resize", moveAd, false);
    } else if (window.attachEvent) {
    	window.attachEvent("onresize", moveAd);
    }
}

function writeAdCall(mn, sizeid, keys) {
    var sCall = "<script language='JavaScript' src='http://ads.aol.co.uk/addyn|3.0|" + adSiteID + "|" + mn + "|0|" + sizeid + "|KEY=" + keys + ";target=_blank;loc=100;misc=1146765267;grp=1'><!-- if (navigator.userAgent.indexOf('Mozilla/2.') >= 0 || navigator.userAgent.indexOf('MSIE') >= 0) {document.write('<a href='http://ads.aol.co.uk/adlink|3.0|" + adSiteID + "|" + mn + "|0|" + sizeid + "|KEY=" + keys + ";grp=1;loc=200;' target='_blank'><img src='http://ads.aol.co.uk/adserv|3.0|" + adSiteID + "|" + mn + "|0|1|KEY=" + keys + ";grp=1;loc=200;misc=1146765267;' border='0' width='468' height='60'></a>');} // --></script>";
    document.write( sCall );
}

function getATs() {
    var eDiv = document.getElementById("lateAd");
    var aATs = new Array(9);
    var n = 0;
    var nDel = 0;
    if (eDiv.innerHTML.indexOf("collapsed") > 0) {
        nMainAdH = 0;
        eDiv.style.height = 0;
    }
    for(i=0;i<eDiv.childNodes.length;i++) {
        eChild = eDiv.childNodes[i];
        for(j=0;j<eChild.childNodes.length;j++) {
            if (eChild.childNodes[j].tagName == "!") {
            } else if (eChild.childNodes[j].tagName == "DIV") {
                if (eChild.childNodes[j].className == "ad_at") {
                    var eAT = eChild.childNodes[j];
                    aATs[n] = eAT;
                    n++;
                }
            } else if (eChild.childNodes[j].tagName == "A") {
                var eAT = eChild.childNodes[j];
                sAd = eAT.innerHTML;
                if ((sAd.indexOf("height=60 ") > 0) || (sAd.indexOf("height=\"60\"") > 0) || (sAd.indexOf("height='60'") > 0) || (sAd.indexOf("120x60_") > 0) || (sAd.indexOf("120x60.") > 0) || (sAd.indexOf("120x60;") > 0) || (sAd.indexOf("120x60_") > 0) || (sAd.indexOf("http://view.atdmt.com/MNC/view/lxxxonrk0060000038mnc/direct/01/") > 0)) {
                    aATs[n] = eAT;
                    n++;
                }
            } else if (eChild.childNodes[j].tagName == "OBJECT") {
                var eAT = eChild.childNodes[j]
                if (eAT.outerHTML) {
                    sAd = eAT.outerHTML;
                } else {
                    // Add sAd definition for FF
                    sAd = "";
                }
                if ((sAd.indexOf("height=\"60\"") > 0) || (sAd.indexOf("height=60 ") > 0) || (eAT.height == 60)) {
                    aATs[n] = eAT;
                    n++;
                }
            } else if (eChild.childNodes[j].tagName == "IMG") {                
                var eAT = eChild.childNodes[j];
                if (eAT.outerHTML) {
                    sAd = eAT.outerHTML;
                } else {
                    // Add sAd definition for FF
                    sAd = "";
                }
                if ((sAd.indexOf("height=60 ") > 0) || (sAd.indexOf("height=\"60\"") > 0) || (sAd.indexOf("height='60'") > 0) || (sAd.indexOf("120x60_") > 0) || (sAd.indexOf("120x60.") > 0) || (eAT.height == 60) || (sAd.indexOf("120x60;") > 0) || (sAd.indexOf("120x60_") > 0) || (sAd.indexOf("http://view.atdmt.com/MNC/view/lxxxonrk0060000038mnc/direct/01/") > 0)) {
                    aATs[n] = eAT;
                    n++;
                }
            }
        }
    }
    // move the ads
    var eFlexDiv = document.getElementById("flexiad");
    if (n > 0) {
        var eATFinalDiv = document.getElementById("ATs");
        for(i=0;i<n;i++) {
            var eAT = aATs[i];
            eAT.parentNode.removeChild(eAT);
            var eDiv1 = document.createElement("div");
            eDiv1.style.paddingBottom = "5px";
            eDiv1.appendChild(eAT);
            eATFinalDiv.appendChild(eDiv1);     
        }
        // make lateAd the right location below the ATs
        nATH = (n * 65);
        eDiv.style.top = eDiv.offsetTop + nATH;
    }
    // increase the size of the flexi-ad div to move the content around
    eFlexDiv.style.height = nATH + nMainAdH;    

}

//
// END Flexiad Code
//

//
// Utility functions
//
function addEvent(elm, evType, fn, useCapture)
{
	if (elm==null){
		return null;
	}
	if (/safari/i.test(navigator.userAgent) && evType == 'dblclick') {
		elm['ondblclick'] = handler;
	} else if (elm.addEventListener){
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent){
		var r = elm.attachEvent('on'+evType, function(){ fn(new W3CDOM_Event(elm)) } );
		return r;
	} else {
		throw new UserException("Cannot add event listener");
	}
}


function W3CDOM_Event(currentTarget) {
	this.currentTarget  = currentTarget;
	this.preventDefault = function() { window.event.returnValue = false }
	return this;
}

function UserException(message) {
   this.message = message;
   this.name = "UserException";
}

function classExists(obj, className){
	return new RegExp('\\b'+className+'\\b').test(obj.className);
}

function removeClass(obj,className){

	var rep=obj.className.match(' '+className)?' '+className:className;
	obj.className=obj.className.replace(rep,'');
}

function addClass(obj,className){
	if(!classExists(obj,className)){
		obj.className+=' '+className;
	}
}

function getTextContent(obj){
	if (obj.innerText) {
		return obj.innerText;
	} else if (obj.textContent) {
		return obj.textContent;
	} else {
		return obj.innerHTML;
	}
}

function setTextContent(obj, text){
	if (obj.innerText) {
		obj.innerText = text;
	} else if (obj.textContent){
		obj.textContent =  text;
	} else {
		obj.innerHTML = text;
	}
}

// returns the parent element of the given element type (and optionally, with a given classname)
function getParentElm(obj, elmType, classname){
	var ret;

	if (obj.parentNode == null){
		return null;
	}
	else if (obj.parentNode.nodeName==elmType){
		if (classExists(obj.parentNode, classname) || classname == '')
		{
			ret = obj.parentNode;
		} else {
			ret = getParentElm(obj.parentNode,elmType, classname);
		}
		
	} else if (obj.parentNode.nodeName=='BODY'){
		//throw new UserException("Cannot find parent node");
	} else {
		ret = getParentElm(obj.parentNode,elmType, classname);
	}
	return ret;
}

// Function to get all elements with a certain class
function getElementsByClassName(elemClass,elem,tag) {

	if (elem == null)
	{
		var matchingElements = new Array();
	} else {
		var sourceElements = elem.getElementsByTagName(tag);
		var matchingElements = new Array();
		var matchingElementsIndex = 0;
		var pattern = new RegExp("(^|\\s)"+elemClass+"(\\s|$)");
		for (i = 0; i < sourceElements.length; i++) {
			if ( pattern.test(sourceElements[i].className) ) {
				matchingElements[matchingElementsIndex] = sourceElements[i];
				matchingElementsIndex++;
			}
		}
	}
	return matchingElements;
}

//parallel to insertBefore function
function insertAfter(parent, node, referenceNode) {
	parent.insertBefore(node, referenceNode.nextSibling);
}

// cancels default event action
function stopDefaultAction(ev){
	ev.returnValue = false;
	ev.cancelBubble = true;
	if (!ev.type)
	{
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	}
	if (typeof ev.preventDefault != "undefined")
	{
		ev.preventDefault();
	}
	if (typeof ev.stopPropagation != "undefined")
	{
		ev.stopPropagation();
	}
}

// Functional Programming 'Map' function
function map(fn, a)
{
	for (i = 0; i < a.length; i++)
	{
		fn(a[i]);
	}
}

// extension to getElementById function which allows the provision for multiple ids
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1)
      return element;

    elements.push(element);
  }
  return elements;
}

// Generic Ajax functions
function makeRequest(url, fn, postdata){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser not supported");
		return;
	}
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			var response = xmlHttp.responseText;
			fn(url, response);
		}
	}
	if (!postdata)
	{
		xmlHttp.open("GET",url,true);
		xmlHttp.setRequestHeader("Content-Type", "text/xml");  
		xmlHttp.send(null);
	} else {
		xmlHttp.open("Post",url,true);
		xmlHttp.setRequestHeader("Content-Type", "text/xml"); 
		xmlHttp.send(postdata);
	}
}
	
function GetXmlHttpObject(){
	var objXMLHttp=null;
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
				objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

function trackOmnitureLink(account_name, link_name, prop18val, prop20val, link_entry){
	var s=s_gi(account_name);
	s_linkType="o";
	s_linkName=link_name;
	s.prop18=prop18val;
	s.prop20=prop20val;
	s.tl(this,'o',link_entry);
}

function addEventHandler (element, name, observer, useCapture) {
    name = name.toLowerCase();
    if (element.addEventListener) {
       element.addEventListener(name, observer, useCapture);
    } else if (element.attachEvent) {
        element.attachEvent(name, observer);
    } else {
        return false;
    }
}

/* Competitions Widget*/
function initCompWidget()	{
	var element = document.getElementById('competitions_widget_form');
	addEvent(element,"submit",handleCompFormSubmit,false );
}

function handleCompFormSubmit(ev)	{
	function generateQSArg(formInput){
		var returnStr = '';
		if (formInput.type != 'submit')
		{
			if (formInput.name.substring(0,8)=='question')
			{
				if (formInput.type == 'radio')
				{
					if (formInput.checked)
					{
						returnStr += formInput.name + '=' + formInput.value;
					}
				} else {
					returnStr +=  formInput.name + '=' + formInput.value;
				}
			} else {
				if (formInput.type == 'checkbox') {
					returnStr += formInput.name + '=' + formInput.checked;
				} else {
					returnStr += formInput.name + '=' + formInput.value;
				}
			}
		}
		return returnStr;
	}
	stopDefaultAction(ev);

	if (compValidation())
	{
		var compForm = document.getElementById('competitions_widget_form');
		var formInputs = compForm.getElementsByTagName('input');
		var textAreaInputs = compForm.getElementsByTagName('textarea');
		var querystring = '';
		compRedirectURL = '';

		for(i=0;i<formInputs.length;i++) 
		{	
			var qsArg = generateQSArg(formInputs[i]);
			if (qsArg != '')
			{
				if (i!=0)
					querystring += '&';
					querystring += qsArg;
			}
			if (formInputs[i].type == 'hidden')
			{
				if (formInputs[i].name == 'redirectURL')
				{
					compRedirectURL = formInputs[i].value;
				}
			}
			
		}
		
		for(i=0;i<textAreaInputs.length;i++) 
		{
			// handle textarea input separately
			querystring += '&' + textAreaInputs[i].name + '=' + textAreaInputs[i].value;
		}
		querystring = querystring.substring(1);
		
		if (window.location.search.indexOf('debug') > -1)
		{
			querystring += '&debug=1';
		}
		
		// loop through form questions

		var actionFld = '/_category/competitionsSubmit.adp';
		makeRequest(actionFld, compResponseFunc, querystring);
	} 

}
var compRedirectURL = '';

function compResponseFunc(url, str) {
	if (compRedirectURL == '')
	{
		document.getElementById('competitions_widget').innerHTML = str;
	} else {
		window.location = compRedirectURL;
	}
}

function validateQuestionsFilledIn(form){
	var QUESTION_PREFIX = 'question_';
	var questionsArray = new Array();

	// loop through all form elements
	for (var i=0;i<form.elements.length;i++) {
		var _elem = form.elements[i];
		// check and validate to see if the input is a question
		if (_elem.name.indexOf(QUESTION_PREFIX)>-1){
			var questionIndex = _elem.name.substring(QUESTION_PREFIX.length);
			// if it's a radio button, we need to loop through to see if any of the answers are checked for that given question (index)
			if (_elem.type =='radio'){
				if (!questionsArray[questionIndex])
				{
					questionsArray[questionIndex] = false;
				}
				if (_elem.checked)
				{
					questionsArray[questionIndex] = true;
				}
			}
			// if it's a textarea, we need to check to see if something has been entered for it
			if (_elem.type =='textarea')
			{
				if (_elem.value.length > 0){
					questionsArray[questionIndex] = true;
				} else {
					questionsArray[questionIndex] = false;
				}
			}
		}
	}
	for (var i=0;i<questionsArray.length;i++) {
		if (!questionsArray[i])
		{
			return false;
		}
	}
	return true;
}

function compValidation()	{
	var compForm = document.getElementById('competitions_widget_form');
	var mandatoryElements = new Array();
	var isValid = true;
	mandatoryElements = getElementsByClassName('mandatory',compForm,'input');
	var errorMessage = '';
	var mandatory_fields_not_populated_flag = false;
	var tandc_fields_not_populated_flag = false;
	
	for(i=0;i<mandatoryElements.length;i++)
	{
		removeClass(mandatoryElements[i],'invalid');
		// check for empty fields
		if (mandatoryElements[i].value.length == 0 )
		{
			addClass(mandatoryElements[i],'invalid');
			mandatory_fields_not_populated_flag = true;
			isValid = false;
		}
		if (mandatoryElements[i].id == 'terms_and_conditions' && !mandatoryElements[i].checked)
		{
			addClass(mandatoryElements[i],'invalid');
			tandc_fields_not_populated_flag = true;
			isValid = false;
		}
		
	}
	if (!validateQuestionsFilledIn(compForm))
	{
		errorMessage += QUESTION_FIELDS_NOT_POPULATED_ERROR;
	}

	if (mandatory_fields_not_populated_flag)
	{
		errorMessage += MANDATORY_FIELDS_NOT_POPULATED_ERROR;
	}
	if (tandc_fields_not_populated_flag)
	{
		errorMessage += TANDC_FIELDS_NOT_POPULATED_ERROR;
	}

	if (!isValid)
	{
		showError(errorMessage);
	}
	return isValid;
}

var QUESTION_FIELDS_NOT_POPULATED_ERROR = 'You haven\'t answered all the questions.\n';
var MANDATORY_FIELDS_NOT_POPULATED_ERROR = 'Mandatory fields have not been populated.\n';
var TANDC_FIELDS_NOT_POPULATED_ERROR = 'You must agree to the terms and conditions.';

function showError(errorKey){
	alert(errorKey);
}

/* Add to Favouries / Add Bookmark code */
function createBookmark() {

    title = document.title; 
    url = location.href;

    if ( window.external ) { // IE Favorite
        window.external.AddFavorite(url, title); 
    }
}

/* Send To A Friend Code
 * Adapted from US code at: cdn.digitalcity.com/_media/staf/staf_init.js
 */

function staf_SE() {

/*
 * Author : STaF Team
 * Includes UK Omniture tracking components.
 */


	var omniture_tracking;

	// Email This variables
	var width, height;        // Width and Height of Email Popup
	var im_width, im_height;  // Width and Height of Email Popup
	var lang = "";            // Language parameter

	// IM Variables
	var message = "";        // IM Message
	var linkURL = "";        // Default URL is the current page.
	var pageTitle = "";      // Page Title
	var confirm = false;     // Confirmation pop-up window for non-AOL browsers

	// Launch IM
	var sendIM = function () {
		winl = (screen.width - im_width) / 2;
		wint = (screen.height - im_height) / 2;

		if (winl < 0) winl = 0;
		if (wint < 0) wint = 0;

		window.open("http://sendtoafriend.aol.com/im.adp?url=" + linkURL + "&title=" + pageTitle + "&lang=" + lang, "IM_Window", "height=" + im_height + ",width=" + im_width + ",top=" + wint + ",left=" + winl + ",statusbar=0,toolbar=0,menubar=0,location=0,resizable=0");
	}

	// Launch Email
	var sendEmail = function () {
		winl = (screen.width - width) / 2;
		wint = (screen.height - height) / 2;

		if (winl < 0) winl = 0;
		if (wint < 0) wint = 0;

		window.open("http://sendtoafriend.aol.com/?url=" + linkURL + "&title=" + pageTitle + "&lang=" + lang, "Email_Window", "height=" + height + ",width=" + width + ",top=" + wint + ",left=" + winl + ",statusbar=0,toolbar=0,menubar=0,location=0,resizable=0");
	}

	// Default Values
	var setDefault = function () {
		message = "Your friend wants you to check this out:";
		linkURL = encodeURIComponent(document.location);
		pageTitle = encodeURIComponent(document.title);
		confirm = false;
		width = 292;
		height = 500;
		im_width = 292;
		im_height = 150;
		lang = "en-GB";
	}

	// Set default values.
	setDefault();

	return {

		sendIM: function () {
			if (omniture_tracking) {
				setOmniStaf("IM"); }
			sendIM();

			var omniTitle = decodeURIComponent(pageTitle);
			s.prop18="STaF - Sent IM on - "+s.channel;s.prop20="STaF - "+omniTitle;s.tl(this,"o","STaF - "+s.channel); s_gi(s_account);
			//alert('Omniture reporting: \n prop18 - '+s.prop18+'\n prop20 - '+s.prop20+  '\nlink name - '+s.tl)
		},

		sendEmail: function () {
			if (omniture_tracking) {
				setOmniStaf("Email"); }
			sendEmail();

			var omniTitle = decodeURIComponent(pageTitle);
			s.prop18="STaF - Sent EMail on - "+s.channel; s.prop20="STaF - "+omniTitle;s.tl(this,"o","STaF - "+s.channel); s_gi(s_account);
			//alert('Omniture reporting: \n prop18 - '+s.prop18+'\n prop20 - '+s.prop20+  '\nlink name - '+s.tl)
		},

		setMessage: function (custom_message) {
			if (typeof(custom_message) == "string") {
				message = custom_message;
			}
		},

		setWidth: function (custom_width) {
			if (typeof(custom_width) == "number") {
				width = custom_width;
			}
		},

		setHeight: function (custom_height) {
			if (typeof(custom_height) == "number") {
				height = custom_height;
			}
		},

		setIMWidth: function (custom_width) {
			if (typeof(custom_width) == "number") {
				im_width = custom_width;
			}
		},

		setIMHeight: function (custom_height) {
			if (typeof(custom_height) == "number") {
				im_height = custom_height;
			}
		},

		setLang: function (custom_lang) {
			if (typeof(custom_lang) == "string") {
				lang = custom_lang;
			}
		},

		setTitle: function (custom_title) {
			if (typeof(custom_title) =="string") {
				pageTitle = encodeURIComponent(custom_title);
			}
		},

		setURL: function (custom_url) {
			if (typeof(custom_url) =="string") {
				linkURL = encodeURIComponent(custom_url);
			}
		},

		setDefault: function () {
			setDefault();
		}
	};

}

// Wrappers for STAF to allow it to be used multiple times on a single page.
function customStafSend (url, title, message, fn) {
	if (staf_obj)
	{
		staf_obj.setURL(unescape(url));
		staf_obj.setTitle(unescape(title));
		staf_obj.setMessage(unescape(message));
		fn();
		staf_obj.setDefault();
	}
}
function customStafSendIM (url, title, message) {
	customStafSend (url, title, message, staf_obj.sendIM);
}
function customStafSendEmail (url, title, message) {
	customStafSend (url, title, message, staf_obj.sendEmail);
}


//Resizes page based on the size of an element in the page
function resizePage(elementID) {

  if (typeof elementID == "undefined")
    var element = document.body;
  else
    var element = document.getElementById(elementID);
  
  var oH = element.clip ? element.clip.height : element.offsetHeight;
  var oW = element.clip ? element.clip.width : element.offsetWidth;
  
  document.body.style.overflow = 'hidden';
  
  window.resizeTo( oW + 0, oH + 0 );
  var myW = 0, myH = 0, d = window.document.documentElement, b = window.document.body;
  
  if (window.innerWidth) { 
    
    myW = window.innerWidth; 
    myH = window.innerHeight; 
  }
  else if (d && d.clientWidth) { 
  alert(d.clientHeight);
    
    myH = d.clientHeight; 
  }
  else if (b && b.clientWidth) { 
    
    myW = b.clientWidth; 
    myH = b.clientHeight;
  }
  
  if (window.opera && !document.childNodes)
    myW += 16;
  
  document.body.style.overflow = '';
  window.resizeTo( oW + ((oW + 0) - myW), oH + ((oH + 0) - myH) );
  if( window.focus ) {window.focus();}
}

function setCustomOmnitureValues() {}



// Included to manage aol:// links

function showAOLLinkWarning() {
    var res = confirm('The link you have selected is only available inside the AOL Client.\n\nIf you have AOL installed click "OK" to continue, otherwise select "Cancel" to return to the previous page.');
    if(!res) {
        return false;
    } else {
        return true;
    }
}


function captureAOLLinkEvents(e) {
    if(navigator.userAgent.toLowerCase().indexOf('aol') == -1) {
        if(window.event){
            var myRef = window.event.srcElement;
            if(myRef.nodeName=="A") {
                if(myRef.href.indexOf('aol://')>=0) {
                    var res =  showAOLLinkWarning();
                    if(!res) {
                        window.event.returnValue = false;
                    } else {
                        window.event.returnValue = true;
                    }
                }
            }
        }
    }
}


function captureAOLIMGLinkEvents(e) {
    if(navigator.userAgent.toLowerCase().indexOf('aol') == -1) {
        if(window.event){
            var myRef = window.event.srcElement;
            if(myRef.nodeName=="IMG") {
                if(myRef.parentNode.href) {
                    if(myRef.parentNode.href.indexOf('aol://')>=0) {
                       var res =  showAOLLinkWarning();
                       if(!res) {
                          window.event.returnValue = false;
                       } else {
                          window.event.returnValue = true;
                       }
                    }
                }
            }
        }
    }
    captureGamesCompareLinks();
}

function captureGamesCompareLinks() {
    if(window.event){
        var myRef = window.event.srcElement;
        if(myRef.nodeName=="IMG") {
			if (myRef.parentNode.href)
			{
				if ((myRef.parentNode.href.indexOf('~NS-1~linkin_id-3063740/')>=0) || (myRef.parentNode.href.indexOf('~NS-1~linkin_id-3063740\\')>=0)) {
					myRef.parentNode.href = myRef.parentNode.href.substring(0,(myRef.parentNode.href.length - 1));
				}
			}
        }
    }
}

function captureAOLLink(e) {
    // Removes query string from aol:// links, except where passing http:// link as value
    // Multi-browser compatibility
    if(navigator.userAgent.toLowerCase().indexOf('msie') == -1) {
        var myRef = e.target;
    } else {
        var myRef = window.event.srcElement;
    }
    // If event is from an anchor tag, examine it and remove query string if needed
    if(myRef.nodeName=="A") {
        if(myRef.href.indexOf('aol://')>=0) {
            if(myRef.href.indexOf('href://') == -1){
                // Set New URL
                var url=myRef.href.split('?');
                myRef.href=url[0];
            }
        }
        if ((myRef.href.indexOf('hometown.aol.co.uk')>=0) || (myRef.href.indexOf('journals.aol.co.uk'))>=0) {
            rExp = /.n=.*p=.*c=.*/gi;
            myRef.href = myRef.href.replace(rExp,'');
        }
    }
    if(navigator.userAgent.toLowerCase().indexOf('aol') == -1) {
        if (myRef.nodeName=="IMG") {
            captureAOLIMGLinkEvents(e);
        } else {
            captureAOLLinkEvents(e);
        }
    } else {
        window.event.returnValue = true;
    }
}

// Only activate the link handler outside the client
if (navigator.userAgent.indexOf("AOL")>-1 && navigator.userAgent.indexOf("aolbrowser")==-1) {
    // do nothing.
} else {
    document.onclick = captureAOLLink;
}

// The two functions below are related and used for replacing ? withs £ in collections

function feedsGetElementsByClassName(searchClass,node,tag) {
    if(node == null)node=document;
    var ce = new Array();
    if(tag==null || tag=='*')tag='*';
    var els = new Array();
    els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    var i;var j;
    for (i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test(els[i].className) )
        if (ce.push) ce.push(els[i]);
        else ce[j++] = els[i];
    }
    return ce;
}

function replacePoundSigns () {
    /*var pageObj = document.getElementById('whole_page');
    var collectionLinks = new Array();
    collectionLinks = feedsGetElementsByClassName('module_body',pageObj,'ul');
    collectionLinks = collectionLinks.concat(feedsGetElementsByClassName('collection',pageObj,'ul'));
    var blocksLen = collectionLinks.length;
    for (var i=0; i < blocksLen; i++) {
      var expression = /\?(?=\d)/g;
      collectionLinks[i].innerHTML = collectionLinks[i].innerHTML.replace(expression,'&#163<!--poundsub-->');
    }*/
}

// Utility function needed for flash writing
function getBrowser() {
		var agt=navigator.userAgent.toLowerCase();
		if ((navigator.platform == "MacPPC" || navigator.platform == "mac") && agt.indexOf("aol") != -1) return 'aolmac';
		if (agt.indexOf("opera") != -1) return 'opera';
		if (agt.indexOf("staroffice") != -1) return 'staroffice';
		if (agt.indexOf("webtv") != -1) return 'webtv';
		if (agt.indexOf("beonex") != -1) return 'beonex';
		if (agt.indexOf("chimera") != -1) return 'chimera';
		if (agt.indexOf("netpositive") != -1) return 'netpositive';
		if (agt.indexOf("phoenix") != -1) return 'phoenix';
		if (agt.indexOf("firefox") != -1) return 'firefox';
		if (agt.indexOf("safari") != -1) return 'safari';
		if (agt.indexOf("skipstone") != -1) return 'skipstone';
		if (agt.indexOf("msie") != -1) return 'internetexplorer';
		if (agt.indexOf("netscape") != -1) return 'netscape';
		if (agt.indexOf("mozilla/5.0") != -1) return 'mozilla';
		if (agt.indexOf('\/') != -1) {
		if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
		return navigator.userAgent.substr(0,agt.indexOf('\/'));}
		else return 'Netscape';} else if (agt.indexOf(' ') != -1)
		return navigator.userAgent.substr(0,agt.indexOf(' '));
		else return navigator.userAgent;
}

// Generic object used to add flash to pages
var flashObject=function(swf, width, height, id, classId,codebase,pluginspage,type)
{
    this.variables = new Array();
	this.parameters = new Array();
	
    this.swf = swf || "";
    this.width = width || "100%";
    this.height = height || "100%";
    this.id = id || "";
	this.classId=classId || "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
	this.codebase=codebase || "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0";
	this.pluginspage=pluginspage || "http://www.adobe.com/go/getflashplayer";
	this.type=type || "application/x-shockwave-flash";
}

flashObject.prototype.setParam=function(name,value){this.parameters[name] = value;};
flashObject.prototype.setVar=function(name,value){this.variables[name] = value;}

flashObject.prototype.loadFlash=function(divId)
{
	eFlashDiv = document.getElementById(divId);
	var sBrowser = getBrowser();

	var flashHTML = "";

	flashHTML += '<object codebase="'+this.codebase+'" width='+this.width+' height='+this.height+' classId="'+this.classId+'" id="'+this.id+'" pluginspage="'+this.pluginspage+'" type="'+this.type+'" '; 
	for (var i in this.variables) {flashHTML += i+'="'+this.variables[i]+'" ';}
	flashHTML += '>';
	flashHTML += '<param name="movie" value="' + this.swf + '" />';

	for (var i in this.parameters) {flashHTML += '<param name="'+i+'" value="'+this.parameters[i]+'" />';}

	
	if (sBrowser == "internetexplorer")
	{		
		flashHTML += '</object>';			
	}
	else
	{
		flashHTML += '<embed src="'+this.swf+'" width="'+this.width+'" height="'+this.height+'" ';
		for (var i in this.variables) {flashHTML += i+'="'+this.variables[i]+'" ';}
		for (var i in this.parameters) {flashHTML += i+'="'+this.parameters[i]+'" ';}
		flashHTML += '></embed>';

		flashHTML += '</object>';
	}
			
	if(sBrowser == "aolmac"){
		eFlashDiv.innerHTML ="";
		document.write(flashHTML);	
	}
	else
	{
		if(eFlashDiv){eFlashDiv.innerHTML = flashHTML;}	
	}
}

function hasFlash()
{
	var sBrowser = getBrowser();
	var hasFlash;
	if(sBrowser == "internetexplorer"){
		if(IEFlashDetect() != "-1"){
			hasFlash = true;
		}
		else {
			hasFlash = false;
		}
	}
	else{
		if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){
			hasFlash = true;
		}
		else
		{
			hasFlash = false;
		}
	}
	return hasFlash;
}

function IEFlashDetect()
{
	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 {
			// 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;
		}
	}
	return version;
}

function loadAOLLink(sLink) {
    try {
        /* Load Target */
        if(document.getElementById("loadFrame")) {
            var oF = document.getElementById("loadFrame");
            oF.parentNode.removeChild(oF);
        }
        var oF = document.createElement("iframe");
        oF.style.display = "none";oF.style.width = "1px";oF.style.height = "1px";oF.id = "loadFrame";
        var oB = document.getElementsByTagName("body").item(0);
        oB.appendChild(oF);
        oF.src = sLink;
    } catch(e) { }   
}

/* Backlinks functions for article pages */

//Backlinks omniture tracking
function backlinksCL (linkType) {
	var omniTitle = document.title;
	s.prop18="Social Bookmarking - clicked "+linkType+" on - "+s.channel;
	s.prop20="Social Bookmarking - "+omniTitle;
	s.tl(this,"o","Social Bookmarking - "+s.channel);
	s_gi(s_account);
} 

var blURL=encodeURIComponent(document.location.href), blTitle=encodeURIComponent(document.title);
function blPop(url, linktype){
	window.open(url,'blPopup','width=800px,height=520px,status=0,location=0,resizable=1,scrollbars=1',0)
	backlinksCL(linktype);
}
function blGo(url, linktype){
	document.location.href = url;
	backlinksCL(linktype);
}

var FocusOnSearchOnloadObject = new Object();
FocusOnSearchOnloadObject.onload = function(){
	try {
			var gSearchHeaderElem = $('gSearch_header');
			if (gSearchHeaderElem)
			{
				var qb=getSearchElement('dsQuery','input');
				qb.focus();
				var shopPaneElems = getElementsByClassName('search_pane_shopping', gSearchHeaderElem, 'div');
				var musicPaneElems = getElementsByClassName('search_pane_music', gSearchHeaderElem, 'div');
				if (shopPaneElems.length > 0)
				{
					if (shopPaneElems[0].style.display != 'none')
					{
						getSearchElement('shopQuery','input').focus();
					}
				}
				if (musicPaneElems.length > 0)
				{
					if (musicPaneElems[0].style.display != 'none')
					{
						getSearchElement('musicQuery','input').focus();
					}
				}
			}

        } catch(e){}
}

Onload.register(FocusOnSearchOnloadObject);

function trackLinksAdtech(event) {
    var targetNode = event.currentTarget;
    if (targetNode.nodeName == "A" && ! targetNode.onclick) {
        var adTechURL = 'http://ads.aol.co.uk/adlink|3.0|517|'+targetNode.mn+'|0|'+targetNode.size+'|ADTECH;loc=100;adid='+targetNode.flightID+';bnid='+targetNode.bannerID+';link='+ targetNode.href + ';';
        event.currentTarget.href = adTechURL;
    }
}
