//      _
//     (_)           _____
//      _ \ _   _   / ____|                                 _            _
//     (_) (_) (_) | (___  _   _ _ __   ___ _ __ ___   __ _| |_ ___  ___| |__
//  _ / _   _ /     \___ \| | | | '_ \ / _ \ '_ ` _ \ / _` | __/ _ \/ __| '_ \
// (_) (_) (_)      ____) | |_| | | | |  __/ | | | | | (_| | ||  __/ (__| | | |
//        \ _      |_____/ \__, |_| |_|\___|_| |_| |_|\__,_|\__\___|\___|_| |_|
//         (_)              __/ |
//                         |___/
//
//  Product:     InstantAJAX
//  Version:     Number $Revision: 1.12 $ $Build: 4 $
//               of $Date: 2007/11/28 18:18:52 $
//               by $Author: pfeil $
//
//  Description: Light JavaScript library for easy and fast programming of 
//               interactive web sites with instant AJAX integration.
//
//  Copyright (C) 2007 by Synematech.com
//
// -----------------------------------------------------------------------TAB=2

function isSet( object )                            { return object != undefined && object != null;                   }

Boolean.prototype.toJSON    = function()            { return String( this ).isBoolean() ? String( this ) : 'null';  }
Boolean.prototype.toBoolean = function()            { return this == true;                                          }
Number.prototype.toJSON     = function()            { return isFinite( this )           ? String( this ) : 'null';  }
Number.prototype.toBoolean  = function()            { return isFinite( this )           ? this != 0 : false;        }
Date.prototype.toJSON       = function()            { var f = function( n ) { return ( n < 10 ? '0' + n : n ); }; return ( this.getUTCFullYear() + '-' + f( this.getUTCMonth() + 1 ) + '-' + f( this.getUTCDate() ) + 'T' + f( this.getUTCHours() ) + ':' + f( this.getUTCMinutes() ) + ':' + f( this.getUTCSeconds() ) + 'Z' ); }

String.prototype.mid        = function( start, length ) {
  if( length < 0 )          length = this.length + length;
  if( start > this.length ) start  = start % this.length;
  var                       end    = start + length;
  if( end > this.length )   end    = this.length;
                            return this.substring( start, end );
} 
String.prototype.left       = function( length )    { return this.mid( 0, length );                                 }
String.prototype.right      = function( length )    { return this.mid( this.length - length, length );              }

String.prototype.startsWith = function( string )    { return this.left( string.length ) == string;                  }
String.prototype.endsWith   = function( string )    { return this.right( string.length ) == string;                 }
String.prototype.isEmpty    = function()            { return this == '';                                            }
String.prototype.isSpace    = function( character ) { return /[\s]/.test( isSet( character ) ? character : this );  }
String.prototype.isBoolean  = function()            { return /^true$|^false$/i.test( this );                        }
String.prototype.isNumber   = function()            { return !this.isNaN();                                         }
String.prototype.ltrim      = function()            { return this.replace( /^\s+/g, '' );                           }
String.prototype.rtrim      = function()            { return this.replace( /\s+$/g, '' );                           }
String.prototype.trim       = function()            { return this.replace( /^\s+|\s+$/g, '' );                      }

String.prototype.contains   = function( needle )    { return this.indexOf( needle ) != -1;                          }
String.prototype.count      = function( needle )    { for( var hits = -1, lastHit = 0; lastHit != -1; hits++ ) lastHit = this.indexOf( needle, ++lastHit ); return hits; }

String.prototype.insert     = function( string, position ) { return this.left( position ) + string + this.substring( position ); }

