CsSearchResultClick = function( queryId, clickUrl ) { 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 ) { clearTimeout( this.T ); document.location.href = clickUrl; } DrAjax.sendRequest( 'AjaxServer.php', this.getResponse, 'call=Product.logSearchClick&queryId=' + queryId ) this.T = setTimeout( 'document.location.href="' + clickUrl + '"', 2000 ); }