YAHOO.namespace('Humana');

 
 
//Contextual Definition Box function
YAHOO.Humana.zipCodeBox = function() {

	//var generalContentPage = document.getElementById('divZIP');
	var generalContentPage = document.getElementById('pricing');
	if(generalContentPage) {
		
		var defTerms = YAHOO.util.Dom.getElementsByClassName('definition-term');
		var defContainer = document.getElementById('definition-info'); //This is the hidden div containing the body of the contextual popup box
		var defTerms = YAHOO.util.Dom.getElementsByClassName('definition-term'); //These are all the terms that will have a contextual popup box

		//Onclick the popup box closes
		var closeBox = document.getElementById('close');
		closeBox.onclick = function () {
			defContainer.style.display = "none";
		}
		
		var showPopup = function(term) {
			//alert("ZIP:");
			//document.Urlform1._ctl0:txtZipCode.value='';
			var definition = YAHOO.util.Dom.getNextSibling(term); //Get next sibling of each definition term, which will contain the definition
			defContainer.style.display = "block"; //Show the popup box
			
			defTerms[defTerm].id = "definition-term-"+defTerm;
			var defContainerChildren = YAHOO.util.Dom.getChildren('definition-list'); //Get the dl
			defContainerChildren[0].innerHTML = term.innerHTML; // Populate the title of the contextual popup box
			defContainerChildren[1].innerHTML = definition.innerHTML; //Populate the body of the contextual popup box
			
			var defObj = null;
			defObj = document.getElementById(defTerms[defTerm].id);
			
			var definition = null;
			definition = YAHOO.util.Dom.getNextSibling(defObj);
			
			//Apply onclick event
			defTerms[defTerm].onclick = function () {
				//var zip = document.getElementById['txtZipCode'];
				//alert("ZIP1:");
				//document.Urlform1._ctl0:txtZipCode.value='';
				//Get the markup that holds the popup box and show it
				var defContainer = document.getElementById('definition-info');
				defContainer.style.display = "block";
				
				//Get the markup for the children of the markup that holds the popup - it's a <dl>
				var defContainerChildren = YAHOO.util.Dom.getChildren('definition-list');
				defContainerChildren[0].innerHTML = defObj.innerHTML;
				defContainerChildren[1].innerHTML = definition.innerHTML; 	
				
				//Get the xy coordinations of the definition term so we know where to place the popup
				var pos = YAHOO.util.Dom.getXY(this);
				var xPos = pos[0];
				var yPos = pos[1];
				
				//Reposition the popup box according the xy coordinations of the definition term
				var posNew = new Array();
				posNew[0] = xPos + 85;
				posNew[1] = yPos - 28;
				YAHOO.util.Dom.setXY(defContainer, posNew);
			}
			
			var pos = YAHOO.util.Dom.getXY(term);  //Get the xy coordinations of the definition term so we know where to place the popup
			var xPos = pos[0];
			var yPos = pos[1];

			var posNew = new Array(); //Reposition the popup box according the xy coordinations of the definition term
			posNew[0] = xPos + 85;
			posNew[1] = yPos - 28;
			YAHOO.util.Dom.setXY(defContainer, posNew);
		}//end showPopup function
		
		//For all the definition terms in the page, do the following
		for(defTerm in defTerms) {	
			
			defTerms[defTerm].onclick = function(){
				showPopup(this);
			}					
		}//end for
		
	}//end if
	
}//end function

 

//Let's load 'em all up
YAHOO.util.Event.onContentReady('main-menu',function() {
	YAHOO.Humana.zipCodeBox();
	 		
});
