// Flash Version Detector  v1.2.1
// documentation: http://www.dithered.com/javascript/flash_detect/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)
// with VBScript code from Alastair Hamilton (now somewhat modified)


/*Build flash function*/
function buildFlash (divId, swfLoc, swfHeight, swfWidth){
		var so = new SWFObject(swfLoc, "swfName", swfWidth, swfHeight, 7, "#FFFFFF");
		so.addParam("wmode", "transparent");
		so.addParam("scale", "noscale");
		if (so.installedVer.major >=7){
			so.write(divId);
		}
}


function isDefined(property) {
  return (typeof property != 'undefined');
}

var flashVersion = 0;
function getFlashVersion() {
var latestFlashVersion = 8;
   var agent = navigator.userAgent.toLowerCase(); 
	
   // NS3 needs flashVersion to be a local variable
   if (agent.indexOf("mozilla/3") != -1 && agent.indexOf("msie") == -1) {
      flashVersion = 0;
   }
   
	// NS3+, Opera3+, IE5+ Mac (support plugin array):  check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		var flashPlugin = navigator.plugins['Shockwave Flash'];
		if (typeof flashPlugin == 'object') { 
			for (var i = latestFlashVersion; i >= 3; i--) {
            if (flashPlugin.description.indexOf(i + '.') != -1) {
               flashVersion = i;
               break;
            }
         }
		}
	}

	// IE4+ Win32:  attempt to create an ActiveX object using VBScript
	else if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) >= 4 && agent.indexOf("win")!=-1 && agent.indexOf("16bit")==-1) {
	   var doc = '<scr' + 'ipt language="VBScript"\> \n';
      doc += 'On Error Resume Next \n';
      doc += 'Dim obFlash \n';
      doc += 'For i = ' + latestFlashVersion + ' To 3 Step -1 \n';
      doc += '   Set obFlash = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) \n';
      doc += '   If IsObject(obFlash) Then \n';
      doc += '      flashVersion = i \n';
      doc += '      Exit For \n';
      doc += '   End If \n';
      doc += 'Next \n';
      doc += '</scr' + 'ipt\> \n';
      document.write(doc);
   }
		
	// WebTV 2.5 supports flash 3
	else if (agent.indexOf("webtv/2.5") != -1) flashVersion = 3;

	// older WebTV supports flash 2
	else if (agent.indexOf("webtv") != -1) flashVersion = 2;

	// Can't detect in all other cases
	else {
		flashVersion = flashVersion_DONTKNOW;
	}

	return flashVersion;
}

flashVersion_DONTKNOW = -1;


var agt= navigator.userAgent.toLowerCase();

var noflashText=new Array() //Heading and text for non flash banners
noflashText[0]="<h1>AIDS at 25</h1>	<p>5 June 2006 marked 25 years since <br />the first cases of AIDS were reported. <br />But what does the future hold?</p>"
noflashText[1]="<h1>Every breath you take</h1>	<p>Asthma is a growing problem in developed <br />countries with 100-150 million people affected <br />by this breathing disorder.</p>"
noflashText[2]="<h1>Eliminating lymphatic filariasis</h1>	<p>Through partnership and donation of <br />albendazole, GSK is working to help <br />eliminate this terrible disease.</p>"
noflashText[3]="<h1>Kicking the habit</h1>	<p>Over a billion people worldwide smoke tobacco, <br />yet it is the leading preventable cause of death globally. <br />So what is the fascination with this lethal leaf?</p>"
noflashText[4]="<h1>The menace of malaria</h1>	<p>Feared since the days of the<br />Roman Empire, malaria remains<br />a major health problem.</p>"
noflashText[5]="<h1>The white plague</h1>	<p>Tuberculosis (TB) was once thought<br />to be a disease of the past, but it <br />has returned in a big way.</p>"

var noflashLink=new Array() //Links for non flash banners
noflashLink[0]="/infocus/aidsat25.htm"
noflashLink[1]="/infocus/asthma.htm"
noflashLink[2]="/infocus/eliminating.htm"
noflashLink[3]="/infocus/tobacco.htm"
noflashLink[4]="/infocus/malaria.htm"
noflashLink[5]="/infocus/whiteplague.htm"


