/*


	BCAnonymousLogin
	
	---------------------------------------------------------------------------------------------------------------------------------------------------

*/



	function BCAnonymousLogin(options)
	{
		
		var o = jQuery.extend({
			type: 'post',
			url: '/ZoneProcess.aspx?ZoneID=-1',
			username: 'anonymous',
			password: 'password',
			errorFlag: 'secure zone access denied',
			connectionErrorMessage: 'There has been an error with the connection. Please refresh your browser window and try again.',
			errorMessage: 'The username and/or password is/are incorrect. Please verify and try again.',
			success: function(){},
			error: function(){alert(o.errorMessage);},
			connectionError: function(){alert(o.connectionErrorMessage);},
			timeout: (10 * 1000)				
		},options);
		
		//If JSON parameter has not been specified
		if(o.url.indexOf('JSON=1') == -1)o.url = o.url + '&JSON=1'; 
		
		var oTimeout = null;
		var oCall = null;
		
		function loginSuccesful(e)
		{
			return(e.toLowerCase().indexOf(o.errorFlag) == -1);	
		}
		
		
		oCall = jQuery.ajax({
			type: o.type,
			url: o.url,
			data: ('Username=' + encodeURIComponent(o.username) + '&Password=' + encodeURIComponent(o.password)), 
			success: function (e) { 
				if(oTimeout)
				{
					clearTimeout(oTimeout);
					oTimeout = null;	
				}
				if(loginSuccesful(e))
				{
					o.success(e);
				} else {
					o.error(e);	
				}
			},
			error: function (e) {
				if(oTimeout)
				{
					clearTimeout(oTimeout);
					oTimeout = null;	
				}
				o.connectionError(e);					
			}
		});

		oTimeout = setTimeout(function(){oCall.abort();},o.timeout);
			
	}
	


















