﻿/**
 * Navigation Breadcrumbs
 */
function SetCustomMenu() {
    SetMenu('custom');
}

function SetMarketMenu() {
    SetMenu('markets');
}

function SetMenu(menu) {
    var gray = 'rgb(80,84,75)';
    if(menu == 'custom') {
        var custom = document.getElementById('pexmenuitemcustom');
        var customsm = document.getElementById('pexcustomsubmenu');
        customsm.style.display = '';
        custom.style.backgroundColor = gray;
    }
    else if(menu == 'markets') {
        var markets = document.getElementById('pexmenuitemmarkets');
        var marketssm = document.getElementById('pexmarketssubmenu');
        marketssm.style.display = '';
        markets.style.backgroundColor = gray;
    }
    else if (menu == 'wwp') {
        var wwp = document.getElementById('pexmenuitemwwp');
        var wwpsm = document.getElementById('pexwwpsubmenu');
        wwpsm.style.display = '';
        wwp.style.backgroundColor = gray;
    }
}

/**
 * Sub Navigation Breadcrumbs
 */
function ShowCustomTechnologies() { document.getElementById('pexsncustomtechnologies').style.display = ''; }
function ShowMarket() { document.getElementById('pexsnmarket').style.display = ''; }
function ShowCommercialArea() { document.getElementById('pexsncommercialarea').style.display = ''; }
function ShowCommercialItem() { document.getElementById('pexsncommercialitem').style.display = ''; }
function ShowIndustrialArea() { document.getElementById('pexsnindustrialarea').style.display = ''; }
function ShowIndustrialItem() { document.getElementById('pexsnindustrialitem').style.display = ''; }
function ShowLifeSciencesArea() { document.getElementById('pexsnlifesciencesarea').style.display = ''; }
function ShowLifeSciencesItem() { document.getElementById('pexsnlifesciencesitem').style.display = ''; }
function ShowFenceItem() { document.getElementById('pexsnfenceitem').style.display = ''; }
function ShowRetailItem() { document.getElementById('pexsnretailitem').style.display = ''; }
function ShowAerospaceItem() { document.getElementById('pexsnaerospaceitem').style.display = ''; }
function ShowMedicalItem() { document.getElementById('pexsnmedicalitem').style.display = ''; }
function ShowTrafficItem() { document.getElementById('pexsntrafficitem').style.display = ''; }

function ShowFenceArea() { document.getElementById('pexsnfencearea').style.display = ''; }
function ShowRetailArea() { document.getElementById('pexsnretailarea').style.display = ''; }
function ShowAerospaceArea() { document.getElementById('pexsnaerospacearea').style.display = ''; }
function ShowMedicalArea() { document.getElementById('pexsnmedicalarea').style.display = ''; }
function ShowTrafficArea() { document.getElementById('pexsntrafficarea').style.display = ''; }
function ShowLightingArea() { document.getElementById('pexsnlightingarea').style.display = ''; }

function ShowProductsItem() { document.getElementById('pexsnproductsitem').style.display = ''; }
function ShowApplicationsItem() { document.getElementById('pexsnapplicationsitem').style.display = ''; }

function ShowLightingItem() { document.getElementById('pexsnlightingitem').style.display = ''; }
function ShowProcessItem() { document.getElementById('pexsnprocessitem').style.display = ''; }
function ShowFabricationItem() { document.getElementById('pexsnfabricationitem').style.display = ''; }
function ShowInnovativeThinkingItem() { document.getElementById('pexsninnovativethinkingitem').style.display = ''; }
function ShowMaterialsItem() { document.getElementById('pexsnmaterialsitem').style.display = ''; }
function ShowAboutUsArea() { document.getElementById('pexsnaboutusarea').style.display = ''; }
function ShowHistoryItem() { document.getElementById('pexsnhistoryitem').style.display = ''; }
function ShowSitemapItem() { document.getElementById('pexsnsitemapitem').style.display = ''; }
function ShowContactUsItem() { document.getElementById('pexsncontactusitem').style.display = ''; }
function ShowPlantLocationsItem() { document.getElementById('pexsnplantlocationsitem').style.display = ''; }
function ShowTermsOfUseItem() { document.getElementById('pexsntermsofuseitem').style.display = ''; }
function ShowPrivacyPolicyItem() { document.getElementById('pexsnprivacypolicyitem').style.display = ''; }
function ShowEventsItem() { document.getElementById('pexsneventsitem').style.display = ''; }
function ShowCareersItem() { document.getElementById('pexsncareersitem').style.display = ''; }