function FlashTag(p_Section, p_flash, p_height, p_txtsize, p_txtalt,p_link,p_Newimg){
	
	if (!p_flash || getFlashVersion() < 6){
			
			if (p_Newimg !=""){
				if (p_height =="257"){
					
					document.write('<div id="txt-top-noflash">'+ noflashText[flashBg-1] +'</div>');
					document.write('<div id="'+ p_txtsize +'"><a href="'+ noflashLink[flashBg-1] +'" class="white"><img src="/common/img/arrow-find.gif" alt=""> Find out more</a></div>');
					document.write('<img src="/common/img/banner/0' + flashBg + '_01.jpg" border="0" alt="' + noflashText[flashBg-1] + '" width="760" height="'+ p_height+'">'); 
				}
				else{
					document.write('<div id="'+ p_txtsize +'"><a href="'+ p_link +'"><img src="/common/img/'+ p_Section +'/txt-'+ p_Section +'-small.gif" border="0" alt="'+ p_txtalt +'"></a></div>'); 
					document.write('<img src="/common/img/'+ p_Section +'/v-'+ p_Newimg +'-small.jpg" border="0" alt="" width="760" height="'+ p_height+'">'); 
				}
			}
			else {
				if (p_height =="257" ){
			
					document.write('<img src="/common/img/banner/0' + flashBg + '_01.jpg" border="0" alt="" width="760" height="'+ p_height+'">');  
				}
				else{
					document.write('<img src="/common/img/'+ p_Section +'/v-'+ p_Section +'-small.jpg" border="0" alt="" width="760" height="'+ p_height+'">'); 
				}
			}
	}
	else {
		if(agt.indexOf("safari")!=-1)  {
		 
			if (p_height =="257"){
				document.write('<div id="txt-top-noflash">'+ noflashText[flashBg-1] +'</div>');
				document.write('<div id="'+ p_txtsize +'"><a href="'+ noflashLink[flashBg-1] +'" class="white"><img src="/common/img/arrow-find.gif" alt=""> Find out more</a></div>');
				document.write('<img src="/common/img/banner/0' + flashBg + '_01.jpg" border="0" alt="' + noflashText[flashBg-1] + '" width="760" height="'+ p_height+'">'); 
			}
			else{
			document.write('<img src="/common/img/'+ p_Section +'/v-'+ p_Section +'-small.jpg" border="0" alt="" width="760" height="'+ p_height+'">'); 
			}
		}
		else if((agt.indexOf("msie")!=-1) && (navigator.userAgent.indexOf("Mac") != -1)) {
			if (p_height =="257"){
			document.write('<div id="txt-top-noflash">'+ noflashText[flashBg-1] +'</div>');
			document.write('<div id="'+ p_txtsize +'"><a href="'+ noflashLink[flashBg-1] +'" class="white"><img src="/common/img/arrow-find.gif" alt=""> Find out more</a></div>');  
			document.write('<img src="/common/img/banner/0' + flashBg + '_01.jpg" border="0" alt="' + noflashText[flashBg-1] + '" width="760" height="'+ p_height+'">'); 
			}
			else{
			document.write('<img src="/common/img/'+ p_Section +'/v-'+ p_Section +'-small.jpg" border="0" alt="" width="760" height="'+ p_height+'">'); 
			}
		}
		else {
			var el=document.getElementById('flash-pict-home'); 
			el.className ="flashBack"+flashBg;
			document.write('<object type="application/x-shockwave-flash" data="/common/flash/home/homePage.swf?Id='+ (flashBg - 1) +'" width="760" height="'+ p_height+'">');
			document.write('<param name="movie" value="/common/flash/home/homePage.swf?Id='+ (flashBg - 1) +'" />');
			document.write('<param name="allowScriptAccess" value="sameDomain" />');
			document.write('<param name="wmode" value="transparent" />');
			document.write('<embed src="/common/flash/home/homePage.swf?Id='+ (flashBg - 1) +'" quality="high" wmode="transparent" bgcolor="#ffffff" width="760" height="280" name="homePage" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
			document.write(' </object>');			

		   }
			
	   } 
	 
}
var messageNo = 0;
function getBanner(x){
	messageNo = x-1;
	
	var agent = navigator.userAgent.toLowerCase()
	mac = agent.indexOf("mac")!=-1;
	if (mac){ 
		loadXML();
	}
	else{
		try
		{		
				document.getElementById("flash-pict-home").style.background = "url(/common/img/banner/0" + x + "_01.jpg) no-repeat"
				var loc = "/common/flash/banner.swf"
				var so = new SWFObject(loc, "banner", "760", "238", 7, "#FFFFFF");
				so.addParam("wmode", "transparent");
				so.addParam("scale", "No Border");
				 so.addVariable("Id", messageNo);
				 if (so.installedVer.versionIsValid(so.getAttribute('version'))){
					so.write("flash-pict-home"); 
				 }
				 else{
					loadXML(); 
				 }
		}
		catch(err)
		{
			loadXML();
		}
	}
}

var xmlDoc;
function loadXML()
{

// code for IE
if (window.ActiveXObject)
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  xmlDoc.async=false;
  xmlDoc.load("/common/xml/images.xml");
  getmessage();

  }
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation &&
document.implementation.createDocument)
  {
	  
  xmlDoc=document.implementation.createDocument("","",null);
  xmlDoc.load("/common/xml/images.xml");
  xmlDoc.onload=getmessage;

  }
}

