//Author: Donovan Bernauer
//Copyright © 2002 by Donovan Bernauer, Inc.
//Library of common routines for prints.airtecperforms.com

var PlatformOS = "Other";
var BrowserVer = "Unknown";

function PrintCurrentDateTime() {
	var today = new Date();
	return today.toLocaleString();
};

function platformDetect() {
	if (typeof(window.navigator.platform) != 'undefined') {
		PlatformOS = window.navigator.platform.toLowerCase();
		if (PlatformOS.indexOf('win') != -1) {
			PlatformOS = 'Microsoft Windows';
		}
		else if (PlatformOS.indexOf('mac') != -1) {
			PlatformOS = 'Macintosh';
		}
		else if (PlatformOS.indexOf('unix') != -1 || PlatformOS.indexOf('linux') != -1 || PlatformOS.indexOf('sun') != -1 || PlatformOS.indexOf('bsd') != -1) {
			PlatformOS = 'Unix/Linux/BSD';
		}
		else {
			PlatformOS = window.navigator.platform
		}
	}
};
platformDetect();

function browserVersion() {
	if(document.getElementById && document.all)
		{BrowserVer = "IE6";}
	else if(!document.getElementById && document.all)
		{BrowserVer = "IE4";}
	else if(document.layers)
		{BrowserVer = "NN4";
		window.onload = NN4_Init();}
	else if(document.getElementById && !document.all)
		{BrowserVer = "GECKO";}
	else {BrowserVer = "Other";}

};
browserVersion();

function DrawClock() {
	if(document.getElementById)
		{document.getElementById('clock').innerHTML = "&nbsp;<br />&nbsp;" + PrintCurrentDateTime();
		}
	else if(BrowserVer == "IE4")
		{document.all('clock').innerHTML = "&nbsp;<br />&nbsp;" + PrintCurrentDateTime();
		}
	else if(BrowserVer == "NN4")
		{ with(document.layers["clock"].document){
		open();
		write('<span class=\"clockNN4\"><center>' + PrintCurrentDateTime() + '</center></span>');
		close();}
		}
	setTimeout('DrawClock()', 1250);
};

function CreateClockLayer() {
 	var strHtml = '';
	if (BrowserVer.indexOf("E") != -1)
		{ strHtml = '<span id=\"clock\" class=\"clock\"> </span>';}
	else if (BrowserVer == "NN4")
		{
		strHtml = '<layer id=\"clock\"> </layer><br />';
		NN4_PaintWindow();
		}
	document.write(strHtml);
};

function NN4_PaintWindow() {
	//Those items that need re-doing in NN4 resizing
	document.bgColor = "#FFFFFF";
};

function NN4_Init() {
	setTimeout("window.onresize = NN4_resizeFix", 1000);
};

function NN4_resizeFix() {
	if (BrowserVer == "NN4") {
  		window.location.reload();
	}
};

function ScreenSize() {
	var ScrnSize = "x"
	if (BrowserVer.indexOf("E") != -1)
	{
		ScrnSize = screen.width + "x" + screen.height;
	}
	else if (BrowserVer.indexOf("NN") != -1)
	{
		//Netscape sees 19 pixels less on Height
		ScrnSize = screen.width + "x" + (screen.height + 19);
	}
	return ScrnSize;
};

function DrawNavBar() {
	document.write('<div class=\"nav\"> | <a href=\"/\">Home</a> | <a href=\"/services/prints/\">Prints &amp; OEMs</a> | <a href=\"/services/account/\">Settings</a> | <a href=\"/services/contact/\">Contact Us</a> | <a href=\"/services/map/\">Site Map</a> |</div>');
};

function disableRightClick(e)
{
	if(!document.rightClickDisabled) {
		if(document.layers) {
			document.captureEvents(Event.MOUSEDOWN);
			document.onmousedown = disableRightClick;
		}
		else document.oncontextmenu = disableRightClick;
		return document.rightClickDisabled = true;
	}
	if (document.layers || (document.getElementById && !document.all)) {
		if (e.which != 1) {
			return false;
		}
	}
	else {
		return false;
	}
};
disableRightClick();

function NewWindow(url, w, h) {
	window.open(url, '', 'height=' + h + ',width=' + w + ',toolbar,status,scrollbars,menubar,location,copyhistory,directories,resizable');
};

function DrawFooter() {
	//Split email address will generally fool web bots.
	var user1 = "air-tec";
	var site1 = "airtecperforms.com";
	var date = new Date;
	var year = date.getYear();
	
	//Special fix for GetYear bug on various browsers.
	if (year < 2000) { year = year + 1900 };

	with (document) { 
		write('<hr class=\"center\" />\r\n');
		write('<div class=\"cr\">Send questions or comments about this <em>web site</em> to the <a id=\"webmaster\" href=\"mailto:' + user1 + '@' + site1 + '\">webmaster</a>.</div>\r\n');
		write('<div class=\"cr\">Questions about this <em>company</em> should be directed to the <a href=\"/services/contact/\">Contact Us</a> page.</div>\r\n');
		write('<div class=\"cr\">&copy; 2004 - ' + year.toString() + ' by Air-Tec. - All Rights Reserved.</div>\r\n');
                write('<div class=\"cr\"><a class=\"center\" href=\"/privacy.htm\">Privacy Policy</a></div>\r\n');
		//write('<p class=\"cr\"><a href=\"http://validator.w3.org/check?uri=referer\"> <img class=\"center\" src=\"/images/valid-xhtml11.gif\" alt=\"Valid XHTML 1.1!\" height=\"31\" width=\"88\" /></a> <a href=\"http://jigsaw.w3.org/css-validator/validator?uri=http://prints.airtecperforms.com/css/main.css\"> <img class=\"center\" src=\"/images/vcss.gif\" alt=\"Valid CSS!\" /></a></p>');
	}
	if (!document.layers) {
		document.body.style.backgroundColor = "#6699CC";
	}
};
