// JavaScript Document

// set global variables
var title = "Ameritrak Detective Agency";
var url = "http://www.ameritrakdetectiveagency.com/";
var fullContact = "109 Fairfield Way, Suite 106<br />Bloomingdale, IL 60108-2512<br />Phone: 630-924-0343<br />Fax: 630-351-9715";
var index = new NavLink("Home", "index.htm", false);
var service = new NavLink("Services", "service.htm", false);
var invest = new NavLink("Investigators", "invest.htm", false);
var tools = new NavLink("Tools", "tools.htm", false);
var locations = new NavLink("About Us", "about.htm", false);
var privacy = new NavLink("Privacy Policy", "privacy.htm", false);
var copy = new NavLink("Copyright", "copy.htm", false);
var contact = new NavLink("Contact Us", "contact.htm", false);

// load the title for every page
onload=document.title=title;

// build navigation link
function NavLink(name, url, selected) {
	this.name = name;
	this.url = url;
	this.selected = selected;
}

// set current page indicator
function CurrentPage(obj, navlink) {
	if(obj.name == navlink.name) {
		navlink.selected = true;
		return  " id=\"current\" ";
	}else{
		return "";
	}
}

//----------------------------------------------------------------------------  
// Code to determine the browser and version.  
//----------------------------------------------------------------------------  
function Browser() {  
  
  var ua, s, i, an;  
  
  this.isKonq  = false;  // Linux Konqueror  
  this.isOmni  = false;  // OmniWeb  
  this.isOpera = false;  // Opera  
  this.isGecko = false;  // Gecko  
  this.isWebTV = false;  // WebTV  
  this.isIcab  = false;  // iCab  
  this.isIE    = false;  // Internet Explorer  
  this.isNS    = false;  // Netscape  
  this.isMoz   = false;  // Other browsers  
  this.version = null;  
  this.an      = navigator.appName;  
  this.isJaveEn= navigator.javaEnabled(); 
  if(document.getElementById) {
	  this.isDOM = true;
  }else{
	  this.isDOM = false;
  }

  
  ua = navigator.userAgent.toLowerCase();  
  
  s = "konqueror";  
  if ((i = ua.indexOf(s)) >= 0) {  
    this.isKonq = true;  
    this.version = parseFloat(ua.substr(i + s.length));  
    return;  
  }  
  
  s = "omniweb";  
  if ((i = ua.indexOf(s)) >= 0) {  
    this.isOmni = true;  
    this.version = parseFloat(ua.substr(i + s.length));  
    return;  
  }  
  
  s = "opera";  
  if ((i = ua.indexOf(s)) >= 0) {  
    this.isOpera = true;  
    this.version = parseFloat(ua.substr(i + s.length));  
    return;  
  }  
  
  s = "webtv";  
  if ((i = ua.indexOf(s)) >= 0) {  
    this.isWebTV = true;  
    this.version = parseFloat(ua.substr(i + s.length));  
    return;  
  }  
  
  s = "icab";  
  if ((i = ua.indexOf(s)) >= 0) {  
    this.isIcab = true;  
    this.version = parseFloat(ua.substr(i + s.length));  
    return;  
  }  
  
  s = "msie";  
  if ((i = ua.indexOf(s)) >= 0) {  
    this.isIE = true;  
    this.version = parseFloat(ua.substr(i + s.length));  
    return;  
  }  
  
//  s = "Netscape6/";  
  s = "netscape/";  
  if ((i = ua.indexOf(s)) >= 0) {  
    this.isNS = true;  
    this.version = parseFloat(ua.substr(i + s.length));  
    return;  
  }  
  
  // Treat any other "Gecko" browser as NS 6.1.  
  s = "gecko";  
  if ((i = ua.indexOf(s)) >= 0) {  
    this.isGecko = true;  
    this.version = parseFloat(ua.substr(ua.indexOf('; r') + s.length)) + " (Compatible with Netscape 6.1 or higher)";  
    return;  
  }  
  
  s = "mozilla/";  
  if ((i = ua.indexOf(s)) >= 0) {  
    this.isMozilla = true;  
    this.version = parseFloat(ua.substr(i + s.length));  
    return;  
  }  
}  
  
//detects OS name
function OS() {  
  var ua;  
  
  ua = navigator.userAgent.toLowerCase();  
  
  this.OS      = null;  
  
  if (checkIt('linux', ua)) {  
    this.OS = "Linux";  
    return;  
  }  
  else if (checkIt('x11', ua)) {  
    this.OS = "Unix";  
    return;  
  }  
  else if (checkIt('mac', ua)) {  
    this.OS = "Mac";  
    return;  
  }  
  else if (checkIt('win', ua)) {  
    this.OS = "Windows";  
    return;  
  }  
  else {  
    this.OS = "an unknown operating system";  
    return;  
  }  
  
  function checkIt(string, u) {  
      place = u.indexOf(string) + 1;  
      return place;  
  }  
}