function getmessage()
{	
	document.getElementById("flash-pict-home").style.background = 'url(' + xmlDoc.getElementsByTagName("image")[messageNo].firstChild.nodeValue + ') no-repeat';
	document.getElementById("fHead").innerHTML = xmlDoc.getElementsByTagName("headline")[messageNo].firstChild.nodeValue;
	document.getElementById("fText").innerHTML = xmlDoc.getElementsByTagName("text")[messageNo].firstChild.nodeValue;
	var lnk = xmlDoc.getElementsByTagName("linktext")[messageNo].firstChild.nodeValue;
	if (lnk != null && lnk != ""){
		document.getElementById("fLink").innerHTML= "<a href='" + xmlDoc.getElementsByTagName("link")[messageNo].firstChild.nodeValue + "'>" + xmlDoc.getElementsByTagName("linktext")[messageNo].firstChild.nodeValue + "</a>"
	}
}

	
/*  TABLE     display: block;*/

var height;
var Category;
function displaySwapShow(p_id, p_class){
	if(document.getElementById(p_id)!='undefined'&&document.getElementById(p_id)!=null){
		document.getElementById(p_id).style.display = 'block'
	
		
		if (height =="280"){
		document.getElementById(p_class).className ="hmenu-table-off";
		}
		else{
			document.getElementById(p_class).className ="menu-table-off";
	
		
		}

		if (Category =="utilities") {
		 document.getElementById(p_class).className ="menu-contact-table-off";
		}
		

	}
}	

function displaySwapHidden(p_id, p_class)
{
	if(document.getElementById(p_id)!='undefined'&&document.getElementById(p_id)!=null)
	{
		document.getElementById(p_id).style.display = 'none' 
		if (height =="280"){
		document.getElementById(p_class).className ="hmenu-table";
		}
		else{
		document.getElementById(p_class).className ="menu-table";
		}
		if (Category =="utilities") {
		 document.getElementById(p_class).className ="menu-contact-table";
		}	
		
	}
}

function displayShow(p_id) {

		 document.getElementById(p_id).style.display = 'block';
}
function displayHidden(p_id) {

			document.getElementById(p_id).style.display = 'none';
}


				
function swapIt(hide,show) {
    show.style.display = "";
    hide.style.display = "none";
  }


/* END TABLE     display: block;*/	

/*

				Drop down

*/

function dropdown(mySel){
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
	if(myVal){
			if(mySel.form.target)myWin = parent[mySel.form.target];
			
			else myWin = window;
			
			if (! myWin) return true;
			myWin.location = myVal;
	   }
return false;
}
function dropdownTarget(mySel){
var myWin, myVal;

myVal = mySel.options[mySel.selectedIndex].value;
	if(myVal){
			if(mySel.form.target)myWin = parent[mySel.form.target];
			
			else myWin = window;
			if (! myWin) return true;
		 	if (myVal.charAt(0)=="/")
				{
					 myWin.location = myVal;
				}
				else
				{

					myWin.open(myVal);
				}
			
			
	   }
return false;
}

//media photo library
function moveMe(direction){
	var obj = document.getElementById("scroller")
	var w = obj.offsetWidth;
	var lft = parseInt(getStyle(obj, "left"));
	var num = 65;
	if(direction == "right"){ 
		num*=-1;
	}
	var clp = 254 + (lft*-1) + num;
	if (clp < w && clp >= 254){
		obj.style.left = (lft-num) + "px"
		obj.style.clip = "rect(0px " + clp + "px 74px " + (clp - 254) + "px)";		
	}
}
function clearMove(){
		var obj = document.getElementById("scroller")
		obj.style.left = "0px"
		obj.style.clip = "rect(0px 254px 74px 0px)";
}
//Returns css style values for an element
function getStyle(oElm, strCssRule){
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
    }
    else if(oElm.currentStyle){
        strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}


/*

				OPEN WINDOW

*/

