user background
diff --git a/erpnext/home/page/activity/activity.js b/erpnext/home/page/activity/activity.js
index b14f1f8..d72c7ae 100644
--- a/erpnext/home/page/activity/activity.js
+++ b/erpnext/home/page/activity/activity.js
@@ -14,7 +14,7 @@
 	init: function(row, data) {
 		this.scrub_data(data);
 		this.add_date_separator(row, data);
-		$(row).append(repl('<span %(onclick)s\
+		$(row).append(sprintf('<span %(onclick)s\
 			class="label %(add_class)s">%(feed_type)s</span>\
 			%(link)s %(subject)s <span class="user-info">%(by)s</span>', data));
 	},
diff --git a/erpnext/home/page/profile_settings/profile_settings.js b/erpnext/home/page/profile_settings/profile_settings.js
index 9dac7f6..8ce94f8 100644
--- a/erpnext/home/page/profile_settings/profile_settings.js
+++ b/erpnext/home/page/profile_settings/profile_settings.js
@@ -26,13 +26,15 @@
 	
 	this.make = function() {
 		this.head = new PageHeader(this.wrapper, 'My Profile Settings');
-		this.head.add_button('Change Password', this.change_password)
+		this.head.add_button('Change Password', this.change_password);
+		this.head.add_button('Change Background', this.change_background);
+		
 		this.tab = make_table($a(this.wrapper, 'div', '', {marginTop:'19px'}), 
 			1, 2, '90%', ['50%', '50%'], {padding:'11px'})
 		this.img = $a($td(this.tab, 0, 0), 'img');
 		set_user_img(this.img, user);
 
-		$btn($a($td(this.tab, 0, 0), 'div', '', {marginTop:'11px'}), 'Change Image', this.change_image)
+		$btn($a($td(this.tab, 0, 0), 'div', '', {marginTop:'11px'}), 'Change Image', this.change_image);
 
 		this.make_form();
 		this.load_details();
@@ -105,32 +107,42 @@
 	//
 	
 	this.change_image = function() {
-		if(!me.change_dialog) {
-
-			var d = new Dialog(400,200,'Set Your Profile Image');
-			d.make_body([
-				['HTML','wrapper']
-			]);	
-
-			var w = d.widgets['wrapper'];
-			me.uploader = new Uploader(w, 
-				{
-					modulename:'home.page.profile_settings.profile_settings',
-					method: 'set_user_image'
-				}, 
-				pscript.user_image_upload, 1)
-			me.change_dialog = d;
-		}
-		me.change_dialog.show();
+		var d = new wn.widgets.Dialog({
+			title: 'Set your Profile'
+		})
+		me.uploader = new Uploader(d.body, {
+				modulename:'home.page.profile_settings.profile_settings',
+				method: 'set_user_image'
+			}, 
+			pscript.user_image_upload, 1)
+		d.show();
+		pscript.open_dialog = d;
+	}
+	
+	this.change_background = function() {
+		var d = new wn.widgets.Dialog({
+			title: 'Set Background Image'
+		})
+		me.uploader = new Uploader(d.body, {
+				modulename:'home.page.profile_settings.profile_settings',
+				method: 'set_user_background'
+			}, 
+			pscript.background_change, 1)
+		d.show();
+		pscript.open_dialog = d;
 	}
 	this.make();
 }
 
+pscript.background_change = function(fid) {
+	//erpnext.set_background_image(fid);
+	pscript.open_dialog.hide();
+}
+
 pscript.user_image_upload = function(fid) {
 	msgprint('File Uploaded');
-	
 	if(fid) {
-		pscript.myprofile.change_dialog.hide();
+		pscript.open_dialog.hide();
 		set_user_img(pscript.myprofile.img, user, null, fid);
 	}
 }
diff --git a/erpnext/home/page/profile_settings/profile_settings.py b/erpnext/home/page/profile_settings/profile_settings.py
index f614c75..fb633fd 100644
--- a/erpnext/home/page/profile_settings/profile_settings.py
+++ b/erpnext/home/page/profile_settings/profile_settings.py
@@ -63,6 +63,31 @@
 	"""
 		Set uploaded image as user image
 	"""
-	from webnotes.utils.file_manager import add_file_list, remove_all
-	remove_all('Profile', webnotes.session['user'])
-	add_file_list('Profile', webnotes.session['user'], fname, fid)
+	from webnotes.utils.file_manager import add_file_list, remove_file
+	user = webnotes.session['user']
+	
+	# remove old file
+	old_image = webnotes.conn.get_value('Profile', user, 'user_image')
+	if old_image:
+		remove_file('Profile', user, old_image)
+		
+	# add new file
+	add_file_list('Profile', user, fname, fid)
+	webnotes.conn.set_value('Profile', user, 'user_image', fid)
+
+@webnotes.whitelist()	
+def set_user_background(fid, fname):
+	"""
+		Set uploaded image as user image
+	"""
+	from webnotes.utils.file_manager import add_file_list, remove_file
+	user = webnotes.session['user']
+	
+	# remove old file
+	old_image = webnotes.conn.get_value('Profile', user, 'background_image')
+	if old_image:
+		remove_file('Profile', user, old_image)
+		
+	# add new file
+	add_file_list('Profile', user, fname, fid)
+	webnotes.conn.set_value('Profile', user, 'background_image', fid)
diff --git a/erpnext/patches/jan_mar_2012/navupdate.py b/erpnext/patches/jan_mar_2012/navupdate.py
index 18338dd..29939e5 100644
--- a/erpnext/patches/jan_mar_2012/navupdate.py
+++ b/erpnext/patches/jan_mar_2012/navupdate.py
@@ -35,6 +35,7 @@
 	reload_doc('setup', 'page', 'modules_setup')
 	reload_doc('utilities', 'page', 'users')
 	reload_doc('home', 'page', 'activity')
+	reload_doc('core', 'doctype', 'profile')
 	
 	webnotes.conn.set_value('Control Panel', 'Control Panel', 'home_page',
 			'desktop')
diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py
index 79fd603..dca9e0c 100644
--- a/erpnext/startup/event_handlers.py
+++ b/erpnext/startup/event_handlers.py
@@ -93,6 +93,8 @@
 		# if no company, show a dialog box to create a new company
 		bootinfo['setup_complete'] = webnotes.conn.sql("""select name from 
 			tabCompany limit 1""") and 'Yes' or 'No'
+			
+		bootinfo['user_background'] = webnotes.conn.get_value("Profile", webnotes.session['user'], 'background_image') or ''
 
 def get_letter_heads():
 	"""load letter heads with startup"""
diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js
index aef298c..ad8289e 100644
--- a/erpnext/startup/startup.js
+++ b/erpnext/startup/startup.js
@@ -50,6 +50,9 @@
 	if(wn.boot.custom_css) {
 		set_style(wn.boot.custom_css);
 	}
+	if(wn.boot.user_background) {
+		erpnext.set_user_background(wn.boot.user_background);
+	}
 		
 	if(user == 'Guest'){
 		if(wn.boot.website_settings.title_prefix) {
@@ -132,6 +135,10 @@
 	wn.updates.id = setInterval(update_messages, 60000);
 }
 
+erpnext.set_user_background = function(src) {
+	set_style(repl('body { background: url("files/%(src)s") repeat !important;}', {src:src}))
+}
+
 // =======================================
 
 // start
diff --git a/erpnext/website/doctype/style_settings/custom_template.css b/erpnext/website/doctype/style_settings/custom_template.css
index e6eeeb3..8eb3d63 100644
--- a/erpnext/website/doctype/style_settings/custom_template.css
+++ b/erpnext/website/doctype/style_settings/custom_template.css
@@ -1,6 +1,6 @@
 body {
 {% if doc.background_image %}
-	background: url("files/{{ doc.background_image }}") repeat !important;
+	background: url("files/{{ doc.background_image }}") repeat;
 {% elif doc.background_color %}
 	background-color: #{{ doc.background_color }};
 {% endif %}	
diff --git a/js/all-app.js b/js/all-app.js
index 09e92a5..e5e7967 100644
--- a/js/all-app.js
+++ b/js/all-app.js
Binary files differ
diff --git a/js/all-web.js b/js/all-web.js
index 98e1a7a..1df9639 100644
--- a/js/all-web.js
+++ b/js/all-web.js
@@ -55,13 +55,13 @@
 else if((match=/^\x25{2}/.exec(_fmt))!==null){parse_tree.push('%');}
 else if((match=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt))!==null){if(match[2]){arg_names|=1;var field_list=[],replacement_field=match[2],field_match=[];if((field_match=/^([a-z_][a-z_\d]*)/i.exec(replacement_field))!==null){field_list.push(field_match[1]);while((replacement_field=replacement_field.substring(field_match[0].length))!==''){if((field_match=/^\.([a-z_][a-z_\d]*)/i.exec(replacement_field))!==null){field_list.push(field_match[1]);}
 else if((field_match=/^\[(\d+)\]/.exec(replacement_field))!==null){field_list.push(field_match[1]);}
-else{}}}
-else{}
+else{throw('[sprintf] huh?');}}}
+else{throw('[sprintf] huh?');}
 match[2]=field_list;}
 else{arg_names|=2;}
 if(arg_names===3){throw('[sprintf] mixing positional and named placeholders is not (yet) supported');}
 parse_tree.push(match);}
-else{}
+else{throw('[sprintf] huh?');}
 _fmt=_fmt.substring(match[0].length);}
 return parse_tree;};return str_format;})();var vsprintf=function(fmt,argv){argv.unshift(fmt);return sprintf.apply(null,argv);};
 /*
@@ -206,7 +206,9 @@
 return s;}
 var rstrip=function(s,chars){if(!chars)chars=['\n','\t',' '];var last_char=s.substr(s.length-1);while(in_list(chars,last_char)){var s=s.substr(0,this.length-1);last_char=s.substr(this.length-1);}
 return s;}
-function repl(s,dict){return sprintf(s,dict);}
+function repl_all(s,s1,s2){var idx=s.indexOf(s1);while(idx!=-1){s=s.replace(s1,s2);idx=s.indexOf(s1);}
+return s;}
+function repl(s,dict){if(s==null)return'';for(key in dict)s=repl_all(s,'%('+key+')s',dict[key]);return s;}
 function keys(obj){var mykeys=[];for(key in obj)mykeys[mykeys.length]=key;return mykeys;}
 function values(obj){var myvalues=[];for(key in obj)myvalues[myvalues.length]=obj[key];return myvalues;}
 function in_list(list,item){for(var i=0;i<list.length;i++)
@@ -1070,6 +1072,7 @@
 erpnext.startup.set_globals=function(){pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway)
 if(inList(user_roles,'System Manager'))is_system_manager=1;}
 erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.custom_css){set_style(wn.boot.custom_css);}
+if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
 if(user=='Guest'){if(wn.boot.website_settings.title_prefix){wn.title_prefix=wn.boot.website_settings.title_prefix;}}else{erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();$('footer').html('<div class="web-footer erpnext-footer">\
    Powered by <a href="https://erpnext.com">ERPNext</a></div>');if(in_list(user_roles,'System Manager')&&(wn.boot.setup_complete=='No')){wn.require("erpnext/startup/js/complete_setup.js");erpnext.complete_setup();}}
 $('#startup_div').toggle(false);}
@@ -1082,6 +1085,7 @@
 if(circle){if(r.message.length){circle.find('span:first').text(r.message.length);circle.toggle(true);}else{circle.toggle(false);}}}else{clearInterval(wn.updates.id);}});}
 erpnext.startup.set_periodic_updates=function(){wn.updates={};if(wn.updates.id){clearInterval(wn.updates.id);}
 wn.updates.id=setInterval(update_messages,60000);}
+erpnext.set_user_background=function(src){set_style(repl('body { background: url("files/%(src)s") repeat !important;}',{src:src}))}
 $(document).bind('startup',function(){erpnext.startup.start();});
 /*
  *	erpnext/website/js/topbar.js
diff --git a/version.num b/version.num
index d6ee760..988e00f 100644
--- a/version.num
+++ b/version.num
@@ -1 +1 @@
-762
\ No newline at end of file
+768
\ No newline at end of file