
/* LOAD XML DOCUMENT  -  load the specified XML file */
function loadxmldoc(fileURL) { 
	if (!fileURL) {
		fileURL='links.xml';
	}
	try { //Internet Explorer
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		//document.write("Internet Explorer <br />");
	} catch(e) {
		try { //Firefox, Mozilla, Opera, etc.
			xmlDoc=document.implementation.createDocument("","",null);
			//document.write(" ... Firefox, Mozilla, Opera, etc. <br />");
		} catch(e) {
			alert(e.message + 'Your browser does not support the JavaScript necessary to navigate this website.');
		}
	}
	try {
		xmlDoc.async=false;
		xmlDoc.load(fileURL);
		return(xmlDoc);
	} catch(e) {
		alert(e.message + '.  Your web browser does not support the JavaScript necessary to navigate our website.  Try a browser that complies with published standards (Firefox, Internet Explorer, Opera, ...).');
		return(null);
	}
} // end function loadxmldoc


/* LOAD LINKS  -  build the menu links */
function loadlinks(fileURL,dirlevel) { 
	var xmlDoc=loadxmldoc(fileURL);
	if (!xmlDoc) {
		alert('Unable to load Links.');
		return(null);
	} else {
		var basx=xmlDoc.getElementsByTagName("basic_link");
		var labx=xmlDoc.getElementsByTagName("label");
		var urlx=xmlDoc.getElementsByTagName("url");
		//var decx=xmlDoc.getElementsByTagName("description");
		if (!dirlevel) {
			urlpre='';
		} else {
			urlpre='../';
		}

		document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
		for (var i=0;i<basx.length;i++)  { 
			document.write('<tr><td><table border="5" cellpadding="0" cellspacing="0" width="100%">');
			document.write('<tr><td align="center" height="30" class="menul1"><a href="' + urlpre);
			document.write(urlx[i].childNodes[0].nodeValue + '" target="_top">');
			document.write(labx[i].childNodes[0].nodeValue + '</a></td></tr></table></td></tr>');
		}	 // end FOR block
		document.write('</table>');
		Initialise();
		return(basx.length);
	}
} // end function loadlinks


/* Initialise */
function Initialise() {		
	setMenuOffset.initialPos = getStyle('links','top');
	window.onscroll = document.documentElement.onscroll = setMenuOffset;
	setMenuOffset();
} // end function Initialise


/* SET MENU OFFSET  -  make the menu scroll up but not past the top */
function setMenuOffset() { 
	var links = document.getElementById('links');
	if (!links) {
		alert('No "links" ID!');
		return;
	}
	var currentOffset = document.documentElement.scrollTop || document.body.scrollTop; // body for Safari
	var startPos = parseInt(setMenuOffset.initialPos) || 180;
	var desiredOffset = startPos - currentOffset;
	if (desiredOffset < 10)
		desiredOffset = 10;
	if (desiredOffset != parseInt(links.style.top)) 
		links.style.top = desiredOffset + 'px';
} // end function setMenuOffset


/* GET STYLES */
function getStyle(el,styleProp) {
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
} // end function getStyle


/* LOAD FOOTER */
function footer() { 
	var footer = document.getElementById('footer');
	if (!footer) return;

	document.write('<br /><hr />');
	document.write('<p align="center">- &nbsp; &nbsp; ');
	document.write('<a href="http://www.americanlaminators.com/site.html" target="_top"> Site Map </a> &nbsp; &nbsp; - &nbsp; &nbsp; ');
	document.write('<a href="http://www.americanlaminators.com/" target="_top"> Home </a> &nbsp; &nbsp; - &nbsp; &nbsp; ');
	document.write('<a href="http://www.amlam.net/" target="_top"> AmLam.net </a> &nbsp; &nbsp; -</p>');
	document.write('<p align="center" class="copyright">Copyright &copy; 2005 - 2009 American Laminators. All Rights Reserved.</p>');
} // end function footer


/* LOAD LITERATURE TABLE */
function loadtable(fileurl,dirlevel) { 
	var xmlDoc=loadxmldoc(fileurl);
	var doc=xmlDoc.getElementsByTagName("basic_doc");
	var sub=xmlDoc.getElementsByTagName("subject");
	var tit=xmlDoc.getElementsByTagName("title");
	var pag=xmlDoc.getElementsByTagName("pages");
	var url=xmlDoc.getElementsByTagName("url");
	var did=xmlDoc.getElementsByTagName("doc_id");
	var siz=xmlDoc.getElementsByTagName("size");
	//alert(doc.length + ' total elements');
	if (!dirlevel) {
		urlpre='';
	} else {
		urlpre='../';
	}

	document.write('<table border="0" width="100%" cellspacing="5" align="center">');
	document.write('<tr><th><u class="heading">Subject</u></th>');
	document.write('<th><u class="heading">Title</u></th>');
	document.write('<th><u class="heading">Pages</u></th>');
	document.write('<th width="90"><u class="heading">Link</u></th>');
	document.write('<th width="50"><u class="heading">Size</u></th></tr>');

	for (var i=0;i<doc.length;i++)  { 
		document.write('<tr align="center"><th>' + sub[i].childNodes[0].nodeValue + '</th>');
		document.write('<td class="headline">' + tit[i].childNodes[0].nodeValue + '</td>');
		document.write('<td>' + pag[i].childNodes[0].nodeValue + '</td>');
		document.write('<td><a href="' + url[i].childNodes[0].nodeValue + '" target="_blank"><img src="' + urlpre + 'images/pdficon.gif" height="30" width="38" border="0" alt="PDF icon" />');
		document.write(' ' + did[i].childNodes[0].nodeValue + '</a></td>');
		document.write('<td>' + siz[i].childNodes[0].nodeValue + '</td></tr>');
	}	 // end FOR block
	document.write('</table>');
} // end function loadtable