// JavaScript Document
		var PAGE_ERROR = false;
		var ERROR = false;
		
		
function jsf_CreateDayTimeGroupSelection()
{
	$('#PROG_DAY_TIME').val('');
	var SELECTION = "";
	$('.chkDayTime').each(function()
								   	{
										if($(this).attr('id') == "program_daytime_dnm")
										{
											if($(this).attr('checked') == true)
											 {
												$('.chkDayTime').each(function()
																			   {
																				 $('#PROG_DAY_TIME').val("");  
																				 if($(this).attr('id') != "program_daytime_dnm")
																				  {
																					$(this).attr("disabled", true);
																					$(this).attr("checked",false);
																				  }
																			   });
												$('#PROG_DAY_TIME').val($(this).val());
											 }
											 else
											 {
												$('.chkDayTime').each(function()
																			   {
																				 if($(this).attr('id') != "program_daytime_dnm")
																				  {
																					$(this).attr("disabled", false);  
																				  }
																			   });
												$('#PROG_DAY_TIME').val("");
											 }
												 
											
											return;
										}
										
									});
	$('.chkDayTime').each(function()
									{ 
										// Test if a required field has no data then set the error flag to true and exit the loop.
										$('#PROG_DAY_TIME').val("");
										if($(this).attr('checked') == true)
										 {
											//$("#program_daytime_dnm").attr("disabled", true);  
											if(SELECTION.length == 0)
											 {
												SELECTION =  $(this).val();
											 }
											else
											 {
												 SELECTION +=   ", " + $(this).val();
											 }
										 }
									}); 
	$('#PROG_DAY_TIME').val(SELECTION);
	PAGE_ERROR=false;
	//$("#program_daytime_dnm").attr("disabled", false); 
}


function jsf_CreateAgeGroupSelection()
{
	$('#PROG_AGE').val('');
	var SELECTION = "";
	
	$('.chkAge').each(function()
									{ 
										// Test if a required field has no data then set the error flag to true and exit the loop.
										if($(this).attr('checked') == true)
										 {
											if(SELECTION.length == 0)
											 {
												SELECTION =  $(this).val();
											 }
											else
											 {
												 SELECTION +=   ", " + $(this).val();
											 }
										 }
									}); 
	$('#PROG_AGE').val(SELECTION);
	PAGE_ERROR=false;
}


function jsf_CreateCategoryGroupSelection()
{
	$('#PROG_CATEGORY').val('');
	var SELECTION = "";
	
	$('.chkCat').each(function()
									{ 
										// Test if a required field has no data then set the error flag to true and exit the loop.
										if($(this).attr('checked') == true)
										 {
											if($(this).val() == "Meeting")
											 {
												$("#PROG_VP").val('MT');

											 }
											else
											 {
												$("#PROG_VP").val('NA');	
											 }
											if(SELECTION.length == 0)
											 {
												SELECTION =  $(this).val();
												
											 }
											else
											 {
												 SELECTION +=   ", " + $(this).val();
											 }
										 }
									}); 

	$('#PROG_CATEGORY').val(SELECTION);
	PAGE_ERROR=false;
}

		
			$(function(){
				// Tabs
				$('#tabs').tabs();
	
				// Dialog			
				$('#dialog').dialog({
					autoOpen: false,
					width: 400,
					height: 100,
					show: 'fold',
					//buttons: {"Ok": function() { $(this).dialog("close"); }, "Cancel": function() { $(this).dialog("close"); }}
					hide: 'fold'
					
				});


				$("#PROG_PRESENTER_CONTACT_PHONE").numeric();
				$("#PROG_PRESENTER_FAX").numeric();


				$("#div_Login").dialog({
									dialogClass: 'ui-state-default',		   
									draggable: false,
									autoOpen: true,
									width: 500,
									height: 200,
									modal:false
					
				});
	
		
				
				$(".ui-dialog-titlebar").addClass('ui-state-error');
				
				//hover states on the static widgets
				$('#dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);
				$(".step").hide();
				$(".field").bind("keypress keyup", 
							function(e)
								{
									$(this).removeClass("required_error"); 
									
									//$(this).next().html('<small>Ok</small>');
									PAGE_ERROR=false;
									
								}
						);

				$(".field_sub").bind("keypress keyup", 
							function(e)
								{
									$(this).removeClass("required_error"); 
									
									//$(this).next().html('<small>Ok</small>');
									PAGE_ERROR=false;
									
								}
						);

				$('.chkDayTime').bind("change", 
												  function(e)
												  {
        											jsf_CreateDayTimeGroupSelection();
    												});	
				$('.chkAge').bind("change", 
											function(e)
												{
        											jsf_CreateAgeGroupSelection();
    											});	

				$('.chkCat').bind("click", 
											function(e)
												{
        											jsf_CreateCategoryGroupSelection();
    											});	


			});
			
			
			
			
			//jsf_CreateAgeGroupSelection()
			
			
			function jsf_Next(_step, _focus, _group, _option)
			 {
					//alert(PAGE_ERROR);
					if(PAGE_ERROR)
					{
						return false; 
					}

					var SEC_ADDRESS = $("#ADDRESS").val();
					if(SEC_ADDRESS.length > 0)
					 {
						return; 
					 }
					
					
					$('*[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).attr('class') == "field" && $(this).val().length == 0)
														 {
															PAGE_ERROR = true;
															//$(this).after('<small>This field is required.</small>');
															$(this).addClass("required_error");
															
															if(_option == "FIELDS")
															 {
																$('#dialog').html('<p>Field marked with red indicates is required and missing data.</p>');	 
															 }
															else
															 {
																 $('#dialog').html('<p>You have not made a valid selection..</p>');	 
															 }
															
															$('#dialog').dialog('open');
															setTimeout('$(\'#dialog\').dialog(\'close\');', 3000);
															return false;
														 }
											}); 
		
					if(PAGE_ERROR)
					{
						return false; 
					}
					
					switch(_focus)
					 {
						case 1:
							ajax_AddSpeaker('init'); 
						break;
						
						case 3:
							ajax_CompileProgramData('DATA_FIELD_3', 3);
						break;

						case 4:
							ajax_CompileProgramData('DATA_FIELD_4', 4);
						break;

						case 5:
							ajax_CompileProgramData('DATA_FIELD_5', 5);
						break;

						case 6:
							ajax_CompileProgramData('DATA_FIELD_6', 6);
						break;


						}

					$("#" + _step).show('bounce');
					$("#tabs").tabs('option', 'selected', _focus);

		 }
		 
