// JavaScript Document
// Some instances of IE on Windows will cause Google Translate to choke.
// This provides graceful error handling for GT, while still providing feedback on other errors:
window.onerror=function(msg, url, linenumber){
	if(url.search(/google/i)==-1){
		return false;
	} else {
		//$("#google_translate_element").html('<a href="http://www.google.com/translate_c?langpair=en|es&u=http://www.websap.net">Translate This Page</a>');
		return true;
	}
}
var t;
var productPage=false;
$(function(){
	preLoadImages("images/nav_over.jpg", "images/sec_nav_over.jpg");
	$("#nav td:last").css("border", "none");
	$("#nav a").hover(function(event){
		$("#nav a").removeClass("over");
		clearTimeout(t);
		if($(this).attr("id")!="products"){
			$("#prodDrop").slideUp();
		}
		$(this).addClass("over");
	}, function(){
		$(this).removeClass("over");
		if($(this).attr("id")!="products"){
			$("#prodDrop").slideUp();
		}
	});
	$("#products").mouseover(function(){
		$("#prodDrop").slideDown();
	});
	$("#prodDrop").hover(function(){
		$("#products").addClass("over");
	}, function(){
		t=setTimeout("clearDrop()", 100);
	});
	$("#masthead, #mastheadMap").mouseover(clearDrop);
	if(productPage){
		$("#rplinks").removeClass("nonProduct");
		$("#contentBlock").css("padding-bottom" , "20px");
	}
	$("#toleranceTable tr").each(function(){
		$(this).find('td:last-child').addClass('last');
		$(this).find('th:last-child').addClass('last');
	});
	$(".blackTable tr").each(function(){
		$(this).find("td:first-child").css({"white-space" : "nowrap", "font-weight" : "bold", "padding-right" : "15px"});
	});
	$("#chemTable tr, .firstLeft tr").each(function(){
		$(this).find("td:first-child, th:first-child").css("text-align", "left");
	});
	$(".spreadTable tr").each(function(){
		$(this).find("td:first-child").css("padding-right", "20px");
		$(this).find("td:last-child").css("padding-left", "20px");
	});
	$("#answers p").after('<div class="btt"><a href="#top">Back to Top</a></div>');
	$(".sprocketTable tr").each(function(){
		$(this).find("td:nth-child(3)").not(".na").each(function(){
			var htm=$(this).html();
			$(this).html('<a href="images/gallery/'+htm+'.jpg" class="lb" title="'+htm+'">'+htm+'</a>');
		});
	});
	$(".sprocketTable th, #repTable td").addClass("notranslate");
	$("a.lb").lightBox();
	$(".wideTable tr").each(function(){
		$(this).find("td:first-child, th:first-child").css({"text-align" : "left"});
	});
});
function clearDrop(){
	$("#prodDrop").slideUp(function(){
		$("#products").removeClass("over");
	});
}
