CsUserSearch = function() { this.getResponse = function( id, status ) { if( DrAjax.statuses[ status ] == 'Complete' ) { var xml = DrAjax.getResponse( id ); var redirect = xml.getElementsByTagName("redirect").item(0); if ( redirect ) { self.location = redirect.getAttribute("url"); } else { var error = xml.getElementsByTagName("e").item(0); if ( error ) { alert ( error.getAttribute("m") ); } else { parseResponse( xml ); } } } } var parseResponse = function( xml ) { var response = xml.getElementsByTagName( 'r' ).item(0); $( 'userSearchResult' ).innerHTML = response.getAttribute( 'c' ); } this.query = ''; this.search = function( query ) { this.query = query; DrAjax.sendRequest( 'AjaxServer.php', this.getResponse, 'call=User.search&q=' + this.query ); return false; } } userSearch = new CsUserSearch();