// <script>
function HideContent(d) {
	document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
	document.getElementById(d).style.display = "block";
}

// maxlength for textareas
function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length < MaxLen);
}

function disableFields() {
	for (i=0; i<document.forms[0].elements.length; i++) {
		var e = document.forms[0].elements[i];
		if(e.type == 'checkbox') {
			e.disabled = true;
		}
		if(e.type == 'radio') {
			e.disabled = true;
		}
		if(e.type == 'text') {
			e.disabled = true;
		}
	}
}
//function submitForm(action) {
//	document.getElementById('action').value = action;
//	document.forms[0].target = '_self';
//	document.forms[0].submit();
//}
function submitPopupForm(action) {
	document.getElementById('action').value = action;
	document.forms[0].target = '_blank';
	document.forms[0].submit();
}

function checkBack() {
	var msg = "New or updated information entered on the current page will be lost if you choose to go Back. Do you want to continue?";
	if(confirm(msg)) {
		document.forms[0].reset();
		submitForm(this,'Previous');
	}
}

function clearDefaultDate(field) {
	if (field.value == 'MM' || field.value == 'DD' || field.value == 'YYYY') {
		field.select();
	}
}
function autotab(original,destination){
	if ((original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
		&& (original.value != 'MM') && (original.value != 'DD') && (original.value != 'YYYY')) {
		destination.focus();
	}
}

function getYesNo(checkbox)
{
	if(checkbox!= null && checkbox == "Y") {
		document.write("Yes");
	} else {
		document.write("No");
	}
}

function validatePartBeffDate( ) {
	var valid = true;
	var disabled = '';
	if(document.forms[0].isDisabledY.checked)
		disabled=true;
	else if(document.forms[0].isDisabledN.checked)
		disabled=false;
	var dob_mon = eval(document.forms[0].dob_month.value);
	var dob_yr = eval(document.forms[0].dob_year.value);
	var b_mon = document.forms[0].eligMedPartBeffDate_month.value;
	var b_yr = document.forms[0].eligMedPartBeffDate_year.value;
	if(!disabled && b_mon != 'MM' && b_yr != 'YYYY') {
		dob_yr = dob_yr + 65;
		dob_mon = dob_mon + 4;
		if(dob_mon > 12) {
			dob_mon = dob_mon - 12;
			dob_yr = dob_yr + 1;
		}
		if(b_yr == dob_yr) {
			if(b_mon >= dob_mon) {
				valid = false;
			} else {
			}
		} else if(b_yr > dob_yr) {
			valid = false;
		}
		if (valid == false) {
			ShowContent('notice6');
		} else {
			HideContent('notice6');
		}
	}
	return valid;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.1
  MM_showHideLayers('lyrSideNav', '', 'show');
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i].toLowerCase();}}
}
function MM_swapImage() { //v3.1
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2].toLowerCase();}
}
function MM_findObj(n, d) { //v4.1
  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() { //v3.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')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
function swapTab(obj,cls) {
	if (obj) {
		if (obj.className) {
			obj.className = cls;
		}
	}
}

function getCookieValue(name) {
	var c = unescape(document.cookie);		
	if (c.indexOf(";") > -1 ) {
		var cArr = c.split("; ");
		for (var i=0;i<cArr.length;i++) {			
			if (cArr[i].indexOf(name + "=") == 0) return cArr[i].substr(name.length+1);
		}
	}
	else if (c.indexOf(name + "=") == 0) return c.substr(name.length+1);
	return '';
}
function viewFAQ(name,text)
{
	MM_openBrWindow("viewFAQ?spec=" + name + "&text=" + text,"","scrollbars=no,resizable=yes,width=200,height=250");
}
function viewPlanDetail(target, division, title)
{
	if (title != null)
		MM_openBrWindow("http://public.hcsc.net/medicaresupp/content.do?popup=true&target=" + target + "&title=" + title + "&division=" + division + "&contentType=DESCRIPTION","","scrollbars=yes,width=450,height=650,resizable=yes");
	else
		MM_openBrWindow("http://public.hcsc.net/medicaresupp/content.do?popup=true&target=" + target + "&division=" + division + "&contentType=DESCRIPTION","","scrollbars=yes,width=450,height=650,resizable=yes");
}
function viewPopup(url, name, params, title)
{
	if (title != null)
		MM_openBrWindow('http://public.hcsc.net/medicaresupp/content.do?popup=true&contentPath='+url+'&title='+title+'&contentType=DESCRIPTION',name,params);
	else
		MM_openBrWindow('http://public.hcsc.net/medicaresupp/content.do?popup=true&contentPath='+url+'&contentType=DESCRIPTION',name,params);
}
function viewPlanCompare(division)
{
	MM_openBrWindow("http://public.hcsc.net/medicaresupp/content.do?target=COMPARECHART&division=" + division + "&contentType=DESCRIPTION","","scrollbars=yes,width=925,height=590");

}