/**
* $Id: nhls_form.js,v 1.1.2.2.2.5 2007-08-15 14:37:31 akinder Exp $
* NHLS Form Functions
*/
/*
* Send radius search info
*/
function doPHASearch()
{
if( formHandler.countySearch.value == '#' )
{
alert( "You must select a county before restricting the radius." );
}
else
{
//
// Should centralize this at some point
// @TODO
if(isEmpty(formHandler.minRad.value)){
alert("Start radius is required");
return false;
}
if(isEmpty(formHandler.maxRad.value)){
alert("End radius is required");
return false;
}
if(!isFloat(formHandler.minRad.value)){
alert("Invalid start radius");
return false;
}
if(!isFloat(formHandler.maxRad.value)){
alert("Invalid end radius");
return false;
}
var r1 = parseFloat(formHandler.minRad.value);
var r2 = parseFloat(formHandler.maxRad.value);
if(r1<0){
alert("Negative start radius");
return false;
}
if(r2<=0){
alert("Negative or 0 end radius");
return false;
}
if(r1>=r2){
alert("End radius must larger than start radius");
return false;
}
formHandler.cmd.value = "doFilter";
formHandler.submit();
}
}
/*
* Functions for the PHA region drilldown
*/
function select_pha_region()
{
if( formHandler.countySearch.value == '#' )
{
formHandler.minRad.value = '0.0';
formHandler.maxRad.value = '0.0';
}
formHandler.cmd.value = "doFilter";
formHandler.submit();
}
/*
* Add a PHA point of contact
*/
function add_pha_contact()
{
//
// Empty checks
//
if( isEmpty( formHandler.region.value ) ||
isEmpty( formHandler.agency.value ) ||
isEmpty( formHandler.firstName.value ) ||
isEmpty( formHandler.lastName.value ) ||
isEmpty( formHandler.address1.value ) ||
isEmpty( formHandler.city.value ) ||
isEmpty( formHandler.state.value ) ||
isEmpty( formHandler.zip.value ) )
{
alert( 'Please fill out all values under Contact Details and Contact Work Address. The middle name and address line 2 fields are optional.');
return false;
}
//
// Send
//
formHandler.submit();
}
/*
* Submit comment
*/
function save_citizen_comment()
{
//
// Form
//
var theForm = document.getElementById('SaveComment');
//
// Empty?
if( isEmpty( theForm.comment.value ) )
{
alert('Please enter a comment.');
return false;
}
theForm.submit();
}
/*
* Toggle the PID for deletes
*/
function toggle_pid( propID )
{
//
// Form
//
var theForm = document.getElementById('removeProperty');
var newArray = new Array();
var dontAdd = 0;
//
// Current PIDS
//
var combValues = theForm.pid.value;
if( !isEmpty( combValues ) )
{
splitValues = combValues.split(",");
for( i=0; i
0 && !validateZIP( zip ) )
{
fail = true;
}
}
//
// CRS Form? Lots of options
//
if( currentFormID == 'radiusSearchForm' || currentFormID == 'prepareRadiusReportForm' )
{
if( !validateCRSForm() )
{
fail = true;
}
//
// Which search are we using?
//
if( currentForm == 'address' )
{
var stateIndex = formHandler.state2.selectedIndex;
var countyIndex = formHandler.county.selectedIndex;
//
// blank out the other ones
//
formHandler.state2.options[ stateIndex ].value = "";
//formHandler.county.options[ countyIndex ].value = "";
}
else
{
formHandler.address.value = "";
formHandler.city.value ="";
formHandler.zip.value ="";
}
}
//
// Rent on this form?
//
if( checkOptions['rent'] )
{
if( !doRentTest( formHandler.low_rent.value, formHandler.high_rent.value ) )
{
fail = true;
}
}
//
// All done?
//
if( !fail )
{
formHandler.submit();
}
}
/*
* Guam, PR, Virgin Islands don't have counties
*/
function skip_county( formValue )
{
if( formValue == 'GU' ||
formValue == 'VI' )
{
return true;
}
else
{
return false;
}
}
function onfocusRad1( e )
{
//
// Already blanked?
//
if( blankRad1 )
{
formHandler.radius1.value = '';
//
// Set flag
//
blankRad1 = false;
}
}
function onfocusRad2( e )
{
//
// Already blanked?
//
if( blankRad2 )
{
formHandler.radius2.value = '';
//
// Set flag
//
blankRad2 = false;
}
}
//
// Displays the search by radius form
//
function showRSForm( type )
{
//
// Hide the opposite, if necessary
//
if( type != '' && currentForm != type && currentForm != '' )
{
toggle_div( currentForm );
}
//
// Already open?
//
if( currentForm == type )
{
return true;
}
currentForm = type;
//
// Now, show the new type
//
toggle_div( type );
//
// And the rest
//
toggle_div( 'searchRadius', true );
if( currentFormID != 'prepareRadiusReportForm' && currentFormID != 'resourceLocatorForm' )
{
toggle_div( 'addInfo', true );
}
toggle_div( 'searchButton', true );
}
//
// Displays the search by user manager form
//
function showUMForm( type )
{
//
// Determine what to show
//
if( type == '' )
{
//If nothing is given, grab the hidden show value on the
//jsp page
type = formHandler.show.value;
}
//
// Hide the opposite, if necessary
//
if( currentForm != '' && currentForm != type )
{
toggle_div( currentForm );
}
//
// Already open?
//
if( currentForm == type )
{
return true;
}
currentForm = type;
//
// Now, show the new type
//
toggle_div( type );
}
//
// Validate and submit user manager form
//
function validateUMForm( form ) {
if( form == 'add' ) {
//set the form command to add
formHandler.cmd.value = 'doAdd';
//validate add form
if ( isEmpty( formHandler.addUserId.value ) ) {
alert("User ID is required");
return false;
}
if ( isEmpty( formHandler.addFirstName.value ) ) {
alert("First Name is required");
return false;
}
if ( isEmpty( formHandler.addLastName.value ) ) {
alert("Last Name is required");
return false;
}
if ( formHandler.accessType.value == "" ) {
alert("Please select an Access Type");
return false;
}
}
else {
if ( form == 'search' ) {
//set the form command to search
formHandler.cmd.value = 'doSearch';
if ( isEmpty( formHandler.editUserId.value ) &&
isEmpty( formHandler.editFirstName.value ) &&
isEmpty( formHandler.editLastName.value ) ) {
alert("Some input is required");
return false;
}
}
else {
if ( form == 'edit' ) {
//set the form command to edit
formHandler.cmd.value = 'doSaveEdit';
//validate edit form
if ( isEmpty( formHandler.editFirstName.value ) ) {
alert("First Name is required");
return false;
}
if ( isEmpty( formHandler.editLastName.value ) ) {
alert("Last Name is required");
return false;
}
}
else {
return false;
}
}
}
formHandler.submit();
}
//
// Navigates to User Manager Edit screen with User selected
//
function doUMEdit( userId )
{
formHandler.userId.value = userId;
formHandler.cmd.value = "doEdit";
formHandler.submit();
}
//
// Returns to User Manager with Edit Search selected
//
function doUMSearch( )
{
formHandler.cmd.value = "doReturnSearch";
formHandler.submit();
}
//
// Returns to User Manager with Edit Search selected
// along with cancellation message
//
function doUMCancel( )
{
formHandler.cmd.value = "doCancelEdit";
formHandler.submit();
}
//
// Actiavtes given user based on userId
//
function doUMActivate( userId )
{
formHandler.userId.value = userId
formHandler.cmd.value = "doActivate";
formHandler.submit();
}
//
// Deactivates given user based on userId
//
function doUMDeactivate( userId )
{
formHandler.userId.value = userId
formHandler.cmd.value = "doDeactivate";
formHandler.submit();
}
//
// Displays the search by user manager form
//
function showDMForm( type )
{
//
// Determine what to show
//
if( type == '' )
{
//If nothing is given, grab the hidden show value on the
//jsp page
type = formHandler.show.value;
}
//
// Hide the opposite, if necessary
//
if( currentForm != '' && currentForm != type )
{
toggle_div( currentForm );
}
//
// Already open?
//
if( currentForm == type )
{
return true;
}
currentForm = type;
//
// Now, show the new type
//
toggle_div( type );
}
//
// Validate and submit disaster manager form
//
function validateDMForm( form ) {
if( form == 'add' ) {
//set the form command to add
formHandler.cmd.value = 'doAdd';
//validate add form
if ( isEmpty( formHandler.addName.value ) ) {
alert("Name is required");
return false;
}
if ( isEmpty( formHandler.addDescription.value ) ) {
alert("Description is required");
return false;
}
if ( isEmpty( formHandler.addArea.value ) ) {
alert("Area is required");
return false;
}
}
else {
if ( form == 'search' ) {
//set the form command to search
formHandler.cmd.value = 'doSearch';
if( !isEmpty( formHandler.editOpenDate.value ) ) {
if( !isValidDate( formHandler.editOpenDate.value ) ) {
alert("Please enter the Open Date in the following format: MM/DD/YYYY");
return false;
}
}
if( !isEmpty( formHandler.editCloseDate.value ) ) {
if( !isValidDate( formHandler.editCloseDate.value) ) {
alert("Please enter the Close Date in the following format: MM/DD/YYYY");
return false;
}
}
if( ( !isEmpty( formHandler.editOpenDate.value ) ) &&
( !isEmpty( formHandler.editCloseDate.value ) ) ) {
var openDate = formHandler.editOpenDate.value;
var closeDate = formHandler.editCloseDate.value;
var format = 'M/d/y';
var comparison = compareDates(openDate, format, closeDate, format);
switch(comparison)
{
case 0:
//continue, closeDate is greater than or equal to openDate
break;
case 1:
alert("Open Date cannot be greater than Close Date");
return false;
break;
}
}
}
else {
if ( form == 'edit' ) {
//set the form command to edit
formHandler.cmd.value = 'doSaveEdit';
//validate edit form
if ( isEmpty( formHandler.editName.value ) ) {
alert("Name is required");
return false;
}
if ( isEmpty( formHandler.editDescription.value ) ) {
alert("Description is required");
return false;
}
if( !isEmpty( formHandler.editCloseDate.value ) ) {
if( !isValidDate( formHandler.editCloseDate.value) ) {
alert("Please enter the Close Date in the following format: MM/DD/YYYY");
return false;
}
else {
var openDate = formHandler.openDate.value;
var closeDate = formHandler.editCloseDate.value;
var format = 'M/d/y';
var comparison = compareDates(openDate, format, closeDate, format);
switch(comparison)
{
case 0:
//continue, closeDate is greater than openDate
break;
case 1:
alert("Open Date cannot be greater than Close Date");
return false;
break;
}
}
}
}
else {
return false;
}
}
}
formHandler.submit();
}
//
// Navigates to Disaster Manager Edit screen with Disaster selected
//
function doDMEdit( disasterId )
{
formHandler.disasterId.value = disasterId;
formHandler.cmd.value = "doEdit";
formHandler.submit();
}
//
// Navigates to Disaster Manager Edit screen with Disaster selected
//
function doDMAdd()
{
formHandler.cmd.value = "doAdd";
formHandler.submit();
}
function selectDMState()
{
formHandler.cmd.value = "doSelectDMState";
formHandler.submit();
}
//
// Returns to Disaster Manager with Edit Search selected
//
function doDMSearch( )
{
formHandler.cmd.value = "doReturnSearch";
formHandler.submit();
}
//
// Returns to Disaster Manager with Edit Search selected
// along with cancellation message
//
function doDMCancel( )
{
formHandler.cmd.value = "doCancelEdit";
formHandler.submit();
}
//
// Closes given disaster based on disasterId
//
function doDMClose( disasterId )
{
formHandler.disasterId.value = disasterId
formHandler.cmd.value = "doClose";
formHandler.submit();
}
//
// Opens given disaster based on disasterId
//
function doDMOpen( disasterId )
{
formHandler.disasterId.value = disasterId
formHandler.cmd.value = "doOpen";
formHandler.submit();
}
//
// Displays the resource type manager form
//
function showRTForm( type )
{
//
// Determine what to show
//
if( type == '' )
{
//If nothing is given, grab the hidden show value on the
//jsp page
type = formHandler.show.value;
}
//
// Hide the opposite, if necessary
//
if( currentForm != '' && currentForm != type )
{
toggle_div( currentForm );
}
//
// Already open?
//
if( currentForm == type )
{
return true;
}
currentForm = type;
//
// Now, show the new type
//
toggle_div( type );
}
//
// Validate and submit resource type manager form
//
function validateRTForm( form ) {
if( form == 'add' ) {
//set the form command to add
formHandler.cmd.value = 'doAdd';
//validate add form
if ( isEmpty( formHandler.addResourceType.value ) ) {
alert("Resource Type is required");
return false;
}
}
else {
if ( form == 'search' ) {
//set the form command to search
formHandler.cmd.value = 'doSearch';
if ( isEmpty( formHandler.editResourceType.value ) ) {
alert("Some input is required");
return false;
}
}
else {
if ( form == 'edit' ) {
//set the form command to edit
formHandler.cmd.value = 'doSaveEdit';
//validate edit form
if ( isEmpty( formHandler.editResourceType.value ) ) {
alert("Resource Type is required");
return false;
}
}
else {
return false;
}
}
}
formHandler.submit();
}
//
// Navigates to Resource Type Manager Edit screen with Resource Type selected
//
function doRTEdit( resourceTypeId )
{
formHandler.passedResourceTypeId.value = resourceTypeId;
formHandler.cmd.value = "doEdit";
formHandler.submit();
}
//
// Returns to Resource Type Manager with Edit Search selected
//
function doRTSearch( )
{
formHandler.cmd.value = "doReturnSearch";
formHandler.submit();
}
//
// Returns to Resource Type Manager with Edit Search selected
// along with cancellation message
//
function doRTCancel( )
{
formHandler.cmd.value = "doCancelEdit";
formHandler.submit();
}
//
// Prompts user to confirm delete of the resource type to Resource Type Manager with Edit Search selected
// Once delete is confirmed, the resource type and associated resources will be deleted
// If the delete is canceled, the user will be returned to the current screen
//
function doRTDelete( type, RTypeId, associatedResources )
{
formHandler.passedResourceTypeId.value = RTypeId;
if(associatedResources > 0) {
if(confirm("Deleteing resource type " + type + " will cause " + associatedResources +
" associated resource(s) to be deleted. " +
"Are you sure you want to delete the resource type " + type + "?")) {
formHandler.cmd.value = "doDelete";
formHandler.submit();
}
else {
alert("Delete was cancelled.");
}
}
else {
if(confirm("Are you sure you want to delete the resource type " + type + "?")) {
formHandler.cmd.value = "doDelete";
formHandler.submit();
}
else {
alert("Delete was cancelled.");
}
}
}
//
// Validates Citizens Report search criteria
//
function validateCRForm( )
{
formHandler.cmd.value = "doGenerateReport";
formHandler.submit();
}
//
// Returns to Citizens Report page
//
function doCRReturn( )
{
formHandler.cmd.value = "doInit";
formHandler.submit();
}
//
// Validates Suggested Property Report search criteria
//
function validateSPRForm( )
{
if( !isEmpty(formHandler.zip.value) )
{
if( !validateZIP( formHandler.zip.value ) )
{
return false;
}
}
formHandler.cmd.value = "doGenerateReport";
formHandler.submit();
}
//
// Returns to Suggested Property Report page
//
function doSPRReturn( )
{
formHandler.cmd.value = "doInit";
formHandler.submit();
}
//
// Validates Unavailable Property Report search criteria
//
function validateUPRForm( )
{
formHandler.cmd.value = "doGenerateReport";
if( !isValidDate( formHandler.lookBackDate.value) ) {
alert("Please enter the Look Back Date in the following format: MM/DD/YYYY");
return false;
}
else
{
var lookBackDate = formHandler.lookBackDate.value;
var todaysDate = formHandler.todaysDate.value;
var format = 'M/d/y';
var comparison = compareDates(lookBackDate, format, todaysDate, format);
switch(comparison)
{
case 0:
//continue, todaysDate is greater than or equal to the lookBackDate
break;
case 1:
alert("Look Back Date cannot be greater than Todays Date");
return false;
break;
}
}
formHandler.submit();
}
//
// Returns to Unavailable Property Report page
//
function doUPRReturn( )
{
formHandler.cmd.value = "doInit";
formHandler.submit();
}
/*
* Moved functions from JSP files
*/
function validateCRSForm()
{
if( currentForm == 'address' )
{
if(isEmpty(formHandler.address.value)){
alert("Address is required");
return false;
}
if(isEmpty(formHandler.city.value)){
alert("City is required");
return false;
}
if(isEmpty(formHandler.zip.value)){
alert("Zipcode is required");
return false;
}
if(!validateZIP(formHandler.zip.value)){
return false;
}
}
else
{
if( isEmpty( formHandler.state2.value ) )
{
alert( 'Please select a State and County.' );
return false;
}
if( formHandler.state2.value == '#' )
{
alert( 'Please choose a state.' );
return false;
}
if( skip_county( formHandler.state2.value ) )
{
return true;
}
else if( !skip_county( formHandler.state2.value ) && isEmpty( formHandler.county.value ) )
{
return false;
}
}
if( currentFormID != 'prepareRadiusReportForm' )
{
if(isEmpty(formHandler.radius1.value)){
alert("Start radius is required");
return false;
}
if(isEmpty(formHandler.radius2.value)){
alert("End radius is required");
return false;
}
if(!isFloat(formHandler.radius1.value)){
alert("Invalid start radius");
return false;
}
if(!isFloat(formHandler.radius2.value)){
alert("Invalid end radius");
return false;
}
var r1 = parseFloat(formHandler.radius1.value);
var r2 = parseFloat(formHandler.radius2.value);
if(r1<0){
alert("Negative start radius");
return false;
}
if(r2<=0){
alert("Negative or 0 end radius");
return false;
}
if(r1>=r2){
alert("End radius must larger than start radius");
return false;
}
//
// Return true
//
return true;
}
else
{
return true;
}
}
function selectRSState()
{
if(formHandler.state.value!='#')
{
formHandler.cmd.value="doSelectState";
formHandler.wstate.value="state";
//
// Blank out the addr
formHandler.address.value = "";
formHandler.city.value ="";
formHandler.zip.value="";
formHandler.submit();
}
}
function selectRS2State()
{
if(formHandler.state2.value!='#')
{
formHandler.cmd.value="doSelectState";
formHandler.wstate.value="state2";
//
// Blank out the addr
formHandler.address.value = "";
formHandler.city.value ="";
formHandler.zip.value="";
formHandler.submit();
}
}
function selectRS3State()
{
if(formHandler.state3.value!='#')
{
formHandler.cmd.value="doSelectState";
formHandler.wstate.value="state3";
//
// Blank out the addr
formHandler.address.value = "";
formHandler.city.value ="";
formHandler.zip.value="";
formHandler.submit();
}
}
//
// Deprec
//
function selectRSCounty()
{
}
function doXMLSubmit(command){
document.xmlInfoForm.cmd.value = command;
document.xmlInfoForm.submit();
}
function doXMLCancel(){
document.form1.cmd = 'doCancel';
document.form1.submit();
}
function doXMLUpload(){
document.form1.cmd = 'doCancel';
if(document.form1.providerName.value==''){
alert("Please select data provider");
return;
}
if(document.form1.xmlFile.value==''){
alert("Please select the XML file to upload");
return;
}
document.form1.submit();
}
function doFEMAUpload(){
document.form1.cmd = 'doCancel';
if(document.form1.xmlFile.value==''){
alert("Please select the XML file to upload");
return;
}
document.form1.submit();
}
function doDataTableUpload(){
if(document.form1.xmlFile.value==''){
alert("Please select the table data file to upload");
return;
}
document.form1.submit();
}
function doRSSearch(){
if(validateRSForm()){
document.prepareRadiusReportForm.submit();
}
}
function validateRSForm(){
if(isEmpty(document.prepareRadiusReportForm.address.value)){
alert("Address is required");
return false;
}
if(isEmpty(document.prepareRadiusReportForm.city.value)){
alert("City is required");
return false;
}
if(isEmpty(document.prepareRadiusReportForm.zip.value)){
alert("Zipcode is required");
return false;
}
if(!validateZIP(document.prepareRadiusReportForm.zip.value)){
return false;
}
return true;
}
function selectHSCounty(countyCode){
if(countyCode!=''){
var url = 'fairMarketRent.do?cmd=doGetRentDetail&county=' + countyCode;
document.getElementById('fmr_detail').src = url;
}
}
function doGCStart(command){
var url = 'googleGeoCoding.do?cmd=doStart';
document.getElementById('fmr_detail').src = url;
var startBtn = document.getElementById('startBtn');
var stopBtn = document.getElementById('stopBtn');
startBtn.disabled = true;
stopBtn.disabled = false;
}
function doGCStop(command){
var url = 'googleGeoCoding.do?cmd=doStop';
document.getElementById('fmr_detail').src = url;
var startBtn = document.getElementById('startBtn');
var stopBtn = document.getElementById('stopBtn');
startBtn.disabled = false;
stopBtn.disabled = true;
}
function doGCCancel(command){
document.googleGeoCodingForm.submit();
}
function selectFMState(){
if(document.fairMarketRentForm.cmd.value!=''){
document.fairMarketRentForm.cmd.value="doSelectState";
document.fairMarketRentForm.submit();
}
}
function selectFMCounty(){
var county = document.fairMarketRentForm.county.value;
if(county!=''){
var url = 'fairMarketRent.do?cmd=doGetRentDetail&county=' + county;
document.getElementById('fmr_detail').src = url;
}
}
function doDPMSubmit(command){
document.dataProviderManagerForm.cmd.value = command;
document.dataProviderManagerForm.submit();
}
function doDPMSave(){
var phone= trimBothEnd(document.dataProviderManagerForm.phone.value);
var zip = trimBothEnd(document.dataProviderManagerForm.zip.value);
if (phone.length>0){
if (checkInternationalPhone(phone)==false){
alert("Please Enter a Valid Phone Number")
document.dataProviderManagerForm.phone.focus();
return;
}
}
if(zip.length>0){
if(!validateZIP(zip)){
document.dataProviderManagerForm.zip.focus();
return;
}
}
document.dataProviderManagerForm.cmd.value = 'doSave';
document.dataProviderManagerForm.submit();
}
function doDPEdit(partnerId){
document.dataProviderForm.cmd.value='doEdit';
document.dataProviderForm.partnerId.value=partnerId;
document.dataProviderForm.submit();
}
function doDPAdd(){
document.dataProviderForm.cmd.value='doAdd';
document.dataProviderForm.submit();
}
function doDPDelete(partnerId){
if(confirm("If a Data Provider is deleted, all properties belongs to this provider will be deleted.")){
document.dataProviderForm.cmd.value='doDelete';
document.dataProviderForm.partnerId.value=partnerId;
document.dataProviderForm.submit();
}
}
function doDPViewContacts(partnerId){
var url = 'contactView.do?cmd=doInit&partnerId=' + partnerId;
document.getElementById('contact_list').src = url;
return;
}
function doCPSubmit(command){
if( trimBothEnd(document.createProviderForm.partnerId.value)=='' && command != 'doCancel' ){
alert("Data provider Id is required.");
return;
}
document.createProviderForm.cmd.value = command;
document.createProviderForm.submit();
}
function doCVEdit(contactId){
document.contactViewForm.cmd.value='doEdit';
document.contactViewForm.contactId.value=contactId;
document.contactViewForm.submit();
}
function doCVAdd(){
document.contactViewForm.cmd.value='doAdd';
document.contactViewForm.submit();
}
function doCVDelete(contactId){
if(confirm("Do you want to delete the contact?")){
document.contactViewForm.cmd.value='doDelete';
document.contactViewForm.contactId.value=contactId;
document.contactViewForm.submit();
}
}
function doCVHide()
{
document.getElementById( 'contact_pane' ).style.display = 'none';
}
function doCMSubmit(command){
document.contactManagerForm.cmd.value = command;
document.contactManagerForm.submit();
}
function doCMSave(){
var phone= trimBothEnd(document.contactManagerForm.phone.value);
if (phone.length>0){
if (checkInternationalPhone(phone)==false){
alert("Please Enter a Valid Phone Number")
document.contactManagerForm.phone.focus();
return;
}
}
document.contactManagerForm.cmd.value = 'doSave';
document.contactManagerForm.submit();
}
function doRadiusSearch()
{
if(validateForm())
{
document.radiusSearchForm.submit();
}
}
function validateForm()
{
if(isEmpty(document.radiusSearchForm.address.value)){
alert("Address is required");
return false;
}
if(isEmpty(document.radiusSearchForm.city.value)){
alert("City is required");
return false;
}
if(isEmpty(document.radiusSearchForm.zip.value)){
alert("Zipcode is required");
return false;
}
if(isEmpty(document.radiusSearchForm.radius1.value)){
alert("Start radius is required");
return false;
}
if(isEmpty(document.radiusSearchForm.radius2.value)){
alert("End radius is required");
return false;
}
if(!validateZIP(document.radiusSearchForm.zip.value)){
return false;
}
if(!isFloat(document.radiusSearchForm.radius1.value)){
alert("Invalid start radius");
return false;
}
if(!isFloat(document.radiusSearchForm.radius2.value)){
alert("Invalid end radius");
return false;
}
var r1 = parseFloat(document.radiusSearchForm.radius1.value);
var r2 = parseFloat(document.radiusSearchForm.radius2.value);
if(r1<0){
alert("Negative start radius");
return false;
}
if(r2<=0){
alert("Negative or 0 end radius");
return false;
}
if(r1>=r2){
alert("End radius must larger than start radius");
return false;
}
//
// Pull the low/high
//
var low_rent = document.radiusSearchForm.low_rent.value;
var high_rent = document.radiusSearchForm.high_rent.value;
//
// Last test
//
if( doRentTest( low_rent, high_rent ) )
{
return true;
}
else
{
return false;
}
}
/*
* Test the rent
*/
function doRentTest( low_rent, high_rent )
{
//
// RegExp for testing blanks
//
var testEmpty=/^\s*$/;
//
// Blank rent boxes?
//
if( testEmpty.test( low_rent ) || testEmpty.test( high_rent ) )
{
alert( 'Please fill out both rent range boxes.' );
}
else
{
//
// Number check
//
if( isNaN( low_rent ) || isNaN( high_rent ) )
{
alert( 'Please enter a valid number in the rent range box.' );
}
else
{
if( low_rent < 0 || high_rent < 0 )
{
alert( 'Rent values can not be negative.' );
return false;
}
//
// Sanity check
//
if( Number(low_rent) > Number(high_rent) )
{
alert( 'Minimum rent cannot be higher than maximum rent.' );
}
else
{
return true;
}
}
}
}
function doSort( el )
{
var sortBy = el.options[ el.selectedIndex ].value;
formHandler.sortBy.value=sortBy;
var sortOrder = formHandler.sortOrder.value;
var lastSortBy = formHandler.lastSortBy.value;
var pageNum = '1';
var pane = document.getElementById( 'propertyList' );
var isPaging = 'false';
sort_property_list(sortOrder, sortBy, lastSortBy, pageNum, isPaging);
}
function doNewSearch(){
document.searchResultForm.cmd.value='doNewSearch';
document.searchResultForm.submit();
}
//
// Change to a common function
//
function doPaging(pageNum)
{
doPagingserverside(pageNum);
//var sortBy = formHandler.sortBy.value;
//alert(sortBy);
//var sortOrder = formHandler.sortOrder.value;
//var lastSortBy = formHandler.lastSortBy.value;
//var pane = document.getElementById( 'propertyList' );
//var isPaging = 'true';
//formHandler.cmd.value='doPaging';
//formHandler.pageNum.value = pageNum;
//sort_property_list(sortOrder, sortBy, lastSortBy, pageNum, isPaging);
}
function selectState(state, stateName)
{
document.stateSelectForm.state.value = state;
//
// + In state name?
//
stateName = stateName.replace( /\+/g, ' ' );
document.stateSelectForm.stateName.value = stateName;
document.stateSelectForm.submit();
}
function doRSSMSave(){
var url = trimBothEnd(document.rssManagerForm.queryUrl.value);
var fiscalYear = trimBothEnd(document.rssManagerForm.fairRentFiscalYear.value);
if (fiscalYear.length<0 || isNaN(fiscalYear))
{
alert("Please Enter a valid Fair Rent Fiscal Year")
document.dataProviderManagerForm.fairRentFiscalYear.focus();
return;
}
if (url.length<0){
alert("Please Enter a Valid URL")
document.dataProviderManagerForm.queryUrl.focus();
return;
}
document.rssManagerForm.cmd.value = 'doSave';
document.rssManagerForm.submit();
}
function doRSSMSubmit(command){
document.rssManagerForm.cmd.value = command;
document.rssManagerForm.submit();
}