/**
* Home Selection
*/

var customsections = Array('pexprocess', 'pexmaterials', 'pexfabrication', 'pexinnovative');
var marketsections = Array('pexmrktindustrial', 'pexmrktlifescience', 'pexmrktcommercial');

function SetHomeSelection(items, section) {
    for (var i = 0; i < items.length; i++) {
        var link = document.getElementById(items[i]);
        var desc = document.getElementById(items[i] + 'desc');
        var img = document.getElementById(items[i] + 'img');
        if (section == items[i]) {
            link.style.border = '1px solid rgb(155,237,7)';
            link.style.color = 'rgb(155,237,7)';
            link.style.backgroundColor = 'rgb(105, 138, 47)';
            desc.style.display = '';
            img.style.display = '';
        }
        else {
            link.style.border = '1px solid #fff';
            link.style.color = '#fff';
            link.style.backgroundColor = '';
            desc.style.display = 'none';
            img.style.display = 'none';
        }
    }
}

/**
* String Util 
*/
function contains(text, term) {
    return text.indexOf(term) > -1;
}

function endsWith(text, term) {
    var i = text.lastIndexOf(term);
    return i > -1 && i == (text.length - term.length);
}


function SetPageMenu() {
    if (contains(window.location.href, 'PexcoAerospace.aspx')) {
        ShowMarket();ShowIndustrialArea();ShowAerospaceItem();SetMarketMenu();    
    }
    else if (contains(window.location.href, 'PexcoAerospaceProducts.aspx')) {
    	ShowMarket();ShowIndustrialArea();ShowAerospaceArea();ShowProductsItem();SetMarketMenu();
	}
    else if (contains(window.location.href, 'PexcoFence.aspx') || contains(window.location.href, 'PexcoFenceContactUs.aspx')) {
    	ShowMarket(); ShowCommercialArea(); ShowFenceItem(); SetMarketMenu();
    }
    else if (contains(window.location.href, 'PexcoFenceProducts.aspx') || contains(window.location.href, 'PexcoFenceAmericanFlag.aspx') ||
    	contains(window.location.href, 'PexcoFenceBottomLock.aspx') || contains(window.location.href, 'PexcoFenceLiteLink.aspx') ||contains(window.location.href, 'PexcoFenceWingedSlat.aspx') ||
    	contains(window.location.href, 'PexcoFenceTopLock.aspx') || contains(window.location.href, 'PexcoFenceIndustrial.aspx') || contains(window.location.href, 'PexcoFenceTopCap.aspx') || 
    	contains(window.location.href, 'PexcoFenceFin2000.aspx') || contains(window.location.href, 'PexcoFenceFinLink.aspx') || contains(window.location.href, 'PexcoFenceFeatherLock.aspx') ||
    	contains(window.location.href, 'PexcoFenceWeave.aspx') || contains(window.location.href, 'PexcoFenceCorpBrand.aspx') || contains(window.location.href, 'PexcoFenceHedgeLink.aspx') ||
    	contains(window.location.href, 'PexcoFencePDS.aspx')) {
        ShowMarket(); ShowCommercialArea(); ShowFenceArea(); ShowProductsItem(); SetMarketMenu();
    }
    else if (contains(window.location.href, 'PexcoLighting.aspx')) {
    	ShowMarket(); ShowIndustrialArea(); ShowLightingItem(); SetMarketMenu();
    }
    else if (contains(window.location.href, 'PexcoMedical.aspx')) {
    	ShowMarket(); ShowLifeSciencesArea(); ShowMedicalItem(); SetMarketMenu();
    }
    else if (contains(window.location.href, 'PexcoMedicalProducts.aspx')) {
    	ShowMarket(); ShowLifeSciencesArea(); ShowMedicalArea(); ShowProductsItem(); SetMarketMenu();
    }
    else if (contains(window.location.href, 'PexcoRetail.aspx')) {
    	ShowMarket(); ShowCommercialArea(); ShowRetailItem(); SetMarketMenu();
    }
    else if (contains(window.location.href, 'PexcoRetailProducts.aspx') || contains(window.location.href, 'PexcoRetailLabelHolders.aspx') ||
    	contains(window.location.href, 'PexcoRetailSignHolders.aspx') || contains(window.location.href, 'PexcoRetailProductMechnadising.aspx') || 
    	contains(window.location.href, 'PexcoRetailDisplayComponents.aspx')) {
    	ShowMarket(); ShowCommercialArea(); ShowRetailArea(); ShowProductsItem(); SetMarketMenu();
    }
    else if (contains(window.location.href, 'PexcoTraffic.aspx') || contains(window.location.href, 'PexcoTrafficContactUs.aspx') || contains(window.location.href, 'PexcoTrafficEvents.aspx') ||
    	contains(window.location.href, 'PexcoTrafficPR.aspx') || contains(window.location.href, 'PexcoTrafficDDPImproveSafety.aspx') || contains(window.location.href, 'PexcoTrafficTestimonials.aspx')) {
    	ShowMarket(); ShowIndustrialArea(); ShowTrafficItem(); SetMarketMenu();
	}
	else if (contains(window.location.href, 'PexcoTrafficProducts.aspx') || contains(window.location.href, 'PexcoTrafficRaisedCurb.aspx') ||
    	contains(window.location.href, 'PexcoTrafficChannelizers.aspx') || contains(window.location.href, 'PexcoTrafficRCP.aspx') || contains(window.location.href, 'PexcoTrafficHOTLanes.aspx') ||
    	contains(window.location.href, 'PexcoTrafficWorkZone.aspx') || contains(window.location.href, 'PexcoTrafficBarricades.aspx') || contains(window.location.href, 'PexcoTrafficBollards.aspx') ||
    	contains(window.location.href, 'PexcoTrafficPedSafety.aspx') || contains(window.location.href, 'PexcoTrafficTOM.aspx') ||  contains(window.location.href, 'PexcoTrafficPavementMarkers.aspx') || 
    	contains(window.location.href, 'PexcoTrafficChipSeal.aspx') || contains(window.location.href, 'PexcoTrafficReflector.aspx') || contains(window.location.href, 'PexcoTrafficRDP.aspx') ||
    	contains(window.location.href, 'PexcoTrafficBarrier.aspx') || contains(window.location.href, 'PexcoTrafficGuardrail.aspx') || contains(window.location.href, 'PexcoTrafficSnowPoles.aspx') ||
    	contains(window.location.href, 'PexcoTrafficParkingProducts.aspx') || contains(window.location.href, 'PexcoTrafficQueitZone.aspx') || contains(window.location.href, 'PexcoTrafficFG300Base.aspx') ||
    	contains(window.location.href, 'PexcoTrafficAdhesives.aspx') || contains(window.location.href, 'PexcoTrafficPARBarricades.aspx') || contains(window.location.href, 'PexcoTrafficType3Barricades.aspx') ||
    	contains(window.location.href, 'PexcoTrafficTypeOBarricades.aspx') || contains(window.location.href, 'PexcoTrafficSignPost.aspx') || contains(window.location.href, 'PexcoTrafficHotDots.aspx') ||
    	contains(window.location.href, 'PexcoTrafficRumble.aspx') || contains(window.location.href, 'PexcoTrafficRPM.aspx')) {
    	ShowMarket(); ShowIndustrialArea(); ShowTrafficArea(); ShowProductsItem(); SetMarketMenu();
    }
    else if (contains(window.location.href, 'PexcoTrafficApplications.aspx')) {
    	ShowMarket(); ShowIndustrialArea(); ShowTrafficArea(); ShowApplicationsItem(); SetMarketMenu();
	}
    else if (contains(window.location.href, 'PexcoCommercial.aspx')) {
    	ShowMarket(); ShowCommercialItem(); SetMarketMenu();
    }
    else if (contains(window.location.href, 'PexcoIndustrial.aspx')) {
    	ShowMarket(); ShowIndustrialItem(); SetMarketMenu();
    }
    else if (contains(window.location.href, 'PexcoLifeSciences.aspx')) {
    	ShowMarket(); ShowLifeSciencesItem(); SetMarketMenu();
   	}
    else if (contains(window.location.href, 'PexcoProcess.aspx')) {
    	ShowCustomTechnologies(); ShowProcessItem();SetCustomMenu();
   	}
    else if (contains(window.location.href, 'PexcoMaterials.aspx')) {
    	ShowCustomTechnologies(); ShowMaterialsItem(); SetCustomMenu();
    	InitMaterial();
    	ShowMaterial();
   	}
    else if (contains(window.location.href, 'PexcoFabrication.aspx')) {
    	ShowCustomTechnologies(); ShowFabricationItem();SetCustomMenu();
   	}
    else if (contains(window.location.href, 'PexcoInnovativeThinking.aspx')) {
    	ShowCustomTechnologies(); ShowInnovativeThinkingItem();SetCustomMenu();
   	}
   	else if (contains(window.location.href, 'PexcoCustomTechnologies.aspx')) {
   		SetCustomMenu(); SetHomeSelection(customsections, 'pexprocess');
   		document.getElementById('pexprocess').onmouseover = function () { SetHomeSelection(customsections, 'pexprocess'); }
   		document.getElementById('pexmaterials').onmouseover = function () { SetHomeSelection(customsections, 'pexmaterials'); }
   		document.getElementById('pexfabrication').onmouseover = function () { SetHomeSelection(customsections, 'pexfabrication'); }
   		document.getElementById('pexinnovative').onmouseover = function () { SetHomeSelection(customsections, 'pexinnovative'); }
   	}
   	else if (contains(window.location.href, 'PexcoMarkets.aspx')) {
   		SetMarketMenu(); SetHomeSelection(marketsections, 'pexmrktindustrial');
   		document.getElementById('pexmrktindustrial').onmouseover = function () {SetHomeSelection(marketsections, 'pexmrktindustrial');}
   		document.getElementById('pexmrktlifescience').onmouseover = function () {SetHomeSelection(marketsections, 'pexmrktlifescience');}
   		document.getElementById('pexmrktcommercial').onmouseover = function () {SetHomeSelection(marketsections, 'pexmrktcommercial');}
   	}
   	else if (contains(window.location.href, 'PexcoDefault.aspx')) {
        document.getElementById('pexcustoma').onmouseover = function () { SetSelectedMarket('pexcustom'); };
        document.getElementById('pexaeroa').onmouseover = function () { SetSelectedMarket('pexaero'); };
        document.getElementById('pexlightinga').onmouseover = function () { SetSelectedMarket('pexlighting'); };
        document.getElementById('pexmedicala').onmouseover = function () { SetSelectedMarket('pexmedical'); };
        document.getElementById('pextraffica').onmouseover = function () { SetSelectedMarket('pextraffic'); };
        document.getElementById('pexretaila').onmouseover = function () { SetSelectedMarket('pexretail'); };
        document.getElementById('pexfencea').onmouseover = function () { SetSelectedMarket('pexfence'); };
        
   		document.getElementById('pexcustom').style.backgroundImage = "url('/PublishingImages/Default/Dies/customon.jpg')";
   		document.getElementById('pexaero').style.backgroundImage = "url('/PublishingImages/Default/Dies/aeroon.jpg')";
   		document.getElementById('pexlighting').style.backgroundImage = "url('/PublishingImages/Default/Dies/lightingon.jpg')";
   		document.getElementById('pexmedical').style.backgroundImage = "url('/PublishingImages/Default/Dies/medicalon.jpg')";
   		document.getElementById('pextraffic').style.backgroundImage = "url('/PublishingImages/Default/Dies/trafficon.jpg')";
   		document.getElementById('pexretail').style.backgroundImage = "url('/PublishingImages/Default/Dies/retailon.jpg')";
   		document.getElementById('pexfence').style.backgroundImage = "url('/PublishingImages/Default/Dies/fenceon.jpg')";
   		
   		VideoSwap();
   	}
    else if (contains(window.location.href, 'PexcoPexcoHistory.aspx')) {
    	ShowAboutUsArea(); ShowHistoryItem();
   	}
   	else if(contains(window.location.href, 'PexcoSiteMap.aspx')) {
		ShowSitemapItem();   	
	}
	else if(contains(window.location.href, 'PexcoContactUs.aspx')) {
		ShowContactUsItem();
	}
	else if(contains(window.location.href, 'PexcoPlantLocations.aspx')) {
		ShowPlantLocationsItem();
	}
	else if(contains(window.location.href, 'PexcoTermsOfUse.aspx')) {
		ShowTermsOfUseItem();
	}
	else if(contains(window.location.href, 'PexcoPrivacyPolicy.aspx')) {
		ShowPrivacyPolicyItem();
	}
	else if(contains(window.location.href, 'PexcoEvents.aspx')) {
		ShowEventsItem();
	}
	else if(contains(window.location.href, 'PexcoCareers.aspx')) {
		ShowCareersItem();
	}
}


