// JavaScript Document

var statHost = "http://www.bcbsks.com";
if ( location.host.indexOf("bingo") != -1 ) {
	statHost = "http://bingo.bcbsks.com";
}
if ( location.host.indexOf("beta") != -1 ) {
	statHost = "http://beta.bcbsks.com";
}
if ( location.host.indexOf("alpha") != -1 ) {
	statHost = "http://alpha.bcbsks.com";
}
if ( location.host.indexOf("delta") != -1 ) {
	statHost = "http://delta.bcbsks.com";
}
if ( location.host.indexOf("search") != -1 ) {
	statHost = "http://www.bcbsks.com";
}
if ( location.host.indexOf("development") != -1 ) {
	statHost = "http://delta.bcbsks.com";
}
if ( location.host.indexOf("integration") != -1 ) {
	statHost = "http://alpha.bcbsks.com";
}
if ( location.host.indexOf("staging") != -1 ) {
	statHost = "http://beta.bcbsks.com";
}
if ( location.host.indexOf("staging2") != -1 ) {
	statHost = "http://beta2.bcbsks.com";
}
if ( location.host.indexOf("mabarker") != -1 ) {
	statHost = "http://gamma.bcbsks.com";
}
//icims
if ( location.host.indexOf("jobs-ksjobs") != -1 ) {
	statHost = "http://www.bcbsks.com";
}
if ( location.host.indexOf("intranet-ksjobs") != -1 ) {
	statHost = "http://www.bcbsks.com";
}

var product = get_cookie("product"); 
var promo = get_cookie("promo"); 

//Open new window

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//Print the page

function PrintThisPage() 
{ 
if (document.getElementById != null)
{   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
       sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

   var sWinHTML = document.getElementById('PageContent').innerHTML; 
   
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       winprint.document.write('<html><link href="'+ statHost +'/css/print.css" rel="stylesheet" media="print"><body>'); 
       winprint.document.write(sWinHTML);          
       winprint.document.write('</body></html>'); 
       winprint.document.close(); 
       winprint.focus(); 
}
else
{
alert("Sorry, the print ready feature is only available in modern browsers.");
}}

function FontSize(text_size) {
  oLnk = document.getElementById("FontSize"); oLnk.href = statHost +"/css/"+text_size+".css"
  var datDate = new Date(); var datNextYear = datDate
	datNextYear.setTime(datDate.getTime()+31536000000)
  document.cookie = "FontSize="+text_size+"; expires="+datNextYear.toGMTString()+"; path=/"
}

//Google Highlighter

var google_text_color = '#000000';

var google_link_colors = new Array('#FFFF99','#FFECEC','#C9F1C9','#CCFFFF','#FFDFDF');

function init_google(){
	var pattern = /bcbsks\./i;
	if (pattern.exec(document.referrer) != null){
		var url_parts = document.referrer.split('?');
		if (url_parts[1]){ 
			var url_args = url_parts[1].split('&');
			for(var i=0; i<url_args.length; i++){
				var keyval = url_args[i].split('=');
				if (keyval[0] == 'q'){
					go_google(decode_url(keyval[1]));
					return;
				}
			}
		}
	}
}

function decode_url(url){
	return unescape(url.replace(/\+/g,' '));
}

function go_google(terms){
	terms = terms.replace(/\"/g,"");
	var terms_split = terms.split(' ');
	var c = 0;
	for(var i=0; i<terms_split.length; i++){
		highlight_goolge(terms_split[i], document.body,google_link_colors[c]);
		c = (c == google_link_colors.length-1)?0:c+1;
	}
}

function highlight_goolge(term, container, color){
	var term_low = term.toLowerCase();

	for(var i=0; i<container.childNodes.length; i++){
		var node = container.childNodes[i];

		if (node.nodeType == 3){
			var data = node.data;
			var data_low = data.toLowerCase();
			if (data_low.indexOf(term_low) != -1){
				//term found!
				var new_node = document.createElement('SPAN');
				node.parentNode.replaceChild(new_node,node);
				var result;
				while((result = data_low.indexOf(term_low)) != -1){
					new_node.appendChild(document.createTextNode(data.substr(0,result)));
					new_node.appendChild(create_node_google(document.createTextNode(data.substr(result,term.length)),color));
					data = data.substr(result + term.length);
					data_low = data_low.substr(result + term.length);
				}
				new_node.appendChild(document.createTextNode(data));
			}
		}else{
			//recurse
			highlight_goolge(term, node, color);
		}
	}
}

function create_node_google(child, color){
	var node = document.createElement('SPAN');
	node.style.backgroundColor = color;
	node.style.color = google_text_color;
	node.appendChild(child);
	return node;
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'inline':(v=='hide')?'none':v; }
    obj.display=v; }
}

