/* © 2006 Craig Nuttall - All rights reserved.  Released under the GNU Public License. */
var cows_ajax_connections;function request_queue_node(x,e){this.r=x;this.e=e;this.z=false;};function cows_ajax(d){if(!cows_ajax_connections){cows_ajax_connections=new Array();};this.ab='5.0';this.q=100;this.u=100;this.k=20000;this.server_url=(d.server_url)?d.server_url:'';this.success_handler=this.i(d.success_handler,'success');this.failure_handler=this.i(d.failure_handler,'failure');this.display_processing_message=d.display_processing_message;this.debug_handler=d.debug_handler;this.b=null;this.a=new Array();this.h=-1;this.w=0;this.v=true;this.j=null;};cows_ajax.prototype.i=function(param_handler_setting,type){if(param_handler_setting){return(param_handler_setting=='none')?null:param_handler_setting;}else{throw new Error("ERROR: undefined "+type+" handler function.  Connection not established");};};cows_ajax.prototype.check_cows_ajax_aware=function(success_command,fail_command){};cows_ajax.prototype.g=function(s){if(this.b!=null){};this.b=document.createElement('SCRIPT');this.b.src=s;this.b.type='text/javascript';var aa=document.getElementsByTagName('HEAD')[0];aa.appendChild(this.b);};cows_ajax.prototype.l=function(){this.b.parentNode.removeChild(this.b);this.b=null;};cows_ajax.prototype.connect=function(d){this.h=cows_ajax_connections.length;cows_ajax_connections.push(this);var s=this.f(d);this.g(s);this.c=this.y()+this.k;this.m();};cows_ajax.prototype.f=function(d){query_param=d.query_param;e=(d.e)?d.e:false;var x=this.server_url+query_param+'&connection_id='+this.h;this.a[this.a.length]=new request_queue_node(x,e);return x;};cows_ajax.prototype.send=function(d){this.f(d);this.m();};cows_ajax.prototype.send_immediate=function(d){this.f(d);this.o();};cows_ajax.prototype.o=function(){if(this.a.length<=0){return;};if((this.display_processing_message)&&(!this.a[0].e)){this.display_processing_message('on');};var p=this.a[0].r;parent.cows_ajax_response=null;this.g(p);this.c=this.y()+this.k;};cows_ajax.prototype.response_received=function(){if(this.display_processing_message){this.display_processing_message('off');};this.a.shift();this.c=null;this.l();if(this.success_handler){this.success_handler();};};cows_ajax.prototype.m=function(){if(this.j==null){this.j=window.setInterval('cows_ajax_connections['+this.h+'].poll()',this.q);};};cows_ajax.prototype.poll=function(){if(this.c){if(this.c<=this.y()){this.n();if(this.failure_handler){this.failure_handler('Server Timed Out');};}else if(parent.cows_ajax_response!=null){parent.cows_ajax_response();};}else if(this.a.length>0){this.o();};};cows_ajax.prototype.t=function(){this.a.length=0;};cows_ajax.prototype.n=function(){this.c=null;this.t();if(this.j){window.clearInterval(this.j);};this.j=null;};cows_ajax.prototype.disconnect=function(remove_iframe){this.n();};cows_ajax.prototype.y=function(){return(new Date()).getTime();};cows_ajax.prototype.debug=function(message){if(this.debug_handler){this.debug_handler(message);};};
