$(document).ready(function()
{
	function buildHelpForm(label)
	{
		if($('.custAddJobOuter') && $('#customHelpForm'))
		{
			try
			{
				numbers = false;
				
				/* ADD LABEL */
				if(label)
				{
					$('#customHelpForm').append('<span class="customHelpFormLabel">'+label+'</span>');
				}
				
				/* BUILD OPTION LIST */
				$('.formInputSelect label:not(.formInputSelect div label)').each
				(
					function()
					{
						if(parseInt($(this).text()))
						{
							numbers = true;
							label = $(this).text();
							id = $(this).parent().attr('id');
							$('<div><input type="radio" name="group1" class="'+id+'" value="1"><label>'+label+'</label></div>').appendTo('#customHelpForm');
						}
					}
				);
				
				/* CRITERA ARE SET SO MAKE FIELDSETS */
				if(numbers == true)
				{
					/* BUILD GROUPS */
					$('.custAddJobOuter form > div.formInput').each
					(
						function()
						{
							if($(this).hasClass('formInputSelect'))
							{
								name = $(this).attr('id');
								
								$(this).add($(this).nextUntil('.formInputSelect')).not('.aplCsc,.aplCic,.aplCaptchaExplain,.button,.error,.roundedButtonLeft').wrapAll('<fieldset class="wrapHide" name="'+ name +'"></fieldset>');
							}
						}
					);
					
					/* CLICK ACTION */
					$('#customHelpForm input').click
					(
						function()
						{
							$('.custAddJobOuter fieldset').each
							(
								function()
								{
									if(!$(this).attr('class','wrapHide'))
									{
										$(this).toggleClass('wrapHide');
									}
								}
							);
							id = $(this).attr('class');
							$('.custAddJobOuter fieldset[name='+id+']').toggleClass('wrapShow');
						}
					);
				}
			}
			catch(err)
			{
				//alert("something wrong");
			}
		}
	}
	buildHelpForm(false);
});
