// sid - shader id
// tid - shader text id
function ShowShader(sid, tid, msg)
{
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shaderOn";
		tex.innerHTML = '<span>' + msg + '</span>';
	}
}

// sid - shader id
// tid - shader text id
function HideShader(sid, tid)
{
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shaderOff";
		tex.innerHTML = "&nbsp;";
	}
}

// sid - shader id
// tid - shader text id
function Show3Shader(sid, tid, msg) {
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shader3On";
		tex.innerHTML = '<span>' + msg + '</span>';
	}
}

// sid - shader id
// tid - shader text id
function Hide3Shader(sid, tid) {
	var sha = document.getElementById(sid);
	var tex = document.getElementById(tid);
	if (sha) {
		sha.className = "shader3Off";
		tex.innerHTML = "&nbsp;";
	}
}

// aid - adlinks container id
// sid - shader id
// cid - collapse container id
function ExpandAdLinks(aid, sid, cid)
{	
	//closes supplier links pop-up
	DisableVerticalSupplierLinksWithPublication()

	var ads = document.getElementById(aid);
	var sha = document.getElementById(sid);
	var col = document.getElementById(cid);
	if (ads) {
		sha.style.display = "none";
		ads.style.height = ads.scrollHeight + "px";
		col.style.display = "block";
		// This forces IE 7 to redraw the adlinks panel and position the 3 boxes below the adlinks to the correct position
		ads.parentNode.style.display = "none";
		ads.parentNode.style.display = "block"; 
	}
}

// aid - adlinks container id
// sid - shader id
// cid - collapse container id
// height - the height at which to collapse the container
function CollapseAdLinks(aid, sid, cid, height)
{
	//closes supplier links pop-up
	DisableVerticalSupplierLinksWithPublication()

	var ads = document.getElementById(aid);
	var sha = document.getElementById(sid);
	var col = document.getElementById(cid);
	if (ads) {
		ads.style.height = height + "px";
		sha.style.display = "block";
		col.style.display = "none";
		// This forces IE 7 to redraw the adlinks panel and position the 3 boxes below the adlinks to the correct position
		ads.parentNode.style.display = "none"; 
		ads.parentNode.style.display = "block";
	}
}

// show - bool value to show or hide drop down lists (true = visible)
function SetDropDownsVisibilityIE6(show)
{
	if (typeof document.body.style.maxHeight == "undefined") // This returns "undefined" only for IE6
	{
		var ddls = document.getElementsByTagName("select");
		for (i = 0; i < ddls.length; i++) {
			ddls[i].style.visibility = show ? "visible" : "hidden";
		}
	}
}

function EnableVerticalSupplierLinks(element)
{
	var lContainer = document.getElementById("verticalSupplierLinks");

	SetDropDownsVisibilityIE6(false);
	
	if (lContainer != null)
	{
		lContainer.style.top = findPosY(element) - 200 + 'px';
	
		SetSupplierDisplayStyle(lContainer,true);
	}
}

// by default - we hide the dropdown lists in IE6
function EnableVerticalSupplierLinksWithPublication(element, code, hideFlashMap, wideContainer, offsetX, offsetY, showDropDownLists)
{
	var lHtmlChildrenElements;
	var lContainer = document.getElementById("verticalSupplierLinksGeneralContainer");

//	if (!showDropDownLists)
//		SetDropDownsVisibilityIE6(false);
		
	if (hideFlashMap == true) {
		ShowCountryFlashMap(false);
	}
	
	if (lContainer != null) {
		if (offsetX != null)
			lContainer.style.left = (element.offsetLeft + 20) + offsetX + 'px';
		else
			lContainer.style.left = (element.offsetLeft + 20) + 'px';

		if (offsetY != null)
			lContainer.style.top = (element.offsetTop + 25) + offsetY + 'px';
		else
			lContainer.style.top = (element.offsetTop + 25) + 'px';

		if (wideContainer == true) {
			lContainer.style.width = '410px';
			if (offsetX == null) {
				lContainer.style.left = (element.offsetLeft) + 'px';
			}
		}
		else {
			lContainer.style.width = '201px';
		}
	
		SetSupplierDisplayStyle(lContainer,true);
		
		lHtmlChildrenElements = lContainer.childNodes;
	
		for (i = 0; i < lHtmlChildrenElements.length; i++)
		{
			if (lHtmlChildrenElements[i].id != null &&
			    lHtmlChildrenElements[i].id.indexOf ("verticalSupplierLinksSpecificContainer-") == 0)
			{
				if (lHtmlChildrenElements[i].id == ("verticalSupplierLinksSpecificContainer-" + code))
				{
					SetSupplierDisplayStyle(lHtmlChildrenElements[i], true);
				}
				else
				{
					SetSupplierDisplayStyle(lHtmlChildrenElements[i], false);
				}
			}
		}
		
		// Set the iframe
		var lIFrame = document.getElementById("SuppliersIFrame");
		var IE = document.all; // for IE6 we will add some extra width and height
		lIFrame.style.width = lContainer.scrollWidth + (IE ? 4 : 0) + "px";
		lIFrame.style.height = lContainer.scrollHeight + (IE ? 4 : 0) + "px";
		lIFrame.style.top = lContainer.offsetTop + "px";
		lIFrame.style.left = lContainer.offsetLeft + "px";
		lIFrame.style.display = "block";
	}
}


function DisableVerticalSupplierLinks()
{
	var lContainer = document.getElementById("verticalSupplierLinks");
	if (lContainer != null)
	{
		SetSupplierDisplayStyle(lContainer,false);
	}
	
	SetDropDownsVisibilityIE6(true);
}

function DisableVerticalSupplierLinksWithPublication ()
{
	var lContainer = document.getElementById("verticalSupplierLinksGeneralContainer");
	if (lContainer != null)
	{
		SetSupplierDisplayStyle(lContainer,false);
		
		// Set the iframe
		var lIFrame = document.getElementById("SuppliersIFrame");
		lIFrame.style.display = "none";
	}

	SetDropDownsVisibilityIE6(true);
	ShowCountryFlashMap(true);
}

function SetSupplierDisplayStyle(container,display)
{
		if(display == true)
		{	
			container.style.display = "block";
		}
		else
		{
			container.style.display = "none";
		}	
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) 
	{
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) 
		{
			curtop += obj.offsetTop
		}
	}
	return curtop;
}

