function ServiceManager()
{
	this.errorCode	= null;
	this.errorMsg	= null;
	this.urlDefault	= null;
}

ServiceManager.prototype.request = function( serviceID, param, paramType )
{
	//Atualiza a URL de Destino 
	var strLocation = this.urlDefault;
		strLocation+= (strLocation.indexOf("?") == -1)?"?":"&";
		strLocation+= "ServiceId=" + serviceID;

	if( paramType == eParamType.nameValue && param != null )
	{
		if( typeof(param) == "string" || param == "object Text" )
		{	
			strLocation+= (param != "")?"&" + param : "";
		}
		else 
		{
			for(var i=0; i < param.length; i++)
			{
				strLocation += "&" + param[i];
			}
		}
	}

	var xmlHTTP = null;
	var xmlDoc	= null;
	
	//Chama URL informada
	if (window.XMLHttpRequest) 
	{
		xmlHTTP = new XMLHttpRequest();
		xmlHTTP.open("GET", strLocation, false);
		xmlHTTP.send( ( eParamType.xml == paramType)?param:null );
		
		xmlDoc = xmlHTTP.responseXML;

		if( this.isParseError(xmlDoc) == true )
		{
			this.errorCode	= "9999";
			this.errorMsg	= "Arquivo inválido !";
		}
		else
		{
			this.errorCode	= xmlDoc.documentElement.getAttribute("ErrorCode");
			this.errorMsg	= xmlDoc.documentElement.getAttribute("ErrorDesc");
		}
	} 
	else if( window.ActiveXObject )
	{
		xmlHTTP = createXmlHttpActiveX();//new ActiveXObject("Microsoft.XMLHTTP");
		if( xmlHTTP ) 
		{
			xmlHTTP.open("GET", strLocation, false);
			xmlHTTP.send( ( eParamType.xml == paramType )?param:null );
			
			xmlDoc = createXmlDomActiveX();//new ActiveXObject("Microsoft.XMLDOM")
			xmlDoc.async = false;
			xmlDoc.validateOnParse = true;
			xmlDoc.loadXML( xmlHTTP.responseText );
			
			if( xmlDoc.parseError.errorCode != 0 )
			{
				this.errorCode	= xmlDoc.parseError.errorCode;
				this.errorMsg	= xmlDoc.parseError.reason;
			}
			else
			{
				this.errorCode	= xmlDoc.selectSingleNode("//ROOT/@ErrorCode").text;
				this.errorMsg	= xmlDoc.selectSingleNode("//ROOT/@ErrorDesc").text;
			}
		}
	}

	return xmlDoc;	
}

ServiceManager.prototype.isParseError = function(doc) 
{
   return (doc.parseError!=null && doc.parseError.errorCode!=0) || (doc.documentElement.tagName=='parsererror' && doc.documentElement.namespaceURI=='http://www.mozilla.org/newlayout/xml/parsererror.xml') || (doc.documentElement == null);
}


