var subNavOffSet = {
		"about":"350px",	//"285px", when history is included
		"capabilities":"85px",
		"businesses":"300px",
		"careers":"535px",
		"contact":"0px",
		"privacy":"0px",
		"":"0px"
	};
var subNavSelection = {
		"about":{"":"", "directions":""},
		"capabilities":{"":"","scm":"","cm":"","src":"","distr":"","mkt":"","custInt":""},
		"businesses":{"":"","cpg":"","psg":"","nv":""},
		"careers":{"":"","opportunity":"","onlineApplication":""},
		"contact":{"":""},
		"privacy":{"":""},
		"":{}
	};
var subNavWidth = {
		"about":"70px",	//"285px", when history is included
		"capabilities":"780px",
		"businesses":"520px",
		"careers":"190px",
		"contact":"0px",
		"privacy":"0px",
		"":"0px"
	};
var hide = true;
var defaultValue = "";
var subNavDefault = "";
var playIntro = false;
var webroot = "";
var subNavContent = {};
var usebg2 = true;
var fadeoutTime = 2000;
var clear = "";

function changeToPass()
{
	document.getElementById('passwordShow').style.display="none";
	document.getElementById('passwordClear').style.display="inline";
	document.getElementById('passwordClear').focus();
	//changeType(document.getElementById("Password1"));
}
function changeToText()
{	
	if (document.getElementById('passwordClear').value == "")
	{
		document.getElementById('passwordClear').style.display="none";
		document.getElementById('passwordShow').style.display="inline";
	}
	//changeType(document.getElementById("Password1"));
}
function changeType(obj)
{
	if(obj.getAttribute('type')=='Text')
    {  
		try
		{
			obj.setAttribute('type','Password');
			obj.type="Password";
		}
		catch(e)
		{
			obj.typeName = "Password";
		}
		obj.value = "";
    }
    else
	{
		if(obj.value == "")
		{
			try
			{
				obj.setAttribute('type','Text');
			}
			catch(e)
			{
				obj.typeName = "Text";
			}			
			obj.value = "PASSWORD";
		}
    }
}
function footerFadeOut()
{
	$("#footerImg1of3").fadeOut(500);
	$("#footerImg2of3").fadeOut(500);
	setTimeout("footerFadeIn()", 5000)
}
function footerFadeIn()
{
	$("#footerImg1of3").fadeIn(500);
	$("#footerImg2of3").fadeIn(500);
	setTimeout("footerFadeOut()",5000);	
}
function fadeSplash() 
{
	$("#intro").fadeOut("slow");
	$("#intro-flash").hide();
	window.onscroll="";
	document.body.style.overflow = "visible";
	document.body.style.visibility = "visible";
	embedObj("main",webroot+"flash/slideshow.swf","881","354", "6px", "0px");
}
function embedObj(div, path, width, height, offset, top)
{
	var flashvars = {};
	var params = {
			wmode: "transparent"
		};
		
	swfobject.embedSWF(path, div, width, height, "9.0.0",false, flashvars, params);
	document.getElementById(div).style.left = offset;
	document.getElementById(div).style.top = top;
		
}
function showSubNav(subDesc)
{
	//this.className=this.className + \" selected\";
	configureSubNav(subDesc, (subDesc == "contact" || subDesc == "privacy"));
}
function showDefaultSubNav(override)
{
	if(override===undefined)
	{
		override = false;
	}
	if(hide || override)
	{
		configureSubNav(defaultValue,(subNavOffSet[defaultValue] == "0px"));
	}
}
function resetNavHighlights(aId)
{
	var about = document.getElementById("ctl00_nav_about");
	var capabilities = document.getElementById("ctl00_nav_capabilities");
	var businesses = document.getElementById("ctl00_nav_businesses");
	var careers = document.getElementById("ctl00_nav_careers");
	var contact = document.getElementById("ctl00_nav_contact");

	if(about != undefined && capabilities != undefined && businesses != undefined && careers != undefined 
		&& contact != undefined)
	{
		about.className = "about";
		capabilities.className = "capabilities";
		businesses.className = "businesses";
		careers.className = "careers";
		contact.className = "contact";
		
		switch (aId)
		{	
			case "about":
				about.className = "about selected";
				break;
			case "capabilities":
				capabilities.className = "capabilities selected";
				break;
			case "businesses":
				businesses.className = "businesses selected";
				break;
			case "careers":
				careers.className = "careers selected";
				break;
			case "contact":
				contact.className = "contact selected";
				break;
		}	
	}
	
}
function configureSubNav(value,condition)
{
	resetNavHighlights(value);
	
	var subnav = document.getElementById("subnav");
	subnav.style.visibility = "visible";
	subnav.innerHTML = subNavContent[value];
	subnav.style.left = subNavOffSet[value];
	subnav.style.width = subNavWidth[value];
	if(condition)
	{
		subnav.style.visibility = "hidden";
	}
}
function clickLogin()
{
	if(document.getElementById("lgBar").style.visibility != "visible")
	{
		document.getElementById("lgBar").style.visibility = "visible";
	}
	else
	{
		document.getElementById("lgBar").style.visibility = "hidden";
	}
}
function setValues(root, subDesc, subDefault, playAnimation, bg)
{
	defaultValue = subDesc;
	subNavDefault = subDefault;
	webroot = root;
	playIntro = playAnimation;
	usebg2 = bg;
	clear = root + "images/blank.gif";
	subNavSelection[defaultValue][subNavDefault] = "class=\"active\"";
	
	subNavContent = {
				"about":
					"<ul id=\"subNavAbout\">" +
						//"<li><a " + subNavSelection["about"][""] + " href=\"" + webroot + "aboutUs/Default.aspx\">HISTORY</a></li>" +
						"<li><a " + subNavSelection["about"]["directions"] + " href=\"" + webroot + "aboutUs/directions.aspx\">DIRECTIONS</a></li>" +
					"</ul>",
				"capabilities":
					"<ul id=\"subNavCapabilities\">" +
						"<li><a " + subNavSelection["capabilities"]["scm"] + " href=\"" + webroot + "capabilities/supplyChainMgmt.aspx\">SUPPLY CHAIN MANAGEMENT</a></li>" +
						"<li><a " + subNavSelection["capabilities"]["cm"] + " href=\"" + webroot + "capabilities/categoryMgmt.aspx\">CATEGORY MANAGEMENT</a></li>" +
						"<li><a " + subNavSelection["capabilities"]["src"] + " href=\"" + webroot + "capabilities/sourcing.aspx\">SOURCING &amp; PROCUREMENT</a></li>" +
						"<li><a " + subNavSelection["capabilities"]["distr"] + " href=\"" + webroot + "capabilities/Distribution.aspx\">DISTRIBUTION &amp; LOGISTICS</a></li>" +
						"<li><a " + subNavSelection["capabilities"]["mkt"] + " href=\"" + webroot + "capabilities/marketing.aspx\">MARKETING OPERATIONS</a></li>" +
						"<li><a " + subNavSelection["capabilities"]["custInt"] + " href=\"" + webroot + "capabilities/custIntimacy.aspx\">CUSTOMER INTIMACY</a></li>" +
					"</ul>",
				"businesses":
					"<ul id=\"subNavBusiness\">" +
						"<li><a " + subNavSelection["businesses"]["cpg"] + " href=\"" + webroot + "businesses/commercialProductsGroup.aspx\">COMMERCIAL PRODUCTS GROUP</a></li>" +
						"<li><a " + subNavSelection["businesses"]["psg"] + " href=\"" + webroot + "businesses/packagingSystemsGroup.aspx\">PACKAGING SYSTEMS GROUP</a></li>" +
						"<li><a " + subNavSelection["businesses"]["nv"] + " href=\"" + webroot + "businesses/nvision.aspx\">NVISION&reg; – MARKETING SUPPLY CHAIN GROUP</a></li>" +
					"</ul>",
				"careers":
					"<ul id=\"subNavCareer\">" +
						"<li><a " + subNavSelection["careers"]["opportunity"] + " href=\"" + webroot + "careers/opportunities.aspx\">OPPORTUNITIES</a></li>" +
						"<li><a " + subNavSelection["careers"]["onlineApplication"] + " href=\"" + webroot + "careers/onlineApplication.aspx\">ONLINE APPLICATION</a></li>" +
					"</ul>",
				"contact":
					"<ul id=\"subNavContact\">" +
						"<li></li>" +
					"</ul>",
				"":
					"<ul>" +
						"<li></li>" +
					"</ul>"
			};
}
window.onload = function()
	{
		//footerFadeOut();
		var oHeight;
		if(document.getElementById)
		{
			oHeight = document.getElementById("main").offsetHeight-310;
			document.getElementById("bgRepeater").style.width = document.getElementById("main").style.width;
			if(oHeight < 0)
			{
				oHeight = 0;
			}
			document.getElementById("bgRepeater").style.height = oHeight + 'px';
		}
		else if (document.layers)
		{
			oHeight = document.layers["main"].clip.height-310;
			document.layers["bgRepeater"].style.width = document.layers["main"].clip.width;
			if(oHeight < 0)
			{
				oHeight = 0;
			}
			document.layers["bgRepeater"].style.height = oHeight;
		}
		
		document.body.style.height = (screen.height + oHeight) + 'px';
		document.getElementById("intro").style.height = (screen.height + oHeight) + 'px';

		var prefix = "mailto:";
		var at = "@";
		var domain = ".com";

//		if(document.getElementById("contact") != undefined)
//		{
//			document.getElementById("custcare").href = prefix + "custcare" + at + "nacorporation" + domain;
//			document.getElementById("custcare").innerHTML = "custcare" + at + "nacorporation" + domain;
//		}
//		else 
		/*if(document.getElementById("privacy") != undefined)
		{
			document.getElementById("webmaster").href = prefix + "webmaster" + at + "nacorporation" + domain;
			document.getElementById("webmaster").innerHTML = "webmaster" + at + "nacorporation" + domain;
		}
		else if(document.getElementById("opportunity") != undefined)
		{
			document.getElementById("resumes1").href = prefix + "resumes" + at + "nacorporation" + domain;
			document.getElementById("resumes1").innerHTML = "resumes" + at + "nacorporation" + domain;
			document.getElementById("resumes2").href = prefix + "resumes" + at + "nacorporation" + domain;
			document.getElementById("resumes2").innerHTML = "resumes" + at + "nacorporation" + domain;
		}
		else if(document.getElementById("onlineApp") != undefined)
		{
			document.getElementById("resumes").href = prefix + "resumes" + at + "nacorporation" + domain;
			document.getElementById("resumes").innerHTML = "resumes" + at + "nacorporation" + domain;
		}*/
		
		var playerVersion = swfobject.getFlashPlayerVersion();
		if(playIntro && playerVersion.major != 0)
		{
			//runAnimation();
			window.scrollTo(0,0);
			window.onscroll=function() { window.scrollTo(0,0) };
			document.body.style.overflow = "hidden";
			document.body.style.visibility = "hidden";
			embedObj("intro",webroot+"flash/intro.swf","100%","100%", "0px", "0px");
			//fadeoutTime = 5000;
		}
		else
		{
			document.getElementById("intro").innerHTML = "";
			document.getElementById("intro").style.visibility = "hidden";
			if(defaultValue == "businesses" && playerVersion.major != 0 && subNavDefault == "")
			{
				embedObj("featureBusMain",webroot+"flash/businesses.swf","435","354", "0px","0px");
			}
			else if(defaultValue == "" && subNavDefault == "" && playerVersion.major != 0)
			{
				embedObj("main",webroot+"flash/slideshow.swf","881","354", "6px","0px");
			}
			document.body.style.overflow = "visible";
			document.body.style.visibility = "visible";
		}

		showDefaultSubNav(true);
		
		var content = document.getElementById("content");
		if(usebg2 == "1")
		{
			content.style.backgroundImage = "url(" + webroot + "images/bg_content-subv1.png)";
		}
		else if(usebg2 == "2")
		{
			content.style.backgroundImage = "url(" + webroot + "images/bg_content-subv2.png)";
		}
		else if(usebg2 == "3")
		{
			content.style.backgroundImage = "url(" + webroot + "images/bg_content-subv3.png)";
		}
		else
		{
			content.style.backgroundImage = "url(" + webroot + "images/bg_content-subv4.png)";			
		}
		content.style.backgroundRepeat = "no-repeat";		
		//setTimeout("footerFadeOut()",2000);//fadeoutTime);
}