﻿
disableAll();
byStatus = 1

function killNA()
{
    x = document.forms[0];
	if (x.ctl00_Page_Content_UcPublicSearch1_Zip_Code.value=="N/A")
	{ 
	    x.ctl00_Page_Content_UcPublicSearch1_Zip_Code.value = "";
	}
	if (x.ctl00_Page_Content_UcPublicSearch1_Keyword_Search.value=="N/A")
	{ 
	    x.ctl00_Page_Content_UcPublicSearch1_Keyword_Search.value = "";
	}
	if (x.ctl00_Page_Content_UcPublicSearch1_City.value=="N/A")
	{ 
	    x.ctl00_Page_Content_UcPublicSearch1_City.value = "";
	 }
	if (x.ctl00_Page_Content_UcPublicSearch1_County.value=="N/A")
	{ 
	    x.ctl00_Page_Content_UcPublicSearch1_County.value = "";
	}
}
//--------------------------------------------------------------------
function disableAll()
{
	document.forms[0].ctl00_Page_Content_AA_Topic.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Zip_Code.disabled=true
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Keyword_Search.disabled=true
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_State.disabled=true
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_City.disabled=true
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_County.disabled=true
}
//--------------------------------------------------------------------
function Search_by_City()
{
    killNA();
	document.forms[0].ctl00_Page_Content_AA_Topic.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Keyword_Search.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_State.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_City.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_County.disabled=true
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_County.visible=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Zip_Code.disabled=true
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Zip_Code.visible=false		
    theObj=document.getElementById("The_County_Row");
    theObj.style.display     = "none";

    theObj=document.getElementById("The_Zip_Row");
    theObj.style.display     = "none";

	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Zip_Code.value="N/A"
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_County.value="N/A"
}
//--------------------------------------------------------------------
function Search_by_County(){
    killNA();
	document.forms[0].ctl00_Page_Content_AA_Topic.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Keyword_Search.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_State.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_County.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Zip_Code.disabled=true
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Zip_Code.visible=false	
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_City.disabled=true	
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_City.visible=false	
	
    theObj=document.getElementById("The_Zip_Row");
    theObj.style.display     = "none";
    theObj=document.getElementById("The_City_Row");
    theObj.style.display     = "none";
	
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_City.value="N/A"	
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Zip_Code.value="N/A"	
}
//--------------------------------------------------------------------
function Search_by_Zip()
{
    killNA();
    document.forms[0].ctl00_Page_Content_AA_Topic.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Zip_Code.disabled=false
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_Keyword_Search.disabled=false
	
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_State.disabled=true
    document.forms[0].ctl00_Page_Content_UcPublicSearch1_State.visible=false
	
    document.forms[0].ctl00_Page_Content_UcPublicSearch1_City.disabled=true	
    document.forms[0].ctl00_Page_Content_UcPublicSearch1_City.visible=false
    	    
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_County.disabled=true
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_County.visible=false
	    
    theObj=document.getElementById("The_State_Row");
    theObj.style.display = "none";
	
    theObj=document.getElementById("The_City_Row");
    theObj.style.display = "none";

	theObj=document.getElementById("The_County_Row");
	theObj.style.display = "none";

	document.forms[0].ctl00_Page_Content_UcPublicSearch1_City.value="N/A"
	document.forms[0].ctl00_Page_Content_UcPublicSearch1_County.value="N/A"
	
}
//--------------------------------------------------------------------
function isKeyword(x){
  the_value = x.options[x.options.selectedIndex].value;
  if(x.options[x.options.selectedIndex].value == "Keyword")
  {
    theObj=document.getElementById("The_Keyword_Row");
    theObj.style.display     = "";
	populate_service_desc(the_value);
  }
  else
  {
	theObj=document.getElementById("The_Keyword_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 onSelectWho(x,y){
    clearRow("Row1");
    clearRow("Row2");
    clearRow("Row3");	
    clearRow("Row4");
	n = "Row" + y;
	selectRow(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 clearRow(x)
{
    n = document.getElementById(x);
  	n.className = "TextBlack";
	n.style.backgroundColor = "#FFFFFF";
}
//--------------------------------------------------------------------
function selectRow(x)
{
    n = document.getElementById(x);
  	n.className = "TextBlackBold";
	n.style.backgroundColor = "#FFCC66";
}
//--------------------------------------------------------------------
function onSelectBy(x,y)
{
    clearRow("Row5");
    clearRow("Row6");
    clearRow("Row7");	
	n = "Row" + y;
	selectRow(n);
 	theObj=document.getElementById("Section3");theObj.style.display     = ""; 
	j = "<span class='TextDarkBlueBold'>Selection :</span> <span class='TextBlackBold'>Search by " + x + "</span>"
	showContent("Sec2_Selection",j);
	if(x == "Zip")
	{
	    byStatus = 3
	    ShowAllRows()
	    Search_by_Zip();
		}
	if(x == "City")
	{
	   byStatus = 1
	   ShowAllRows()
	   Search_by_City();
	}
	if(x == "County")
	{
	   byStatus = 2
	   ShowAllRows()
	   Search_by_County();
	}
}
//--------------------------------------------------------------------
function ShowAllRows()
{
	  theObj=document.getElementById("The_AA_Row");theObj.style.display     = ""; 
	  theObj=document.getElementById("The_State_Row");theObj.style.display     = "";
	  theObj=document.getElementById("The_City_Row");theObj.style.display     = "";
	  theObj=document.getElementById("The_Zip_Row");theObj.style.display     = "";
	  theObj=document.getElementById("The_County_Row");theObj.style.display     = "";
	  
}
//--------------------------------------------------------------------
function fake()
{
    return false;
}


function validateForm()
{
  f= document.forms[0];
  flag=0;
  ErrMsg = "";

      if(byStatus == 1)
      { //City
	      if(f.ctl00_Page_Content_AA_Topic.value == 'none'){ flag=1;ErrMsg = ErrMsg + "Topic:\n";}
	      if(f.ctl00_Page_Content_UcPublicSearch1_State.value == 'none'){flag=1;ErrMsg = ErrMsg + "State:\n";}
	      if(f.ctl00_Page_Content_UcPublicSearch1_City.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(byStatus == 2)
	  { // County
	      if(f.ctl00_Page_Content_AA_Topic.value == 'none'){ flag=1;ErrMsg = ErrMsg + "Topic:\n";}
	      if(f.ctl00_Page_Content_UcPublicSearch1_State.value == 'none'){flag=1;ErrMsg = ErrMsg + "State:\n";}
	      if(f.ctl00_Page_Content_UcPublicSearch1_County.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(byStatus == 3)
	  { // Zip
	      if(f.ctl00_Page_Content_AA_Topic.value == 'none'){ flag=1;ErrMsg = ErrMsg + "Topic:\n";}
	      if(f.ctl00_Page_Content_UcPublicSearch1_Zip_Code.value.length != 5){flag = 1;ErrMsg = ErrMsg + "Zip Code:\n";}
	      if(!zipValid(f.ctl00_Page_Content_UcPublicSearch1_Zip_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 checkWho(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 zipValid(f)
{
    isValid = true;
    var numericString = "0,1,2,3,4,5,6,7,8,9";
    for(i=0;i<f.value.length;i++){
        if(f.value.charAt(i) != ",")
        {
            if(numericString.indexOf(f.value.charAt(i)) == -1)
            {
                isValid = false;
            }
        }
    }
    return isValid;
}
//--------------------------------------------------------------------

