/*************************************************************/
var WEB_ROOT = "http://www.guardianlife.com";
var APP_ROOT = "http://www.guardianlife.com";
var MAP_ROOT = "http://map.glic.com";
var Search_SERVLET = "SearchServlet";
var Context_ROOT = "GuardianLife";

var DEMO_EMPLOYERS_LINK = "http://wsp.gliconline.com/group/bm/cbt/opencbt.htm";
var DEMO_EMPLOYEES_LINK = "http://wsp.gliconline.com/group_wbts/gbm_ee_wbt/gbm_ee_bm.html";
var DEMO_PRODUCERS_LINK = "http://wsp.gliconline.com/group_wbts/gpc_wbt/gpc_bm.html";
var REGISTER_EMPLOYEES_LINK = "https://wsp.gliconline.com/SR/client/pagRole.jsp?ROLE=PRT";
var REGISTER_EMPLOYERS_LINK = "https://wsp.gliconline.com/SR/client/pagRole.jsp?ROLE=SPN";
var REGISTER_PRODUCERS_LINK = "https://wsp.gliconline.com/SR/client/pagRole.jsp?ROLE=GRP";
var REGISTER_PROVIDERS_LINK = "https://wsp.gliconline.com/SR/client/pagRole.jsp?ROLE=PRV";

var WEB_EMPLOYERS_LINK = "http://www.guardiananytime.net/webtour/planholder/";
var WEB_MEMBERS_LINK = "http://www.guardiananytime.net/webtour/member/";
var WEB_PRODUCERS_LINK = "http://www.guardiananytime.net/webtour/producer/";
var WEB_PROVIDERS_LINK = "http://www.guardiananytime.net/webtour/provider/";
var GROUP_EMPLOYERS_LINK= "https://wsp.gliconline.com/?SSOCMD=GETLOGINVARS&amp;LOGINURL=GLIC_NO_SR_PLANSPONSOR";
var GROUP_EMPLOYEES_LINK= "https://wsp.gliconline.com/?SSOCMD=GETLOGINVARS&amp;LOGINURL=BM_PRTC";
var GROUP_HEALTHCARE_LINK= "https://wsp.gliconline.com/?SSOCMD=GETLOGINVARS&amp;LOGINURL=PROVIDERS";
var REGISTER_LOGIN_PORTAL= "https://www.guardiananytime.com/app3SR/wps/portal/SR";

var GROUP_VERSION = "2.0";
/************************************************************/	
//
var nav_list;
var init_nav;


m_nver = parseInt(navigator.appVersion);
m_ver = navigator.appVersion;
m_agent = navigator.userAgent;
m_dom = document.getElementById ? 1 : 0;
m_ie3=(m_ver.indexOf("MSIE") && (m_nver < 4));
m_ie4 = (document.all && !m_dom) ? 1 : 0;
m_ie5 = (m_ver.indexOf("MSIE 5") > -1 && m_dom) ? 1 : 0;
m_ie6 = (m_ver.indexOf("MSIE 6") > -1 && m_dom) ? 1 : 0;
m_ie = m_ie4 || m_ie5 || m_ie6;

m_ns4 = (document.layers && !m_dom) ? 1 : 0;
m_ns6 = (m_dom && parseInt(m_ver) >= 5) ? 1 : 0;

function getRef(name)
{
  var obj;

  if (m_ie4) return document.all[name]
  if (m_ns4) return document.layers[name];
  if (m_ie5) return document.getElementById(name);
  if (m_ns6) return document.getElementById(name);

  return document.all[name];
}

var ns4 = (document.layers) ? true : false;
var ie4 = (document.all) ? true : false;
var ng5 = (document.getElementById) ? true : false;



function on(img) { eval("document." + img + ".src = " + img + "_on.src"); }	
function off(img){ eval("document." + img + ".src = " + img + ".src"); }

function showNavId(show_id, maxNum) {

  var elemShow = getRef(show_id);
  var dash = show_id.indexOf('-');

  for (var i = 0; i < maxNum; i++) {

    var elem_name = show_id.substring(0, dash) + '-' + (i + 1);
    nav_elem = getRef('nav_' + elem_name);
    if (nav_elem != null) nav_elem.className = '';

    elem = getRef(elem_name);
    if (elem == null) break;

    elem_bname = 'buttons_' + (i + 1);
    var elem_b = getRef(elem_bname);

    if (elem_name != show_id) {
      elem.className = 'hidden';
      if (elem_b != null) elem_b.className = 'hidden';
      for (var x = 0; x < 10; x++) {
        var selem_name = elem_name + '.' + (x + 1);
        selem = getRef(selem_name);
        if (selem == null) break;
        selem.className = 'hidden';
        
      }
    } else {
      if (elemShow != null) {
        elemShow.className = '';
        nav_elem = getRef('nav_' + show_id);
        if (nav_elem != null) nav_elem.className = 'grayBold';
        if (elem_b != null) elem_b.className = '';
      }
    }
  }
}

