/* demo functions for dialogs.js */

// alert box test function
function testalert_ok()
{
	dialogsjs._get('sandbox').innerHTML = 'You clicked the OK or Cancel button of the alert box.';
}

// confirm box test functions
function testconfirm_ok()
{
	dialogsjs._get('sandbox').innerHTML = 'You clicked the OK button of the confirm box.';
}

function testconfirm_cancel()
{
	dialogsjs._get('sandbox').innerHTML = 'You clicked the Cancel button of the confirm box.';
}

// prompt box test functions
function testprompt_ok()
{
	dialogsjs._get('sandbox').innerHTML = 'The value of the prompt box is: ' + dialogsjs.getpromptvalue() + '.';
}

function testprompt_cancel()
{
	dialogsjs._get('sandbox').innerHTML = 'You clicked the Cancel button of the prompt box.';
}

// form validation example
window.onload = function()
{
	
	var formname = dialogsjs._get('name');
	var formemail = dialogsjs._get('email');
	var message = dialogsjs._get('message');
	document.forms[0].onsubmit = function()
	{
		if(formname.value == '')
		{
			dialogsjs.showalert('Please, type name in the input box.', '');
			return false;
		}
		if(formemail.value == '')
		{
			dialogsjs.showalert('Please, type email in the input box.', '');
			return false;
		}
		if(message.value == '')
		{
			dialogsjs.showalert('Please, type message in the input box.', '');
			return false;
		}
		else
		{
			dialogsjs.showconfirm('Would you like to send the form now?', 'sendform()', '');
			return false;
		}
	}
}

function sendform()
{
	window.setTimeout(function(e)
	{
		dialogsjs.showalert('Thank you!', '');
	}, 1);
}