/***********************************************************************
*	MYUHC.COM DYNAMIC HTML PROGRAMMING INTERFACE AND APPLICATION
*	Copyright (c) 2003 digital@jwt. All rights reserved.
*	Authored by: Spencer H. Bennett & Elverse Jordan
***********************************************************************/

//-- DHTML API METHODS

function getObj(id){
	return document.getElementById(id);
	}

function getPosX(x){
	var obj = getObj(x), posX = 0;
	while (obj.offsetParent){
		posX += obj.offsetLeft;
		obj = obj.offsetParent;
		}  
	return posX;
	}

function getPosY(x){
	var obj = getObj(x), posY = 0;
	while (obj.offsetParent){
		posY += obj.offsetTop;
		obj = obj.offsetParent;
		}  
	return posY;
	}

//-- USER AGENT OBJECT

function clsUa(){
	this.ua=navigator.userAgent.toLowerCase();
	this.mac=(this.ua.indexOf("mac")!=-1);
	this.w3c=(document.getElementById)?1:0;
	this.ieX=(document.all)?1:0;
	this.ie5=(this.ieX && this.w3c)?1:0;
	//if (!this.w3c || (this.ie5 && this.mac)) alert('\nYour browser may not be supported by this website.\n\nWe encourage you to upgrade.\n');
	}

//-- MENU : CHILD OBJECT AND METHODS

function cMthState(x){
	clearTimeout(arrP[this.intRp].objTo);
	this.objSty.cursor = 'hand';
	this.objSty.backgroundColor = (x) ? '#8c96d3' : '#4455cb';
	}

function clsC(x,y){
	this.intRp = x;
	this.intRc = y;
	this.strTx = arrP[x][1][y][0];
	this.strUrl = arrP[x][1][y][1];
	// TOM new window indicator
	this.newWin = arrP[x][1][y][2];
	this.strDv = 'menu' + x + y;
	//this.strCh = '<div id="' + this.strDv + '" class="cx"><div class="cy">' + this.strTx + '</div><div onmouseover="arrP[' + x + '].arrCc[' + y + '].state(1);arrP[' + x + '].state(1);" onmouseout="arrP[' + x + '].arrCc[' + y + '].state(0);arrP[' + x + '].state(1);" class="cz"><img src="images/menuDth.gif" width="199" height="21" /></div></div>';
	if (this.strUrl == "") {
	    this.strCh = '<div id="' + this.strDv + '" class="cx"><div class="cy"><a href="' + this.strUrl + '" class="pz">' + this.strTx + '</a></div><div onmouseover="arrP[' + x + '].arrCc[' + y + '].state(1);arrP[' + x + '].state(1);" onmouseout="arrP[' + x + '].arrCc[' + y + '].state(0);arrP[' + x + '].state(1);" class="cz"><img src="images/menuDth.gif" width="199" height="21" /></div></div>';
	} else {
	    this.strCh = '<div id="' + this.strDv + '" class="cx"><div class="cy"><div onmouseover="arrP[' + x + '].arrCc[' + y + '].state(1);arrP[' + x + '].state(1);" onmouseout="arrP[' + x + '].arrCc[' + y + '].state(0);arrP[' + x + '].state(1);" onclick="return false;" class="cz"><img src="images/menuDth.gif" width="215" height="21" />';
	
		// TOM this code for popup 
		if (this.newWin)
			this.strCh += '<a href="javascript:popupWoutCtrls(\'' + this.strUrl + '\')"';
		else 
			this.strCh += '<a href="' + this.strUrl + '"';
		// TOM end popup code
		    
	    this.strCh += ' class="pz" onclick="return false;">' + this.strTx + '</a></div></div></div>';
	}

	this.strMv = 'arrP[' + x + '].arrCc[' + y + '].move()';
	this.state = cMthState;
	}

//-- MENU : PARENT OBJECT AND METHODS

function pMthInitC(){
	this.arrCc = arrP[this.intRf][1];
	this.strCa = this.strDv + 'ca';
	this.strCz = this.strDv + 'cz';
 	this.strCh = '<div id="' + this.strCa + '" class="ca" onmouseover="clearTimeout(arrP[' + this.intRf + '].objTo);" onmouseout="arrP[' + this.intRf + '].state(0);">';
	for (var i = 0; i < this.arrCc.length; i++){
		var objC = 'objC' + this.intRf + i;
		objC = new clsC(this.intRf,i);
		this.strCh += objC.strCh;
		this.arrCc[i] = objC;
		}
	this.strCh += '<div id="' + this.strCz + '" class="cb"><img src="images/menuBot.gif" width="215" height="8" /></div></div>';
 	}

