/**
 * Writes the HTML to the browser for a link to the Thomas Register Catalog.
 * You are responsible for passing in the querystring for the catalog,
 * WITHOUT a template.  In other words, you will typically include...
 * 		az, type, sort, ptno, number, show, and tablewidth 
 *
 * The template should be specified as the second parameter to this function.
 *
 * Finally, this function anticipates humanReadable, which is something
 * that the user will understand for the link, like 
 *		"RIGID BOROSCOPES". 
 */
function standardThomasLink(querystring, template, humanReadable) {
	// build up the URL
	var html = "<a class='nav01' target='_top' href='";
	html += customizableThomasLink(querystring, template);
	
	// a little schnick-schnack
	html += "'><img src='images/arrow.gif' width='15' height='11' alt='' border='0'>&nbsp;";
	
	// finally, the humanReadable and finish it up
	html += humanReadable;
	
	html += "</a>";
	
	document.write(html);
}


/**
 * Exactly the same as the other Thomas Link, except that this one just
 * returns the href that you will require.
 */
function customizableThomasLink(querystring, template) {
	// build up the URL
	var html = "";
	html += "http://www.thomasregister.com/smartcat.cgi";
	if (querystring.length > 0 && querystring.charAt(0) != '?') html += "?";
	
	// tack on the query string that was specified
	html += querystring;
	if (querystring.indexOf("template=") == -1) html += "&template=";
	// but automatically figure out the template server (this server)
	
	var serverName = location.hostname+"";
	// work around our fire wall -- NOTE WE ARE GOING TO STAGE IF ON DEV!!
	if (serverName.indexOf(".dev.") != -1) serverName = "lenoxinst.stage.pingsite.com";
	
	html += "http://"+serverName+"/thomasregister/";
	html += template;
	
	return html;
}
