var cInd = new Array();
var fObj = new Array();

var ajaxConReq = null;
var curajaxConReq = 0;
var curProcImg = null;
var allCountClips = 0;

var isAXObj = false;
isAXObj = window.ActiveXObject ? true : false;

function getAObj()
{
	var tmp = isAXObj == true ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
	return tmp;
}

var ajax = function()
{
	this.request = null;
	this.callback = null;
	this.cbparams = null;
	
	this.getData = function(path, toObj)
	{
		this.request = getAObj();
		var selfObj = this;
		
		this.request.onreadystatechange = function() 
		{
			if(selfObj.request.readyState == 4 && selfObj.request.status == 200)
			{
				if(typeof(selfObj.callback) == 'function') 
				{
					if(selfObj.callback(selfObj.request, selfObj.cbparams)) toObj.innerHTML = selfObj.request.responseText;
				}
				else toObj.innerHTML = selfObj.request.responseText;	
			}
		}
		
		try
		{
			this.request.open("GET", path, true);
			this.request.send(null);	
			this.loadingFunc(toObj);
		}
		catch(Exception){alert(Exception.message);}
	}
	
	this.postData = function(path, data, toObj)
	{
		this.request = getAObj();
		var selfObj = this;
		
		this.request.onreadystatechange = function() 
		{
			if(selfObj.request.readyState == 4 && selfObj.request.status == 200)
			{
				if(typeof(selfObj.callback) == 'function') 
				{
					if(selfObj.callback(selfObj.request, selfObj.cbparams)) toObj.innerHTML = selfObj.request.responseText;
				}
				else toObj.innerHTML = selfObj.request.responseText;	
			}
		}
		
		try
		{
			this.request.open("POST", path, true);
			this.request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			this.request.send(data);	
			this.loadingFunc(toObj);
		}
		catch(Exception){alert(Exception.message);}
	}
	
	this.loadingFunc = function(toObj)
	{
		toObj.innerHTML = '<b class="small">Loading</b>';
	}
}


function checkXmlErrors(o, callback)
{
    var err_mes = '';
    var tmp = o.responseXML.getElementsByTagName('error_messages');
    if(tmp.length > 0)
	{
		tmp = tmp[0];
		for(i=0;i<tmp.childNodes.length;i++) err_mes += (isAXObj == true ? tmp.childNodes[i].text : tmp.childNodes[i].textContent) + "\n";
		if(err_mes != '') 
		{
			alert(err_mes);
			if(callback && typeof(callback) == 'function') callback();
		}	
		return true;
	}	
	return false;
}
