//detect user's browser and OS and set global scripting variables
agt=navigator.userAgent.toLowerCase();
ie=(document.all) ? 1:0
ie4=(agt.indexOf('msie 4')!=-1) ? 1:0
ie5=(agt.indexOf('msie 5')!=-1) ? 1:0
ie6=(agt.indexOf('msie 6')!=-1) ? 1:0
ie7=(agt.indexOf('msie 7')!=-1) ? 1:0
saf=(agt.indexOf('safari')!=-1) ? 1:0
ff=(agt.indexOf('firefox')!=-1) ? 1:0
nsx=(agt.indexOf('netscape')!=-1) ? 1:0
ns4=(document.layers && parseInt(navigator.appVersion)>=4) ? 1:0
win=( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) )
mac=(agt.indexOf("mac")!=-1);
imgs=(document.images) ? 1:0
ie=(ie6||ie7)?1:0
ns=(ns4||nsx||ff||saf)?1:0
ff=(ff||saf)
timeoout=1
keep=-1
var arrFormHide
var formHideNum = 0
//alert(nsx);
//This block is used for certain forms and ViewTemplates that are having zindex issues
if (ff) {
	var zindexmodifier = 0;
}
else {
	var zindexmodifier = -1;
}
//Create layers for top navigation menus
navImage=new Array()
navImage[0]="button-fyrewrap-quick-links"
navImage[1]="button-fyrewrap-company-overview"
navImage[2]="button-fyrewrap-locations"
navImage[3]="button-fyrewrap-contact-us"
//Entire nav layer for 1 element
droplayer=new Array()
droplayer[0]="Layer00"
droplayer[1]="Layer11"
droplayer[2]="Layer22"
droplayer[3]="Layer33"
//Transparent grey shadow
ylayer=new Array()
ylayer[0]="Layer0a"
ylayer[1]="Layer1a"
ylayer[2]="Layer2a"
ylayer[3]="Layer3a"
//Actual nav layer content
yylayer=new Array()
yylayer[0]="Layer0"
yylayer[1]="Layer1"
yylayer[2]="Layer2"
yylayer[3]="Layer3"
//Pass variables through URL
	var p = parseGetVars();
	if (isNaN(p['pid']) == true){
		var thePageNo = parseInt(0);
	}else if (p['pid'] == "undefined"){
		var thePageNo = parseInt(0);
	}else if (parseInt(p['pid']) < 0	){
		var thePageNo = parseInt(1);
	}else{
		var thePageNo = parseInt(p['pid']);
	}
function parseGetVars() {
var getVars = new Array();
var qString = unescape(top.location.search.substring(1));
var pairs = qString.split(/\&/);
for (var i in pairs) {
var nameVal = pairs[i].split(/\=/);
getVars[nameVal[0]] = nameVal[1];
} 
return getVars;
}
//Detect method for handling layers and divs
function getRefToDiv(divID,oDoc) {
    if( !oDoc ) { oDoc = document; }
    if( document.layers ) {
        if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
            //repeatedly run through all child layers
            for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
                //on success, return that layer, else return nothing
                y = getRefToDiv(divID,oDoc.layers[x].document); }
            return y; } }
    if( document.getElementById ) {
        return document.getElementById(divID); }
    if( document.all ) {
        return document.all[divID]; }
    return false;
}
function hideProds()
{
	document.getElementById('splash-interior-forms1').style.position= '';
	document.getElementById('splash-interior-lines1').style.position= '';
	document.getElementById('splash-interior-applications1').style.position= '';
}
function showProds()
{
	document.getElementById('splash-interior-forms1').style.position= 'absolute';
	document.getElementById('splash-interior-lines1').style.position= 'absolute';
	document.getElementById('splash-interior-applications1').style.position= 'absolute';
}
//Top navigation functions
function showdrop(theLayer){
	//hideProds();
	roll(navImage[theLayer]);
	keep=theLayer; hideall(); checkpos=0; showitnow=1
	showit(theLayer)
	}
