/**
 * AreaMap module scripts for provider settings form
 *
 * @copyright (c) 2004-2007, SWsoft
 */
function refreshAreaMapProvidersForm(radio) {
	var googleForm = self.document.getElementById('areaMapProviderForm_google');
	var msmpForm = self.document.getElementById('areaMapProviderForm_msmp');
	
	switch (radio.value) {
		case 'google':
			msmpForm.style.display = 'none';
			googleForm.style.display = 'block';
			break;

		case 'msmp':
			msmpForm.style.display = 'block';
			googleForm.style.display = 'none';
			break;
		
		default:
			msmpForm.style.display = 'none';
			googleForm.style.display = 'none';
	}
}

function onSubmitAreaMapProvidersForm() {
	var formObject = self.sbEditorObject.getFormObject();
	var radio = null;
	for (var i = 0; i < formObject.areaMapProvider.length; i++) {
		if (formObject.areaMapProvider[i].checked) {
			radio = formObject.areaMapProvider[i];
			break;
		}
	}

	var result = true;
	if (radio) {
		switch (radio.value) {
			case 'google':
				result = validateField('SB_Validator.notEmpty', 'google_key', 'EMPTY-GOOGLE-KEY');
				break;

			case 'msmp':
				result = validateField('SB_Validator.notEmpty', 'mmp_login', 'EMPTY-LOGIN') &&
					validateField('SB_Validator.notEmpty', 'mmp_password', 'EMPTY-PASSWORD');
				break;
			
			default:
				alert('internal SiteBuilder error: AreaMap provider is not defined');
		}
	
	}
	return result;
}