// JavaScript Document



// THE CODE BELOW IS USED FOR THE EXPANDING / COLLAPSING SECTIONS
function ExpandNCollapse(sectionId, imageName)
{
	expandit(sectionId);
	changeImage(imageName);
}

function expandit(sectionId)
{
	var folder = document.all ? document.all[sectionId].style : document.getElementById(sectionId).style;
	if (folder.display=="none")
		folder.display="block";
	else
		folder.display="none";
}

function changeImage(name)
{
	if (document[name].src != null && document[name].src == minusImage.src)
	{
		document[name].src = plusImage.src;
		document[name].alt = plusImage.alt;
	}
	else
	{
		document[name].src = minusImage.src;
		document[name].alt = minusImage.alt;
	}
}

function FULLexpandNcollapse()
{
	for (i=0; i<13; i++)
		if ((document.getElementById("section["+i+"]").style.display=="none" && !fullExpand) ||
			(document.getElementById("section["+i+"]").style.display=="block" && fullExpand))
				ExpandNCollapse("section["+i+"]","drop["+i+"]");
	fullExpand = !fullExpand;
}

function formatDates()
{
	var monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

	var TDs = document.all ? document.all.tags("td") : document.getElementsByTagName("td");
	for (t=0; t<TDs.length; t++)
	{
		var text = TDs[t].innerHTML;
		if (TDs[t].className.indexOf("ESPEnews") > -1 && text.indexOf("00:00:0") > -1)
		{
			text = text.split("00:00:0")[0];

			var year = text.split("-")[0];
			var month = text.split("-")[1];
			var day = text.split("-")[2].split(" ")[0];
			
			if (location.href.toString().indexOf("en_US") > -1)
				text = month + " / " + day + " / " + year;
			else
				text = day + " / " + month + " / " + year;

			TDs[t].innerHTML = text;			
		}
	}
}

function truncateBreadCrumb()
{
	var oldBreadCrumb = document.getElementById("cShellBcrumb").innerHTML.split("&nbsp;");
	var newBreadCrumb = "";
	for (i=0; i<oldBreadCrumb.length; i++)
	{
		temp = oldBreadCrumb[i].toLowerCase();
		if (temp.indexOf("></a>") < 0 && temp.indexOf("> </a>") < 0 && temp.indexOf("not used</a>") < 0)
			newBreadCrumb += oldBreadCrumb[i] + " ";
		if (location.href.indexOf("hu_HU") > -1 && i == oldBreadCrumb.length-2)
			newBreadCrumb += " &gt; <a href='/wps/portal/3M/hu_HU/3M-ESPE/dental-professionals/products/new/'>&Uacute;j term&eacute;kek</a> ";
	}
	document.getElementById("cShellBcrumb").innerHTML = newBreadCrumb;
	
//	window.alert(oldBreadCrumb + "\n\n\n" + newBreadCrumb);
}

// 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>
 */
var popupwin = null;
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("<ht" + "ml><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();
}