// modified 5/17/08

// ---------------------- Sniffer Lite -------------------------
var agt = navigator.userAgent
var nme = navigator.appName
var ver = navigator.appVersion
var vendSub = navigator.vendorSub

var ie = (ver.indexOf("MSIE")!=-1)
var ieVer = (ie) ? parseFloat(ver.split("MSIE")[1]) : null ;
var ie5up = (ieVer>=5.0)

var ff = (agt.indexOf("Firefox")!=-1)
var ffVer = (ff && typeof(vendSub)!="undefined") ? parseFloat(vendSub) : null ;
var ff09up = (ffVer>=0.9)

var op=agt.toLowerCase().indexOf("opera")!=-1
var op6up = ((agt.indexOf("Opera 6")!=-1)||(agt.indexOf("Opera/6")!=-1) || (agt.indexOf("Opera/7")!=-1) || (agt.indexOf("Opera 7")!=-1) || (agt.indexOf("Opera 8")!=-1) || (agt.indexOf("Opera/8")!=-1) || (agt.indexOf("Opera 9")!=-1)||(agt.indexOf("Opera/9")!=-1))
ie5up=(ie5up && op6up != true);
//alert(op)
var moz = (agt.indexOf("Mozilla/")!=-1 && agt.indexOf("Gecko/")!=-1 && agt.indexOf("Camino/")==-1)
var mozVer = (moz) ? parseFloat(agt.substring(agt.indexOf("rv:")+3, agt.indexOf(")"))) : null ;
var moz16up = (mozVer>=1.4)

var ns = (agt.indexOf("Netscape/")!=-1)
var nsVer = (ns) ? parseFloat(agt.substring(agt.indexOf("Netscape/")+9, agt.length)) : null ;
var ns8up = (nsVer>=8)

var saf = (agt.indexOf("Safari/")!=-1 && agt.indexOf("AppleWebKit/")!=-1)
//var saf12 = (saf) ? parseFloat(agt.substring(agt.indexOf("rv:")+3, agt.indexOf(")"))) : null ;
//var saf16up = (saf16>=1.4)

var cam = (agt.indexOf("Camino/")!=-1 && agt.indexOf("Mac")!=-1)

var pie = (nme=="Microsoft Pocket Internet Explorer")

var wtv = (nme.indexOf("WebTV")!=-1)

var mac = (agt.toLowerCase().indexOf("mac")!=-1)

cssSupported = (ie5up || op6up || ff09up || moz16up || ns8up || saf || cam)
menuSupported = (ie5up || ff09up || moz16up || ns8up || saf || cam)
menuAnimSupported = false;//op6up || ff09up || moz16up || ns8up)
if(mac && ie) { cssSupported=menuSupported=menuAnimSupported=false; }


// For Debugging...  allows you to add ?supported=false to the url to check both
sTempUrl = window.location.href;
if(sTempUrl.indexOf('supported=true')!=-1){ cssSupported=menuSupported=menuAnimSupported=true; }
if(sTempUrl.indexOf('supported=false')!=-1){ cssSupported=menuSupported=menuAnimSupported=false; }

function writeDetection() {
	document.write("<b>navigator.userAgent:</b> "+agt+"<br />");
	document.write("<b>Reported Browser:</b> ie5up:"+ie5up+"; op6up:"+op6up+"; ff09up:"+ff09up+"; moz16up:"+moz16up+"; ns8up:"+ns8up+"; saf:"+saf+"; cam:"+cam+";<br />");
	document.write("<b>cssSupported:</b> "+cssSupported+"<br />");
	document.write("<b>menuSupported:</b> "+menuSupported+"<br />");
	document.write("<b>menuAnimSupported:</b> "+menuAnimSupported+"<br />");
}
//writeDetection();


var sMailToLink="mailto:?subject="+document.title+"&body=You've been sent the following link from BannerHealth.com:%0D "+window.location.href+"%OD%OD";

