function inputTextRemember(selector) {	
	$(selector).each(function(){
		//if this item has been cookied, restore it
		var name = $(this).attr('name');
		if($.cookie(name)){
			$(this).val($.cookie(name));
		}
		//assign a change function to the item to cookie it
		$(this).change(function() {
			$.cookie(name, $(this).val(), { path: '/', expires: 365 });
		});
	});
}	
function selectRemember(selector) { 
	$(selector).each(function(){
		var name = $(this).attr('name');			
		if($.cookie(name)){
			option = $(this).children().filter('[value='+$.cookie(name)+']');
			option.attr('selected','selected');
		}	
		
		$(this).change(function() {
			var value = $(this).children("option:selected").attr("value"); 
			$.cookie(name, value, { path: '/', expires: 365 });
		});

	});	
}
function textAreaRemember(selector) {	
	$(selector).each(function(){
		var name = $(this).attr('name');
		
		if($.cookie(name)){
			$(this).val($.cookie(name));
		}	
		
					
		$(this).change(function() {
			value = $(this).val();
			$.cookie(name, value, { path: '/', expires: 365 });
		});
	});
}
$(function(){
	inputTextRemember('#first_name');
	inputTextRemember('#last_name');
	inputTextRemember('#title');
	selectRemember('#state');
	selectRemember('#country');
	inputTextRemember('#email');
	inputTextRemember('#phone');
	inputTextRemember('#company');
	selectRemember('#00N50000001NgDC');
	textAreaRemember('#description');
	inputTextRemember('#city');
});