function nctoggle(num)
{
	ncResetAll()
	document.getElementById('d'+num+'t').style.borderRight = "none"
	document.getElementById('d'+num+'t').style.backgroundColor = "#FCFDC6"
	document.getElementById('d'+num+'t_div').style.display = ""
	document.getElementById('d'+num+'t_div').style.width = "300px"
}
function ncResetAll()
{
	numitems = 5
	for(i=1; i<=numitems; i++)
	{
		document.getElementById('d'+i+'t').style.borderRight = "solid 1px #989B6E"
		document.getElementById('d'+i+'t').style.backgroundColor = "#AFCAE4"
		document.getElementById('d'+i+'t_div').style.display = "none"
		document.getElementById('d'+i+'t_div').style.width = "300px"
	}
}

function staticLoadScript()
		{
		var pagepath = "http://www.bcbsks.com/js/";
		if ( location.host.indexOf("bingo") != -1 ) {
			pagepath = "http://bingo.bcbsks.com/js/";}
		myStrings = location.search.substr(1).split("=");
		//variableName = location.search.substr(14).split("?");
		prodName = location.search.substr(1).split("?");
		}

function fitScreen_module(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=790,height=560,left = 140,top = 162');");
}

function fitScreen_module_howie(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=850,height=650,left = 0,top = 0');");
}

function fitScreen_rb_promo(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=430,left = 140,top = 162');");
}

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function loadornot(){
if (get_cookie('poppedup')==''){
MM_popupMsg()
document.cookie="poppedup=yes"
}
}

function MM_popupMsg(msg) { //v1.0
var zDate = new Date();
zDate = new Date(zDate.getTime() + (30*24*60*60*1000));
	document.cookie="poppedup=yes; Path=/; Expires= " +zDate.toGMTString();
	window.open(statHost +'/help/fillableForms.htm','FillableForms','scrollbars=yes,resizable=yes,width=410,height=460')
	//alert('                      Did you know? \n\n Any form on this page with a red asterisk next to it \n can be filled out using your computer before printing.\n                        Give it a try!');
}

function healthy_tips(){
var mytext=new Array()
//specify random text below. You can have as many as you wish
mytext[1]="Rinsing the mouth with water after eating can reduce bacteria by 30 percent."
mytext[2]="To help prevent back pain take deep breaths, full inhalation and exhalations will stretch out the rib cage as well as the vertebrae in your back."
mytext[3]="Leave toenails slightly longer than the tips of your toes. Trim your toenails straight across with clippers specially designed for the purpose."
mytext[4]="Walking contributes to your general health by improving circulation, contributing to weight control and promoting all-around well-being."
mytext[5]="Fast Food tip - To avoid eating food that may have been sitting under a heat lamp for a long time, special order your meal, even if it means having to put on your own ketchup and mustard."
mytext[6]="Avoid napping during late afternoons or evenings. If you must nap, do so early in the afternoon and limit it to 30 minutes."
mytext[7]="Your dietary cholesterol intake should be 200 mg or lower each day."
mytext[8]="Carbohydrates should be 50 percent to 60 percent of your calories each day. These should come from whole grains, fruits and vegetables."
mytext[9]="To both treat and prevent chapped hands, try to keep them out of water. Use gloves when you do dishes."
mytext[10]="To help prevent nightmares avoid eating just before bed, which can increase brain activity."

var ry=Math.floor(Math.random()*mytext.length)
if (ry==0)
ry=1
document.write(mytext[ry])
}

function fast_facts(){
var mytext=new Array()
//specify random text below. You can have as many as you wish
mytext[1]="Mission Statement: To be the best at providing health insurance in Kansas."
mytext[2]="BCBSKS has office locations in Topeka, as well as Dodge City, Garden City, Hays, Hutchinson, Independence, Lawrence, Manhattan, Pittsburg, Salina and Wichita."
mytext[3]="Service Area: All Kansas counties except Johnson and Wyandotte (103 of 105 counties)."
mytext[4]="Governance Structure: BCBSKS is governed by a 16-member board of directors; 15 are non-employees. They represent individual and group policyholders, and health care providers."
mytext[5]="Number of Employees (as of Oct. 1, 2009): 1,466 (1,359 in Topeka, 107 outside of Topeka)"
mytext[6]="Provider Networks: For 2009, 98 percent of medical doctors and acute care hospitals, and 93 percent of all other professional providers and medical facilities in its service area."
mytext[7]="As of Sept. 30, 2009 - we serve 891,105 Kansans."
mytext[8]="Earned a Rating of 'A' or “excellent” from A.M. Best."

var ry=Math.floor(Math.random()*mytext.length)
if (ry==0)
ry=1
document.write(mytext[ry])
}

