﻿<!--
    function webServicesComponent() {
        function getXmlHttpRequest() {
	        var httpRequest = null;
    	    
	        try {
		        httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	        }
	        catch (e) {
		        try {
			        httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
		        }
		        catch (e) {
		            try {
		                httpRequest = new XMLHttpRequest();
		            }
		            catch (e) {
			            httpRequest = null;
			        }
		        }
	        }    
        	
	        return httpRequest;
        }
        
        function sendRequest(url, method, data, async, stateChangeCallback) { 
	        var xmlHttpReq = getXmlHttpRequest(); 

	        if (!xmlHttpReq)
		        return;

	        xmlHttpReq.open("POST", url, async);
	        
            xmlHttpReq.onreadystatechange = function() {
		        stateChangeCallback(xmlHttpReq);
		        };
		        
	        xmlHttpReq.setRequestHeader('Content-Type', 'application/soap+xml; charset=utf-8');
	        xmlHttpReq.send(createSoapXml(method, data));
        }
        
        function createSoapXml(method, data) {
            soapXml = '<?xml version="1.0" encoding="utf-8"?>';
            soapXml += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">';
            soapXml += '<soap:Body>';
            soapXml += '<' + method + ' xmlns="http://tempuri.org/">';
            soapXml += data;
            soapXml += '</' + method + '>';
            soapXml += '</soap:Body>';
            soapXml += '</soap:Envelope>';

            return soapXml;
        }
        
        function execOnSuccess(stateChangeCallback) {
	        return function(xmlHttpReq) {
			            if (xmlHttpReq.readyState == 4 && xmlHttpReq.status == 200)
				            stateChangeCallback(xmlHttpReq);
		            };
		}
		
		function getNodeValue(xmlHttpReq, nodeName) {
		    var responseText = xmlHttpReq.responseText;
		    
            if (responseText.indexOf(nodeName) > 0 && responseText.indexOf(nodeName) != responseText.lastIndexOf(nodeName)) {
		        return responseText.substring(responseText.indexOf(nodeName) + nodeName.length + 1, responseText.lastIndexOf(nodeName) - 2);
		    }
		    else {
		        return '';
		    }
		}	
        
        this.getXmlHttpRequest = getXmlHttpRequest;
        this.sendRequest = sendRequest;
        this.execOnSuccess = execOnSuccess;
        this.getNodeValue = getNodeValue;
    }
    
    var wsComponent = new webServicesComponent();
//-->


