﻿
var isNumericString = "0,1,2,3,4,5,6,7,8,9";
var isTogDesc = 0;
var isContentReady = 0;

fnDisableAll();
iiByStatus = 1

function fnKillNA()
{
    x = document.forms[0];
	if (x.ctl00_Page_Content_ucPublic_Search1_rZip_Code.value=="N/A")
	{ 
	    x.ctl00_Page_Content_ucPublic_Search1_rZip_Code.value = "";
	}
	if (x.ctl00_Page_Content_ucPublic_Search1_rKeyword_Search.value=="N/A")
	{ 
	    x.ctl00_Page_Content_ucPublic_Search1_rKeyword_Search.value = "";
	}
	if (x.ctl00_Page_Content_ucPublic_Search1_rCity.value=="N/A")
	{ 
	    x.ctl00_Page_Content_ucPublic_Search1_rCity.value = "";
	 }
	if (x.ctl00_Page_Content_ucPublic_Search1_rCounty.value=="N/A")
	{ 
	    x.ctl00_Page_Content_ucPublic_Search1_rCounty.value = "";
	}
}
//--------------------------------------------------------------------
function fnDisableAll()
{
	document.forms[0].ctl00_Page_Content_AA_Topic.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rZip_Code.disabled=true
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rKeyword_Search.disabled=true
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rState.disabled=true
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCity.disabled=true
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCounty.disabled=true
}
//--------------------------------------------------------------------
function SearchByCity()
{
    fnKillNA();
	document.forms[0].ctl00_Page_Content_AA_Topic.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rKeyword_Search.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rState.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCity.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCounty.disabled=true
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCounty.visible=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rZip_Code.disabled=true
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rZip_Code.visible=false		
    theObj=document.getElementById("The_rightCounty_Row");
    theObj.style.display     = "none";

    theObj=document.getElementById("The_rightZip_Row");
    theObj.style.display     = "none";

	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rZip_Code.value="N/A"
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCounty.value="N/A"
}
//--------------------------------------------------------------------
function SearchByCounty(){
    fnKillNA();
	document.forms[0].ctl00_Page_Content_AA_Topic.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rKeyword_Search.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rState.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCounty.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rZip_Code.disabled=true
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rZip_Code.visible=false	
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCity.disabled=true	
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCity.visible=false	
	
    theObj=document.getElementById("The_rightZip_Row");
    theObj.style.display     = "none";
    theObj=document.getElementById("The_rightCity_Row");
    theObj.style.display     = "none";
	
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCity.value="N/A"	
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rZip_Code.value="N/A"	
}
//--------------------------------------------------------------------
function SearchByZip()
{

    fnKillNA();
    document.forms[0].ctl00_Page_Content_AA_Topic.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rZip_Code.disabled=false
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rKeyword_Search.disabled=false
	
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rState.disabled=true
    document.forms[0].ctl00_Page_Content_ucPublic_Search1_rState.visible=false
	
    document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCity.disabled=true	
    document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCity.visible=false
    	    
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCounty.disabled=true
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCounty.visible=false
	    
    theObj=document.getElementById("The_rightState_Row");
    theObj.style.display = "none";
	
    theObj=document.getElementById("The_rightCity_Row");
    theObj.style.display = "none";

	theObj=document.getElementById("The_rightCounty_Row");
	theObj.style.display = "none";

	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCity.value="N/A"
	document.forms[0].ctl00_Page_Content_ucPublic_Search1_rCounty.value="N/A"
	
}
//--------------------------------------------------------------------
function fnIsKeyword(x){
  the_value = x.options[x.options.selectedIndex].value;
  if(x.options[x.options.selectedIndex].value == "Keyword")
  {
    theObj=document.getElementById("The_rightKeyword_Row");
    theObj.style.display     = "";
	populate_service_desc(the_value);
  }
  else
  {
	theObj=document.getElementById("The_rightKeyword_Row");theObj.style.display     = "none";
	populate_service_desc(the_value);
  }
}
//--------------------------------------------------------------------
function showContent(divid, divContent)
{ 
  
    if (document.all) 
    {  
	 eval("document.all." + divid + ".innerHTML = unescape(divContent)");
    } 
    else if (document.getElementById) 
    { 
	  eval("document.getElementById(\"" + divid + "\").innerHTML = unescape(divContent)");
    } 
    else 
    {  
	  eval("document." + divid + ".document.write(unescape(divContent))"); 
	  document.close(); 
    }  
}
//--------------------------------------------------------------------
function fnOnSelectWho(x,y)
{
    fnClearRow("Row1");
    fnClearRow("Row2");
    fnClearRow("Row3");	
    fnClearRow("Row4");
	n = "Row" + y;
	fnSelectRow(n);
 	theObj=document.getElementById("Section2");
 	theObj.style.display     = ""; 
	j = "<span class='TextDarkBlueBold'>Selection :</span> <span class='TextBlackBold'>" + x + "</span>"
	showContent("Sec1_Selection",j);
	document.forms[0].WhoAreYou.value = x;
}
//--------------------------------------------------------------------
function fnClearRow(x)
{
    n = document.getElementById(x);
  	n.className = "TextBlack";
	n.style.backgroundColor = "#FFFFFF";
}
//--------------------------------------------------------------------
function fnSelectRow(x)
{
    n = document.getElementById(x);
  	n.className = "TextBlackBold";
	n.style.backgroundColor = "#FFCC66";
}
//--------------------------------------------------------------------
function fnToggleDisplays()
{
	  theObj=document.getElementById("rightSide");theObj.style.display = ""; 
	  theObj=document.getElementById("leftSide");theObj.style.display  = "none";
}
function fnOnSelectBy(x,y)
{
    fnClearRow("rRow5");
    fnClearRow("rRow6");
    fnClearRow("rRow7");	
	n = "rRow" + y;
	fnSelectRow(n);
 	theObj=document.getElementById("rSection3");
 	theObj.style.display     = ""; 
	j = "<span class='TextDarkBlueBold'>Selection :</span> <span class='TextBlackBold'>Search by " + x + "</span>"

	if(x == "Zip")
	{
	    iiByStatus = 3
	    fnShowAllRows()
	    SearchByZip();
		}
	if(x == "City")
	{
	   iiByStatus = 1
	   fnShowAllRows()
	   SearchByCity();
	}
	if(x == "County")
	{
	   iiByStatus = 2
	   fnShowAllRows()
	   SearchByCounty();
	}
}
//--------------------------------------------------------------------
function fnShowAllRows()
{
	  theObj=document.getElementById("The_AA_Row");theObj.style.display     = ""; 
	  theObj=document.getElementById("The_rightState_Row");theObj.style.display     = "";
	  theObj=document.getElementById("The_rightCity_Row");theObj.style.display     = "";
	  theObj=document.getElementById("The_rightZip_Row");theObj.style.display     = "";
	  theObj=document.getElementById("The_rightCounty_Row");theObj.style.display     = "";
	  
}
//--------------------------------------------------------------------
function fnFake()
{
    return false;
}