function pMthState(x){
	clearTimeout(this.objTo);
	this.objStx.cursor = 'hand';
	this.objSty.backgroundColor = (x) ? '#4455cb' : '#8c96d3';
	if (this.booChi){
		var xPos = getPosX('divP') + this.posX;
		if (this.intRf > 6) xPos += eval(this.intWd - 216);
		this.objStyCa.left = xPos + 'px';
		this.objStyCa.visibility = 'visible';
		this.objStyCa.zIndex = (x) ? 920 : 919;
		this.trgPos = (x) ? 110 : this.intCy;
		if (objUa.ieX){
			this.offset = (x) ? 15 : -15;
		} else {
			this.offset = (x) ? 75 : -75;
			}
		if (x) this.move()
		else this.objTo = setTimeout(this.strMv,25);
		}
	}

function pMthMove(){
	var currentPos = getPosY(this.strCa);
	if (this.offset > 0 && this.trgPos - currentPos < this.offset || this.offset < 0 && this.trgPos - currentPos > this.offset){
		this.objStyCa.top = this.trgPos;
	} else if (currentPos != this.trgPos){
		this.objStyCa.top = eval(currentPos + this.offset) + 'px';
		setTimeout(this.strMv,5);
	} else {
		return;
		}
	}

function clsP(x){
	this.intRf = x;
	this.strTx = arrP[x][0][0];
	this.strUrl = arrP[x][0][1];
	this.booChi = (arrP[x][1]) ? 1 : 0;
	this.arrCc = new Array();
	this.strDv = 'menu' + x;
	this.intWd = (arrP.length > 6) ? arrP[x][0][3] : arrP[x][0][2];
	if (this.strUrl == "") {
	    this.strPh = '<div id="' + this.strDv + 'x" class="px" onmouseover="arrP[' + x + '].state(1);" onmouseout="arrP[' + x + '].state(0);"><div id="' + this.strDv + 'y" class="py"><div class="pz">' + this.strTx + '</div></div></div>';
	} else {
	    this.strPh = '<div id="' + this.strDv + 'x" class="px" onmouseover="arrP[' + x + '].state(1);" onmouseout="arrP[' + x + '].state(0);" onclick="return false;"><div id="' + this.strDv + 'y" class="py"><a href="' + this.strUrl + '" class="pz" onclick="return false;">' + this.strTx + '</a></div></div>';
	}
	if (x != arrP.length - 1) this.strPh += '<div id="' + this.strDv + 'v" class="pv"><img src="images/menuDtv.gif" width="1" height="28" /></div>';
	this.strMv = 'arrP[' + x + '].move()';
	this.move = pMthMove;
	this.state = pMthState;
	this.spawn = pMthInitC;
	if (this.booChi) this.spawn();
	arrP[x] = this;
	}

//-- MENU : PARENT INITIALIZATION

function pInitMenu(){
	var divP = getObj('divP'), divC = getObj('divC'), intPosX = 20, strPh = '', strCh = '';
	strPh += '<div id="divLft"><img src="images/menuLft.gif" width="20" height="30" /></div>';
	strPh += '<div id="divRgt"><img src="images/menuRgt.gif" width="20" height="30" /></div>';
	for (var i = 0; i < arrP.length; i++){
		var objMenuP = 'objMenuP' + i;
		objMenuP = new clsP(i);
		strPh += objMenuP.strPh;
		}
	divP.innerHTML = strPh;
	for (var i = 0; i < arrP.length; i++){
		arrP[i].objDvx = getObj(arrP[i].strDv + 'x');
		arrP[i].objStx = arrP[i].objDvx.style;
		arrP[i].objDvy = getObj(arrP[i].strDv + 'y');
		arrP[i].objSty = arrP[i].objDvy.style;
		arrP[i].objSty.width = arrP[i].intWd + 'px';
		arrP[i].posX = (i) ? intPosX + 1 : intPosX;
		arrP[i].objStx.left = intPosX + 'px';
		intPosX += arrP[i].intWd;
		if (i != arrP.length - 1){
			arrP[i].objDvv = getObj(arrP[i].strDv + 'v');
			arrP[i].objStv = arrP[i].objDvv.style;
			arrP[i].objStv.left = intPosX + 'px';
			}
		if (arrP[i].booChi) strCh +=  arrP[i].strCh;
		}
	divC.innerHTML = strCh;
	for (var i = 0; i < arrP.length; i++){
		if (arrP[i].booChi){
			var intClng = arrP[i].arrCc.length;
			arrP[i].objDivCa = getObj(arrP[i].strCa);
			arrP[i].objStyCa = arrP[i].objDivCa.style;
			arrP[i].objDivCz = getObj(arrP[i].strCz);
			arrP[i].objStyCz = arrP[i].objDivCz.style;
			arrP[i].objStyCz.top = intClng * 21 + 'px';
			arrP[i].intCh = 8;
			for (var j = 0; j < intClng; j++){
				arrP[i].arrCc[j].objDiv = getObj(arrP[i].arrCc[j].strDv);
				arrP[i].arrCc[j].objSty = arrP[i].arrCc[j].objDiv.style;
				arrP[i].arrCc[j].objSty.top = j * 21 + 'px';
				arrP[i].intCh += 21;
				}
			arrP[i].intCy = 110 - arrP[i].intCh;
			arrP[i].objStyCa.top = arrP[i].intCy + 'px';
			}
		}
	}