/**
 * Video Rotate
 */

var sections = new Array("pexcustom", "pexaero", "pexlighting", "pexmedical", "pextraffic", "pexretail", "pexfence");
function PopulateFlashCode(path) {
    //alert(path);
    return '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="512" HEIGHT="232">' +
        '<PARAM NAME=movie VALUE="'+path+'"><EMBED src="'+path+'" quality=high WIDTH="512" HEIGHT="232" NAME="custom" ALIGN="" TYPE="application/x-shockwave-flash" ' +
        'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> </OBJECT>';
}

function IsiOSDevice() {
	return navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i);
}

function PopulateMovies(path) {
	// return '<img src="http://97.67.160.163/PublishingImages/Default/custom.gif" />';
	return '<video width="512" height="232" autoplay="true" controls><source src="' + path + '" type="video/mp4" /><param name="autoplay" value="true" /><object data="'+path+'" width="512" height="232"><embed src="'+path+'" width="512" height="232" /></object></video>';
}

var pexvideos = new Array('http://97.67.160.163/SiteCollectionDocuments/Homepage/pex_custom_seq.swf',
    'http://97.67.160.163/SiteCollectionDocuments/Homepage/pex_aero_seq.swf',
    'http://97.67.160.163/SiteCollectionDocuments/Homepage/pex_light_seq.swf',
    'http://97.67.160.163/SiteCollectionDocuments/Homepage/pex_med_seq.swf',
    'http://97.67.160.163/SiteCollectionDocuments/Homepage/pex_traffic_seq.swf',
    'http://97.67.160.163/SiteCollectionDocuments/Homepage/pex_retail_seq.swf',
    'http://97.67.160.163/SiteCollectionDocuments/Homepage/pex_fence_seq.swf');
