// -------- LAUNCHES INFINITE IN AS MANY FLAVORS AS YOU WANT --------

IE5=NN6=false
if(document.all)IE5=true
else if(document.getElementById)NN6=true

var prodTabIDs = new Array(2);
prodTabIDs[0] = "1180602579990";
prodTabIDs[1] = "1180602580008";
//prodTabIDs[2] = "1114292039903";
//prodTabIDs[3] = "1114292040775";

var homeTabIDs = new Array(3);
homeTabIDs[0] = "1114288696776";
homeTabIDs[1] = "1114288687066";
homeTabIDs[2] = "1114288691525";

var home2TabIDs = new Array(2);
home2TabIDs[0] = "1114288699827";
home2TabIDs[1] = "1114288702332";

var jobSolTabIDs = new Array(2);
jobSolTabIDs[0] = "1114292495992";
jobSolTabIDs[1] = "1114292496527";

var brochureTabIDs = new Array(3);
brochureTabIDs[0] = "1114293275826";
brochureTabIDs[1] = "1114293276182";
brochureTabIDs[2] = "1114293276587";

function showDiv(what,which,numdivs) {//	PATHS FOR ON AND OFF IMAGES
	var imagePathPrefix = "/3MContentRetrievalAPI/BlobServlet?locale=en_US&univid=";
	var imagePathPostfix = "&fallback=true&assetType=MMM_Image&blobAttribute=ImageFile&version=current";
	var imagePathPostfixOn = "&fallback=true&assetType=MMM_Image&blobAttribute=ThumbnailImage&version=current";
	var full_Image = document.getElementById("tab_"+which);
	var fullImage = document.getElementById("tab"+which);

//	TURN OFF ALL LAYERS AND/OR TABS
	for(i=0;i<numdivs;i++) {
		if(IE5) eval("document.all."+what+i+".style.display='none'")
		if(NN6) eval("document.getElementById('"+what+i+"').style.display='none'")
		if (what == "table") {//	PRODUCT FAMILY PAGES
			fullImage = document.getElementById("tab"+i);
			fullImage.src = imagePathPrefix + prodTabIDs[i] + imagePathPostfix;
		}
		if (what == "home") {//	HOME PAGE
			fullImage = document.getElementById("tab"+i);
			fullImage.src = imagePathPrefix + homeTabIDs[i] + imagePathPostfix;
		}
		if (what == "home2") {//	HOME PAGE
			full_Image = document.getElementById("tab_"+i);
			full_Image.src = imagePathPrefix + home2TabIDs[i] + imagePathPostfix;
		}
		if (what == "jobSol") {//	Job Solutions Page
			full_Image = document.getElementById("tab_"+i);
			full_Image.src = imagePathPrefix + jobSolTabIDs[i] + imagePathPostfix;
		}
		if (what == "brochures") {//	Brochures and Guides Page
			full_Image = document.getElementById("tab_"+i);
			full_Image.src = imagePathPrefix + brochureTabIDs[i] + imagePathPostfix;
		}
	}

//	GO BACK THROUGH AND TURN ON THE DESIRED LAYER AND/OR TABS
	if(IE5) eval("document.all."+what+which+".style.display='block'")
	if(NN6) eval("document.getElementById('"+what+which+"').style.display='inline'")

	if (what == "table") {//	PRODUCT FAMILY PAGES
		fullImage = document.getElementById("tab"+which);
		fullImage.src = imagePathPrefix + prodTabIDs[which] + imagePathPostfixOn;

		// we were having an issue with having two Products tabs both which have 'tab0' as an id (see ** on we needed 2 Products tabs).  So we changed the name of the second Products tab to 'tabProd'.  In doing this, the
		// original solution, which controlled the turning on and off of the images, no longer worked for the second Products tab.  So, the code below controls turning on and off the Products tab when both the Products 
		// and Documentation tabs are being displayed.  This code is only used when both tabs are displayed.

		// ** we needed 2 products tabs because CGD only wanted the Documentation tab displayed when there were documents, which is different from how the original XSLT, which we based our XSLT on, worked.  The original
		// XSLT displayed both the Products and Documents tabs all the time.  So our solution was to create two <div>s (oneTab and twoTabs), one that contained only the Product tab and another that contained both the Product and Documentation
		// tabs.  This allowed us to selectively choose which <div> to display.  rgentile 7.31.08
		
		prodImage = document.getElementById("tabProd");
		// if which == 1 we know the user has clicked on the Documentation tab which means we need to turn off the Products tab.
		if (which == 1) {
			// display off version of Products tab
			prodImage.src = "/3MContentRetrievalAPI/BlobServlet?locale=en_US&univid=1180602579990&fallback=true&assetType=MMM_Image&blobAttribute=ImageFile&version=current";
		} else {
			// display on version of Products tab			
			prodImage.src = "/3MContentRetrievalAPI/BlobServlet?locale=en_US&univid=1180602579990&fallback=true&assetType=MMM_Image&blobAttribute=ThumbnailImage&version=current";
		}
	}

	if (what == "home") {//	HOME PAGE
		fullImage = document.getElementById("tab"+which);
		fullImage.src = imagePathPrefix + homeTabIDs[which] + imagePathPostfixOn;
	}
	if (what == "home2") {//	HOME PAGE
		full_Image = document.getElementById("tab_"+which);
		full_Image.src = imagePathPrefix + home2TabIDs[which] + imagePathPostfixOn;
	}
	if (what == "jobSol") {//	Job Solutions Page
		full_Image = document.getElementById("tab_"+which);
		full_Image.src = imagePathPrefix + jobSolTabIDs[which] + imagePathPostfixOn;
	}
	if (what == "brochures") {//	Brochures and Guides Page
		full_Image = document.getElementById("tab_"+which);
		full_Image.src = imagePathPrefix + brochureTabIDs[which] + imagePathPostfixOn;
	}
}

