// This JavaScript was automatically generated by
// GpsGate.WebService.Json.JsonRpcCrossSiteProxyGenerator, GpsGate.WebService.Json, Version=1.1.0.308, Culture=neutral, PublicKeyToken=null
// on Friday, October 12, 2007 at 7:35:50 AM (Pacific Daylight Time)

var login_callback;
var register_callback;
var listMethods_callback;
var version_callback;
var about_callback;

function Auth(url)
{
    this["login"] = function(strUsername, strPassword, callback)
    {
        login_callback=callback;
        xssCall("login", { 'strUsername':strUsername, 'strPassword':strPassword });
    }
    
    this["register"] = function(iBTAppId, strUsername, strEmail, strName, strSurname, strPassword, callback)
    {
        register_callback=callback;
        xssCall("register", { 'iBTAppId':iBTAppId, 'strUsername':strUsername, 'strEmail':strEmail, 'strName':strName, 'strSurname':strSurname, 'strPassword':strPassword });
    }
    
    // Returns an array of method names implemented by this service.
    
    this["listMethods"] = function(callback)
    {
        listMethods_callback=callback;
        xssCall("system.listMethods", { });
    }
    
    // Returns the version server implementation using the major, minor, build and revision format.
    
    this["version"] = function(callback)
    {
        version_callback=callback;
        xssCall("system.version", { });
    }
    
    // Returns a summary about the server implementation for display purposes.
    
    this["about"] = function(callback)
    {
        about_callback=callback;
        xssCall("system.about", { });
    }
    
    var url = typeof(url) === 'string' ? url : 'http://apps.gpsgate.com/Services/Auth.ashx';
    
	function xssCall(method, params)
	{
		var callUrl = url + '/' + method + '?jsonp=' + method.replace('system.', '') + '_callback' + buildParams(params);	
		
		var obj= new JSONscriptRequest(callUrl);
		obj.buildScriptTag();     
		obj.addScriptTag();
	}

	function buildParams(arrParams)
	{
		var strParams = '';
		
		for(prop in arrParams)
		{
			strParams += '&' + prop + '=' + arrParams[prop];
		}
		
		return strParams;
	}

	function JSONscriptRequest(fullUrl) 
	{
	    this.fullUrl = fullUrl; 
	    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
	    this.headLoc = document.getElementsByTagName('head').item(0);
	    this.scriptId = 'YJscriptId' + JSONscriptRequest.scriptCounter++;
	}

	JSONscriptRequest.scriptCounter = 1;
	JSONscriptRequest.prototype.buildScriptTag = function () 
	{
	    this.scriptObj = document.createElement('script');
	    this.scriptObj.setAttribute("type", "text/javascript");
	    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
	    this.scriptObj.setAttribute("id", this.scriptId);
	}
	 
	JSONscriptRequest.prototype.removeScriptTag = function () 
	{
	    this.headLoc.removeChild(this.scriptObj);  
	}

	JSONscriptRequest.prototype.addScriptTag = function () 
	{
	    this.headLoc.appendChild(this.scriptObj);
	}
}

Auth.rpcMethods = ["login","register","listMethods","version","about"];
