    /// <reference path="js/objService.js" />

    // Copyright P Capozzi - All rights reserved - May not be copied or used without express permission

    function Service(){
        this.ReturnFuncToCall; 
        this.RemoteFuncToCall; 
        this.qString ;
        this.Xurl;
    }

    Service.prototype.ReturnFuncToCall = retFunc;
    Service.prototype.RemoteFuncToCall = "";
    Service.prototype.qString = "";
    Service.prototype.Xurl = "";
   
    Service.prototype.AddPostValue = function(name,value)    // Define Method
    {    
        this.qString += "&" + name + "=" + value
    } 
    
	var retFunc = null
	
	//Xurl = "LocalServices.aspx"

	// Xurl -  is the remote page to call
	// retfuncToCall - is the local javascript function to call on sucessfull completion
	// functocall - is a string passed to the remote page to indicate the function to call at that end
	// qstring  - is the post data as name value pairs eg "&userid=" + somevalue 
	
	
	Service.prototype.CallService = function callService() {
 
		http_request = false;

		 if (this.Xurl == ""){
		    logService.Xurl = "LocalServices.aspx";
		 }  
 
		retFunc = this.ReturnFuncToCall
 
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
      
        http_request.onreadystatechange = HandleReady;
        http_request.open('POST', Xurl, true);
        // for post
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        http_request.send("process=" + this.RemoteFuncToCall + this.qString);

    }
    
    
    function HandleReady(){
 
		if (http_request==null )
				{ return; }
				
				
		if (http_request.readyState==4)
		{ 
		
			//alert("here")
			if (http_request.status == 200) {
				retFunc(http_request.responseText)
				//alert(http_request.responseText);
			} else {
				alert('There was a problem with the request.' + http_request.status);
			}
		
		}
    }
    
    
    
    function alertContents() {

        
        if (undefined != http_request){
   
			if (http_request.readyState == 4) {
				if (http_request.status == 200) {
					alert(http_request.responseText);
				} else {
					alert('There was a problem with the request.');
				}
			}
		}
    }
    
    
    
    // these are generic functions that pass out a comma deliminated array
    function xExecScalar(){
    
    
    }
    
    function xSPExecuteOnly(retfuncToCall,funcToCall,qString){
    
        if (window.XMLHttpRequest) { // Mozilla, Safari, ...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }
        http_request.onreadystatechange = retfuncToCall;
        http_request.open('POST', Xurl, true);
        // for post
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        http_request.send("process=" + funcToCall + qString);
    
    }
    
    function xGetDataSet(){
    
    
    }
    
    
    function geninsert(){
    
		if (http_request.readyState == 4) {
				if (http_request.status == 200) {
					if (http_request.responseText != "0"){
						alert("Soft XmlHttpError : " + http_request.responseText);
					}
					
				} else {
					alert('Hard XmlHttpError : status = ' + http_request.status);
				}
		}
    
		/*
		if(result.error) { 
			var xfaultstring = result.errorDetail.string; 
			alert("insert error : " + xfaultstring); 
		} 
		else { 
			if(result.value!=1){
				alert("insert fail (geninsert): " & result.value)
			} 
		}
		*/

}
    
    