function showit(theLayer){
var f = document.forms[formHideNum];
		if(ie){ 
			eval(droplayer[theLayer]+'.style.visibility="visible"');
			if (arrFormHide != undefined){
				var arrForm = new Array();
				for (i=0; i < arrFormHide.length; i++) {
					arrForm = arrFormHide[i].split("|");
				   if (theLayer == arrForm[0]) {
				   	if (arrForm[1] == "") {
				   		intLimit = f.length;
				   	}else{
				   		intLimit = arrForm[1];
				  	}
						for(x=0;x<intLimit;x++){  
							f[x].style.visibility = "hidden";
						}
				  }
				}
			}	
		}
		if(ns){ 
	    refLayer = getRefToDiv(droplayer[theLayer]);
      	refLayer.style.visibility = 'visible';
	    return true;
		}
	}
function hidedrop(theLayer){
//showProds();
restore(navImage[theLayer]);
var f = document.forms[formHideNum];
		if(ie){
			if (arrFormHide != undefined){
				var arrForm = new Array();
					for (i=0; i < arrFormHide.length; i++) {
						arrForm = arrFormHide[i].split("|");
						   if (theLayer == arrForm[0]) {
						   	if (arrForm[1] == "") {
						   		intLimit = f.length;
						   	}else{
						   		intLimit = arrForm[1];
						  	}
								for(x=0;x<intLimit;x++){  
									f[x].style.visibility = "visible";
								}
						  }
					}
				}
	  }
		if(ns){
	    refLayer = getRefToDiv(droplayer[theLayer]);
      refLayer.style.visibility = 'hidden';
	    return true;
	  }
	keep=-1; 
	checkpos=1;
	setTimeout('hideall()',timeoout)
}
function hideall(){
	for(i=0;i<droplayer.length;i++){  
		 
		if(ie && (keep!=i)){ 
			eval(droplayer[i]+'.style.visibility="hidden"')
		}
		if (ns && (keep!=i)) {
			hideit=0; 
			if(hideit){ 
				eval('document.'+droplayer[i]+'.visibility="hide"')
			}
		}
	}
}
//Clear and fill prefilled fields, i.e. Search Box
function clearField(objField, strDefault){
	if (objField.value == strDefault){
		objField.value = "";
	}
}
function fillField(objField, strDefault){
	if (objField.value == ""){
		objField.value = strDefault;
	}
}
//Standard rollover and select menu functions from Macromedia
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function roll(obj) {
var o = document.images[obj];
	var base=o.name;
	var path=o.src;
	var file=path.substring(0,path.length-4);
	var newImage=file + ".gif";
	o.src=newImage;
	return;
}
function restore(obj) {
var o = document.images[obj];
	var base=o.name;
	var path=o.src;
	var file=path.substring(0,path.length-4);
	//alert(file);
	var newImage=file + ".gif";
	o.src=newImage;
	return;
}
//Set background color of entire div
function color_div(o,b){
	if(!ff){
		if(b==1){
			o.style.backgroundColor = "#EAEAEA";
		}
		else{
			o.style.backgroundColor = "#FFF";
		}
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////// 
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
 if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
 else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
 
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
 
function MM_swapImgRestore() { //v3.0
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
 
function MM_findObj(n, d) { //v4.01
 var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function MM_swapImage() { //v3.0
 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_Color(o,b){
	if(b==1){
		o.style.textDecoration = "underline";
		o.style.color = "#99CC00";
		o.style.backgroundColor = "#fff";
	}else{
		o.style.textDecoration = "none";
		o.style.color = "#666666";
		o.style.backgroundColor = "";
	}
}
function emailPage(doctitle, urlpath) {
	var url = '/' + imgdb + '/EmailPage?OpenForm&pagetitle=' + doctitle + '&urlpath=' + urlpath;
	var newWin = window.open(url,'PraxairEmail','scrollbars=0,toolbar=0,menubar=0,resizable=0,location=0,status=1,copyhistory=1,width=272,height=420');
}
function printPage(docunid) {
	var url = '/' + db + '/Print/' + docunid + '?OpenDocument';
	// A width of 650 is the approximate print width on 8.5" x 11" paper
	var newWin = window.open(url, 'AWPrint', 'scrollbars=1,toolbar=0,menubar=1,location=0,resizable=1,width=650,height=400');
}
function getyear(){
     now = new Date();
     document.write(now.getFullYear());
}
function TrimStr(inputString) {
// rather than return a non-string, convert the input to a string.
s = inputString.toString();
// the space in the patterns below is important!
// the two patterns mean,
// one or more spaces at the beginning,
// one or more spaces at the end.
s = s.replace(/^ +/, '').replace(/ +$/, '');
// this pattern means, two or more spaces in a row
// note there are two spaces before the plus sign.
innerspace = /  +/;
while (s.match(innerspace))
s = s.replace(innerspace, ' ');
return s;
}
// End Trim Function 
function openDbRelativeURL( url, target ){
//Check we have a target window;
target = (target == null ) ? window : target;
//Work out the path of the database;
path = location.pathname.split('.nsf')[0] + '.nsf/';
target.location.href = path + url;
}
function openSiteSearchDbURL( url, sitedB, target ){
//Check we have a target window;
target = (target == null ) ? window : target;
//Work out the path of the database;
target.location.href = "/" + sitedB + url;
}
function doSiteSearch(query,arg2) {
if (query =="   < Search >"){
return 
}
var regExp1 =/\band\b|\bor\b|\bfield\b/i;
var regExp2 = /[(,),<,>,\[,\]]/;
if (s0 != ""){
s0=query;
var s0 = TrimStr(s0)
if ( regExp1.test( s0 ) || regExp2.test( s0 ) ){
return alert (alertMsgforAdvSearch());
}
var s0 = s0.replace(/\s/g, "+AND+");
openSiteSearchDbURL("/AllContent?SearchView&Query=" + escape( s0 ) + "&start=1&count=30", arg2)
} else {
return alert("Please make a search selection")
}
}
function alertMsgforAdvSearch(){
var alertMsg = "Please note the following should not be used in search:"; 
alertMsg += "\n\nReserved words should not be used: 'FIELD','OR','AND'\n\nNor the characters [  ]  (  )  <  >  ,";
return(alertMsg);
}
//*******************Navigation Script*******************
//
//Stores array for all site navigation
//
//arrImgSplit = "PAGE NAME|IMAGE NAME|IMAGE WIDTH|PAGEID|URL"
//arrNavSplit[Incremental Integer] = "PAGE NAME|PAGEID|PARENT PAGE NAME|DEPTH WITHIN NAVIGATION|WINDOW TARGET|URL"
function buildNav(theSection, theStyle, theSub1, theSub2, theSub3, thePage){
	var totalNav;
	var arrNavSplit = new Array();
	var arrNav = new Array();
	var arrImgSplit = new Array();
	var arrImg = new Array();
	//alert(theSection);
// *************************************************************************************
if (theSection == "0") {
	var a = 0;
	arrImgSplit = 'Quick Links|button-fyrewrap-quick-links|152|2172D0A50585464685257035005ED872|';
		arrNavSplit[a] = 'Product Info Sheets|1009BFE5BFE9AA5D85257035005F3431|none|0||/DispProdInfoSheets?OpenForm&Count=20&ParentUNID=6CFFC9A7C250919885256EED006C36AE'; a++;
                                arrNavSplit[a] = 'MSDS Sheets|1009BFE5BFE9AA5D85257035005F3431|none|0||/DispMSDS?OpenForm&Count=20&ParentUNID=ECDBD90A7B0A76D585256EE8005746A4'; a++;
                                arrNavSplit[a] = 'Trade Shows|1009BFE5BFE9AA5D85257035005F3431|none|0||/HTMLNews/1EF294077BFB3D2585256E22004B9D13?OpenDocument'; a++;
                                arrNavSplit[a] = 'First Source Online|1009BFE5BFE9AA5D85257035005F3431|none|0|_new|http://www.reedfirstsource.com/members/result.asp?key=Unifrax#DOCS'; a++;
                                arrNavSplit[a] = 'Product Catalog Pages|1009BFE5BFE9AA5D85257035005F3431|none|Quick Links|_new|http://www.thomasnet.com/catalognavigator.html?cov=NA&which=comp&what=Unifrax&cid=374093&CNID=&cnurl= '; a++;
}else if (theSection == "1") {
	var a = 0;
	arrImgSplit = 'Company Overview|button-fyrewrap-company-overview|191|55FEF66A50FEC1D285257035005EEA8D|/AllDocuments/6A7E415632289B6685256EE60044CDDC?OpenDocument';
		arrNavSplit[a] = 'Affiliations|93AD1D6DD57695578525704900639CF2|none|0||/AllDocuments/55306A9252B069C18525696100442CBD?OpenDocument'; a++;
		arrNavSplit[a] = 'Company History|AF909F1096D4E0BC852570490063A174|none|0||/AllDocuments/11B58B29C23D7A2F8525696100444A90?OpenDocument '; a++;
		arrNavSplit[a] = 'News|3437FB4E1C9CD6EC852570490063A532|none|0||/DispNews/?OpenForm '; a++;
                                arrNavSplit[a] = 'Product Stewardship|AF909F1096D4E0BC852570490063A174|none|0||/AllDocuments/15FB58892325DE0D85256DC100509C73?OpenDocument '; a++;
                                arrNavSplit[a] = 'Quality|AF909F1096D4E0BC852570490063A174|none|0||/AllDocuments/56DA36938CDDBBF585256EE000651230?OpenDocument '; a++;
                                arrNavSplit[a] = 'Unifrax Today|AF909F1096D4E0BC852570490063A174|none|0||/AllDocuments/2330331904ED88BA85256EE1005534F2?OpenDocument '; a++;

}else if (theSection == "2") {
	var a = 0;
	arrImgSplit = 'Locations|button-fyrewrap-locations|124|EFEFB4473D119D7185257035005EEF62|/AllDocuments/B7F0C6ACFFEBF16385256EE60044CDD7?OpenDocument';
		arrNavSplit[a] = 'Sales|7D191C037D8DFAFF8525704B0058FB59|none|0||/AllDocuments/3BE6F755601F0BAB85256EE60044CDD8?OpenDocument '; a++
}else if (theSection == "3") {
	var a = 0;
	arrImgSplit = 'Contact Us|button-fyrewrap-contact-us|124|EFEFB4473D119D7185257035005EEF62|/Feedback?OpenForm';
	arrNavSplit[a] = 'By Email|BB99E322786CC5CF8525704B0058F7DF|none|0||/Feedback?OpenForm'; a++;
		
}

// **************************************************************************************
arrImg = arrImgSplit.split("|");
var topNavTest = 0;
var topNavLength = 0;
if (theStyle == "top"){
	var shadowImgH = 2;
	var shadowImgW = 191;
	for (i=0; i < arrNavSplit.length; i++) {
		arrNav = arrNavSplit[i].split("|");
		if (arrNav[3] == "0"){
			topNavLength = topNavLength+1;
			shadowImgH = shadowImgH + 19;
			if ((arrNav[0].length > 27) && (arrNav[0].lastIndexOf(' ') > 18)){
				shadowImgH = shadowImgH + 13;
			}
		}
	}
	if (ns){
		var shadowImgH = 0;
		var shadowImgW = 0;
	}
	totalNav = '<div id=nav onMouseOut="hidedrop('+theSection+');" onMouseOver="showdrop('+theSection+');"><a href="/web/UnifraxHome3.nsf/'+arrImg[4]+'"class=topNav><img src="/' + db + '/'+arrImg[1]+'.gif" name="'+arrImg[1]+'" width='+arrImg[2]+' height=36 border=0 /></a></div>\
				<div id="Layer'+theSection+theSection+'" name="Layer'+theSection+theSection+'" onmouseout="hidedrop('+theSection+');" onmouseover="showdrop('+theSection+');">\
				<div id="Layer'+theSection+'a" name="Layer'+theSection+'a"><img src="/' + db + '/grey_spacer.gif" width='+shadowImgW+' height='+shadowImgH+' border=0 /></div>'
	if (ns){
		totalNav = totalNav + '<div><table class="Layer'+theSection+'" cellpadding=0 cellspacing=0 border=0><tr><td>'
	}else{
		totalNav = totalNav + '<div id="Layer'+theSection+'">'	
	}
	  for (i=0; i < arrNavSplit.length; i++) {
			arrNav = arrNavSplit[i].split("|");
			if (arrNav[3] == "0") {
		  	if (theSub1 == arrNav[2]) {	  		
				if ((arrNav[0].length > 27) && (arrNav[0].lastIndexOf(' ') > 18) && (ns))
				{
		  			if (arrNav[4]=="_new") 
					{
						totalNav = totalNav+'<div id=topNavItem onmouseover="MM_Color(this,1);" onmouseout="MM_Color(this,0);" onclick="window.location.href=\''+arrNav[5]+'\'" style="height: 24px;">'+arrNav[0]+'</div>'; topNavTest++;
					}
					else
					{
						totalNav = totalNav+'<div id=topNavItem onmouseover="MM_Color(this,1);" onmouseout="MM_Color(this,0);" onclick="window.location.href=\'/web/UnifraxHome3.nsf'+arrNav[5]+'\'" style="height: 24px;">'+arrNav[0]+'</div>'; topNavTest++;
					}	
				}
				else
				{
		  			if (arrNav[4]=="_new") 
					{
			  			totalNav = totalNav+'<div id=topNavItem onmouseover="MM_Color(this,1);" onmouseout="MM_Color(this,0);" onclick="window.location.href=\''+arrNav[5]+'\'">'+arrNav[0]+'</div>'; topNavTest++;
					}
					else
					{
			  			totalNav = totalNav+'<div id=topNavItem onmouseover="MM_Color(this,1);" onmouseout="MM_Color(this,0);" onclick="window.location.href=\'/web/UnifraxHome3.nsf'+arrNav[5]+'\'">'+arrNav[0]+'</div>'; topNavTest++;
					}	
			  	}
		  		if (topNavTest < (topNavLength)){
		  			totalNav = totalNav+'<div id=topNavSep><img src="/' + db + '/topnav_sep.gif" width=185 height=2 border=0 /></div>\n';
					}else{
						totalNav = totalNav+'\n';
					}	  		
		  	}
			}
		}
		if (ns){
			totalNav = totalNav+'</tr></td></table></div>\n</div>\n';	
		}else{
			totalNav = totalNav+'</div>\n</div>\n';	
		}
		
		return totalNav;
}else{
	if (arrImg[3] == thePage){
		var currSec = arrImg;
	}else{
		for (i=0; i < arrNavSplit.length; i++) {
			arrNav = arrNavSplit[i].split("|");
			if (thePage == arrNav[1]){
				var currSec = arrNav;
			}
		}
	}
		totalNav = '<div style="clear: both;"><div id=leftNavArrowDown><a href="index.html"><img src="/' + db + '/arrow_green_down.gif" width=7 height=4 border=0></a></div><div id=leftNavItemDown><a href="index.html">Home</a></div></div>';
		if (thePage == arrImg[3]){
			totalNav = totalNav+'<div style="clear: both;"><div id=leftNavArrowDown><a href="'+arrImg[4]+'"><img src="/' + db + '/arrow_green_down.gif" width=7 height=4 border=0></a></div><div id=leftNavItemDownActive><a href="'+arrImg[4]+'">'+arrImg[0]+'</a></div></div>';
		}else{
			totalNav = totalNav+'<div style="clear: both;"><div id=leftNavArrowDown><a href="'+arrImg[4]+'"><img src="/' + db + '/arrow_green_down.gif" width=7 height=4 border=0></a></div><div id=leftNavItemDown><a href="'+arrImg[4]+'">'+arrImg[0]+'</a></div></div>';
		}
	  for (i=0; i < arrNavSplit.length; i++) {
			arrNav = arrNavSplit[i].split("|");
			if (thePage == arrNav[1]) {
				if (theSub1 == arrNav[2]) {
	  			if (theSub2 != "") {
	  				if (theSub3 != ""){
	  					if ((arrNav[4] == "none") && (thePage != arrNav[1])){
			  				totalNav = totalNav+'<div style="clear: both;"><div id=leftNavItem><a href="'+arrNav[5]+'">'+arrNav[0]+'</a></div></div>';	
	  					}else{
	  						if (arrNav[4] == "none"){
			  					totalNav = totalNav+'<div style="clear: both;"><div id=leftNavActive><a href="'+arrNav[5]+'">'+arrNav[0]+'</a></div></div>';	
			  				}else{
			  					totalNav = totalNav+'<div style="clear: both;"><div id=leftNavArrowDown><img src="/' + db + '/arrow_green_down.gif" width=7 height=4 border=0></div><div id=leftNavItemDownActive><a href="'+arrNav[5]+'">'+arrNav[0]+'</a></div></div>';	
			  				}
	  					}
		  			}else{
		  				totalNav = totalNav+'<div style="clear: both;"><div id=leftNavArrowDown><a href="'+arrNav[5]+'"><img src="/' + db + '/arrow_green_down.gif" width=7 height=4 border=0></a></div><div id=leftNavItemDownActive><a href="'+arrNav[5]+'">'+arrNav[0]+'</a></div></div>';	
		  			}
	  			}else{
		  			totalNav = totalNav+'<div style="clear: both;"><div id=leftNavActive><a href="'+arrNav[5]+'">'+arrNav[0]+'</a></div></div>';				  			
	  			}
		  	}else{
		  		totalNav = totalNav+'<div style="clear: both;"><div id=leftNavArrowDown><a href="'+arrNav[5]+'"><img src="/' + db + '/arrow_green_down.gif" width=7 height=4 border=0></a></div><div id=leftNavItemDownActive><a href="'+arrNav[5]+'">'+arrNav[0]+'</a></div></div>';	
		  	}
		  }else{
		  	if (theSub1 == arrNav[0]) {
		  		totalNav = totalNav+'<div style="clear: both;"><div id=leftNavArrowDown><a href="'+arrNav[5]+'"><img src="/' + db + '/arrow_green_down.gif" width=7 height=4 border=0></a></div><div id=leftNavItemDown><a href="'+arrNav[5]+'">'+arrNav[0]+'</a></div></div>';	
		  	}
		  	if ((theSub1 == arrNav[2]) && (theSub2 == "")) {
  				totalNav = totalNav+'<div style="clear: both;"><div id=leftNavItem><a href="'+arrNav[5]+'">'+arrNav[0]+'</a></div></div>';
		  	}
		  	if ((theSub2 == arrNav[2])) {
		  		totalNav = totalNav+'<div style="clear: both;"><div id=leftNavItem><a href="'+arrNav[5]+'">'+arrNav[0]+'</a></div></div>';			  			
		  	}
		  }
		}
		return totalNav;
}
}

