// replace any strange characters
String.prototype.normalize = function()
{
//  return this.replace( /^\s+/g , '' ).replace( /\s+$/g , '' ).replace( /\s+/g , " " ) ;

  return this.replace( /%20+/g , ' ' ).replace( /_/g , "" ).replace( /-/g , "" ).replace( /,/g , "" ).replace( /\s+/g , "" ) ;
  
}

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

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

// determine the server
var DOM   = '';
var local = 'localhost/wsa/'; //'website/';
//var live  = 'westersurg.org/';
var live  = '207.126.52.217/';
//var live  = 'site253.webhost4life.com/cdchc'; //temp url
//((url.lastIndexOf(local) > 1) ? DOM = local : DOM = live )
((url.indexOf(local) > -1)? DOM = local: DOM =  live);

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

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

//alert('subdir =' + subdir)
//alert('section =' + section)
//alert('filename =' + filename)

// Browser Sniffer
var sAgent = navigator.userAgent;
var mac = sAgent.indexOf("Mac") > -1;
var bName = navigator.appName;
var 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;

function NavOn(ele) {
  if(eval('document.all.'+ele) || eval('document.getElementById(\'' + ele + '\')')) {
	var bg = '#A4A691';
	var weight = 'bold';
	if (ns4) { 
		eval('document.ids.'+ele+ '.fontWeight = \"'+weight+'\"'); 
		eval('document.ids.'+ele+ '.color = \"'+bg+'\"'); 
	} else if (ns6) {
		//eval('document.getElementById(\'' + ele + '\').fontWeight = \"'+weight+'\"'); 
		//eval('document.getElementById(\'' + ele + '\').color = \"'+bg+'\"'); 
		eval('document.getElementById(\'' + ele + '\').className = \"'+'secnavon'+'\"');
	} else if (ie5) {
		//eval('document.getElementById(\'' + ele + '\').fontWeight = \"'+weight+'\"'); 
		//eval('document.getElementById(\'' + ele + '\').color = \"'+bg+'\"'); 
		eval('document.getElementById(\'' + ele + '\').className = \"'+'secnavon'+'\"');		
	} else {
		//eval('document.all.'+ele+ '.style.fontWeight = \"'+ weight +'\"'); 
		//eval('document.all.'+ele+ '.style.color = \"'+bg+'\"');
		eval('document.all.'+ele+ '.style.className = \"'+'secnavon'+'\"'); 
		eval('document.all.'+ele+ '.style.class = \"'+'secnavon'+'\"'); 		
	} 
  }
}

// Open Search Window with Map for MEMBERS
function OpenSearchMap() {
	var popup = self.location.href;
	if (popup.indexOf('login.php') < 0 ) { 
		srchMap=window.open('http://www.westernsurg.org/members/map.php','mappage','resizable=no,scrollbars=no,width=420,height=309,top=400,left=400');
		if (window.opener == null)  { window.opener = window; }
		window.opener.name = "opener";
		window.srchMap.document.focus();
	} else {
		alert('Please login. Then, you can access the searches.');
	}
}

// Open Search Window with Map for ADMIN
function OpenSearchMapAdmin() {
	var popup = self.location.href;
	if (popup.indexOf('login.php') < 0 ) { 
		srchMap=window.open('http://www.westernsurg.org/admin/map.php','mappage','resizable=no,scrollbars=no,width=420,height=309,top=400,left=400');
		if (window.opener == null)  { window.opener = window; }
		window.opener.name = "opener";
		//alert(opener.name);		
		window.srchMap.document.focus();
	} else {
		alert('Please login. Then, you can access the searches.');
	}
}


function OpenEmail(email) {
//alert(email);
var popup = self.location.href;
win=window.open('http://westernsurg.org/emails/' + email,'emailpage','resizable=yes,scrollbars=yes,width=550,height=600,top=400,left=400');
if (window.opener == null)  { 
	window.opener = window; }
window.win.document.focus();
}
