var currentForm = "GeneralInquiry";
var isAccountInfoVisible = false;

$(function(){
	$('.datebox').datepicker({
			showOn: 'button',
			buttonImage: '../_images/template/button_calendar.gif',
			buttonImageOnly: true
		});
});

function changeForm(value) {
	var idBase = value.replace(' ','');
	idBase = idBase.replace(' ','');
	$('#' + currentForm + 'Sub').hide();
	$('#' + currentForm + 'Form').hide();
	
	if(idBase == 'CustomerService' || idBase == 'BusinessQuestion' || idBase == 'ChangeofAddress') {
		$('#AccountInfoForm').show();
		isAccountInfoVisible = true;
	}else{
		$('#AccountInfoForm').hide();
		isAccountInfoVisible = false;
	}
	
	$('#' + idBase + 'Sub').show();
	$('#' + idBase + 'Form').show();
	currentForm = idBase;
}

function validateForm()
{
	var reqFields = $('#generalFields .requiredField input');
	var formValid = true;
	
	// General Information Fields
	for(var i = 0; i< reqFields.length; i++) {
		var value = $(reqFields[i]).val();
		if(value == null || value == '') {
			formValid = false;
			$(reqFields[i]).addClass('failed');
		}
	}
	
	if (String(isAccountInfoVisible) == 'true') {
		reqFields = $('#AccountInfoForm .requiredField input');
		for(var i = 0; i< reqFields.length; i++) {
			var value = $(reqFields[i]).val();
			if(value == null || value == '') {
				formValid = false;
				$(reqFields[i]).addClass('failed');
			}
		}	
	}
	
	reqFields = $('#' + currentForm + 'Form .requiredField input');
	for(var i = 0; i< reqFields.length; i++) {
		var value = $(reqFields[i]).val();
		if(value == null || value == '') {
			formValid = false;
			$(reqFields[i]).addClass('failed');
		}
	}
	if(formValid == false) {
		$('.errorMessage').show();
	}
	return formValid;
}