function showSubNavId(show_id, maxNum) {
	// there is a more optimized way of doing this but will do some other time.
	var elem = getRef(show_id);
	var dot = show_id.lastIndexOf('.');
	var m_ptr = 0;

	for (var i = 0; i < maxNum; i++) {
		var elem_name = show_id.substring(0, dot) + '.' + (i + 1);
		var belem_name = 'b' + elem_name;
	    
		if (m_ns6) {
			document.getElementById(elem_name).className = "hidden";
			document.getElementById(elem_name).style.visibility = "hidden";
			document[belem_name].src = eval('num' + (i + 1)).src;
		} else {
			var xelem = getRef(elem_name);
			var belem = getRef(belem_name);
		    if (xelem != null) xelem.className = 'hidden';
			belem.src = eval('num' + (i + 1) + '.src');
		}
		
		if (show_id == elem_name) m_ptr = i + 1;
	}

	var elem_name = show_id.substring(0, dot) + '.' + m_ptr;
	var belem_name = 'b' + elem_name;
	
	if (m_ns6) {
		document.getElementById(show_id).className = "";
		document.getElementById(show_id).style.visibility = "";
		document[belem_name].src = eval('num' + m_ptr + '_on').src;
	} else {
		if (elem != null) elem.className = '';
		var belem = getRef(belem_name);
		belem.src = eval('num' + m_ptr + '_on.src');
	}

}

function oldOneshowSubNavId(show_id, maxNum) {
  var elemShow = getRef(show_id);
  var dot = show_id.lastIndexOf('.');

  for (var i = 0; i < maxNum; i++) {
    var elem_name = show_id.substring(0, dot) + '.' + (i + 1);
    var belem_name = 'b' + elem_name;
    var belem = getRef(belem_name);

    if (elem_name != show_id) {
      var elem = getRef(elem_name);
      if (elem != null) elem.className = 'hidden';
	  belem.src = eval('num' + (i + 1)).src;
    } else {
      if (elemShow != null) elemShow.className = '';
	  belem.src = eval('num' + (i + 1) + '_on').src;
    }
  }
}

function openCalc(url) {
	window.open(url,'','width=600,height=600,left=100,top=50,scrollbars=yes,resizable=yes');
}

function getValue() {
	var preValue = 0;
	var curValue = 0;
	for ( i=0; i<document.forms.cc.elements.length; i++) {
		if (document.forms.cc.elements[i].checked) {
			curValue = parseInt(document.forms.cc.elements[i].value);
			preValue = preValue + curValue;
		}
	}
	return preValue;
}		

function getAnswer(page) {
	var url = page + '_answer.html';
	var theScore = getValue();
	window.open(url + '?' + theScore,'','width=341,height=470,left=100,right=150,scrollbars=yes');
}	

function getScore() {
	var theScore = getValue();
	if( theScore > 10) {
		alert("Your score = "+ theScore +";\n Excellent profile! Inquire further!");
		document.forms.cc.elements[i].checked = false;
		return true;
	}	
	if( theScore > 4 && theScore < 11 )  {
		alert("Your score = "+ theScore +";\n Pause and take a hard look before you leap.");
		document.forms.cc.elements[i].checked = false;
		return true;
	}	
	if( theScore < 5 )  {
		alert("Your score = "+ theScore +";\n Not a good career choice.");
		document.forms.cc.elements[i].checked = false;
		return true;
	}	
}

function getWatchListS(){
	var debug = window.location.toString();
	var questionindex = debug.indexOf("?");
	var parameter_string = debug.substring(questionindex + 1, debug.length);
	document.write("<script language='javascript' src='http://custom.marketwatch.com/custom/guardian-life/jsinc-watchlist-small.asp?" + parameter_string + "'>");
	document.write("</" + "script>");
}	

function getWatchListB() {
		var debug = window.location.toString();
		var questionindex = debug.indexOf("?");
		var parameter_string = debug.substring(questionindex + 1, debug.length);
		document.write("<script language='javascript' src='http://custom.marketwatch.com/custom/guardian-life/jsinc-watchlist-big.asp?" + parameter_string + "'>");
		document.write("</" + "script>");
}

function getQuoteBlock(){
	var debug = window.location.toString();
	var questionindex = debug.indexOf("?");
	var parameter_string = debug.substring(questionindex + 1, debug.length);
	document.write("<script language='javascript' src='http://custom.marketwatch.com/custom/guardian-life/jsinc-fp-quoteblock.asp?" + parameter_string + "'>");
	document.write("</" + "script>");
}	

function getQuoteResults(){
	var debug = window.location.toString();
	var questionindex = debug.indexOf("?");
	var parameter_string = debug.substring(questionindex + 1, debug.length);
	document.write("<script language='javascript' src='http://custom.marketwatch.com/custom/guardian-life/jsinc-quote.asp?" + parameter_string + "'>");
	document.write("</" + "script>");
}

function getMarketSnapshot() {
	var debug = window.location.toString();
		var questionindex = debug.indexOf("?");
		var parameter_string = debug.substring(questionindex + 1, debug.length);
		document.write("<script language='javascript' src='http://custom.marketwatch.com/custom/guardian-life/jsinc-snapshot.asp?" + parameter_string + "'>");
		document.write("</" + "script>");
}	