function DW1(dwURL) {
popupWin = window.open(dwURL, 'DW1', 'scrollbars,resizable=yes,width=700,height=600,left=25,top=25');
window.top.name = 'opener';
}
function DW(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=517,height=400,left=25,top=25');
window.top.name = 'opener';
}
function DW2(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=433,height=400,left=25,top=25');
window.top.name = 'opener';
}
function DW4(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=560,height=370,left=25,top=25');
window.top.name = 'opener';
}
function DW5(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=587,height=370,left=25,top=25');
window.top.name = 'opener';
}
function DW6(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=587,height=570,left=25,top=25');
window.top.name = 'opener';
}
function DW8(dwURL) {
popupWin = window.open(dwURL, 'DW8', 'resizable=no,width=400,height=590,left=25,top=25');
window.top.name = 'opener';
}


function Present(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=805,height=450,left=25,top=25');
window.top.name = 'opener';
}
function Present2(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=790,height=593,left=25,top=25');
window.top.name = 'opener';
}
function External(dwURL) {
popupWin = window.open(dwURL, 'DW1', 'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=700,height=600,left=25,top=25');
window.top.name = 'opener';
}



//legacy script - used everywhere except careers
function DW1(dwURL) {
popupWin = window.open(dwURL, 'DW1', 'scrollbars,resizable=yes,width=700,height=600,left=25,top=25');
window.top.name = 'opener';
}
//used in careers - updated as it clashed with earlier version of DW1 used in the about section
function DWjoin(dwURL) {
popupWin = window.open(dwURL, 'DWjoin', 'scrollbars,resizable=yes,width=600,height=550,left=25,top=25');
window.top.name = 'opener';
}

function DWUS(dwURL) {
popupWin = window.open(dwURL, 'DWUS', 'scrollbars,resizable=yes,width=575,height=500,left=25,top=25');
window.top.name = 'opener';
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
var loc = "http://"+selObj.options[selObj.selectedIndex].value;
if(loc.length > 9)
	window.location=loc;
}

function Profile(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=667,height=450,left=25,top=25');
window.top.name = 'opener';
}

function Hemscott(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=667,height=450,left=25,top=25');
window.top.name = 'opener';
}
//used in the products section mainly
function openProducts(dwURL) {
  products = window.open(dwURL, 'products', 'scrollbars,resizable=yes,width=520,height=400,left=25,top=25');
  window.top.name = 'opener';
}

function Profilebig(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=800,height=700,left=25,top=25');
window.top.name = 'opener';
}

function PCbig(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=882,height=600,left=25,top=25');
window.top.name = 'opener';
}

function chartinfo(dwURL) {
popupWin = window.open(dwURL, 'DW', 'scrollbars,resizable=yes,width=300,height=200');
window.top.name = 'opener';
}
//Used for flash content in Your Health
function healthflash(dwURL) {
popupWin = window.open(dwURL, 'DW', 'resizable=yes,width=585,height=445,left=25,top=25');
window.top.name = 'opener';
}

function doSearch() {
  document.forms[1].submit();
}
function display_search() {
  if (navigator.appName == "Netscape") { 
    document.write("<input type=text name=Search size=8 maxlength=50>");
  }
  else { 
    document.write("<input type=text name=Search size=14 maxlength=50>");
  }
}

//About us/background/history flash file/ Function written for calling from the flash movie. It turns all divs off besides the one requested.
function displayHideOthers(p_id) {

		 document.getElementById('1700').style.display = 'none';
		 document.getElementById('1800').style.display = 'none';
		 document.getElementById('1850').style.display = 'none';
 		 document.getElementById('1900').style.display = 'none';				 		 
 		 document.getElementById('1950').style.display = 'none';
		 document.getElementById('2000').style.display = 'none';		 
		 document.getElementById(p_id).style.display = 'block';
}


//Community/default page/Function written for calling from the flash movie. It turns all divs off besides the one requested.
function displayPartnership(p_id) {

		 document.getElementById('prog0').style.display = 'none';
		 document.getElementById('prog1').style.display = 'none';
		 document.getElementById('prog2').style.display = 'none';
		 document.getElementById('prog3').style.display = 'none';
 		 document.getElementById('prog4').style.display = 'none';				 		 
 		 document.getElementById('prog5').style.display = 'none';
		 document.getElementById('prog6').style.display = 'none';
		 document.getElementById('prog7').style.display = 'none';
		 document.getElementById('prog8').style.display = 'none';
		 document.getElementById('prog9').style.display = 'none';
 		 document.getElementById('prog10').style.display = 'none';				 		 
 		 document.getElementById('prog11').style.display = 'none';
		 document.getElementById('prog12').style.display = 'none';	
		 document.getElementById(p_id).style.display = 'block';		 

}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
