function submit_encrypt() {
	 if (document.getElementById('message').value == '') {
		alert('Error: Please Enter Your Message');
		document.getElementById('message').focus();

		return;
	}

	document.getElementById('encrypt_form').submit();
}

function message_update() {
	document.getElementById('message').value = document.getElementById('message').value.substring(0, 1024);
	document.getElementById('characters_left').innerHTML = (1024 - document.getElementById('message').value.length) + ' Characters Left';
}

function submit_decrypt() {
	 if (document.getElementById('img_file').value == '') {
		alert('Error: Please Select a File to Decrypt');
		document.getElementById('img_file').focus();

		return;
	}

	document.getElementById('decrypt_form').submit();
}

function check_for_errors() {
	var error = getQueryVariable('error');
	if (!error)
		return;

	switch(error) {
	case 'missing_info':
		alert('Error: Your browser did not submit all the required information. Please try again.');
		break;
	case 'invalid_size':
		alert('Error: The image you tried to upload was too large. Please try a smaller picture.');
		break;
	case 'missing_image':
		alert('Error: You failed to upload a an image. Please select one using the \'browse\' button at the top right and try again.');
		break;
	case 'upload_failure':
		alert('Error: The image you selected failed to upload completely. Please try again.');
		break;
	case 'database_failure':
		alert('Error: Sorry! Our database returned an error. Our bad. Please try again.');
		break;
	case 'invalid_type':
		alert('Error: The image that you tried to upload was an invalid type. mozaiq only accepts JPEG\'s/JPG\'s or PNG\'s. Please try a different picture.');
		break;
	case 'invalid_format':
		alert('Error: The image that you tried to decrypt does not appear to have a message in it. It is possible that you entered the incorrect password. Please try again.');
		break;
	default:
		alert('An unknown error has occured. Please try again.');
		break;
	}
}
