function changeformaction(straction,sURL) {
    alert(straction);
    document.forms[0].action = straction;
    document.forms[0].submit();
}  

function zchangeformaction(straction,sURL,strOpt) {
//change the page to post to to straction parameter
//pass the selections in the hidden variable txtHidden
         var strHidden = document.forms[0].txtHiddenTowns.value;
         vxSVM = String.fromCharCode(252);
         vxVM = String.fromCharCode(253);
         vxAM = String.fromCharCode(254);
         vxRM = String.fromCharCode(255);
         blnSubmit = true;
	 switch(document.title) {
             case 'Towns' :
                strOption = "Towns" + vxAM;
                strPage = "towns.asp";
                hasKey = true;
                break;
             case 'Architectural Styles' :
                strOption = "ArchitecturalStyles" + vxAM;
                strPage = "options.asp";
                hasKey = true;
                break;
             case 'Areas Of Significance' :
                strOption = "AreasOfSignificance" + vxAM;
                strPage = "options.asp";
                hasKey = true;
                break;
             case 'Resource Types' :
                strOption = "ResourceTypes" + vxAM;
                strPage = "options.asp";
                hasKey = true;
                break;
             case 'Designation Types' :
                strOption = "DesignationTypes" + vxAM;
                strPage = "options.asp";
                hasKey = true;
                break;
             case 'Use Types' :
                strOption = "UseTypes" + vxAM;
                strPage = "options.asp";
                hasKey = true;
                break;
             case 'Results' :
                strOption = "Results" + vxAM;
                strPage = "results.asp";
                hasKey = false;
                break;
             default:
                strOption = "";
                hasKey = false;
         }
      	 //strCriteria = "";
         if (sURL == "options.asp" && document.forms[0].txtHiddenTowns.value == "TownsțALLü(All Towns)" && document.forms[0].txtHiddenOptions.value == "")
            {
            alert("To search on 'All Towns', you must select at least one other search criteria.  Please refine your search.");
            return;
            }
         if (sURL == "towns.asp" && document.forms[0].UserSelections.length == 0)
	      {
              alert("You must select a town in order to continue.");
              return;
              //document.forms[0].action="towns.asp?Page=towns.asp";
              //document.forms[0].txtHidden.value = "";
              }
         else
            {
	    if (sURL == "towns.asp" || sURL == "options.asp")
               {
	       if (sURL == "options.asp")
		  {
		  if (straction == "results.asp")
                  //Check that if the user selected "All Towns", there is at least one other criteria other than
                  //ResourceType
                     {
		     sPos = strHidden.indexOf("All Towns");
		     if (sPos > 0)
                        {
                        strStripped = strHidden;
                        //Strip out the Sort Clause from the hidden text
                        sPos = strStripped.indexOf("Sort" + vxAM);
                        if (sPos > 0)
                           {
                           ePos = strStripped.indexOf(vxRM, sPos);
                           strTemp = strStripped.substr(sPos, (ePos - sPos) +1);
                           strTemp = strStripped.replace(strTemp,"");
                           strStripped = strTemp;
                           }
                        //Strip out ResourceTypes if it exists in hidden text
                        sPos = strStripped.indexOf("ResourceTypes" + vxAM);
                        if (sPos > 0)
                           {
                           ePos = strStripped.indexOf(vxRM, sPos);
                           strTemp = strStripped.substr(sPos, (ePos - sPos) + 1);
                           strTemp = strStripped.replace(strTemp,"");
                           strStripped = strTemp;
                           }                   
                        //Strip out Town criteria from hidden text     
			sPos = strStripped.indexOf("Towns");
			ePos = strStripped.indexOf(vxRM, sPos);
	                strTemp = strStripped.substr(sPos, (ePos - sPos) + 1);
                        strTemp = strStripped.replace(strTemp,"");
                        strStripped = strTemp;
                        //If there is nothing left after Sort, Town, and ResourceType have been stripped out then
                        //the recordset would be too big, so we won't allow it.
                        if (strStripped == "" || strStripped == " ")
                           {
                           alert("Resultset would be too large.  Please refine your search.");
                           blnSubmit = false;
                           }
                        }
                     }
                  }
               }

            if (sURL == "towns.asp" || sURL == "results.asp")
		document.forms[0].action="VMWeb.asp?Page=" + straction + "&OptionType=ArchitecturalStyle";
	    else
		if (straction == "results.asp")         //going to results.asp
		   document.forms[0].action="VMWeb.asp?Page=results.asp&OptionType=" + strOpt + "&RecNo=1";
                else                                     
 	           document.forms[0].action="VMWeb.asp?Page=" + straction + "&OptionType=" + strOpt;
            } 
         if (blnSubmit == true) {
            document.forms[0].target = "";
	    document.forms[0].submit();	}
}










function GetHiddenVal(strHiddenVal,strOptionVal,strCriteriaVal,strvxRM) {

   if (strHiddenVal.indexOf(strOptionVal) > -1)
      {
      startPos = strHiddenVal.indexOf(strOptionVal);
      endPos = strHiddenVal.indexOf(strvxRM, startPos);
      strFullOption = strHiddenVal.substr(startPos, (endPos - startPos) + 1);
      strHiddenVal = strHiddenVal.replace(strFullOption, strCriteriaVal);
      }
   else
      strHiddenVal = strHiddenVal + strCriteriaVal;
   return strHiddenVal
}




function newsearch(straction) {
   document.forms[0].txtHiddenTowns.value = "";
   document.forms[0].txtHiddenOptions.value = "";
   document.forms[0].txtHiddenSort.value = "";
   document.forms[0].target = "";
   changeformaction(straction);
}








function newsearchfromdetails(straction) {
//from details page, start new search at towns page
     document.forms[0].txtHiddenTowns.value="";
     document.forms[0].txtHiddenOptions.value="";
     document.forms[0].txtHiddenSort.value="";
     document.forms[0].action=straction + "?Page=" + straction;
     document.forms[0].submit();
}




function xreturntolist(straction) {
//from details page, return to results page
     document.forms[0].action=straction + "?Page=" + straction;
     document.forms[0].submit();	
}




function xreturntoresults(straction) {
//from details page, return to results page
     document.forms[0].action=straction + "?Page=" + straction + "&RecNo=1";
     document.forms[0].submit();
}




function xshowoption(straction) {
//change the option page to show the action selected by hypertext click
//pass the selections in the hidden variable txtHidden

	document.forms[0].action=straction; 
        document.forms[0].submit();	
}




function xshowproperty() {
//shows the details page for the property selected
	alert(window.event.srcElement.innerText);
}




function showresults(strRecNo) {
//show next group of results, starting with strRecNo
	document.forms[0].action="results.asp?Page=results.asp&RecNo=" + strRecNo;
	document.forms[0].submit();
}




















