/** * $Id: nhls_ajax.js,v 1.1.2.1.2.5 2007-09-07 18:57:37 akinder Exp $ * NHLS Ajax Functions and Callbacks */ var overridePopped = 0; var caseMode = 0; /* * Check case prop */ function check_prop_image( propID, caseID ) { // // Reset // caseType = 'Add'; if( var_can_use_cookies ) { // // Pull our cookie // var combValues = my_getcookie( 'nhls-case-' + caseID ); if( combValues != null ) { // // Split em // splitValues = combValues.split(","); for( var i=0; i<=splitValues.length; i++ ) { if( splitValues[i] != "" ) { if( splitValues[i] == propID ) { // // Del // caseType = 'Del'; } } } // // Flip the image // if( caseType == 'Del' ) { document.getElementById( 'prop-' + propID ).src = imgCaseDel; document.getElementById( 'prop-' + propID ).alt = 'Remove Property to Case'; document.getElementById( 'prop-' + propID ).title = 'Remove Property from Case'; } } } } /* * Toggle case prompt */ function toggle_case_prop_radius( propID ) { // // Split and fix // var callBack = trimBothEnd( propID ); response = callBack.split(":"); caseMode = 1; toggle_case_prop( response[0], response[1], response[2] ); } /* * Toggle case prompt */ function toggle_case_prop( propID, caseID, count ) { // // Reset // caseType = 'Add'; if( var_can_use_cookies ) { // // Toggle // toggle_div( 'AjaxComments' ); } // // Ajax // var xml_request = var_base_url + 'Ajax.do?cmd=doCase' + caseType + '&propID=' + escape( propID ) + '&caseID=' + caseID + '&unitCount=' + count; // // Send using AJAX lib // var request = YAHOO.util.Connect.asyncRequest('POST', xml_request, load_case_callback ); } /* * Print out info */ var prop_case_call = function(o) { // // Handler to ajaxpane // var pane = document.getElementById( 'AjaxPane' ); // // Send response // var callBack = unescape( trimBothEnd( o.responseText ) ); response = callBack.split(":"); // // Trigger loading // if( var_can_use_cookies ) { toggle_div('AjaxComments'); } if( response[0].match("limit") && caseType != 'Del' ) { if( confirm( "This property has already been added to several other cases in the past 30 days. There is a possibility that there are no more units available. If you still wish to add this property, please click 'Ok', otherwise click 'Cancel'." ) ) { toggle_div('AjaxComments'); // // Ajax // var xml_request = var_base_url + 'Ajax.do?cmd=doCaseAdd&propID=' + escape( response[1] ) + '&caseID=' + response[2] + '&unitCount=0&overRide=1'; // // Send using AJAX lib // var request = YAHOO.util.Connect.asyncRequest('POST', xml_request, load_case_callback ); } else { alert( "This property was not added to the case." ); } } else { caseType = 'Add'; // // Pull our cookie // var combValues = my_getcookie( 'nhls-case-' + response[2] ); if( combValues == null ) { // // Set the cookie with just this propID // my_setcookie( "nhls-case-" + response[2], response[1] ); } else { // // New array // var newArray = new Array(); // // Split em // splitValues = combValues.split(","); for( var i=0; i<=splitValues.length; i++ ) { if( splitValues[i] != "" ) { if( splitValues[i] == response[1] ) { // // Del // caseType = 'Del'; } else { newArray.push( splitValues[i] ); } } } if( caseType != 'Del' ) { // // Manual add // newArray.push( response[1] ); } var newString = newArray.join(","); // // Set again // my_setcookie( "nhls-case-" + response[2], newString ); } // // Flip the image // if( caseType == 'Add' && caseMode == 0 ) { // // Flip to a del // document.getElementById( 'prop-' + response[1] ).src = imgCaseDel; document.getElementById( 'prop-' + response[1] ).alt = 'Remove Property from Case'; document.getElementById( 'prop-' + response[1] ).title = 'Remove Property from Case'; } else if( caseType == 'Del' && caseMode == 0 ) { document.getElementById( 'prop-' + response[1] ).src = imgCaseAdd; document.getElementById( 'prop-' + response[1] ).alt = 'Add Property to Case'; document.getElementById( 'prop-' + response[1] ).title = 'Add Property from Case'; } } } var load_case_callback = { success: prop_case_call, failure: ajax_error } /* * Adding case comment */ function ajax_add_case_comment( case_id ) { // // Disable the submit // // // Encode // var encodeComment = trimBothEnd( document.getElementById( 'NewComment' ).value ); // // Grey out the text box // //document.getElementById( 'NewComment' ).disabled = true; // // Encode // encodeComment = escape( encodeComment ); // // Ajax URL // var xml_request = 'Ajax.do?cmd=doAddCaseComment&caseID=' + case_id + '&comment=' +encodeComment; NHLS.AjaxRequest( xml_request, 'CommentPane', '' ); // //var request = YAHOO.util.Connect.asyncRequest( 'POST', xml_request, load_post_case_comment_callback ); } /* * Load case comments */ function load_case_comments( caseID, citizenID ) { // // Toggle div // toggle_div( 'AjaxComments', true ); toggle_div( 'LoadingPane' ); // // Ajax // var xml_request = var_base_url + 'Ajax.do?cmd=doCaseComments&citizenID='+ escape( citizenID ) + '&caseID=' + escape( caseID ); // // Send using AJAX lib // var request = YAHOO.util.Connect.asyncRequest('POST', xml_request, load_case_comment_callback ); } var display_case_comments = function(o) { // // Trigger loading // toggle_div('LoadingPane'); // // Handler to ajaxpane // var pane = document.getElementById( 'AjaxPane' ); // // Send response // pane.innerHTML = unescape( o.responseText ); // // Center the div // center_div('AjaxComments'); } /* * Load comments, ajax style */ function load_comments( propID, propHash ) { // // Toggle div // toggle_div( 'AjaxComments', true ); toggle_div( 'ajax-loader' ); // // Ajax // var xml_request = var_base_url + 'Ajax.do?cmd=doInit&propID=' + escape( propID ) + '&propHash=' + escape( propHash ); // // Send using AJAX lib // var request = YAHOO.util.Connect.asyncRequest('POST', xml_request, load_comment_callback ); } /* * Add a new comment */ function ajax_add_comment( prop_id, prop_id_hash ) { // // Loading // var comment_status = ""; // // Disable the submit // // // Encode // var encodeComment = trimBothEnd( document.getElementById( 'NewComment' ).value ); // // Grey out the text box // document.getElementById( 'NewComment' ).disabled = true; // // Defaults? // // Unavailable position 0 // Uninhabitable position 1 // Available position 2 // Habitable position 3 // if( $( 'isUnavailable' ) && $( 'isUnavailable' ).get('checked')) { //encodeComment = "Property is unavailable.
" + encodeComment; comment_status = comment_status + "1"; } else { comment_status = comment_status + "0"; } if( $( 'isUninhabitable' ) && $( 'isUninhabitable' ).get('checked') ) { //encodeComment = "Property is uninhabitable.
" + encodeComment; comment_status = comment_status + "1"; } else { comment_status = comment_status + "0"; } if( $( 'isAvailable' ) && $( 'isAvailable' ).get('checked') ) { //encodeComment = "Property is available.
" + encodeComment; comment_status = comment_status + "1"; } else { comment_status = comment_status + "0"; } if( $( 'isHabitable' ) && $( 'isHabitable' ).get('checked') ) { //encodeComment = "Property is habitable.
" + encodeComment; comment_status = comment_status + "1"; } else { comment_status = comment_status + "0"; } // // Encode // encodeComment = escape( encodeComment ); // // Ajax URL // var xml_request = 'Ajax.do?cmd=doAddComment&status=' + comment_status + '&propID=' + prop_id + '&propHash=' + prop_id_hash + '&comment=' +encodeComment; //var request = YAHOO.util.Connect.asyncRequest( 'POST', xml_request, load_post_comment_callback ); NHLS.AjaxRequest( xml_request, 'AjaxComments', '' ); } function ajax_deleteCommentById(comment_id, prop_id, prop_id_hash){ // Ajax URL var xml_request = 'Ajax.do?cmd=doDeleteCommentById&id=' + comment_id + '&propID=' + prop_id + '&propHash=' + prop_id_hash; NHLS.AjaxRequest( xml_request, 'AjaxComments', '' ); } /* * Callback functions * o.responseText = callback */ var reload_case_comments = function(o) { toggle_div( 'LoadingPane' ); var pane = document.getElementById( 'CommentPane' ); pane.innerHTML = unescape( o.responseText ); // // Add message // document.getElementById( 'newSubmitComment' ).value = 'Comment Added.'; document.getElementById( 'NewComment' ).disabled = false; // // Set back to starter state // toggle_submit_button( 'newSubmitComment', 'Add Comment' ); } var reload_prop_comments = function(o) { toggle_div( 'LoadingPane' ); var pane = document.getElementById( 'CommentPane' ); pane.innerHTML = unescape( o.responseText ); // // Add message // document.getElementById( 'newSubmitComment' ).value = 'Comment Added.'; document.getElementById( 'NewComment' ).disabled = false; // // Set back to starter state // toggle_submit_button( 'newSubmitComment', 'Add Comment' ); } var display_prop_comments = function(o) { // // Trigger loading // toggle_div('LoadingPane'); // // Handler to ajaxpane // var pane = document.getElementById( 'AjaxPane' ); // // Send response // pane.innerHTML = unescape( o.responseText ); // // Center the div // center_div('AjaxComments'); } /* * Ajax callbacks */ var load_comment_callback = { success: display_prop_comments, failure: ajax_error }; var load_case_comment_callback = { success: display_case_comments, failure: ajax_error } var load_post_case_comment_callback = { success: reload_case_comments, failure: ajax_error } var load_post_comment_callback = { success: reload_prop_comments, failure: ajax_error }; /* * Standard error */ var ajax_error = function(o) { // // Trigger loading // document.getElementById( 'LoadingPane' ).style.display = 'none'; // // Handler to ajaxpane // var pane = document.getElementById( 'AjaxPane' ); // // Send response // pane.innerHTML = 'There was an issue loading this request.'; } /* * Change County List */ function change_county_list( state, div_id, isMultiple ) { // // Blank out the city list $('scity').value = ""; $('search-add-list').innerHTML = "No Cities added."; var xml_request = 'Ajax.do?cmd=doCountyList&state=' + state + '&multiple=' + isMultiple; NHLS.AjaxRequest(xml_request, div_id, ''); } /* * Change County List */ function change_county_list_locator( state, div_id, isMultiple ) { var xml_request = 'Ajax.do?cmd=doCountyList&state=' + state + '&multiple=' + isMultiple; NHLS.AjaxRequest(xml_request, div_id, ''); } function sort_property_list(sortOrder, sortBy, lastSortBy, pageNum, isPaging){ var xml_request = 'Ajax.do?cmd=doSortProperty&sortOrder=' + sortOrder + '&sortBy=' + sortBy + '&lastSortBy=' + lastSortBy + '&pageNum=' + pageNum + '&isPaging=' + isPaging; NHLS.AjaxRequest(xml_request, 'propertyList', ''); } function addShoppingCart(unithash){ // Small hack $('shoppingCartIcon').set('src', 'resources/images/case_cart_greyout.gif'); $('shoppingCartIcon').setStyle('cursor','none'); var xml_request = 'shoppingCart.do?cmd=doAddProperty&unithash=' + unithash; NHLS.AjaxCallBack(xml_request, 'end-page'); } function check_data_import_status( div_id ) { var xml_request = 'Ajax.do?cmd=doGetDataImportStatus'; NHLS.AjaxRequest(xml_request, div_id, ''); } function check_fair_market_rent_load_status( div_id ) { var xml_request = 'Ajax.do?cmd=doGetFairMarketRentLoadStatus'; NHLS.AjaxRequest(xml_request, div_id, ''); }