var pexflix = new Array('http://97.67.160.163/Pex_extrude_custom.mp4',
	'http://97.67.160.163/Pex_extrude_aerospace.mp4',
	'http://97.67.160.163/Pex_extrude_lighting.mp4',
	'http://97.67.160.163/Pex_extrude_medical.mp4',
	'http://97.67.160.163/Pex_extrude_traffic.mp4',
	'http://97.67.160.163/Pex_extrude_retail.mp4',
	'http://97.67.160.163/Pex_extrude_fence.mp4');

var pexvideoindex = 0;
var pexloopstop = false;
var pexvideocomplete = false;
function VideoSwap() {
    var div = document.getElementById('pexvideo');
    if (pexloopstop) {
        return;
    }
	
	if(!pexvideocomplete) {
	    var code = '';
	    if (IsiOSDevice()) {
	    	code = PopulateMovies(pexflix[pexvideoindex]);
	    }
	    else {
		    code = PopulateFlashCode(pexvideos[pexvideoindex]);
		}
	    div.innerHTML = code;
	    SetSectionVisible(sections[pexvideoindex], false);
	    //alert(pexvideoindex);
	}
	else {
		SetSectionVisible(sections[pexvideoindex], true);
        div.innerHTML = '';
		div.style.display = 'none';
	    //alert(pexvideoindex);
	}
	
    pexvideoindex++;

    if (pexvideoindex + 1 > pexvideos.length) {
        pexvideoindex = 0;
        pexvideocomplete = true;
	}
	
    setTimeout(VideoSwap, 7000);
}

