// JavaScript Document
var ereFORM = false;
// ***********************************************************************************************************************
function js__applyClass(_this)
{
	var _value = $("#" + _this).val();
	$("#m_Classification").val(_value);
	switch(_value)
	 {
		 case "Professional":
		 	$("#m_Total").val(50);
		 break;
		 
		 case "Retiree":
		 	$("#m_Total").val(15);
		 break;
		 
		 case "Student":
		 	$("#m_Total").val(20);
		 break;
		 
		 case "Sr_Student":
		 	$("#m_Total").val(35);
		 break;
	 }
}
// ***********************************************************************************************************************
function js__applyDuration(_duration)
{
	$("#m_Total").val(_duration);
}
// ***********************************************************************************************************************
function jsf_Next(_to, _group, _objtype)
{
	$('*[name=' + _group + ']').each(function()
								{ 
									// Test if a required field has no data then set the error flag to true and exit the loop.
									if($(this).val().length == 0)
									 {
										errFORM = true;
										$(this).addClass("ui-state-error");
										if(_objtype != "text")
										{
											$('#div_' + _group).html(ERR_IMG + ' You must make one selction at least.');
										}
										else
										{
											$('#div_' + _group).html(ERR_IMG + ' Missing field in red. Please provide.');
										}
										setTimeout(function()
															{
																$('#div_' + _group).html("");
																AJAXERROR = false;
																
															}, 4000);
										 //$("#accordion").accordion("disable");
										return false; 
									 }
									 errFORM = false;
						}); 
	
	if(errFORM)
	{
		return;	
	}
	$("#" + _to).show('fast');
	$("#accordion").accordion( "activate" , _to);
	$("#accordion").accordion({
								animated: 'easeslide'

								});
}
// ***********************************************************************************************************************			
function js__CreateEmploymentLevel()
{
	var _array = "";
	$("input:checkbox[name=EmpInfo]:checked").each(function()
	{
		if(_array.length == 0)
		 {
			 _array = $(this).val();
		 }
		else
		 {
			 _array += ", " + $(this).val();
		 }
		// add $(this).val() to your array
	});	
	$("#m_EmploymentLevel").val(_array);
}
// ***********************************************************************************************************************
function js__CreateSpecilization()
{
	var _array = "";
	$("input:checkbox[name=Spec]:checked").each(function()
	{
		if(_array.length == 0)
		 {
			 _array = $(this).val();
		 }
		else
		 {
			 _array += ", " + $(this).val();
		 }
		// add $(this).val() to your array
	});	
	$("#m_Specialization").val(_array);
	
}
// ***********************************************************************************************************************
function js__CreateInterests()
{
	var _array = "";
	$("input:checkbox[name=Int]:checked").each(function()
	{
		if(_array.length == 0)
		 {
			 _array = $(this).val();
		 }
		else
		 {
			 _array += ", " + $(this).val();
		 }
		// add $(this).val() to your array
	});	
	$("#m_Interests").val(_array);
}
// ***********************************************************************************************************************
function js__Wrapper()
{
											$('*[name=EmpInfo]').bind("click", 
														function(e)
															{
																js__CreateEmploymentLevel();
															}
													);
											
											$('*[name=Spec]').bind("click", 
														function(e)
															{
																js__CreateSpecilization();
															}
													);

											$('*[name=Int]').bind("click", 
														function(e)
															{
																js__CreateInterests();
															}
													);

$("#m_InitYear").numeric();
$("#m_Zip").numeric();
$("#m_Phone").numeric();
$("#EmployeePhone").numeric();
$("#m_CreditCardNumber").numeric();
$("#m_CCcode").numeric();
//$("#m_Phone").mask("(999)999-9999");
//$("#m_EmployeePhone").mask("(999)999-9999");

// Credit Card Validation
$("#m_CreditCardNum").numeric();
$("#m_CCcode").numeric();
$("#m_CreditCardExpDate").numeric();
$("#m_CreditCardExpDate").mask("99/99");


$("#CopyAddress").click(function(){js__CopyBillingAddress();});




}

function js__CopyBillingAddress()
{
//alert("copy");
	if ($('#CopyAddress').attr('checked')) 
	{
	    $('#m_CreditCardAddress').val($("#m_Address").val()); 
		$('#m_CreditZipCode').val($("#m_Zip").val());
	}
	else
	{
	    $('#m_CreditCardAddress').val(""); 
		$('#m_CreditZipCode').val("");
	}

}