/* Similar function is already existing in util.js
function doPopup(given) {
	window.open(given,"_blank","menubar=0,resizable=1,titlebar=0,toolbar=0");
}
*/

// This function is called during OnLoad to display the dynamic menu
// we have to disable the menu on IE5 for Mac
function initMenu()
{
  objUa = new clsUa();
  if (!(objUa.ie5 && objUa.mac))
  	pInitMenu();
  // else disabling menu for IE5 mac
}


//-- Toggle function for tabs

var currentID = "defaultDiv";	
var healthID = "defaultHSDiv";
	
function toggle(id) {		
	var newId = id;	
	var newVis;
	var currVis;		 

	currVis = document.getElementById(currentID).style;
	newVis = document.getElementById(newId).style;		  
	
	if (newId != currentID) {
		newVis.display = 'block';	
		currVis.display = 'none';
		currentID = newId;
	} else {
		currVis.display = 'block';
	}
	
	//set tab image src
	if (id=='healthWellness') {	
		tabHW.src='images/tab_healthWellness_on.gif';
		tabPM.src='images/tab_messages.gif';
		tabSF.src='images/tab_features.gif';
	}
	if (id=='messages') {		
		tabHW.src='images/tab_healthWellness.gif';
		tabPM.src='images/tab_messages_on.gif';
		tabSF.src='images/tab_features.gif';
	}
	if (id=='resources') {		
	
		tabHW.src='images/tab_healthWellness.gif';
		tabPM.src='images/tab_messages.gif';
		tabSF.src='images/tab_features_on.gif';
	}	
}	

// -- window for claims glossary
function DefWindow( def ) {

    var url = "/glossaryPopUp.do";
    oWidth = 450;
    oHeight = 250;
    //x = window.screenX + 50;
    x = 20;
    //y = window.screenY + 30;
    y = 20;
    
    var properties = "toolbar=no" +
             ",location=no" +
             ",directories=no" +
             ",status=no" +
             ",menubar=no" +
             ",scrollbars=yes" +
             ",resizable=yes" +
             ",copyhistory=no" +
             ",width=" + oWidth +
             ",height=" + oHeight +
             ",screenX=" + x +
             ",screenY=" + y;

    var defWin = window.open( url + "?term=" + def, "DefWin", properties );
    defWin.moveTo(20,20);
    
}


function toggleHealthSum(id) {		
	var hsId = id;	
	var hscVis;
	var hsnVis;		 
	
	hscVis = document.getElementById(healthID).style;
	hsnVis = document.getElementById(hsId).style;		  
	
	if (hsnVis != hscVis) {
		hsnVis.display = 'block';	
		hscVis.display = 'none';
		healthID = hsId;
		switch(hsId) {
			case 'eligibility':
				document.getElementById('plel').src = 'images/tab_HS_eligibility_on.gif';
				document.getElementById('cosu').src = 'images/tab_HS_copay_next.gif';
				document.getElementById('deou').src = 'images/tab_HS_deductible_off.gif';	
				document.getElementById('flsp').src = 'images/tab_HS_gen_off.gif';						
				break;
			case 'copay':
				document.getElementById('plel').src = 'images/tab_HS_eligibility_off.gif';
				document.getElementById('cosu').src = 'images/tab_HS_copay_on.gif';
				document.getElementById('deou').src = 'images/tab_HS_deductible_next.gif';	
				document.getElementById('flsp').src = 'images/tab_HS_gen_off.gif';						
				break;
			case 'deductable':
				document.getElementById('plel').src = 'images/tab_HS_eligibility_off.gif';
				document.getElementById('cosu').src = 'images/tab_HS_copay_off.gif';
				document.getElementById('deou').src = 'images/tab_HS_deductible_on.gif';
				document.getElementById('flsp').src = 'images/tab_HS_gen_next.gif';						
				break;
			case 'fsa':
				document.getElementById('plel').src = 'images/tab_HS_eligibility_off.gif';
				document.getElementById('cosu').src = 'images/tab_HS_copay_off.gif';
				document.getElementById('deou').src = 'images/tab_HS_deductible_off.gif';	
				document.getElementById('flsp').src = 'images/tab_HS_gen_on.gif';						
				break;
			default:
				document.getElementById('plel').src = 'images/tab_HS_eligibility_on.gif';
				document.getElementById('cosu').src = 'images/tab_HS_copay_next.gif';
				document.getElementById('deou').src = 'images/tab_HS_deductible_off.gif';
				document.getElementById('flsp').src = 'images/tab_HS_gen_off.gif';							
				break;
		}
	} else {
		hscVis.display = 'block';
	}
}	

		
