var IE4plus = (document.all) ? true : false;
var NS4 = (document.layers) ? true : false;
var bookmarkname = 'T.S. Moly Lubricants, Inc.';
var bookmarksite = 'http://www.tsmoly.com';

function clickIE() { return false; }

function clickNS(e) {
	if (e.which==2 || e.which==3) { return false; }
}

function disableRightClick() {
	if (!IE4plus) {
		document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
		document.onmousedown = clickNS;
		document.onmouseup = clickNS;
		// For NS 6+
		document.oncontextmenu = clickIE;
	}
	else {
		document.onmouseup = clickIE;
		document.oncontextmenu = clickIE;
	}
}

function preloadimg(src1) {
	img = new Image();
	img.src = src1;
	return img;
}

function popup(page, w, h, style) {
	if (!w) w = 450;
	if (!h) h= 300;
	if (!page) page= "#";
	if (!style) {
		style = "toolbar=0,location=0,directories=0,status=0,scrollbars=yes,resizable=yes,copyhistory=no,"
			+ "width=" + w + ",height=" + h;
	}
	PopUp = window.open(page, "PopUp", style)
	PopUp.name = "PopUp";
	if (!PopUp.opener) { PopUp.opener = self; }
	if (PopUp.focus) { PopUp.focus(); }
}


function get_cookie(name) {
	var start = document.cookie.indexOf(name+"=");
	var len = start+name.length+1;
	if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
	if (start == -1) return null;
	var end = document.cookie.indexOf(";",len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len,end));
}

function set_cookie(name,value,expires,path,domain,secure) {
	document.cookie = name + "=" +escape(value) +
		( (expires) ? ";expires=" + expires.toGMTString() : "") +
		( (path) ? ";path=" + path : "") +
		( (domain) ? ";domain=" + domain : "") +
		( (secure) ? ";secure" : "");
}


function delete_cookie(name,path,domain) {
	if (Get_Cookie(name)) document.cookie = name + "=" +
		( (path) ? ";path=" + path : "") +
		( (domain) ? ";domain=" + domain : "") +
		";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}


function bookmark_site() {
	if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
		window.external.AddFavorite(bookmarksite, bookmarkname);
	}
	else {
		alert("Hit CTRL-D to bookmark this site for this browser.");
	}
}

function body_onload() {
	preloadimg('/images/home_on.jpg');
	preloadimg('/images/company_on.jpg');
	preloadimg('/images/rfq_on.jpg');
	preloadimg('/images/links_on.jpg');
	preloadimg('/images/msds_on.jpg');
	preloadimg('/images/faqs_on.jpg');
	preloadimg('/images/contact_on.jpg');
}
