/**
 * !!! NOTE: This file is only for testing atmail online demo AND
 * !!! Should NOT be used as production code
*/

function atmail_a6demo_login() {
	// Check if we can login ( does our cookie work? )	
	var authUrl = "../../index.php/mail/auth/processlogin";
	var params = {
		MailType	: 'IMAP',
		email		: 'demo@demo.atmail.com',
		password	: 'demo',
		emailDomain : 'demo.atmail.com',
		emailName	: 'demo',
		expectJson	: 1,
		expectSettings : 0,
		requestedServer : 'demo.atmail.com'
	};
	
	$.getJSON(authUrl, params, function(json) { 
		if ( json ) { 
			if(json.auth == 'success') {
				document.location.reload(1);
			} else {
			}
		}
		
	});	
	
}

function atmail_a6demo_checkauth() {
	var authUrl = "../../index.php/api/mail/auth";
	var params = { format: 'json' };

	$.getJSON(authUrl, params, function(json) { 
		if ( json ) { 

			if(json.message == 'OK') {
			} else {
				atmail_a6demo_login();
			}
		}
		
	});
}

atmail_a6demo_checkauth();