function SetSelectedMarket(selected) {
    pexloopstop = true;
    document.getElementById('pexvideo').style.display = 'none';
    SetSectionVisible(selected, true);
}


function SetSectionVisible(section, useImage) {
    for (var i = 0; i < sections.length; i++) {
        var element = document.getElementById(sections[i]);
        var image = document.getElementById(sections[i] + "img");
        var desc = document.getElementById(sections[i] + "desc");
        if (element.id == section) {
            element.children[0].children[0].style.visibility = "hidden";
            desc.style.display = "";
           	if (useImage) { image.style.display = ""; }
        }
        else {
            element.children[0].children[0].style.visibility = "";
            if (useImage) { image.style.display = "none"; }
            desc.style.display = "none";
        }
    }
    return false;
}

/**
 * Search
 */
 
function SearchInit() {
	var search = document.getElementById('txtsearch');
	var button = document.getElementById('btnsearch');
	//button.value = 'false';
	search.onclick = function() {
		if(search.value == 'Search'){// && button.value == 'false') {
			search.value = '';
			//button.value = 'true';
		}
	}
	search.onkeypress = function(e) {
		if(window.event.keyCode == 13) {
			//window.event.cancelBubble = true;
			return Search();
		}
	}
	button.onclick = Search;
}

function Search() {
	var searchbox = document.getElementById('txtsearch');
	//var button = document.getElementById('btnsearch');

	//if(button.value == 'false') {
	//	searchbox.value = '';
	//	button.value = 'true';
	//	searchbox.focus();
	//}
	//else {
		var link = 'http://www.pexco.com/_layouts/Search.aspx?k='+escape(searchbox.value);
		window.location = link;
		return false;
	//}
}

