/* --------------------------------------------------------------------------- RLajax.base.js by Rainer Libowski version: 0.41 copyright (c) 2007-2008 latest version available from http://scripts.rl21.de ------------------------------------- COPYRIGHT NOTICE AND LICENSE: Copyright 2008 Rainer Libowski. All Rights Reserved. This work (and included software, documentation such as READMEs, or other related items) is provided by the copyright holder under the following license. By obtaining, using and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions. The use of this software is permitted for free provided that the following conditions are met: This software may be used for private or commercial operation, with or without modifications, as long as this copyright notice and the header above remain intact. Any redistribution is expressively forbidden without prior written consent of the copyright holder. THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------- */ var LangRL = new Object(); LangRL.noajax = 'Sorry, Ajax not available!'; LangRL.servererror = 'Sorry, unspecified server error!'; var AjaxRL = new Object(); AjaxRL.VERSION = 0.41; AjaxRL.CreateObject = function() { var request = null; try { // check for native support: request = new XMLHttpRequest(); } catch(e) { // check for Microsoft ActiveX try { // new MS-parser request = new ActiveXObject("MSXML2.XMLHTTP"); } catch(e) { try { // old MS-parser request = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { } } } return request; }; AjaxRL.SendRequest = function(uri, callback, timeout, AlertOnError) { var http = AjaxRL.CreateObject(); if (http == null) { // alert, if requested: if (AlertOnError) { alert(LangRL.noajax); } return false; } http.open('get', uri, true); http.onreadystatechange = AjaxRL.HandleResponse(http, callback); // timeout handling - wrap in try-block due to IE6 failing on setTimeout try { http.timeout = timeout || 5000; http.timeoutID = window.setTimeout( function() { // if (http.readyState != 4) { http.abort(); // } }, http.timeout); } catch (e) {} http.send(null); }; AjaxRL.HandleResponse = function(http, callback) { return function () { var response = ''; if(http.readyState == 4){ // clear timeout - wrap in try-block due to IE6 failing try { window.clearTimeout(http.timeoutID); } catch (e) {}; // on success if (http.status == 200) { response = http.responseText; callback(response); } else { return false; } } }; }; // End of file