  $(document).ready(function(){
	
	$("#directory").hide();
	$("#toggleDirectory, #close").click(function () {
	  $("#directory").toggle("blind");
	});
	
	$(document).ready(function(){
		$('#searchForm .submit').autofill({
			value: 'Search...',
			defaultTextColor: '#bbbbbb',
			activeTextColor: '#333333'
		});
	});
	
	
	$("#job_title_preview").html( $("#job_title").val() );
	$("#job_title").bind("keyup", function(){
		$("#job_title_preview").html( $(this).val() );
	});
	
	$("#job_ref_preview").html( $("#job_ref").val() );
	$("#job_ref").bind("keyup", function(){
		$("#job_ref_preview").html( $(this).val() );
	});
	
	
	
	
         
  
	
	
	$("input:radio[name=job_type]").click(function(){
        var job_type = $('input:radio[name=job_type]:checked').val();
		$("#job_type_preview").html( job_type );

});
	
	

	$("#job_salary_preview").html( $("#job_salary").val() );
	$("#job_salary").bind("keyup", function(){
		$("#job_salary_preview").html( $(this).val() );
	});
	
	$("#job_location_preview").html( $("#job_location").val() );
	$("#job_location").bind("keyup", function(){
		$("#job_location_preview").html( $(this).val() );
	});
	
	$("#job_description_preview").html( $("#job_description").val() );
	$("#job_description").bind("keyup", function(){
		$("#job_description_preview").html( $(this).val() );
	});	
	
	$("#job_apply_preview").html( $("#job_apply").val() );
	$("#job_apply").bind("keyup", function(){
		$("#job_apply_preview").html( $(this).val() );
	});
	
		
		
	function updateBlogList() {         
		var allVals = [];
		$('.postajob_bloglist :checked').each(function() {
			//allVals.push($(this).val());
			allVals.push($(this).parent().attr("name"));
		});
		
		if (allVals.length < 2) {needs = "";} else {needs = "s";}
		
		if (allVals.length < 1) {
			intro = "";
			outtro = "";
			cost = "";
		} else {
			intro = "This listing will appear on the <strong>";
			outtro = "</strong> channel" + needs + " for 30 days.";
			cost =  "$" + (14.99 * allVals.length).toFixed(2);
		}
		
		$("#job_blogs_preview").html( intro + allVals.join(", ") + outtro );
		$("#job_adcost_preview").html( cost);
		$("#job_adcost").val( cost.replace('$',''));
		
	}
	
	$(function() {
		$('.postajob_bloglist input').click(updateBlogList);
		updateBlogList();
	 });



	$("#postajob_form").validate({
		rules: {
			"job_blogs[]": {required: true, minlength: 1},
			agree: {required: true}
		},
		messages: {
			"job_blogs[]": "Please select at least ONE channel.",
			agree: "You need to agree to the terms."
		}
		
	});
	
	
	
	
		
	
	
	


  });