//set browser and os global variables
var os = new OS();  
var browser = new Browser();

//returns current users year
function getThisYear(){
	var today = new Date();
	var year = today.getYear();
	var day = today.getDay();
	var month = today.getMonth();

	if(year < 2000) 
		year += 1900;

	return year;
}

function getCopyWrite() {
	var address = "<span style=\"font-size:10px;\"><br />" + fullContact + "</span>";
	var copyWrite = "Copyright &copy;2005 -" + getThisYear() + " " + title + address;
	
	return copyWrite;
}

function getNavBarLinks(obj) {
	var links = "<a href=\"" + index.url + "\" class=\"nav\"" + CurrentPage(obj, index) + ">" + index.name + "</a> ";
		links += "<a href=\"" + service.url + "\" class=\"nav\"" + CurrentPage(obj, service) + ">"  + service.name + "</a> ";
		links += "<a href=\"" + invest.url + "\" class=\"nav\"" + CurrentPage(obj, invest) + ">" + invest.name + "</a> ";
		links += "<a href=\"" + tools.url + "\" class=\"nav\"" + CurrentPage(obj, tools) + ">" + tools.name + "</a> ";
		links += "<a href=\"" + locations.url + "\" class=\"nav\"" + CurrentPage(obj, locations) + ">" + locations.name + "</a> ";
		links += "<a href=\"" + contact.url + "\" class=\"nav\"" + CurrentPage(obj, contact) + ">" + contact.name + "</a>";
		
	return links;
}

function getGlobalLinks() {
	var links = "<a href=\"" + index.url + "\">" + index.name + "</a> | ";
		links += "<a href=\"" + service.url + "\">"  + service.name + "</a> | ";
		links += "<a href=\"" + invest.url + "\">" + invest.name + "</a> | ";
		links += "<a href=\"" + tools.url + "\">" + tools.name + "</a> | ";
		links += "<a href=\"" + locations.url + "\">" + locations.name + "</a> | ";
		links += "<a href=\"" + privacy.url + "\">" + privacy.name + "</a> | ";
		links += "<a href=\"" + copy.url + "\">" + copy.name + "</a> | ";
		links += "<a href=\"" + contact.url + "\">" + contact.name + "</a>";
		
	return links;
}

function writeBrowserLink() {
	var sniff = "";
	
	if(browser == null)
		browser = new Browser();
	
	if (browser.isIE) {
		sniff = ("&nbsp;<a style=\"cursor:hand\" onMouseOver=\"status='Make " + title.toUpperCase() + " my start page!';return true;\" onMouseOut=\"status='';return false;\"onclick=\"this.style.behavior='url(#default#homepage)';this.setHomePage(location.href);\"><img src=\"images/common/sethome.gif\" border=\"0\" width=\"14\" height=\"14\" alt=\"Make " + title.toUpperCase() + " my start page!\"/></a>&nbsp;<a style=\"cursor:hand\" onMouseOver=\"status='Make " + title.toUpperCase() + " my start page!';return true;\" onMouseOut=\"status='';return false;\" onclick=\"this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.doorsinfo.com');\" title=\"Make " + title.toUpperCase() + " my start page!\">Make " + title.toUpperCase() + " your start page!</a><br />");
		sniff += ("&nbsp;<a style=\"cursor:hand\" onMouseOver=\"status='Bookmark " + title.toUpperCase() + " NOW!';return true;\" onMouseOut=\"status='';return false;\" onclick=\"window.external.AddFavorite(location.href, document.title);\"><img src=\"images/common/favorites.gif\" width=\"15\" height=\"13\" alt=\"Bookmark " + title.toUpperCase() + " NOW!\" /></a>&nbsp;<a style=\"cursor:hand\" onMouseOver=\"status='Bookmark " + title.toUpperCase() + " NOW!';return true;\" onMouseOut=\"status='';return false;\" onclick=\"window.external.AddFavorite(location.href, document.title);\" title=\"Bookmark " + title.toUpperCase() + " NOW!\">Bookmark " + title.toUpperCase() + " NOW!</a><br />");
	}else if (browser.isOpera) {
		sniff = ("<img src=\"images/common/opera_bookmark.gif\" width=\"12\" height=\"15\" alt=\"Bookmark " + title.toUpperCase() + " NOW!\" />&nbsp;Bookmark " + title.toUpperCase() + " NOW! Press Crtl + T<br />");
	}else if (browser.isNS || browser.isGecko) {
		sniff = ("<img src=\"images/common/ns_bookmark.gif\" width=\"16\" height=\"16\" alt=\"Bookmark " + title.toUpperCase() + " NOW!\" />&nbsp;Bookmark " + title.toUpperCase() + " NOW! Press Crtl + D<br />");
	}else {
		sniff = ("&nbsp;Don\'t Forget to Bookmark " + title.toUpperCase() + " NOW!<br />");
	}
document.write(sniff);
}