// ---------------------- General Functions --------------------
function checkForWarning() {
	var bCkVal = readCookie("bh_Warned");
	if(typeof(bCkVal)!='undefined') { bCkVal = bCkVal.toLowerCase(); }
	if(bCkVal=="true" || bCkVal=="false") {
		if(readCookie("bh_Warned")=="true") {
			return '<style type="text/css" media="all">#ahem { display:none; }</style>';
		}
	}
	return '';
}
function writeFlash(swfUrl, sId, sWidth, sHeight, flshVer) {
	var sFlashHtml = getFlashHtml(swfUrl, sId, sWidth, sHeight, flshVer);
	document.write(sFlashHtml);
}
function getFlashHtml(swfUrl, sId, sWidth, sHeight, flshVer) {
	var s_classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000";
	var s_codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+flshVer+",0,0,0";
	
	// force a unique id so IE doesn't flip out when you close the window or leave the page
	var reIeCheck = /MSIE/gi;
	if(reIeCheck.test(navigator.userAgent)) { sId = getUniqueFlashId(sId); }

	var sFlashHtml = '';
	sFlashHtml += '<object id="'+sId+'" classid="'+s_classid+'" codebase="'+s_codebase+'" width="'+sWidth+'" height="'+sHeight+'">';
	sFlashHtml += '	<param name="movie" value="'+swfUrl+'">';
	sFlashHtml += '	<param name="quality" value="best">';
	sFlashHtml += '	<param name="wmode" value="transparent">';
	sFlashHtml += '	<param name="allowFullScreen" value="true" />';
	sFlashHtml += '	<param name="allowScriptAccess" value="always" />';
	sFlashHtml += '	<embed src="'+swfUrl+'" id="'+sId+'" allowFullScreen="true" allowScriptAccess="always" quality="best" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+sWidth+'" height="'+sHeight+'"></embed>';
	sFlashHtml += '</object>';
	return sFlashHtml;
}
function getUid() {
	var S4 = function() { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); }
	return (S4()+S4()+'-'+S4()+'-'+S4()+'-'+S4()+'-'+S4()+S4()+S4());
}
function getUniqueFlashId(sDefault) {
	if(typeof(sDefault)=='undefined' || sDefault=='' || sDefault==null) { return getUid(); }
	if(typeof(jQuery)!='undefined') { if(jQuery('#'+sDefault).length==0) { return sDefault; } }
	return getUid();
}


// ------------ Font Size Changer -----------------
function changeFontSize(sObjToChgId, sNewSize) {
	if(document.getElementById) {
		// update passed in object's font size (usually the page content)
		document.getElementById(sObjToChgId).style.fontSize = sNewSize+"em";
		writeCookie("bh_fontSize", sObjToChgId+","+sNewSize, 1);
	}
}
function nextFontSize(sObjId, bUp) {
	if(document.getElementById) {
		var sCurSize=document.getElementById(sObjId).style.fontSize;
		if(sCurSize=="") { sCurSize="1"; }
		else if(sCurSize.indexOf("em")!=-1) { sCurSize=sCurSize.substring(0, sCurSize.indexOf("em")); }
		else if(sCurSize.indexOf("pt")!=-1) { sCurSize=sCurSize.substring(0, sCurSize.indexOf("pt")); }
		else if(sCurSize.indexOf("px")!=-1) { sCurSize=sCurSize.substring(0, sCurSize.indexOf("px")); }
		
		var iIncrement=(bUp) ? 0.2 : -0.2 ;
		iNewSize=parseFloat(sCurSize);
		if(iNewSize>0.8 && !bUp || iNewSize<2.4 && bUp) {
			return iNewSize+iIncrement;
		}
		else { return iNewSize; }
	}
}
function checkFontSize() {
	var sCookie = readCookie("bh_fontSize");
	if(typeof(sCookie)!='undefined') {
		if(sCookie!="null" && document.getElementById) {
			var aCookie = sCookie.split(",");
			document.getElementById(aCookie[0]).style.fontSize = aCookie[1]+"em";
		}
	}
}

// -------------------- Cookies Tools ----------------------
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
function writeCookie(name, value, hours) { 
  var expire = "";
  if(hours != null) {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

// alert( readCookie("myCookie") );
function readCookie(name) {
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0) 
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1) 
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end)) 
      return cookieValue;
    } 
     else{
     cookieValue="null"
     return cookieValue;}
  }
 
 
}
function DeleteCookie (name) {
   var exp = new Date();
   exp.setTime (exp.getTime() - 1);  // This cookie is history
   var cval = GetCookie (name);
   document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();

} 










var isDefined = function(o) {
	return (typeof(o)!='undefined' && o!=null);
};
String.prototype.contains = function(s) {
	return (this.match(s)==s);
};
String.prototype.startsWith = function(s) {
	return (this.match('^'+s)==s);
};
String.prototype.endsWith = function(s) {
	return (this.match(s+'$')==s);
};
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g, '');
};
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,  '');
};
String.prototype.rtrim = function() {
	return this.replace(/\s+$/, '');
};
