function PW( theAppID )
{
	this.appID= theAppID;
	this.services= this;
	this.accessToken= "";
	this.redirectURI= "";
}

PW.prototype.init = function ( theAccessToken)
{	
	console.log( "PW::init accessToken=" + theAccessToken );
	this.accessToken= theAccessToken;
}

PW.prototype.getAPI = function ()
{
	return this;
}
PW.prototype.setRedirect = function ( theURL )
{
	this.redirectURI= theURL;
}

PW.prototype.setAccessToken = function ( theAccessToken )
{
	console.log( "PW::setAccessToken called accessToken=" + theAccessToken );
	this.accessToken= theAccessToken;
}

PW.prototype.getAccessToken = function ()
{
	console.log( "PW::getAccessToken called accessToken=" + this.accessToken );
	return this.accessToken;
}

PW.prototype.getAppID = function ()
{
	return this.appID;
}


PW.prototype.showSignInBox = function()
{
	var url= "http://www.playwala.com/app/dialog";
	
	url += "?pw_app_id=" + this.appID;
	
	if( this.accessToken != "")
		url += "&pw_access_token=" + this.accessToken;
	
	if( this.redirectURI != "")
		url += "&pw_redirect_uri=" +encodeURIComponent(this.redirectURI);
	
	w= window.open( url, 'Login', 'width=400,height=200');
	if( window.focus )
	{
		w.focus();
	}	
}

PW.prototype.showLogoutBox = function()
{
	var url= "http://www.playwala.com/app/logout";
	
	url += "?pw_app_id=" + this.appID;
	
	if( this.accessToken != "")
		url += "&pw_access_token=" + this.accessToken;
	
	if( this.redirectURI != "")
		url += "&pw_redirect_uri=" +encodeURIComponent(this.redirectURI);
	
	w= window.open( url, 'Logout', 'width=400,height=200');
	if( window.focus )
	{
		w.focus();
	}	
}

PW.prototype.showRegisterBox = function()
{
	var url= "http://www.playwala.com/app/register";
	
	url += "?pw_app_id=" + this.appID;
	
	if( this.accessToken != "")
		url += "&pw_access_token=" + this.accessToken;
	
	if( this.redirectURI != "")
		url += "&pw_redirect_uri=" +encodeURIComponent(this.redirectURI);
	
	w= window.open( url, 'Register', 'width=800,height=650');
	if( window.focus )
	{
		w.focus();
	}	
}

PW.prototype.showDonateBox = function()
{
	var url= "http://www.playwala.com/donate/dialogcause/";
	
	url += "?pw_app_id=" + this.appID;
	
	if( this.accessToken != "")
		url += "&pw_access_token=" + this.accessToken;
	
	if( this.redirectURI != "")
		url += "&pw_redirect_uri=" +encodeURIComponent(this.redirectURI);
	
	w= window.open( url, 'Donate', 'width=400,height=200');
	if( window.focus )
	{
		w.focus();
	}	
}
