var requests = new Array();
	var	_array = new Array();
if(typeof(XMLHttpRequest) == 'undefined')
var XMLHttpRequest = function()
{
	var request = null;
	try
	{
		request = new ActiveXObject('Msxml2.XMLHTTP');
	}
	catch(e)
	{
		try
		{
			request = new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch(ee)
		{ 
		} 
	}
	return request;
}

function ajax_create_request(context)
{
   
   
	for(var i=0; i<requests.length; i++)
	{
		if(requests[i].readyState == 4)
		{
			requests[i].abort();
			requests[i].context = context;
			return requests[i];
			
		}
	}

	var pos = requests.length;
    requests[pos] = Object();
	requests[pos].obj = new XMLHttpRequest();
	requests[pos].context = context;
	
	return requests[pos];
	
	
}

function ajax_request(url, data, callback, context)
{
	var request = ajax_create_request(context);
	var async = typeof(callback) == 'function';
	if(async) request.obj.onreadystatechange = function()
	{
		if(request.obj.readyState == 4)
			callback(new ajax_response(request));
	}
	
	if(data != null)
	{
		request.obj.open('POST', url, async);
	}
	else
	{ 
		request.obj.open('GET', url, async);
	}
	request.obj.send(data);
	
	if(!async)
		return new ajax_response(request);
}

function ajax_response(request)
{
	this.request = request.obj;
	this.error = null;
	this.value = null;
	this.context = request.context;
	if(request.obj.status == 200)
	{
		try
		{
			this.value = request.obj.responseText;
			if(this.value && this.value.error)
			{
				this.error = this.value.error;
				this.value = null;
			}
		}
		catch(e)
		{
			this.error = true;
		}
	}
	else
	{
		this.error = true;
	}
	
	return this;
}
	/************ the threads javascript ********/
	
	function CallXMLHTTP ( url, method, callback, index ) {
	    
	  
	   
	    
		try {
			var sVars = null;
			
			if ( method == "POST" ) {
				var rmatch = /^([^\?]*)\?(.*)$/.exec ( in_url );
				in_url = rmatch[1];
				sVars = unescape ( rmatch[2] );
			}
			_array[index]['request_object'] = new XMLHttpRequest();
			_array[index]['request_object'].open(method, url, true);
			
			if ( method == "POST" ) {
			    
				_array[index]['request_object'].setRequestHeader("Method", "POST "+url+" HTTP/1.1");
				_array[index]['request_object'].setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			}
		
			_array[index]['request_object'].onreadystatechange = callback;
		
			_array[index]['request_object'].send(sVars);
		
			
			return true;
		} catch ( z ) {
		   
		}
		
		return false;
	};
	
	
	function MakeNewCall(url, callback, method){
	
	
		if(!method){
			method = "GET";
		}
		var i = 1;	
	
		while(_array[i]&&
		       (typeof(_array[i])!='undefined')){
		        i++};
	
		_array[i] = new Array();
		_array[i]['request_callback'] = callback;
		_array[i]['request_method'] = method;
		
	    
		var funcbody = 'var index='+i+';';
		funcbody += 'var stage=_array[index]["request_object"].readyState;';
		funcbody += 'var resp="";';
		funcbody += 'if(stage==4){ resp=_array[index]["request_object"].responseText};';
		funcbody += 'if((stage==4) && _array[index]["request_callback"]){';
		funcbody += '_array[index]["request_callback"](resp); };';
		funcbody += 'if(stage==4){';
		funcbody += 'if(_array[index]["timeout_t"]){clearTimeout(_array[index]["timeout_t"])};';
		funcbody += '_array[index]["request_object"]=null;';
		funcbody += '_array[index]["request_callback"]=null;';
		funcbody += '_array[index]["request_method"]=null;';
		funcbody += '_array[index]["callback"]=null;';
		
		funcbody += '_array[index]=null;';
		
		funcbody += "}";
		
		_array[i]['callback'] = new Function (funcbody);
		
		var ret = null;
		
		if(CallXMLHTTP ( url, method, _array[i]['callback'], i )){
		    
			ret = i;
		}
		
		return ret;
	};
	
		function CallSearcherWS ( uri, callback, method) {
			if ( (typeof method == 'undefined') || ((method != 'GET')&&(method != 'POST')) ) {
				method = 'GET';
				}
			
			method = method.toUpperCase();
			
			if ( (typeof uri != 'undefined') && uri && (typeof callback == 'function') ) {
				return MakeNewCall ( uri, callback, method);
				}
			else {
				return false;
				}
		}
		
		
	function CalleJScriptAcitf(){
      
      var wSearviceArray = new Array();
      wSearviceArray[0]="wservicesshow";
      wSearviceArray[1]="wservicesaudioondemand";
      wSearviceArray[2]="wservicesvideoondemand";
      for(var i=0; i<wSearviceArray.length; i++){
            var wservices = document.getElementById(wSearviceArray[i]);
            if (wservices!=null) {
	            var visible =  wservices.style.visibility;
	            if(visible!="visible"){
	       			wservices.style.visibility= "visible";
	       			wservices.style.display = "block";
	       		}
	       	}
      }
	};
