
window.onload = function()
{

	highlightNav('left-nav');

}



function highlightNav(divId)
{
	var thispath = window.location.toString().split('#')[0].split('?')[0];
	var navwrap = document.getElementById(divId);
	
	if (navwrap) {
			var navanchors = navwrap.getElementsByTagName('a');
			if (navanchors) {
				for(var i = 0; i <= navanchors.length-1; i++) {
					if ((navanchors[i].href == thispath) || (navanchors[i].href + 'default.asp' == thispath)) {
						navanchors[i].className = 'selected';
						break;
					}
				}
			}
	}
}


function showhide(divId)
{
	var heading = document.getElementById(divId);
	var wrapper = document.getElementById('state-' + divId);
	
	if (wrapper) {
		if (wrapper.className == 'hide') {
			wrapper.className = 'show';
			heading.className = 'show';
		} else {
			wrapper.className = 'hide';
			heading.className = 'hide';
		}
	}
}

function showhidesingle(divId)
{
	var wrapper = document.getElementById(divId);
	
	if (wrapper) {
		if (wrapper.style.display == 'none') {
			wrapper.style.display = 'block';
		} else {
			wrapper.style.display = 'none';
		}
	}
}

// ----- randomized products/projects and header images for homepage -----

function loadrandomheader() {
	
	var imgqty = 5; // quantity of header images
	var imgpath = "/images/headers/";
	var imgbase = "header-";
	var imgnum = Math.round(Math.random()*(imgqty - 1)) + 1;
	var imgextension = ".jpg";
	var homeimage = document.getElementById("header-image");
	
	if (homeimage) {
		homeimage.src = imgpath + imgbase + imgnum + imgextension;
	}

}

function loadrandomproduct() {
	
	// random featured products
	var featuredProducts = new Array(
	
		new Array('Electrical Vault','/images/products/electrical-vault-featured.jpg','/products/utilities/electrical-vaults.asp','Electrical vaults house power cables and transformers, and are a preferred alternative to running electrical power cables above the ground and across utility poles.'),
	
		new Array('Median Barrier','/images/products/barrier-featured.jpg','/products/transportation/barriers.asp','Our median barriers take many forms, including guard road and highway dividers, posts and curbs.'),
	
		new Array('Oil/Water Separator','/images/products/oil-water-separator-featured.jpg','/products/environmental/oil-water-separator.asp','Our separators are available in a wide range of sizes and styles and work both aboveground and underground.'),

		new Array('Manhole','/images/products/manhole-featured.jpg','/products/drainage/manhole.asp','Oldcastle Precast provides sealed manhole systems that can be built to specification to include a variety of important features.'),
		
		new Array('Hollowcore Plank','/images/products/hollow-core-plank-featured.jpg','/products/non-residential/hollowcore-plank.asp','Hollowcore plank is used to expand the outside and inside of homes and buildings.')
	
	);
	
	var numFeaturedProducts = 5; // number of featured products in array
	var productNum = Math.round(Math.random()*(numFeaturedProducts - 1));
	var featuredProduct = document.getElementById("featured-product");
	
	if (featuredProduct) {
		featuredProduct.getElementsByTagName('a')[0].firstChild.src = featuredProducts[productNum][1]; // set image src
		featuredProduct.getElementsByTagName('a')[0].href = featuredProducts[productNum][2]; // set image href
		featuredProduct.getElementsByTagName('a')[1].innerHTML = featuredProducts[productNum][0]; // set title
		featuredProduct.getElementsByTagName('a')[1].href = featuredProducts[productNum][2]; // set title href
		featuredProduct.getElementsByTagName('p')[0].innerHTML = featuredProducts[productNum][3]; // set product description
	}

}

function loadrandomproject() {
	
	// random featured products
	var featuredProjects = new Array(
	
	new Array('Lights, Camera, Precast','/images/projects/lights-camera-precast-featured.jpg','/projects/lights-camera-precast.asp','It took just 70 days for Oldcastle Precast Building Systems to help turn a former shipyard into a state-of-the-art film studio.'),
	
	new Array('Victory on Bakers Peak','/images/projects/bakers-peak-featured.jpg','/projects/victory-bakers-peak.asp','Oldcastle Precast engineering is challenged to create a standardized watertight precast sand filter that would comply with regulations and would be easy to install and easy to inspect.'),
	
	new Array('The Kennecott Challenge','/images/projects/kennecott-challenge-featured.jpg','/projects/kennecott-challenge.asp','In a project that would normally take a year, Oldcastle Precast completed 11 miles of pipeline in just 4 months.'),
			  
	new Array('Innovations in Stormwater Treatment','/images/projects/innovations-featured.jpg','/projects/innovative-stormwater-treatment.asp','It took just 70 days for Oldcastle Precast Building Systems to help turn a former shipyard into a state-of-the-art film studio.'),

	new Array('The Ingenuity of Precast','/images/projects/ingenuity-featured.jpg','/projects/precast-ingenuity.asp','Oldcastle Precast creates a stunning interior fountain for the Desert Diamond Casino in Sahuarita, Arizona.'),

	new Array('New Life For Surplus Concrete','/images/projects/fire-training-featured.jpg','/projects/new-life-surplus-concrete.asp','Oldcastle Precast facilities are finding new ways to reuse concrete and help others at the same time.'),
	
	new Array('A Gateway In Alaska','/images/projects/gateway-alaska-featured.jpg','/projects/gateway-in-alaska.asp','Oldcastle Precast StarTrack product, a smooth surface ideal for both cars and railroad tracks was used to create the longest highway-rail crossing in the world.'),

	new Array('Safety Wins','/images/projects/vpp-new-member-featured.jpg','/projects/vpp-new-member.asp','Oldcastle Precast Utility Vault earns VPP Star Award for excellence in workplace safety.')

	);
	
	var numFeaturedProjects = 8; // number of featured products in array
	var projectNum = Math.round(Math.random()*(numFeaturedProjects - 1));
	var featuredProject = document.getElementById("project-showcase");
	
	if (featuredProject) {
		featuredProject.getElementsByTagName('a')[0].firstChild.src = featuredProjects[projectNum][1]; // set image src
		featuredProject.getElementsByTagName('a')[0].href = featuredProjects[projectNum][2]; // set image href
		featuredProject.getElementsByTagName('a')[1].innerHTML = featuredProjects[projectNum][0]; // set title
		featuredProject.getElementsByTagName('a')[1].href = featuredProjects[projectNum][2]; // set title href
		featuredProject.getElementsByTagName('p')[0].innerHTML = featuredProjects[projectNum][3]; // set project description
	}

}