/**
 *
 */
function ETrack(handler)
{
	this.handler = handler;
	
	this._addEvent = function(eventID, msg, msg_add)
	{
		var f = {};
		f.event_id = eventID;
		f.msg = msg;
		f.msg_add = msg_add;
		
		this.getSContent(this.handler, 1, f);
	}
	
	// -----------------------------
	
	/**
	 *	
	 */
	this.getHTTP = function()
	{    
		var xmlHttp = false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		try 
		{
		  xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
		} 
		catch (e) 
		{
		  try 
		  {
		    xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
		  } 
		  catch (e2) 
		  {
		    xmlHttp = false;
	  	  }
		}
		@end @*/
		
		if (!xmlHttp && typeof XMLHttpRequest != 'undefined') 
		{
			xmlHttp = new XMLHttpRequest();
		}
		
		return xmlHttp;
	}
	
	// -----------------------------
	
	/**
	 *	
	 */
	this.getSContent = function(url, type, obj)
	{
		var paramStr = this.getParamStr(obj);
		
		url = url + "?" + paramStr;
		
		http = this.getHTTP();
		http.open("GET", url, false);
		http.send(null);
	
		return this.getResponse(http, type);
	}
	
	// -----------------------------
	
	/**
	 *	
	 */
	this.getASContent = function(url, type, obj)
	{
		var paramStr = this.getParamStr(obj);
		
		url = url + "?" + paramStr;
		
		http = this.getHTTP();
		http.open("GET", url, true);
		http.onreadystatechange = function () 
		{
			if (http.readyState == 4 && http.status == "200") 
			{   
		    	if(type == 2) 
				{
					return http.responseXML;
				}
				
				return http.responseText;
			}
		}

		http.send(null);
	}	
	
	// ------------------------------
	
	/**
	 *	
	 */
	this.getParamStr = function(obj)
	{
		var paramStr = "";
		
		var i = 1;
		for (var key in obj) 
		{
			if(i > 1) { paramStr += "&"; }
			paramStr += key + "=" + encodeURIComponent(obj[key]);
			i++;
		}
	
		return paramStr;
	}
		
	// ------------------------------
	
	/**
	 *	
	 */
	this.getResponse = function(http, type)
	{
		if (http.readyState == 4 && http.status == "200") 
		{   
	    	if(type == 2) 
			{
				return http.responseXML;
			}
			
			return http.responseText;
		}
		
		return "";
	}


	// -----------------------------
	
}

var etrack = new ETrack('/etrack/etrack.php');