function fnValidateForm()
{
  f= document.forms[0];
  flag=0;
  ErrMsg = "";

      if(iiByStatus == 1)
      { //City
	      if(f.ctl00_Page_Content_AA_Topic.value == 'none')
	      { 
	        flag=1;ErrMsg = ErrMsg + "Topic:\n";
	      }
	      if(f.ctl00_Page_Content_ucPublic_Search1_rState.value == 'none')
	      {flag=1;ErrMsg = ErrMsg + "State:\n";}
	      if(f.ctl00_Page_Content_ucPublic_Search1_rCity.value.length == 0)
	      {flag = 1;ErrMsg = ErrMsg + "City:\n";}
	      f.Service_Name.value = f.ctl00_Page_Content_AA_Topic.options[f.ctl00_Page_Content_AA_Topic.options.selectedIndex].text;
	      if(flag ==0){return true;}else{ErrMsg = "Please Fill in the following fields:\n\n" + ErrMsg;alert(ErrMsg);return false;} 
	  }
	  if(iiByStatus == 2)
	  { // County
	      if(f.ctl00_Page_Content_AA_Topic.value == 'none'){ flag=1;ErrMsg = ErrMsg + "Topic:\n";}
	      if(f.ctl00_Page_Content_ucPublic_Search1_rState.value == 'none'){flag=1;ErrMsg = ErrMsg + "State:\n";}
	      if(f.ctl00_Page_Content_ucPublic_Search1_rCounty.value.length == 0){flag = 1;ErrMsg = ErrMsg + "County:\n";}
	      f.Service_Name.value = f.ctl00_Page_Content_AA_Topic.options[f.ctl00_Page_Content_AA_Topic.options.selectedIndex].text;
	      if(flag ==0){return true;}else{ErrMsg = "Please Fill in the following fields:\n\n" + ErrMsg;alert(ErrMsg);return false;} 
	  }
	  if(iiByStatus == 3)
	  { // Zip
	      if(f.ctl00_Page_Content_AA_Topic.value == 'none'){ flag=1;ErrMsg = ErrMsg + "Topic:\n";}
	      if(f.ctl00_Page_Content_ucPublic_Search1_rZip_Code.value.length != 5){flag = 1;ErrMsg = ErrMsg + "Zip Code:\n";}
	      if(!fnZipValid(f.ctl00_Page_Content_ucPublic_Search1_rZip_Code)){flag = 1;ErrMsg = ErrMsg + "Zip Code Must Be Numeric:\n";}
	      f.Service_Name.value = f.ctl00_Page_Content_AA_Topic.options[f.ctl00_Page_Content_AA_Topic.options.selectedIndex].text;
	      if(flag ==0){return true;}else{ErrMsg = "Please Fill in the following fields:\n\n" + ErrMsg;alert(ErrMsg);return false;} 
	  }
}
//--------------------------------------------------------------------
function fnCheckWho(x){
 for(i=0;i<document.forms[0].elements.length;i++){
   j = document.forms[0].elements[i];
   if(j.type == "radio")
   {
      if(j.value == x)
      {
	     j.checked = true;
	  }
   }
 }
}
//--------------------------------------------------------------------
function populate_service_desc(x){
	var isContent = "";
    fnToggleDisplays();	
	if(x == '02')
	{
		isContent = escape("Information and assistance programs assist older persons, their families and others who need information but don't know where to turn.  Specialists provide assistance and linkage to the full range of services and resources available in the community. Some of the services include: transportation, home delivered meals, home health services, senior center programs, health promotion programs, adult day care programs, and case management.  For more information on available services click <a href='/eldercare/Public/network/main.asp'>here</a>");
		show_Content("service_desc",isContent);
	}
	if(x == '04')
	{
		isContent = escape("Allegations of abuse, neglect and exploitation of senior citizens are investigated by highly trained protective service specialists. Intervention is provided in instances of substantiated elder abuse, neglect or exploitation.");
		show_Content("service_desc",isContent);
	}
	if(x == '98')
	{
		isContent = escape("State Health Insurance Counseling and Assistance Programs utilize paid professionals and  trained volunteers who offer unbiased, one on one counseling to assist consumers to understand their  Medicare health insurance benefits and resolve billing problems and to address issues related to supplemental insurance and long term care insurance options.");
		show_Content("service_desc",isContent);
	}
	if(x == '96')
	{
		isContent = escape("A resource where the elderly, people with disabilities, their caregivers and professionals can go to get information about long-term options that help people stay at home. There are currently 198 Aging and Disability Resource Centers in 43 States & Territories covering 38% of U.S. population");
		show_Content("service_desc",isContent);
	}	
	if(x == '15')
	{
		isContent = escape("Legal advice and representation is available to persons aged 60 and over for certain types of legal matters including government program benefits, tenant rights, and consumer problems.");
		show_Content("service_desc",isContent);
	}
	if(x == '16')
	{
		isContent = escape("Long term care ombudsmen, state and local, work cooperatively with nursing homes and board and care facilities to improve the quality of life for residents. They serve as patient's rights advocates, investigating and negotiating resolutions to concerns voiced by residents in matters of resident services and care.");
		show_Content("service_desc",isContent);
	}
	if(x == 'none' || x == 'Keyword')
	{
		isContentReady = 0;
		isContent = "";
		show_Content("service_desc",isContent);
		theObj=document.getElementById("The_service_desc_Row");theObj.style.display     = "none";
	}
	else
	{
		isContentReady = 1;
		//theObj=document.getElementById("The_service_desc_Row");theObj.style.display     = "";
	}
}
//--------------------------------------------------------------------
function show_desc_row(){
	populate_service_desc(document.getElementById('ctl00_Page_Content_AA_Topic').value);
	if(isTogDesc || !isContentReady){
	    isTogDesc = 0;
		theObj=document.getElementById('The_service_desc_Row');
		theObj.style.display= 'none';
	}
	else
	{
		isTogDesc =1;
		theObj=document.getElementById('The_service_desc_Row');
		theObj.style.display= '';
	}

}
//--------------------------------------------------------------------
function fnZipValid(f)
{
    isValid = true;
    for(i=0;i<f.value.length;i++){
        if(f.value.charAt(i) != ",")
        {
            if(isNumericString.indexOf(f.value.charAt(i)) == -1)
            {
                isValid = false;
            }
        }
    }
    return isValid;
}
//--------------------------------------------------------------------