String.prototype.explode    = function( delimiter ) { 
  switch( delimiter ) { 
    case '; ': var components = this.split( /; / );                       break;
    case '=':  var components = this.split( /=/ );                        break;
    default:   var components = this.split( delimiter.escape( '\\x' ) );  break;
  } if( typeof( components ) == 'string' )                                return new Array();
                                                                          return components;
}
String.prototype.escape     = function( prefix )    { if( !isSet( prefix ) ) { prefix = '%'; } return this.replace( /[^0-9A-Za-z]/g, function( a ) { return prefix + Number( a.charCodeAt() ).toString( 16 ); } ); }
String.prototype.toJSON     = function()            { return '"' + this.replace( /[\x00-\x1f\\"]/g, function( a ) { var c = a.charCodeAt(); return '\\u00' + Math.floor( c / 16 ).toString( 16 ) + ( c % 16 ).toString( 16 ); } ) + '"'; }
String.prototype.toBoolean  = function()            { return this.toLowerCase() != 'false';                         }

Array.prototype.isEmpty     = function()            { return this.length == 0;                                      }
Array.prototype.contains    = function( needle )    { for( var i = 0, I = this.length; i < I; i++ ) { if( this[ i ] == needle ) return true; } return false; }
Array.prototype.top         = function()            { return ( this.isEmpty() ? null : this[ this.length - 1 ] );   }
Array.prototype.toJSON      = function()            { 
  for( var buffer = '[ ', i = 0, I = this.length; i < I; i++ ) {
    var                                               value   = this[ i ];
    if( !isSet( value ) )                             buffer += 'null,';
    else switch( typeof( value ) ) {
      case 'string':  case 'number':  case 'boolean': buffer += value.toJSON() + ',';   break;
      case 'object':  if( value.toJSON )              buffer += value.toJSON() + ',';
                      else return ( alert( 'ERROR in Array.prototype.toJSON: "cant convert".' ) ? null: null );
      default:             return ( alert( 'ERROR in Array.prototype.toJSON: "cant convert".' ) ? null: null );
  } } return buffer.left( -1 ) + ' ]';
}

document.isForm             = function( item )      { return isSet( document.forms[ item ] );                       }
document.getElements        = function( item )      { 
  function ElementList( node )                      { 
    var elements      = new Array(),
        add           = function( node )            { if( isSet( node ) ) elements.push( node );                    },
        getType       = function( object )          { 
          var validate = function ( type )          { switch( type )  { 
              case 'checkbox': case 'radio':  case 'button': case 'hidden': case 'password': case 'text':       case 'select-multiple':
              case 'textarea': case 'submit': case 'div':    case 'img':    case 'option':   case 'select-one': case 'form': return type;
              case 'file':  return ( alert( "InstantAJAX ERROR: Type '" + type + "' not supported." ) ? null : null );
              default:      return ( alert( "InstantAJAX ERROR: Type '" + type + "' unknown." )       ? null : null );
          } }
          if( !isSet( object ) )                                          return null;
          if( object instanceof Array )                                   return 'array'; // for iCab3.0.3
          switch( String( object ).toLowerCase() )  {
            case '[object nodelist]': case '[object htmlcollection]':     return 'nodelist';
            case '[object form]':     case '[object htmlformelement]':    return 'form';
            case '[object div]':      case '[object htmldivelement]':     return 'div';
            case '[object img]':      case '[object htmlimageelement]':   return 'img';
            case '[object option]':   case '[object htmloptionelement]':  return 'option';
            case '[object htmlfieldsetelement]':                          break;  // skip for FireFox
            case '[object]':                                              // for IE
                   if( object.type )                                      return validate( String( object.type ).toLowerCase() );
              else if( object.nodeName ) {
                if( object.nodeName.toLowerCase() == 'fieldset' )         break; // skip for IE
                else                                                      return validate( object.nodeName.toLowerCase() ); // div/img/form
              } else if( object.length )                                  return 'array';
              else                                                        break;
            default:                                                      // case '[object input]':    case '[object htmlinputelement]':                                      
              if( object.type )                                           return validate( String( object.type ).toLowerCase() );                                                      
          }                                                               return null;
        };
    this.length       = function()                  { return elements.length;                                       }
    this.enable       = function()                  { for( var i = 0, I = elements.length; i < I ; i++ ) elements[ i ].disabled = false;  return this; }
    this.disable      = function()                  { for( var i = 0, I = elements.length; i < I ; i++ ) elements[ i ].disabled = true;   return this; }
    this.show         = function( visible )         { 
      if( !isSet( visible ) || visible == true )                          visible = 'visible'; else visible = 'hidden';
      for( var i = 0, I = elements.length; i < I ; i++ ) { var            style = elements[ i ].getAttributeNode( 'style' );
        if( !isSet( style ) )                                             elements[ i ].setAttributeNode( style = document.createAttribute( 'style' ) );
        if( !isSet( style.visibility ) )                                  style.nodeValue  = style.nodeValue + 'visibility:' + visible + ';';
        else                                                              style.visibility = visible; 
      }                                                                   return this; 
    } 
    this.hide         = function()                  { return this.show( false );                                    }
    
    this.toJSON       = function()                  { 
      var json   = '[ ',
          append = function( type, id, name, value ) { 
            if( !isSet( type ) || type.isEmpty() ) return;
            json += '{"type":'  + type.toJSON();
            json += ',"id":'    + ( isSet( id )   && !id.isEmpty()   ? id.toJSON()    : 'null' );
            json += ',"name":'  + ( isSet( name ) && !name.isEmpty() ? name.toJSON()  : 'null' );
            json += ',"value":' + ( isSet( value )                   ? value.toJSON() : 'null' ) + '},';
          };
      for( var i = 0, I = elements.length; i < I ; i++ ) {
        var type  = getType( elements[ i ] ),                             value = null;
        switch( type ) {
          case 'checkbox': case 'radio':                                  value = elements[ i ].checked;
            if( value == true )                                           value = ( isSet( elements[ i ].value ) ? elements[ i ].value : value );
            if( value == 'on' )                                           value = true;                                               break; 
          case 'button': case 'hidden': case 'password':
          case 'text': case 'textarea': case 'submit':                    value = elements[ i ].value;                                break;
          case 'div':                                                     value = elements[ i ].innerHTML;                            break;
          case 'img':                                                     value = elements[ i ].src;                                  break;         
          case 'option':                                  
            if( elements[ i ].selected ) {                                value = elements[ i ].value;
              if( !isSet( value ) || value.isEmpty() )                    value = elements[ i ].text; 
              if( !isSet( value ) || value.isEmpty() )                    value = true;
            } else                                                        value = false;                                              break;
          case 'select-one':                                              value = elements[ i ].options[ elements[ i ].selectedIndex ].value;
            if( !isSet( value ) || value.isEmpty() )                      value = elements[ i ].options[ elements[ i ].selectedIndex ].text; 
            if( !isSet( value ) || value.isEmpty() )                      value = elements[ i ].selectedIndex;                        break;
          case 'select-multiple': for( var j = 0, J = elements[ i ].length; j < J; j++ ) {
            if( elements[ i ].options[ j ].selected ) {                   value = elements[ i ].options[ j ].value;
              if( !isSet( value ) || value.isEmpty() )                    value = elements[ i ].options[ j ].text; 
              if( !isSet( value ) || value.isEmpty() )                    value = true;
            } else                                                        value = false;                                         
            append( type, elements[ i ].getAttribute( 'id' ), elements[ i ].getAttribute( 'name' ), value );                  
          }                                                                                                                           continue;
          default: /* silently skip unknown elements */                                                                               continue;
        } append( type, elements[ i ].getAttribute( 'id' ), elements[ i ].getAttribute( 'name' ), value );
      } return json.left( -1 ) + ' ]';
    }
    this.eval         = function( buffer )          { 
      if( !isSet( buffer ) || buffer.isEmpty() )      return;
      var json        = eval( buffer ),
          fetch       = function( id, name, type )  { var index  = null,
                                                          J      = json.length;
            if( isSet( id )   && !id.isEmpty() )      for( var j = 0; j < J && !isSet( index ); j++ ) if( isSet( json[ j ] ) && json[ j ].type == type && json[ j ].id    == id   ) index = j;
            if( isSet( name ) && !name.isEmpty() )    for( var j = 0; j < J && !isSet( index ); j++ ) if( isSet( json[ j ] ) && json[ j ].type == type && json[ j ].name == name ) index = j;
                                                      for( var j = 0; j < J && !isSet( index ); j++ ) if( isSet( json[ j ] ) && json[ j ].type == type )                            index = j;
                                                      return index;
          };
      for( var i = 0, I = elements.length; i < I; i++ ) { var             type  = getType( elements[ i ] ),
                                                                          id    = elements[ i ].getAttribute( 'id' ),
                                                                          name  = elements[ i ].getAttribute( 'name' ),
                                                                          index = fetch( id, name, type );
        if( !isSet( index ) )                                             continue;
        var                                                               value = json[ index ].value;
                                                                          json[ index ] = null;
        switch( type ) {
          case 'div':                                                     elements[ i ].innerHTML = value;                            continue;
          case 'img':                                                     var path = elements[ i ].src.left( 1 + elements[ i ].src.lastIndexOf( '/' ) );
                                                                          elements[ i ].src       = '';
            if( !isSet( value ) || value.isEmpty() )                                                                                  continue;
                                                                          elements[ i ].src       = value;
            if( value.startsWith( '/' ) || value.startsWith( '.' ) )                                                                  continue;       
            if( value.toLowerCase().startsWith( 'http://' ) )                                                                         continue;    
            if( !isSet( path ) || path.isEmpty() )                                                                                    continue;  
                                                                          elements[ i ].src       = path + value;                     continue; 
          case 'checkbox': case 'radio': 
            if( !String( value ).isBoolean() )                            elements[ i ].value     = String( value );
                                                                          elements[ i ].checked   = value.toBoolean();                continue;
          case 'option': 
            if( !String( value ).isBoolean() )                            elements[ i ].text      = String( value );
                                                                          elements[ i ].selected  = value.toBoolean();                continue;
          case 'button': case 'hidden': case 'password':
          case 'text': case 'textarea': case 'submit':                    elements[ i ].value     = null; // for iCab3.0.3
                                                                          elements[ i ].value     = value;                            continue;
          case 'select-one': 
            for( var j = 0, J = elements[ i ].length, found = false; j < J && !found; j++ ) {
              if( !found && elements[ i ].options[ j ].value == value ) found = true;
              if( !found && elements[ i ].options[ j ].text  == value ) found = true;
              if( found )                                               value = j;
            } elements[ i ].options[ value ].selected = value.toBoolean();                                                            continue;
          case 'select-multiple': 
            for( var j = 0, J = elements[ i ].length; j < J && isSet( index ); j++ ) {
                                                                          json[ index ] = null;
              if( !String( value ).isBoolean() )                          elements[ i ].options[ j ].value    = String( value );
                                                                          elements[ i ].options[ j ].selected = value.toBoolean();
              if( isSet( index = fetch( id, name, type ) ) )              value = json[ index ].value;
            }                                                                                                                         continue;
          default:  /* silently skip unknown elements */                                                                              continue;
      } } return this; 
    }
    this.get          = function()                  { 
       var values   = new Array(),
           noname   = 1,
           append   = function( key, value ) { 
                  if( typeof( values[ key ] ) == 'undefined' )            values[ key ] = String( value );
             else if( typeof( values[ key ] ) == 'string' )               values[ key ] = new Array( values[ key ], String( value ) );
             else                                                         values[ key ].push( String( value ) );
           };
      for( var v = eval( this.toJSON() ), i = 0, I = v.length; i < I; i++ ) {
        if( I == 0 )                                                      return null;
        var                                                               value = v[ i ].value;
        if( I == 1 )                                                      return value;
        var                                                               label = v[ i ].name;
        if( !label )                                                      label = v[ i ].id;
        if( !label )                                                      label = 'elementNo_' + noname++;
        if( v[ i ].type == 'radio' )                                      label = 'R_' + label;  // Checkboxes?
        if( v[ i ].type == 'select-multiple' )                            label = 'M_' + label;  
                                                                          append( label, value );
      }
      var temp   = values;
          values = new Array();
      for( var key in temp ) {     
             if( typeof( temp[ key ] ) == 'function' )                    continue;
        else if( typeof( temp[ key ] ) == 'string'   )                    append( key, temp[ key ] );
        else {
          for( var value = new Array(), v = 0, V = temp[ key ].length; v < V; v++ ) {
            if( key.startsWith( 'R_' ) ) {
              if( temp[ key ][ v ].isBoolean() )                          value.push( temp[ key ][ v ] );
              else {                                                      value  = new Array();
                                                                          append( key.right( -2 ), temp[ key ][ v ] );                break;
            } } else if( key.startsWith( 'M_' ) ) { 
                  if( temp[ key ][ v ].toBoolean() )                      append( key.right( -2 ), temp[ key ][ v ] ); 
              } else                                                      append( key, temp[ key ][ v ] );
          } if( value.length > 0 && value.contains( 'true' ) ) 
              for( var i = 0, I = value.length; i < I; i++ )              append( key.right( -2 ), value[ i ] );
      } }
      var buffer = ''; for( var key in values ) 
             if( typeof( values[ key ] ) == 'function' )                  continue;
        else if( typeof( values[ key ] ) == 'string' )                    buffer += '&' + encodeURIComponent( key ) + '=' + encodeURIComponent( values[ key ] );
        else for( var i in values[ key ] ) { 
          if( typeof( values[ key ][ i ] ) != 'function' )                buffer += '&' + encodeURIComponent( key ) + '=' + encodeURIComponent( values[ key ][ i ] );
        }
      return buffer.right( -1 );
    }
    this.set          = function( value )           { 
      if( isSet( value ) ) for( var i = 0, I = elements.length, json = '[ ', type = null; i < I; i++ )
        if( isSet( type = getType( elements[ i ] ) ) ) {
          if( type == 'div' ) elements[ i ].innerHTML = value;  /* iCab 3.0.3 speedup */
          else                json += '{"type":' + type.toJSON() + ',"id":null,"name":null,"value":' + value.toJSON() + '},';
        } return this.eval( json.left( -1 ) + ' ]' );
    }
    this.clear        = function()                  { 
      for( var i = 0, I = elements.length; i < I; i++ ) {
        var element = new ElementList( elements[ i ] );
        switch( getType( elements[ i ] ) ) {
          case 'checkbox': case 'radio':    case 'option':                element.set( false );                                       continue;
          case 'hidden':   case 'password': case 'text':      
          case 'img':      case 'div':      case 'textarea':              element.set( '' );                                          continue;           
          case 'select-one':  case 'select-multiple':                    
            for( j = elements[ i ].length; j >= 0; j-- )                  elements[ i ].options[ j ] = null;                          continue;
          case 'submit':   case 'button':   default:                                                                                  continue;                     
      } } return this; 
    }
    this.append       = function( value )           { 
      for( var i = 0, I = elements.length; i < I; i++ ) {
        switch( getType( elements[ i ] ) ) {
          case 'checkbox': case 'radio': case 'option':                   elements[ i ].value = String( value );                      continue; 
          case 'button':   case 'hidden':   case 'password': 
          case 'text':     case 'textarea': case 'submit':  
          case 'img':      case 'div':                                    var element = new ElementList( elements[ i ] );
                                                                          element.set( element.get() + value );                       continue;
          case 'select-one': case 'select-multiple':                      elements[ i ].options[ elements[ i ].length ] = new Option( value ); continue;
          default:                                                                                                                    continue;
      } } return this; 
    }
    
    this.update       = function()                  { 
      for( var arguments = this.update.arguments, i = 0, I = arguments.length, j = 0, args = ''; i < I; i++ ) {
       if( String( arguments[ i ] ).toLowerCase() != '[object arguments]' ) args += arguments[ i ].toJSON();
       else for( var k = 0, K = arguments[ i ].length; k < K; k++ )         args += arguments[ i ][ k ].toJSON();
                                                                            args += ',';
      }
      for( var i = 0, I = elements.length; i < I; i++ ) { // Update only a single Element?
        if( !elements[ i ].getAttribute( 'id' ) ) alert( 'InstantAJAX ERROR: Only Elements with a valid id can be updated.' );
        else                                      eval( 'InstantAJAX.execute( ' + args + "'target=" + elements[ i ].getAttribute( 'id' ) + "' );" );
      } return this;
    }  

    switch( getType( node ) ) {
      case 'form': case 'nodelist': case 'array': for( var i = 0, I = node.length; i < I; i++ )  add( node[ i ] );  break;   
      default:                                                                                   add( node );       break; // single element or null
  } }                                     
  if( !isSet( item ) || item.isEmpty() )                                  return null;
  var                                                                     elements = null;
  if( document.isForm( item ) )                                           elements = document.forms[ item ].elements;
  if( !isSet( elements ) )                                                elements = document.getElementsByName( item );
  if( elements.length == 0 )                                              elements = document.getElementById( item );
  if( !isSet( elements ) )                                                return null;    
                                                                          return new ElementList( elements );                    
}

window.InstantAJAX = new function()                 { 
  this.connections = new Array();
  this.execute     = function execute( url )        { 
    var connection = new Array();
    
    connection[ 'ajax.request' ]      = null;
    connection[ 'ajax.timeout' ]      = 10000; // 10s
    connection[ 'ajax.async' ]        = 'true';
    connection[ 'indicator' ]         = null;         connection[ 'indicator.success' ] = 'done.gif';
    connection[ 'indicator.error' ]   = 'error.gif';  connection[ 'indicator.timeout' ] = 'done.gif';
    connection[ 'indicator.abort' ]   = 'done.gif';   connection[ 'indicator.process' ] = 'wait.gif';
    
    if( !window.ActiveXObject ) {
      if( window.XMLHttpRequest ) connection[ 'ajax.request' ] = new XMLHttpRequest();  // Mozilla, Opera, Safari, Internet Explorer 7      
    } else if (window.ActiveXObject) {                                                  // Internet Explorer 6
      try {                       connection[ 'ajax.request' ] = new ActiveXObject( 'Msxml2.XMLHTTP' ); }
      catch( exception ) { try {  connection[ 'ajax.request' ] = new ActiveXObject( 'Microsoft.XMLHTTP' ); 
    } catch( exception ) { } } }
    if( !connection[ 'ajax.request' ] ) return ( delete connection ? null : null );
    
                   this.connections.push( connection );
    var objectID = this.connections.length - 1;

    for( var i = 1, I = this.execute.arguments.length, data = '', argument = null, key = null, value = null, elements = null; i < I; i++ ) {
      argument = this.execute.arguments[ i ].trim(); 
      if( argument.startsWith( '[' ) && argument.endsWith( ']' ) && argument.contains( '=' ) ) {
        argument = argument.mid( 1, -2 ).explode( '=' );
        if( argument.length == 2 ) connection[ argument[ 0 ] ] = argument[ 1 ];
      } else if( argument.startsWith( '[' ) || argument.endsWith( ']' ) ) {
        connection[ argument.mid( 1, -2 ) ] = 'true';  
      } else {   
        if( ( elements = document.getElements( argument ) ) == null ) {                // Arg not found (is not an id, name or from name)
          if( argument.contains( '=' ) ) {  argument = argument.explode( '=' );
                                            data    += '&' + encodeURIComponent( argument[ 0 ] ) + '=' + encodeURIComponent( argument[ 1 ] );
          } else                            data    += '&' + encodeURIComponent( argument )      + '=true';   
        } else { // id[1]=argument or name[1..n]=argument or form[1]=argument    
          if( elements.length() > 1 )       data    += '&' + elements.get( 'x-www-form-urlencoded' );        
          else                              data    += '&' + encodeURIComponent( argument ) + '=' + encodeURIComponent( elements.get() );
    } } } 
    var indicator = document.getElements( connection[ 'indicator' ] ); 
    if( isSet( indicator ) && isSet( connection[ 'indicator.process' ] ) ) indicator.set( connection[ 'indicator.process' ] );
    
    connection[ 'ajax.driver' ]       = function () { 
      if( connection[ 'ajax.request' ].readyState == 4 ) {
        if( connection[ 'ajax.request' ].status == 200 ) {
          var response = unescape( connection[ 'ajax.request' ].responseText ); //alert( response );
          window[ 'InstantAJAX' ].abort( objectID, connection[ 'indicator.success' ] );
          eval(  response );            
        } else {
          window[ 'InstantAJAX' ].abort( objectID, connection[ 'indicator.error' ] );
          alert( 'ERROR: ' + connection[ 'ajax.request' ].status + '(' + connection[ 'ajax.request' ].statusText + ')' );
    } } }
    connection[ 'ajax.async' ]        = connection[ 'ajax.async' ].toBoolean();
    connection[ 'ajax.timeout' ]      = window.setInterval( "window[ 'InstantAJAX' ].abort( " + ( objectID ) + ", '" + connection[ 'indicator.timeout' ] + "' )", connection[ 'ajax.timeout' ] );
    if( connection[ 'ajax.async' ] == true ) connection[ 'ajax.request' ].onreadystatechange = connection[ 'ajax.driver' ];
    
    connection[ 'ajax.request' ].open( 'POST', url, connection[ 'ajax.async' ] == true );
    connection[ 'ajax.request' ].setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
    connection[ 'ajax.request' ].setRequestHeader( 'Accept', 'text/plain' );
    connection[ 'ajax.request' ].send( data.right( -1 ) ); // drop first '&'

    if( connection[ 'ajax.async' ] == false ) connection[ 'ajax.driver' ]();
    return objectID;
  }
  this.abort       = function abort( connectionID, icon ) { 
                                                                          this.connections  = window.InstantAJAX.connections;
    if( connectionID >= this.connections.length )                         return;
    if( isSet( this.connections[ connectionID ][ 'ajax.timeout' ] ) )     window.clearInterval( this.connections[ connectionID ][ 'ajax.timeout' ] );
    if( isSet( this.connections[ connectionID ][ 'ajax.request' ] ) )     this.connections[ connectionID ][ 'ajax.request' ].abort();
                                                                          this.connections[ connectionID ][ 'ajax.request' ] = null;
    if( !isSet( icon ) ||  icon.isEmpty() )                               icon = this.connections[ connectionID ][ 'indicator.abort' ];    
    if(  isSet( icon ) && !icon.isEmpty() && document.getElements( this.connections[ connectionID ][ 'indicator' ] ) ) 
      document.getElements( this.connections[ connectionID ][ 'indicator' ] ).set( icon );
      
    while( !this.connections.isEmpty() && !isSet( this.connections.top()[ 'ajax.request' ] ) ) this.connections.pop();
  } 
  this.cookie      = function( name )               { 
    this.get      = function()                      { 
      if( !window.document.cookie ) window.document.cookie = '';
      var records = new Array(),
          tokens  = window.document.cookie.explode( '; ' );
      for( var i = 0, I = tokens.length, parts = null; i < I; i++ ) {
        if( tokens[ i ].contains( '=' ) )             parts = tokens[ i ].explode( '=' ); else continue;
        if( parts.length == 2 )                       records[ parts[ 0 ] ] = parts[ 1 ];
      } return isSet( records[ _key ] ) ? decodeURIComponent( records[ _key ] ) : undefined;   
    }
    this.expire   = function( seconds )             { _expires = new Date(); _expires = new Date( _expires.getTime() + seconds * 1000 );                                            return this;  }
    this.path     = function( path )                { _path    = path;                                                                                                              return this;  }
    this.clear    = function()                      { window.document.cookie = _key + '=; expires=Mon, 1 Jan 1970 0:00:00 UTC';                                                     return this;  }
    this.set      = function( value )               { window.document.cookie = _key + '=' + encodeURIComponent( value ) + ';'
                                                                                          + ( isSet( _expires ) ? 'expires=' + _expires.toGMTString() + ';' : '' ) 
                                                                                          + ( isSet( _path )    ? 'path='    + _path + ';'                  : '' );                 return value; }
    var _key      = name,
        _path     = null,
        _expires  = null;
    return this;
  }
}