// -------- HUGHES WINDOW OPENING FOR FLASH ------------
function hughesWindow(url) {
	var newWin = window.open(url,'rs','');
	newWin.focus();	
}

// -------- LAUNCHES LAYERS FROM PULLDOWN MENUS --------    
    IE5=NN6=false
    if(document.all)IE5=true
    else if(document.getElementById)NN6=true

    function showBack( which,numdivs ) {
        for(i=0;i<numdivs;i++) {
            if(IE5) eval("document.all.back"+i+".style.display='none'")
            if(NN6) eval("document.getElementById('back"+i+"').style.display='none'")
        }
		if (which == -1) {
	        for(j=0;j<numdivs;j++) {
		        if(IE5) eval("document.all.back"+j+".style.display='block'")
		        if(NN6) eval("document.getElementById('back"+j+"').style.display='inline'")
			}
		} else {
	        if(IE5) eval("document.all.back"+which+".style.display='block'")
	        if(NN6) eval("document.getElementById('back"+which+"').style.display='inline'")
		}
    }

function jumpMenu(selObj,restore){
eval("self.location='javascript:showBack("+selObj.options[selObj.selectedIndex].value+")'"); if (restore) selObj.selectedIndex=0;}

// -------- FLASH ACTIVEX CONTROLLER FIX -------- 

// new way to write the flash tag to get around the patent suit in IE
// args are as follows
// file -- path to swf file
// id -- object name in the DOM
// w -- width
// h -- height
// bg -- hex for background color, or 'transparent'
// al -- align parameter
function flashTag(file, id, w, h, bg, al, scale, vars){
	var txt = "<object type=\"application/x-shockwave-flash\" width=\""+w+"\" ";
	txt += "height=\""+h+"\"";
	if (id != null){
		txt += " id=\""+id+"\" name=\""+id+"\"";
	}
	txt += " data=\"/3MContentRetrievalAPI/BlobServlet?assetId=1114301184678&assetType=MMM_Image&blobAttribute=ImageFile&file="+file+"\"><param name=\"movie\" value=\"/3MContentRetrievalAPI/BlobServlet?assetId=1114301184678&assetType=MMM_Image&blobAttribute=ImageFile&file="+file+"\" />";
	if (bg == null){
		txt += "<param name=\"bgcolor\" value=\"#000000\" />";
	}else if (bg.toLowerCase() == "transparent"){
		txt += "<param name=\"wmode\" value=\"transparent\" />";
	}else{
		txt += "<param name=\"bgcolor\" value=\"#"+bg+"\" />";
	}
	if (scale != null){
		txt += "<param name=\"scale\" value=\""+scale+"\" />";
	}else{
		txt += "<param name=\"scale\" value=\"noscale\" />";
	}
	if(al != null){
		txt += "<param name=\"salign\" value=\""+al+"\" />";
	}
	if(vars != null){
		txt += "<param name=\"flashvars\" value=\""+vars+"\" />";
	}
	document.write(txt);
}

// this function will display the popup help in the QuickClicks sidebar
function showSearchHelp(state) {
	if (state == "on") {
		document.getElementById('searchHelpMe').style.display = 'block';
	} else {
		if (state == 'off') {
			document.getElementById('searchHelpMe').style.display = 'none';
		}	
	}
}
