if (top.location != self.location) {
  top.location = self.location;
}

var url = self.location.href;
url = url.toLowerCase();

// determine the server
var DOM   = '';
var local = 'website/';
var live  = 'rooseveltchiropractic.com/';
((url.lastIndexOf(local) > 1) ? DOM = local : DOM = live )

// determine relpath, section of site and subdirectory variable
var endOfDOM = url.lastIndexOf(DOM);
var endOfURL = url.substring((endOfDOM + DOM.length), url.length);
var relpath = '';
var subdir = '';
var section = '';

for (i=0; i<endOfURL.length; i++) {
  if (i < endOfURL.lastIndexOf('/') )  { subdir  += endOfURL.charAt(i).toLowerCase(); }
  if (i < endOfURL.indexOf('/') )      { section += endOfURL.charAt(i).toLowerCase(); }  
  if (endOfURL.charAt(i)=='/')         { relpath += '../'; }
}

// ensure section is defined and is lowercase
if (section + '' == 'undefined' || section == ''){ section = 'services'; } 

// determine filename
var HTM = '.htm';
var endOfHTM = url.lastIndexOf(HTM);
var beg_file = url.lastIndexOf('/');
var filename = url.substring(beg_file + 1, endOfHTM);

//determine nav section and IDs
var global_nav_id    = section;
var secondary_nav_id = filename;

// set event for Start/Run/Word shortcut
var dir  = 'C:\\web\\sites\\roosechiro\\docsite\\';

var adminURL      = dir + endOfURL 
adminURL          = adminURL.replace('.htm','.doc');
adminURL          = adminURL.replace('/','\\');
function getKey() {
	if (event.keyCode == 27 && url.lastIndexOf(live) < 0) {
		var adminWin = window.open(relpath + 'window.htm', 'newWin', 'left=50,top=100,width=500,height=250,menubar=yes,toolbar=no,location=no,resizable=yes,scrollbars=no');
		adminWin.document.admin.adminText.value = adminURL;
		adminWin.document.admin.adminText.focus();
		adminWin.document.close();
	}
}
document.onkeypress = getKey;

// Browser Sniffer
var sAgent = navigator.userAgent;
var mac = sAgent.indexOf("Mac") > -1;
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
var ns3 = (bName == "Netscape" && bVer == 3);
var ie3 = (bName == "Microsoft Internet Explorer" && bVer == 3);
var ns4 = (document.layers) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

// Just in case function 
function init(){null}

// Netscape Resize Workaround
if (ns4) {
	widthCheck = window.innerWidth
	heightCheck = window.innerHeight
	window.onResize = refresh
}

function refresh() {
	if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
	document.location.href = document.location.href
}

// Rollover Function
function findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
}

function swapImage(){//v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function swapImgRestore(){//v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


// changes color of secondary nav to show state 
// in NS it needs to be declared prior to writing the subnav
// in IE after (function is called after writing the 'subnav' variable)
if (ns4) { subideval() }

function subideval() {
	var subidcolor = '#660000';
	var type = typeof subid;
	if (type != 'undefined' ) { 
		if (ns4) { eval('document.ids.' + subid + '.color = "' + subidcolor + '"')
		} else { eval('document.all.' + subid +  '.style.color = "' + subidcolor + '"')
		}
	}
}

// changes color of tertiarary nav to show state 
// in NS it needs to be declared prior to writing thetertiarary nav
// in IE after (function is called after writing the 'tertiarary nav' variable)
if (ns4) { tertideval() }

function tertideval() {
	var tertidcolor = '#660000';
	var type = typeof tertnavid;
	if (type != 'undefined' ) { 
		if (ns4) { eval('document.ids.' + tertnavid + '.color = "' + tertidcolor + '"')
		} else { eval('document.all.' + tertnavid +  '.style.color = "' + tertidcolor + '"')
		}
	}
}

// Build Secondary Left Navigation

// repeating variables
var sep      = ','; 
var nl       = '<br>'; 
var state    = '';
