// JavaScript Document
// Used for Flash popups on the site
/* Example on usage:
 * Format:  <a href='javascript:popupFlash("EWCD Flash Image URL",height,width,"Pagetitle");'>LinkText</a>
 * Example: <a href='javascript:popupFlash("_CSEMBED...",640,480,"3M: Meeting &amp; Presentation Solutions");'>LinkText</a>
 */

var popupwin = null;

function popupFlash(fileURL,fileWidth,fileHeight,popupTitle) {
	// Width & Height of your Flash Document
	var sx = fileWidth;
	var sy = fileHeight;
	// Position the window in the Middle of the Screen
	var winl = (screen.width-sx)/2;
	var wint = (screen.height-sy)/2;
	// The following two lines prevents an IE error.
	popupwin=window.open("","NewWindow","top="+wint+",left="+winl+",width=200,height=200");
	popupwin.window.close();
	
	var flash_insert="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+sx+"' height='"+sy+"'><param name='movie' value='"+fileURL+"'><param name=quality value=high><embed src='"+fileURL+"' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='"+sx+"' height='"+sy+"'></embed></object>";
	popupwin=window.open("","NewWindow","toolbar=no,location=no,scrollbars=no,directories=no,status=no,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");
	popupwin.document.write("<HTML><HEAD><TITLE>"+popupTitle+"</TITLE><style type='text/css'> HTML, BODY { overflow: hidden; margin:0;padding:0;color:#fff } </style></HEAD>"+flash_insert+"</HTML>");
	popupwin.window.focus();
}


// Used for Gallery Image-popups on the site
/* Example on usage:
 * Format:  <a href='javascript:popupFlash("EWCD Flash Image URL",height,width,"Pagetitle");'>LinkText</a>
 * Example: <a href='javascript: popupImage("_CSEMBED...",135,130,"3M")'>LinkText</a>
 */

function popupImage(ImageURL,fileWidth,fileHeight,popupTitle) {
	// Width & Height of your Flash Document
	var sx = fileWidth;
	var sy = fileHeight;
	// Position the window in the Middle of the Screen
	var winl = (screen.width-sx)/2;
	var wint = (screen.height-sy)/2;
	// The following two lines prevents an IE error.
	popupwin=window.open("","NewWindow","top="+wint+",left="+winl+",width=200,height=200");
	popupwin.window.close();
	
	var image_insert="<a href='javascript:self.close()'><img src='"+ImageURL+"' height='"+fileHeight+"' width='"+fileWidth+"' border='0'></a>";
	popupwin=window.open("","NewWindow","toolbar=no,location=no,scrollbars=no,directories=no,status=no,menubar=no,top="+wint+",left="+winl+",width="+sx+",height="+sy+"");
	popupwin.document.write("<HTML><HEAD><TITLE>"+popupTitle+"</TITLE><style type='text/css'> HTML, BODY { overflow: hidden; margin:0;padding:0;color:#fff } </style></HEAD><Bo"+"dy>"+image_insert+"</Bo"+"dy></HTML>");
	popupwin.window.focus();
}


// Tab Chooser ****************************************************************
	IE5=NN6=false
	if(document.all)IE5=true
	else if(document.getElementById)NN6=true
	
	// Tabs when they're on
	var homeTabIDsOn = new Array(3);
	homeTabIDsOn[0] = "1114291154508";
	homeTabIDsOn[1] = "1114291154916";
	homeTabIDsOn[2] = "1114291154952";
	// Tabs when they're off
	var homeTabIDsOff = new Array(3);
	homeTabIDsOff[0] = "1114291157016";
	homeTabIDsOff[1] = "1114291157053";
	homeTabIDsOff[2] = "1114291157090";
	
	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 fullImage = document.getElementById("tab"+which);
	
	//	TURN OF 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 == "home") {//		HOME PAGE
				fullImage = document.getElementById("tab"+i);
				fullImage.src = imagePathPrefix + homeTabIDsOff[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 == "home") {//		HOME PAGE
			fullImage = document.getElementById("tab"+which);
			fullImage.src = imagePathPrefix + homeTabIDsOn[which] + imagePathPostfix;
		}
	}
// END Tab Chooser ****************************************************************



