$(function(){
	
	
	// form validation with jQuery //	
	$('#frmContactUs').validate({
		
			debug:false,
			errorElement: 'span',
			errorContainer: $('.errorDisplay'),
			errorPlacement: function(error, elem){
				
				var tag = elem.parent().get(0).tagName;
				
				if(tag == "P")
				{
					error.appendTo(elem.parent().children("span.errorDisplay"));
				}
				else if(tag == "LABEL")
				{
					error.appendTo(elem.parent().parent().parent().children('span.errorDisplay'));
				}	

			},
			success: function(span){				
				span.html("&nbsp;&nbsp;").addClass('success');			
			},
			rules: {
				firstName_textbox:{required:true},
				lastName_textBox:{required:true},
				organization_textbox:{required:true},
				email_textbox:{required:true, email:true},
				postalCode_textbox:{required:true},
				phoneNumber_textbox:{required: true},
				subject_textbox:{required: true},
				comments_textarea:{required: true}
			},
			messages: {
				isCustomer:{required: '&nbsp;'},
				firstName_textbox:{required: '&nbsp;'},
				lastName_textBox:{required: '&nbsp;'},
				organization_textbox:{required: '&nbsp;'},
				email_textbox:{required: '&nbsp;', email: '&nbsp;'},
				postalCode_textbox:{required: '&nbsp;'},
				phoneNumber_textbox:{required: '&nbsp;'},
				subject_textbox:{required: '&nbsp;'},
				comments_textarea:{required: '&nbsp;'}
			}
		
		});

	// Hightlight active input
	$('#frmContactUs input').inputFocus();
	$('#frmContactUs textarea').inputFocus();
	
	
	// subject options //
	
	var subIsCust = {
		'Additional Service Requests' : 'Additional Service Requests',
		'Scheduling Inquiries' : 'Scheduling Inquiries',
		'Billing Inquiries' : 'Billing Inquiries',
		'Other' : 'Other'
	}
	
	var subNotCust = {
		'Pricing Information' : 'Pricing Information',
		'Speak to a Sales Rep' : 'Speak to a Sales Rep',
		'Schedule a Service' : 'Schedule a Service',
		'Community Shred/Events' : 'Community Shred/Events',
		'Careers with Securit or Human Resources' : 'Careers with Shred-it/Human Resources',
		'Other'	 : 'Other'		
		}
	
	// remove all subjects
	$('#subject_selectBox').removeOption(/./);
	
	// add not customer subjects
	$('#subject_selectBox').addOption(subNotCust, false);
	
	// set default to not a customer
	var isCust = null;
	//$('#frmContactUs input[name="isCustomer"]').attr('checked', 'checked');
	
	
	
	
	$('#frmContactUs input[name="isCustomer"]').change(function(){
	
		isCust = $(this).val();
		
		if ( isCust === "2")
		{
			// remove all subjects
			$('#subject_selectBox').removeOption(/./);
			
			// add not customer subjects
			$('#subject_selectBox').addOption(subIsCust, false);
		}
		
		if ( isCust === "1")
		{
			// remove all subjects
			$('#subject_selectBox').removeOption(/./);
			
			// add not customer subjects
			$('#subject_selectBox').addOption(subNotCust, false);
		}
			


	
	});
	 
	
	
	
	

});