/*
 * Materials
 */

var materials = Array('pexmatabco', 'pexmatabs', 'pexmatacrylic', 'pexmatasa', 'pexmatbutyrate', 'pexmatpetg', 'pexmatcrystal', 'pexmateva', 'pexmatfpvc', 'pexmatfluoro', 'pexmathdpe', 'pexmatimpactacrylic',
    'pexmatimpactpolystyrene', 'pexmatldpe', 'pexmatnoryl', 'pexmatnylon6', 'pexmatnylon66', 'pexmatnylon11', 'pexmatnylon12', 'pexmatpeek', 'pexmatultem', 'pexmatpes', 'pexmatpolycarbonate', 'pexmatpolypropylene',
    'pexmatpolysulfone', 'pexmatpvc', 'pexmatrpvc', 'pexmattpe', 'pexmattpo');

function ToggleMaterial(selected) {
    var img = document.getElementById(selected + 'img');
    var tr = document.getElementById(selected + 'tr');
    if(tr.style.display == '') {
    	tr.style.display = 'none';
    	img.src = 'http://www.pexco.com/PublishingImages/Default/pexexpand.png';
    }
    else {
    	tr.style.display = '';
    	img.src = 'http://www.pexco.com/PublishingImages/Default/pexretract.png';
    }
}

