function addLoadEvent(func) {
	var oldOnLoad = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
		  if (oldOnLoad) {
			oldOnLoad();
		  }
          func();
		}
	}
}

function helpPagePopup(pageUrl) {
	newWindow = window.open(pageUrl, 'HelpPage', 
				'height=450,width=500,scrollbars=yes,resizable=yes');
	return false;
}

function medicareCalculatorPopup(pageUrl) {
	newWindow = window.open(pageUrl, 'MedicareCalulator', 
				'height=900,width=768,scrollbars=yes,resizable=yes');
	return false;
}

function initialFocus() {
	initialFocusById('firstFocus');
}

function initialFocusById(id) {
	if (id == null) id = 'firstFocus';
	if (document.getElementById(id) != null) {
		document.getElementById(id).focus();
	}
}

function printpage() {
	window.print();  
}


// Enables or disables a block element (usually div) by changing its 
// style class and enabling or disabling any contained form fields.
function enableBlock(blockId, enabled) {
	//alert("enableBlock: " + blockId + " enabled: " + enabled);
	var block = document.getElementById(blockId);
	if (block) {
		if (enabled) {
			//alert("display block " + blockId);
			block.className = "enabledBlock";
			disableFormFields(block, false);
		} else {
			//alert("don't display block " + blockId);
			block.className = "disabledBlock";
			disableFormFields(block, true);
		}
	}
}

// Disables or enables fom fields conatined within a block level
// element.
function disableFormFields(element, on) {
	var fields = element.getElementsByTagName("input");
	for (var i=0; i<fields.length; i++) {
		//fields[i].setAttribute("disabled", "disabled");
		fields[i].disabled = on;
		fields[i].readonly = on;
	}
	fields = element.getElementsByTagName("select");
	for (var i=0; i<fields.length; i++) {
		//fields[i].setAttribute("disabled", "disabled");
		fields[i].disabled = on;
		fields[i].readonly = on;
	}
}


addLoadEvent(initialFocus);

$(document).ready(function(){
	$(".nonlinkrollover, .hoverText, .featureName").tooltip({delay: 400, fade: true, showURL: false});
	$('#topMenu').clickMenu();
});

