// 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)

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]=""
noflashText[1]=""
noflashText[2]=""
noflashText[3]=""
noflashText[4]=""
noflashText[5]=""

var noflashLink=new Array() //Links for non flash banners
noflashLink[0]=""
noflashLink[1]=""
noflashLink[2]=""
noflashLink[3]=""
noflashLink[4]=""
noflashLink[5]=""


function FlashTag(p_Section, p_flash, p_height, p_txtsize, p_txtalt,p_link,p_Newimg){

	/*if (!p_flash || getFlashVersion() < 5){
		
			if (p_Newimg !=""){
				if (p_height =="220"){*/
					/*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="images/arrow-find.gif" alt="" border="0">Find out more</a></div>');*/
					document.write('<img src="common/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 =="220" ){
					document.write('<img src="images/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 =="220"){
				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="images/arrow-findout.gif" alt=""> Find out more</a></div>');
				document.write('<img src="images/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="images/arrow-find.gif" alt=""> Find out more</a></div>');  
			document.write('<img src="images/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('flashObj'); 
			el.className ="flashBack"+flashBg;
			document.write('<object type="application/x-shockwave-flash" data="homePage-us-home.swf?Id='+ (flashBg - 1) +'" width="760" height="259" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" >');
			document.write('<param name="movie" value="homePage-us-home.swf?Id='+ (flashBg - 1) +'" />');
			document.write('<param name="allowScriptAccess" value="sameDomain" />');
			document.write('<param name="wmode" value="transparent" />');
			document.write('<embed src="homePage-us-home.swf?Id='+ (flashBg - 1) +'" quality="high" wmode="transparent" bgcolor="#ffffff" width="760" height="259" name="homePage" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
			document.write(' </object>');			
		   }
			
	   } 
	 */
}

	
/*  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)=="index.html")
				{
					 myWin.location = myVal;
				}
				else
				{

					myWin.open(myVal);
				}
			
			
	   }
return false;
}


/*

				OPEN WINDOW

*/

function DW1(dwURL) {
popupWin = window.open(dwURL, 'DW1', 'scrollbars,resizable=yes,width=517,height=400,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];}
}

/*Added by Wipro for Primary Navigation Links*/
function activePrmLink() {
	var winLoc = window.location.href;
	var folderName = "html/"; // word appears before section folder name in URL
	var folderLgt = folderName.length;
	var index = winLoc.indexOf(folderName);
	var lastIndex = winLoc.lastIndexOf("/");
	var getVal = winLoc.slice(index+folderLgt, lastIndex);
	var docElement = document.getElementById(getVal).firstChild;
	docElement.style.backgroundImage = "url(../../images/activeLink-arrow.gif)";
	docElement.style.backgroundRepeat = "no-repeat";
	docElement.style.backgroundPosition = "left center";
	docElement.style.color = "#f55a1c";
}
/*Added by Wipro for Left Navigation Links*/
function activeLeftLink(param, menuID1, menuID2, menuID3 ) {
	var linkID = param;
	if (linkID.length == "9") {
		// for Second level
		var docElemtLink = document.getElementById(linkID);
		docElemtLink.className = "inActive";
		var subMenu = document.getElementById(menuID1);
		subMenu.className = "displayON";
	}
	
	if (linkID.length == "12") {
		// for second level link
		var docPrntID = param.slice("0", param.lastIndexOf("-"));
		var docPrntLink = document.getElementById(docPrntID);
		docPrntLink.className = "inActive";
		var subMenu = document.getElementById(menuID1);
		subMenu.className = "displayON";
		// for Third level link
		var docElemtLink = document.getElementById(linkID);
		docElemtLink.className = "inActive";
		var subMenu2 = document.getElementById(menuID2);
		subMenu2.className = "displayON";		
	}
	
	
	else if (linkID.length == "15") {
		// for second level link
		var docPrntID1 = param.slice("0", param.indexOf("-"));
		var docPrntLink1 = document.getElementById(docPrntID1);
		docPrntLink1.className = "inActive";
		var subMenu = document.getElementById(menuID1);
		subMenu.className = "displayON";
		// for Third level link
		var docPrntID = param.slice("0", param.lastIndexOf("-"));
		var docPrntLink = document.getElementById(docPrntID);
		docPrntLink.className = "inActive";
		var subMenu = document.getElementById(menuID2);
		subMenu.className = "displayON";
		// for Fourth level link
		var docElemtLink = document.getElementById(linkID);
		docElemtLink.className = "inActive";
		
	}
	else if (linkID.length == "18") {
		// for second level link
		var docPrntID1 = param.slice("0", param.indexOf("-"));
		var docPrntLink1 = document.getElementById(docPrntID1);
		docPrntLink1.className = "inActive";
		var subMenu = document.getElementById(menuID1);
		subMenu.className = "displayON";
		// for Third level link
		var docPrntID = param.slice("0", param.lastIndexOf("-")-3);
		var docPrntLink = document.getElementById(docPrntID);
		docPrntLink.className = "inActive";
		var subMenu = document.getElementById(menuID2);
		subMenu.className = "displayON";
		// for Fourth level link
		var docPrntID = param.slice("0", param.lastIndexOf("-"));
		var docPrntLink = document.getElementById(docPrntID);
		docPrntLink.className = "inActive";
		var subMenu = document.getElementById(menuID3);
		subMenu.className = "displayON";
		// for Fifth level link
		var docElemtLink = document.getElementById(linkID);
		docElemtLink.className = "inActive";
		
	}
	
}

<!-- Showing and hidding data values -- !>

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";
}



// Added by Wipro to refocus the page on click of browser back button and to check the Operating systemif it is MAC. 
// This funtion is to support navigation functions defined above
onload=function(){ 
	window.focus();
}



//External Popup window script
function openExternalSite() {
	var winLoc = window.location.href;
	var folderLgt = winLoc.length;
	var lastIndex = winLoc.lastIndexOf("?");
	var getVal = winLoc.slice(lastIndex+1, folderLgt);
	window.location.href = getVal
}

function consumerClick () {
	
	var valName = document.quicklinks.consumer.options[document.quicklinks.consumer.selectedIndex].value;
	var folderLgt = valName.length;
	var lastIndex = valName.lastIndexOf(":");
	var getVal = valName.slice(lastIndex, folderLgt).length;
	var strLnk = valName.slice(getVal, folderLgt);
	if (strLnk == ".htm" || strLnk == "html" ) {
	window.open(valName,'win_name', '' );
	}
	else {
	window.location.href = valName;
	}
}