function page_init() {  
//	alert("page_init "+WEB_ROOT);
	if (document.images) {     
		num1_on = new Image();
		num1_on.src = WEB_ROOT + "/images/buttons/num1_on.gif";
		num2_on = new Image(); 
		num2_on.src = WEB_ROOT + "/images/buttons/num2_on.gif"; 
		num3_on = new Image();
		num3_on.src = WEB_ROOT + "/images/buttons/num3_on.gif";  
		num4_on = new Image();
		num4_on.src = WEB_ROOT + "/images/buttons/num4_on.gif";
		num5_on = new Image();
		num5_on.src = WEB_ROOT + "/images/buttons/num5_on.gif";
		num6_on = new Image();
		num6_on.src = WEB_ROOT + "/images/buttons/num6_on.gif";
		num7_on = new Image();
		num7_on.src = WEB_ROOT + "/images/buttons/num7_on.gif";
		num8_on = new Image();
		num8_on.src = WEB_ROOT + "/images/buttons/num8_on.gif";
		num9_on = new Image();
		num9_on.src = WEB_ROOT + "/images/buttons/num9_on.gif";
		num10_on = new Image();
		num10_on.src = WEB_ROOT + "/images/buttons/num10_on.gif";
		num11_on = new Image();
		num11_on.src = WEB_ROOT + "/images/buttons/num11_on.gif";
		num12_on = new Image();
		num12_on.src = WEB_ROOT + "/images/buttons/num12_on.gif";
		num13_on = new Image();
		num13_on.src = WEB_ROOT + "/images/buttons/num13_on.gif";
		num14_on = new Image();
		num14_on.src = WEB_ROOT + "/images/buttons/num14_on.gif";
		num15_on = new Image();
		num15_on.src = WEB_ROOT + "/images/buttons/num15_on.gif";
		num1 = new Image(); 
		num1.src = WEB_ROOT + "/images/buttons/num1.gif";
		num2 = new Image(); 
		num2.src = WEB_ROOT + "/images/buttons/num2.gif";  
		num3 = new Image();
		num3.src = WEB_ROOT + "/images/buttons/num3.gif"; 
		num4 = new Image(); 
		num4.src = WEB_ROOT + "/images/buttons/num4.gif";
		num5 = new Image(); 
		num5.src = WEB_ROOT + "/images/buttons/num5.gif";
		num6 = new Image(); 
		num6.src = WEB_ROOT + "/images/buttons/num6.gif";
		num7 = new Image(); 
		num7.src = WEB_ROOT + "/images/buttons/num7.gif";
		num8 = new Image(); 
		num8.src = WEB_ROOT + "/images/buttons/num8.gif";
		num9 = new Image(); 
		num9.src = WEB_ROOT + "/images/buttons/num9.gif";
		num10 = new Image(); 
		num10.src = WEB_ROOT + "/images/buttons/num10.gif";
		num11 = new Image(); 
		num11.src = WEB_ROOT + "/images/buttons/num11.gif";
		num12 = new Image(); 
		num12.src = WEB_ROOT + "/images/buttons/num12.gif";
		num13 = new Image(); 
		num13.src = WEB_ROOT + "/images/buttons/num13.gif";
		num14 = new Image(); 
		num14.src = WEB_ROOT + "/images/buttons/num14.gif";
		num15 = new Image(); 
		num15.src = WEB_ROOT + "/images/buttons/num15.gif";
	}
}   

function openMap(id)
{
	var link;
	if ( id == 'home' ) {
		link = MAP_ROOT + '/scripts/mqinterconnect.exe?link=map&streetaddress=7 Hanover Square&city=New York&state=NY&zip=10004';
	}	
	if ( id == 'midwestern' ) {
		link = MAP_ROOT + '/scripts/mqinterconnect.exe?link=map&streetaddress=2300 East Capital Drive&city=Appleton&state=WI&zip=54911';
	}	
	if ( id == 'northeastern' ) {
	 	link = MAP_ROOT + '/scripts/mqinterconnect.exe?link=map&streetaddress=3900 Burgess Place&city=Bethlehem&state=PA&zip=18017';
	}	
	if ( id == 'western' ) {
		link = MAP_ROOT + '/scripts/mqinterconnect.exe?link=map&streetaddress=777 East Magnesium Road&city=Spokane&state=WA&zip=99208';
	}	
	if ( id == 'berkshire' ) {
		link = MAP_ROOT + '/scripts/mqinterconnect.exe?link=map&streetaddress=700 South Street&city=Pittsfield&state=MA&zip=01201';
	}	
	if ( id == 'boston' ) {
		link = MAP_ROOT + '/scripts/mqinterconnect.exe?link=map&streetaddress=One Lakeshore Drive&city=Bridgewater&state=MA&zip=02324';
	}
	
	window.open(link,'','width=620,height=455,resizable=yes');
}

function openDemo(destination)
{
	var dest = destination;
	window.open(dest,'','height=200,width=350,left=100,top=100,location=yes,Directory=yes,Status=yes,menubar=yes,scrollbars=yes,toolbar=yes,resizable=yes');
}
