// CONFIG SETTING var MAX_NUM_AREAS = 3; function submitEditContactForm( id ) { var theForm = $( 'editContactForm' + id ); if( theForm.submit.value == 'Please Wait...' ) { alert( "Please wait..." ); return false; } if( validateEditContactForm( theForm ) == false ) return false; theForm.submit.value = 'Please Wait...'; var opt = { method: 'post', parameters: "do=saveContact&" + theForm.serialize(), onSuccess: function(t) { theForm.submit.value = 'Save'; var responseJson = gEvalJSON( t, "webSignUps - submitEditContactForm" ); if( responseJson.status == "OK" ) { Effect.BlindUp( 'addContact', {duration:0.45} ); setTimeout( function() { Effect.Appear( "thankYou", {duration:0.45} ); }, 500 ); } else { gClearHighlightedErrorFields( theForm ); // There may have been fixed errors from the previous attempt gHighlightErrorFields( responseJson.errorFields, id ); alert( responseJson.message ); gFocusFirstErrorField( responseJson.errorFields, id ); } }, onFailure: function(t) { theForm.submit.value = 'Save'; gAjaxFailure( t ); } } new Ajax.Request( theForm.action, opt ); return false; } function validateEditContactForm( theForm ) { return true; } function determinePropertyOptions( id ) { var contactType = $( 'contactType' + id ).value; var propertyType = $( 'editContactForm' + id ).propertyType.value; // Reset all to blank $( 'infoSection' + id ).hide(); $( 'mainSection' + id ).hide(); $( 'propertyDetails' + id ).hide(); $( 'buyResidential' + id ).hide(); $( 'rentResidential' + id ).hide(); $( 'saleCommercial' + id ).hide(); $( 'rentCommercial' + id ).hide(); $( 'area' + id ).hide(); if( contactType == '' ) { $( 'infoSection' + id ).show(); } else if( contactType == 'buyer' || contactType == 'investor' ) { $( 'mainSection' + id ).show(); $( 'propertyDetails' + id ).show(); $( 'buyOrRent' + id ).innerHTML = 'buy'; if( propertyType == 'residential' ) { $( 'buyResidential' + id ).show(); $( 'area' + id ).show(); } else if ( propertyType == 'commercial' ) { $( 'saleCommercial' + id ).show(); $( 'area' + id ).show(); } } else if( contactType == 'renter' ) { $( 'mainSection' + id ).show(); $( 'propertyDetails' + id ).show(); $( 'buyOrRent' + id ).innerHTML = 'rent'; if( propertyType == 'residential' ) { $( 'rentResidential' + id ).show(); $( 'area' + id ).show(); } else if ( propertyType == 'commercial' ) { $( 'rentCommercial' + id ).show(); $( 'area' + id ).show(); } } } function changeContactType( id ) { var contactType = $( 'contactType' + id ).value; $( 'seekerIconType' + id ).className = ( id == 0 ? 'add' : 'edit' ) + 'SeekerIcon-' + contactType; if( !( $( 'editContactForm' + id ).subscriptionLength.value == '' && $( 'infoSection' + id ).style.display == 'block' ) ) { determinePropertyOptions( id ); } } function getPropertiesMatched( id ) { } function addPostcodeArea( id ) { $( 'areaAnywhere' + id ).style.display = 'none'; $( 'postcodesBlock' + id ).style.display = 'block'; $( 'postcodeLine1-' + id ).style.display = 'block'; displayPostcodeButtons( id ); $( 'editContactForm' + id ).numPostcodesDisplayed.value = 1; $( "area1Radius-" + id ).focus(); } function addAnotherPostcode( postcodeLine, id ) { $( 'postcodeLine' + ( postcodeLine + 1 ) + '-' + id ).style.display = 'block'; displayPostcodeButtons( id ); $( 'editContactForm' + id ).numPostcodesDisplayed.value = postcodeLine + 1; $( 'area' + (postcodeLine + 1) + 'Radius-' + id ).focus(); } function removePostcode( postcodeLine, id ) { $( 'postcode' + postcodeLine + '-' + id ).value = ''; $( 'area' + postcodeLine + 'Radius-' + id ).value = ''; //$( 'landmark' + postcodeLine + '-' + id ).innerHTML = ''; $( 'postcodeLine' + postcodeLine + '-' + id ).style.display = 'none'; displayPostcodeButtons( id ); if( postcodeLine == 1 ) { $( 'postcodesBlock' + id ).style.display = 'none'; $( 'areaAnywhere' + id ).style.display = 'block'; } $( 'editContactForm' + id ).numPostcodesDisplayed.value = postcodeLine - 1; } function displayPostcodeButtons( id ) { var postcodeDisplayed = new Array(); for( i = 1; i <= MAX_NUM_AREAS; i++ ) { postcodeDisplayed[ i ] = $( 'postcodeLine' + i + '-' + id ).style.display == 'block'; } var lastPostcodeDisplayed = 1; for( i = 1; i <= MAX_NUM_AREAS; i++ ) { if( postcodeDisplayed[ i ] ) lastPostcodeDisplayed = i; } for( i = 1; i <= MAX_NUM_AREAS; i++ ) { $( 'add' + i + '-' + id ).style.display = 'none'; $( 'remove' + i + '-' + id ).style.display = 'none'; } if( lastPostcodeDisplayed != MAX_NUM_AREAS ) $( 'add' + lastPostcodeDisplayed + '-' + id ).style.display = 'block'; $( 'remove' + lastPostcodeDisplayed + '-' + id ).style.display = 'block'; }