function InitMaterial() {
	document.getElementById('pexmatabco'+'img').onclick = function () { ToggleMaterial('pexmatabco'); }
	document.getElementById('pexmatabs'+'img').onclick = function () { ToggleMaterial('pexmatabs'); }
	document.getElementById('pexmatacrylic'+'img').onclick = function () { ToggleMaterial('pexmatacrylic'); }
	document.getElementById('pexmatasa'+'img').onclick = function () { ToggleMaterial('pexmatasa'); }
	document.getElementById('pexmatbutyrate'+'img').onclick = function () { ToggleMaterial('pexmatbutyrate'); }
	document.getElementById('pexmatpetg'+'img').onclick = function () { ToggleMaterial('pexmatpetg'); }
	document.getElementById('pexmatcrystal'+'img').onclick = function () { ToggleMaterial('pexmatcrystal'); }
	document.getElementById('pexmateva'+'img').onclick = function () { ToggleMaterial('pexmateva'); }
	document.getElementById('pexmatfpvc'+'img').onclick = function () { ToggleMaterial('pexmatfpvc'); }
	document.getElementById('pexmatfluoro'+'img').onclick = function () { ToggleMaterial('pexmatfluoro'); }
	document.getElementById('pexmathdpe'+'img').onclick = function () { ToggleMaterial('pexmathdpe'); }
	document.getElementById('pexmatimpactacrylic'+'img').onclick = function () { ToggleMaterial('pexmatimpactacrylic'); }
	document.getElementById('pexmatimpactpolystyrene'+'img').onclick = function () { ToggleMaterial('pexmatimpactpolystyrene'); }
	document.getElementById('pexmatldpe'+'img').onclick = function () { ToggleMaterial('pexmatldpe'); }
	document.getElementById('pexmatnoryl'+'img').onclick = function () { ToggleMaterial('pexmatnoryl'); }
	document.getElementById('pexmatnylon6'+'img').onclick = function () { ToggleMaterial('pexmatnylon6'); }
	document.getElementById('pexmatnylon66'+'img').onclick = function () { ToggleMaterial('pexmatnylon66'); }
	document.getElementById('pexmatnylon11'+'img').onclick = function () { ToggleMaterial('pexmatnylon11'); }
	document.getElementById('pexmatnylon12'+'img').onclick = function () { ToggleMaterial('pexmatnylon12'); }
	document.getElementById('pexmatpeek'+'img').onclick = function () { ToggleMaterial('pexmatpeek'); }
	document.getElementById('pexmatultem'+'img').onclick = function () { ToggleMaterial('pexmatultem'); }
	document.getElementById('pexmatpes'+'img').onclick = function () { ToggleMaterial('pexmatpes'); }
	document.getElementById('pexmatpolycarbonate'+'img').onclick = function () { ToggleMaterial('pexmatpolycarbonate'); }
	document.getElementById('pexmatpolypropylene'+'img').onclick = function () { ToggleMaterial('pexmatpolypropylene'); }
	document.getElementById('pexmatpolysulfone'+'img').onclick = function () { ToggleMaterial('pexmatpolysulfone'); }
	document.getElementById('pexmatpvc'+'img').onclick = function () { ToggleMaterial('pexmatpvc'); }
	document.getElementById('pexmatrpvc'+'img').onclick = function () { ToggleMaterial('pexmatrpvc'); }
	document.getElementById('pexmattpe'+'img').onclick = function () { ToggleMaterial('pexmattpe'); }
	document.getElementById('pexmattpo'+'img').onclick = function () { ToggleMaterial('pexmattpo'); }
	document.getElementById('pexmattpu'+'img').onclick = function () { ToggleMaterial('pexmattpu'); }
}

function ShowMaterial() {
	if(contains(window.location.href, 'Material=')) {
		for(var i = 0; i < materials.length; i++) {
			if(contains(window.location.href, materials[i])) {
				ToggleMaterial(materials[i]);
				document.getElementById(materials[i] + 'tr').scrollIntoView();
				break;
			}
		}
	}
}
