Merge branch 'master' into latest
diff --git a/.gitignore b/.gitignore
index e9e476b..28fcc88 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,8 @@
 *.comp.js
 .DS_Store
 server_tools
+services
+user_files
 patch.log
 lib
 versions-local.db
diff --git a/erpnext/home/__init__.py b/erpnext/home/__init__.py
index 8969695..7059cec 100644
--- a/erpnext/home/__init__.py
+++ b/erpnext/home/__init__.py
@@ -48,9 +48,9 @@
 
 def update_feed(doc, method=None):   
 	"adds a new feed"
-	if method=='validate':
-		return
-	subject, color = feed_dict.get(doc.doctype, [None, None])
-	if subject:
-		subject = subject % doc.fields
-		make_feed(doc, subject, color)
+	if method=='on_update':
+		subject, color = feed_dict.get(doc.doctype, [None, None])
+		if subject:
+			subject = subject % doc.fields
+			
+			make_feed(doc, subject, color)
diff --git a/erpnext/home/page/dashboard/dashboard.js b/erpnext/home/page/dashboard/dashboard.js
index aac42a3..8ef2ffb 100644
--- a/erpnext/home/page/dashboard/dashboard.js
+++ b/erpnext/home/page/dashboard/dashboard.js
@@ -1,6 +1,7 @@
 pscript.onload_dashboard = function() {
 	// load jqplot
 	$.scriptPath = 'js/'
+	wn.require('lib/css/jqpot.css');
 	wn.require('lib/js/legacy/jquery/jquery.jqplot.min.js');
 	wn.require('lib/js/legacy/jquery/jqplot-plugins/jqplot.barRenderer.js'); 
 	wn.require('lib/js/legacy/jquery/jqplot-plugins/jqplot.canvasAxisTickRenderer.min.js');
diff --git a/erpnext/home/page/event_updates/event_updates.js b/erpnext/home/page/event_updates/event_updates.js
index ee348e6..6e09cca 100644
--- a/erpnext/home/page/event_updates/event_updates.js
+++ b/erpnext/home/page/event_updates/event_updates.js
@@ -6,7 +6,7 @@
 			
 	pscript.home_make_body();
 	pscript.home_make_status();
-	pscript.home_pre_process();
+	pscript.home_set_banner();
 	pscript.home_make_widgets();
 }
 
@@ -30,7 +30,7 @@
 
 // ==================================
 
-pscript.home_pre_process = function(wrapper) {
+pscript.home_set_banner = function(wrapper) {
 	var wrapper = page_body.pages['Event Updates'];
 	var cp = locals['Control Panel']['Control Panel'];
 
@@ -632,7 +632,7 @@
 		var d = new Dialog(400, 200, "Please Complete Your Registration");
 		if(user != 'Administrator'){
 			d.no_cancel(); // Hide close image
-			$dh(page_body.wntoolbar.wrapper);
+			$('header').toggle(false);
 		}
 
 		d.make_body([
@@ -672,7 +672,7 @@
 				$c_obj('Setup Control','setup_account',JSON.stringify(args),function(r, rt){
 					sys_defaults = r.message;
 					d.hide();
-					$ds(page_body.wntoolbar.wrapper);
+					$('header').toggle(true);
 				});
 			}
 		}
diff --git a/erpnext/home/page/my_company/my_company.js b/erpnext/home/page/my_company/my_company.js
index 58ff91e..a057ac3 100644
--- a/erpnext/home/page/my_company/my_company.js
+++ b/erpnext/home/page/my_company/my_company.js
@@ -43,14 +43,11 @@
 //
 pscript.myc_add_user = function() {
 	var fields = [{
-		fieldtype: 'Data',
-		fieldname: 'user',
-		reqd: 1,
-		label: 'Email Id of the user to add'
-	}];
-
-	if(!pscript.is_erpnext_saas) {
-		fields = fields.concat([
+			fieldtype: 'Data',
+			fieldname: 'user',
+			reqd: 1,
+			label: 'Email Id of the user to add'
+		},
 		{
 			fieldtype: 'Data',
 			fieldname: 'first_name',
@@ -67,14 +64,14 @@
 			fieldname: 'password',
 			reqd: 1,
 			label: 'Password'
-		}]);		
-	}
+		},
+		{
+			fieldtype: 'Button',
+			label: 'Add',
+			fieldname: 'add'
+		}];
 
-	fields.push({
-		fieldtype: 'Button',
-		label: 'Add',
-		fieldname: 'add'
-	});
+	fields.push();
 
 	var d = new wn.widgets.Dialog({
 		title: 'Add User',
@@ -246,7 +243,8 @@
 		// image
 		this.img = $a($td(this.tab,0,0),'img','',{width:'41px'});
 		set_user_img(this.img, det.name, null, 
-			(det.file_list ? det.file_list.split(NEWLINE)[0].split(',')[1] : ('no_img_' + (det.gender=='Female' ? 'f' : 'm'))));		
+			(det.file_list ? det.file_list.split(NEWLINE)[0].split(',')[1] : 
+				('no_img_' + (det.gender=='Female' ? 'f' : 'm'))));
 	}
 	
 	// set other details like email id, name etc
diff --git a/erpnext/home/page/my_company/my_company.py b/erpnext/home/page/my_company/my_company.py
index c239162..1610506 100644
--- a/erpnext/home/page/my_company/my_company.py
+++ b/erpnext/home/page/my_company/my_company.py
@@ -1,6 +1,7 @@
 import webnotes
 
 from webnotes.utils import cint, load_json, cstr
+from webnotes.model.doc import Document
 
 try: import json
 except: import simplejson as json
@@ -65,8 +66,7 @@
 # add profile record
 #
 def add_profile(args):
-	from webnotes.utils import validate_email_add
-	from webnotes.model.doc import Document
+	from webnotes.utils import validate_email_add, now
 	email = args['user']
 			
 	sql = webnotes.conn.sql
@@ -80,7 +80,7 @@
 	if sql("select name from tabProfile where name = %s", email):
 		# exists, enable it
 		sql("update tabProfile set enabled = 1, docstatus=0 where name = %s", email)
-		webnotes.msgprint('Profile exists, enabled it')
+		webnotes.msgprint('Profile exists, enabled it with new password')
 	else:
 		# does not exist, create it!
 		pr = Document('Profile')
@@ -92,11 +92,24 @@
 		pr.user_type = 'System User'
 		pr.save(1)
 
-		if args.get('password'):
-			sql("""
-				UPDATE tabProfile 
-				SET password = PASSWORD(%s)
-				WHERE name = %s""", (args.get('password'), email))
+	if args.get('password'):
+		sql("""
+			UPDATE tabProfile 
+			SET password = PASSWORD(%s), modified = %s
+			WHERE name = %s""", (args.get('password'), now, email))
+
+	send_welcome_mail(email, args)
+
+def send_welcome_mail(email, args):
+	"""send welcome mail to user with password and login url"""
+	pr = Document('Profile', email)
+	from webnotes.utils.email_lib import sendmail_md
+	args.update({
+		'company': webnotes.conn.get_default('company'),
+		'password': password,
+		'account_url': webnotes.conn.get_default('account_url')
+	})
+	sendmail_md(pr.email, subject="Welcome to ERPNext", msg=welcome_txt % args)
 
 #
 # post comment
@@ -166,3 +179,20 @@
 		else:
 			webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s", (args['new_password'], args['user']))
 	else: webnotes.msgprint('Settings Updated')
+
+welcome_txt = """
+## %(company)s
+
+Dear %(first_name)s %(last_name)s
+
+Welcome!
+
+A new account has been created for you, here are your details:
+
+login-id: %(name)s
+password: %(password)s
+
+To login to your new ERPNext account, please go to:
+
+%(account_url)s
+"""
\ No newline at end of file
diff --git a/erpnext/home/page/profile_settings/profile_settings.py b/erpnext/home/page/profile_settings/profile_settings.py
index 22af804..ef969ca 100644
--- a/erpnext/home/page/profile_settings/profile_settings.py
+++ b/erpnext/home/page/profile_settings/profile_settings.py
@@ -8,16 +8,12 @@
 	"""
 	arg = load_json(arg)
 	
-	if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
-		import server_tools.gateway_utils
-		webnotes.msgprint(server_tools.gateway_utils.change_password(arg['old_password'], arg['new_password'])['message'])
-	else:
-		if not webnotes.conn.sql('select name from tabProfile where name=%s and password=password(%s)', (webnotes.session['user'], arg['old_password'])):
-			webnotes.msgprint('Old password is not correct', raise_exception=1)
+	if not webnotes.conn.sql('select name from tabProfile where name=%s and password=password(%s)', (webnotes.session['user'], arg['old_password'])):
+		webnotes.msgprint('Old password is not correct', raise_exception=1)
 			
-		from webnotes.utils import nowdate
-		webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s",(arg['new_password'], nowdate(), webnotes.session['user']))
-		webnotes.msgprint('Password Updated');
+	from webnotes.utils import nowdate
+	webnotes.conn.sql("update tabProfile set password=password(%s), modified=%s where name=%s",(arg['new_password'], nowdate(), webnotes.session['user']))
+	webnotes.msgprint('Password Updated');
 
 def get_user_details(arg=None):
 	"""
diff --git a/erpnext/patches/jan_mar_2012/subdomain_login_patch.py b/erpnext/patches/jan_mar_2012/subdomain_login_patch.py
new file mode 100644
index 0000000..2b89368
--- /dev/null
+++ b/erpnext/patches/jan_mar_2012/subdomain_login_patch.py
@@ -0,0 +1,27 @@
+import webnotes
+from webnotes.model.doc import Document
+
+def execute():
+	from webnotes.modules import reload_doc
+	add_default_home_page()
+	cleanup()
+	reload_doc('setup','doctype','manage_account')
+	webnotes.conn.commit()
+	webnotes.conn.sql("drop table tabDocTrigger")
+	
+def cleanup():
+	from webnotes.model import delete_doc
+	delete_doc("DocType", "SSO Control")
+	delete_doc("DocType", "WN ERP Cient Control")
+	delete_doc("DocType", "DocTrigger")
+	
+def add_default_home_page():
+	if not webnotes.conn.sql("""select name from `tabDefault Home Page`
+		where role='Guest' and home_page='Login Page'"""):
+		d = Document('Default Home Page')
+		d.parent = 'Control Panel'
+		d.parenttype = 'Control Panel'
+		d.parentfield = 'default_home_pages'
+		d.role = 'Guest'
+		d.home_page = 'Login Page'
+		d.save(1)
diff --git a/erpnext/setup/doctype/manage_account/manage_account.js b/erpnext/setup/doctype/manage_account/manage_account.js
index 7c3b193..63cc1d5 100644
--- a/erpnext/setup/doctype/manage_account/manage_account.js
+++ b/erpnext/setup/doctype/manage_account/manage_account.js
@@ -1,6 +1,6 @@
 // Validate
 cur_frm.cscript.validate = function(doc, cdt, cdn) {
-  $c_obj(make_doclist(cdt, cdn), 'update_cp', '', function(r, rt){
+  $c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){
     sys_defaults = r.message;
   });
 }
\ No newline at end of file
diff --git a/erpnext/setup/doctype/manage_account/manage_account.py b/erpnext/setup/doctype/manage_account/manage_account.py
index 5b1292a..757d323 100644
--- a/erpnext/setup/doctype/manage_account/manage_account.py
+++ b/erpnext/setup/doctype/manage_account/manage_account.py
@@ -1,66 +1,60 @@
-# Please edit this list and import only required elements
+"""Global Defaults"""
 import webnotes
 
-from webnotes.utils import cint, cstr, get_defaults, set_default, fmt_money, get_last_day, get_first_day
-from webnotes import session, form, is_testing, msgprint, errprint
-
-sql = webnotes.conn.sql
-
-	
-# -----------------------------------------------------------------------------------------
-
+keydict = {
+	"fiscal_year": "current_fiscal_year",
+    'company': 'default_company',
+    'currency': 'default_currency',
+    'price_list_name': 'default_price_list',
+	'price_list_currency': 'default_price_list_currency',
+    'item_group': 'default_item_group',
+    'customer_group': 'default_customer_group',
+    'cust_master_name': 'cust_master_name', 
+    'supplier_type': 'default_supplier_type',
+    'supp_master_name': 'supp_master_name', 
+    'territory': 'default_territory',
+    'stock_uom': 'default_stock_uom',
+    'fraction_currency': 'default_currency_fraction',
+    'valuation_method': 'default_valuation_method',
+	'date_format': 'date_format',
+	'currency_format':'default_currency_format',
+	'account_url':'account_url'
+}
 
 class DocType:
-  def __init__(self, d, dl):
-    self.doc, self.doclist = d, dl
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
 
-#---------------------------------------------------------------------------------------------------------------------------------------------  
-  def get_bal(self,arg):
-    bal = sql("select `tabAccount Balance`.balance,`tabAccount`.debit_or_credit from `tabAccount`,`tabAccount Balance` where `tabAccount Balance`.account=%s and `tabAccount Balance`.period=%s and `tabAccount Balance`.account=`tabAccount`.name ",(arg,self.doc.current_fiscal_year))
-    if bal:
-      return fmt_money(flt(bal[0][0])) + ' ' + bal[0][1]
-
-
-# =========================================================================================================================================
-
-  # Update Default
-  # ---------------
-  def set_system_default(self, defkey, defvalue):
-    set_default(defkey, defvalue)
-
-    if defkey == 'fiscal_year':
-      ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", cstr(defvalue))
-      ysd = ysd and ysd[0][0] or ''
-      if ysd:
-        set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
-        set_default('year_end_date', get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
-
-
-  # Update
-  # --------
-  def update_cp(self):
-    def_list = [['fiscal_year',self.doc.current_fiscal_year],
-                ['company',self.doc.default_company],
-                ['currency',self.doc.default_currency],
-                ['price_list_name',self.doc.default_price_list or ''],
-				['price_list_currency', self.doc.default_price_list_currency or ''],
-                ['item_group',self.doc.default_item_group or ''],
-                ['customer_group',self.doc.default_customer_group or ''],
-                ['cust_master_name',self.doc.cust_master_name or ''], 
-                ['supplier_type',self.doc.default_supplier_type or ''],
-                ['supp_master_name',self.doc.supp_master_name], 
-                ['territory',self.doc.default_territory or ''],
-                ['stock_uom',self.doc.default_stock_uom or ''],
-                ['fraction_currency',self.doc.default_currency_fraction or ''],
-                ['valuation_method',self.doc.default_valuation_method]]
-
-    for d in def_list:
-      self.set_system_default(d[0],d[1])
-    # Update Currency Format
+	def get_bal(self,arg):
+		"""get account balance (??)"""
+		from webnotes.utils import fmt_money, flt
+		bal = webnotes.conn.sql("select `tabAccount Balance`.balance,`tabAccount`.debit_or_credit from `tabAccount`,`tabAccount Balance` where `tabAccount Balance`.account=%s and `tabAccount Balance`.period=%s and `tabAccount Balance`.account=`tabAccount`.name ",(arg,self.doc.current_fiscal_year))
+		if bal:
+			return fmt_money(flt(bal[0][0])) + ' ' + bal[0][1]
 	
-    sql("update `tabSingles` set value = '%s' where field = 'currency_format' and doctype = 'Control Panel'" % self.doc.default_currency_format)
-    sql("update `tabSingles` set value = '%s' where field = 'date_format' and doctype = 'Control Panel'" %self.doc.date_format)
-
-
-    return get_defaults()
-
+	def validate(self):
+		"""validate"""
+		if not (self.doc.account_url and (self.doc.account_url.startswith('http://') \
+			or self.doc.account_url.startswith('https://'))):
+			webnotes.msgprint("Account URL must start with 'http://' or 'https://'", raise_exception=1)
+	
+	def on_update(self):
+		"""update defaults"""
+		self.validate()
+		
+		for key in keydict:
+			webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], ''))
+			
+		# update year start date and year end date from fiscal_year
+		ysd = webnotes.conn.sql("""select year_start_date from `tabFiscal Year` 
+			where name=%s""", self.doc.fiscal_year)
+			
+		ysd = ysd and ysd[0][0] or ''
+		from webnotes.utils import get_first_day, get_last_day
+		if ysd:
+			webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
+			webnotes.conn.set_default('year_end_date', \
+				get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d'))
+		
+	def get_defaults(self):
+		return webnotes.conn.get_defaults()
\ No newline at end of file
diff --git a/erpnext/setup/doctype/manage_account/manage_account.txt b/erpnext/setup/doctype/manage_account/manage_account.txt
index 8a156a0..18a9872 100644
--- a/erpnext/setup/doctype/manage_account/manage_account.txt
+++ b/erpnext/setup/doctype/manage_account/manage_account.txt
@@ -5,14 +5,13 @@
 	{
 		'creation': '2010-08-08 17:09:09',
 		'docstatus': 0,
-		'modified': '2011-12-21 13:22:33',
+		'modified': '2012-01-20 11:25:18',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-
 		'_last_update': '1323855502',
 		'allow_copy': 1,
 		'allow_email': 1,
@@ -29,7 +28,7 @@
 		'section_style': 'Tabbed',
 		'server_code_error': ' ',
 		'show_in_menu': 1,
-		'version': 515
+		'version': 517
 	},
 
 	# These values are common for all DocField
@@ -106,6 +105,37 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
+		'label': 'System'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Example: http://frappe.erpnext.com',
+		'doctype': 'DocField',
+		'fieldname': 'account_url',
+		'fieldtype': 'Data',
+		'label': 'Account URL'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Column Break'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'sms_sender_name',
+		'fieldtype': 'Data',
+		'label': 'SMS Sender Name'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Section Break',
 		'label': 'Company'
 	},
 
@@ -176,14 +206,6 @@
 	# DocField
 	{
 		'doctype': 'DocField',
-		'fieldname': 'sms_sender_name',
-		'fieldtype': 'Data',
-		'label': 'SMS Sender Name'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
 		'label': 'Stock'
 	},
@@ -510,4 +532,4 @@
 		'label': 'Employee Records to be created by ',
 		'options': '\nNaming Series\nEmployee Number'
 	}
-]
+]
\ No newline at end of file
diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py
index 304d2e4..798c201 100644
--- a/erpnext/startup/event_handlers.py
+++ b/erpnext/startup/event_handlers.py
@@ -2,102 +2,34 @@
 import webnotes.defs
 from webnotes.utils import cint
 
-#
-# alias the current user
-#
 def on_login(login_manager):
+	"""
+		called from login manager, before login
+	"""
+	try:
+		if login_manager.user not in ('Guest', None, ''):
+			import server_tools.gateway_utils
+			server_tools.gateway_utils.check_login(login_manager.user)
+	except ImportError:
+		pass
 
-	# login as
-	if login_manager.user == 'Administrator':
-		user = webnotes.form.getvalue('login_as')
-	   
-		if user:
-			# create if missing (due to some bug)
-			login_as(user, login_manager)
-
-			# alisaing here... so check if the user is disabled
-			if not webnotes.conn.sql("select ifnull(enabled,0) from tabProfile where name=%s", user)[0][0]:
-				# throw execption
-				webnotes.msgprint("Authentication Failed", raise_exception=1)
-
-			if hasattr(webnotes.defs, 'validate_ip'):
-				msg = getattr(webnotes.defs, 'validate_ip')()
-				if msg: webnotes.msgprint(msg, raise_exception=1)
-			
-			login_manager.user = user
-
-#
-# update account details
-#
-def update_account_details():
-	# additional details (if from gateway)
-	if webnotes.form_dict.get('is_trial'):
-		webnotes.conn.set_global('is_trial', cint(webnotes.form_dict.get('is_trial')))
-
-	if webnotes.form_dict.get('days_to_expiry'):
-		webnotes.conn.set_global('days_to_expiry', webnotes.form_dict.get('days_to_expiry'))
-
-	if webnotes.form_dict.get('first_name'):
-		from server_tools.gateway_utils import update_user_details
-		update_user_details()
 		
-#
-# save (login from)
-#
 def on_login_post_session(login_manager):
-	# login from
-	if webnotes.form_dict.get('login_from'):
-		webnotes.session['data']['login_from'] = webnotes.form.getvalue('login_from')
-		webnotes.session_obj.update()
-	
+	"""
+		called after login
+		update login_from and delete parallel sessions
+	"""
 	# Clear previous sessions i.e. logout previous log-in attempts
-	exception_list = ['demo@webnotestech.com', 'Administrator']
+	exception_list = ['demo@webnotestech.com', 'Administrator', 'Guest']
 	if webnotes.session['user'] not in exception_list:
 		sid_list = webnotes.conn.sql("""
-			SELECT sid
-			FROM `tabSessions`
+			DELETE FROM `tabSessions`
 			WHERE
 				user=%s AND
-				sid!=%s
-			ORDER BY lastupdate desc""", \
+				sid!=%s""", \
 			(webnotes.session['user'], webnotes.session['sid']), as_list=1)
-		for sid in sid_list:
-			webnotes.conn.sql("DELETE FROM `tabSessions` WHERE sid=%s", sid[0])
 
-	update_account_details()
-
-#
-# logout the user from SSO
-#
-def on_logout(login_manager):
-	if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')):
-		from server_tools.gateway_utils import logout_sso
-		logout_sso(user=login_manager.user)
-
-#
-# create a profile (if logs in for the first time)
-#
-def login_as(user, login_manager):
-	import os
-	import webnotes
-	webnotes.session = {'user': user}
-	ip = os.environ.get('REMOTE_ADDR')
-
-	# validate if user is from SSO
-	if ip == '72.55.168.105' or 1:
-		# if user does not exist, create it
-		if not webnotes.conn.sql("select name from tabProfile where name=%s", user):
-			from webnotes.model.doc import Document
-			
-			import webnotes
-			import webnotes.utils.webservice    
-
-			p = Document('Profile')
-			p.first_name = webnotes.form_dict.get('first_name')
-			p.last_name = webnotes.form_dict.get('last_name')
-			p.email = user
-			p.name = user
-			p.enabled = 1
-			p.owner = user
-			p.save(1)
-			
+def doclist_all(doc, method):
+	"""doclist trigger called from webnotes.model.doclist on any event"""
+	import home
+	home.update_feed(doc, method)
\ No newline at end of file
diff --git a/erpnext/startup/startup.css b/erpnext/startup/startup.css
index 7b2b6e5..f7aff1c 100644
--- a/erpnext/startup/startup.css
+++ b/erpnext/startup/startup.css
@@ -12,22 +12,14 @@
 	background-color: #e2e2e2;
 }
 
-.layout_wrapper {
-	padding: 13px;
-	margin: 7px;
-	-moz-box-shadow: 1px 1px 6px #AAA;
-	-webkit-box-shadow: 1px 1px 6px #AAA;
-	box-shadow: 1px 1px 6px #AAA;
-	background-color: #FFF;
+.erpnext-footer {
+	margin: 3px auto;
+	color: #888;
+	text-align: center;
 }
 
-#birthday_area {
-	display: none;
-	padding: 4px;
-	margin-bottom: 8px;
-	background-color: #FDD;
-	padding: 4px;
-	color: #644;
+.erpnext-footer a, .erpnext-footer a:hover, .erpnext-footer a:visited {
+	color: #666;
 }
 
 .module-icons {
diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js
index 5a66ec6..ad4e78e 100644
--- a/erpnext/startup/startup.js
+++ b/erpnext/startup/startup.js
@@ -10,29 +10,18 @@
 // check if session user is system manager
 if(inList(user_roles,'System Manager')) is_system_manager = 1;
 
+wn.require('erpnext/startup/toolbar.js');
+
 function startup_setup() {
 	pscript.is_erpnext_saas = cint(locals['Control Panel']['Control Panel'].sync_with_gateway)
 
-
 	if(get_url_arg('embed')) {
 		// hide header, footer
-		$dh(page_body.banner_area);
-		$dh(page_body.wntoolbar);
+		$('.topbar').css('display', 'none');
 		$dh(page_body.footer);
 		return;
 	}
-
-	if(user=='Guest' && !get_url_arg('akey')) {
-		if(pscript.is_erpnext_saas) {
-			window.location.href = 'https://www.erpnext.com';
-			return;
-		}
-	}
-
-	// page structure
-	// --------------
-	$td(page_body.wntoolbar.body_tab,0,0).innerHTML = '<i><b>erp</b>next</i>';
-	$y($td(page_body.wntoolbar.body_tab,0,0), {width:'140px', color:'#FFF', paddingLeft:'8px', paddingRight:'8px', fontSize:'14px'})
+	
 	$dh(page_body.banner_area);
 
 	// sidebar
@@ -41,10 +30,10 @@
 
 	// border to the body
 	// ------------------
-	$dh(page_body.footer);
+	page_body.footer.innerHTML = '<div class="erpnext-footer">Powered by <a href="https://erpnext.com">ERPNext</a></div>';
 
 	// setup toolbar
-	pscript.startup_setup_toolbar();
+	erpnext.toolbar.setup();
 }
 
 // ====================================================================
@@ -56,14 +45,6 @@
 		// menu
 		var ml = r.message;
 
-		// login-file
-		if(r.login_url){
-			login_file = 'http://' + r.login_url;
-		}
-		else if(pscript.is_erpnext_saas) {
-			login_file = 'https://www.erpnext.com';
-		}
-
 		// clear
 		page_body.left_sidebar.innerHTML = '';
 
@@ -427,37 +408,6 @@
 	$c_obj('Home Control', 'get_module_order', '', callback)
 
 }
-
-// ====================================================================
-
-pscript.startup_setup_toolbar = function() {
-  var menu_tab = page_body.wntoolbar.menu_table_right;
-	// help
-	// ----
-	$td(menu_tab,0,0).innerHTML = '<a style="font-weight: bold; color: #FFF" href="http://erpnext.blogspot.com/2011/03/erpnext-help.html" target="_blank">Help</a>';
-	
-	$td(menu_tab,0,1).innerHTML = '<a style="font-weight: bold; color: #FFF" href="http://groups.google.com/group/erpnext-user-forum" target="_blank">Forum</a>';
-	
-	if(pscript.is_erpnext_saas){
-		// Live Chat Help
-		// --------------
-		$td(menu_tab,0,2).innerHTML = '<a style="font-weight: bold; color: #FFF" href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">Chat</a>';
-		
-		// Manage account
-		// --------------
-		if(is_system_manager) {
-			$td(menu_tab,0,3).innerHTML = '<a style="font-weight: bold; color: #FFF;" href="#!billing">Billing</a>';
-		}
-	}
-	else{
-		$dh($td(menu_tab,0,2));
-		$dh($td(menu_tab,0,3));
-	}
-
-	$y(cell, page_body.wntoolbar.right_table_style);
-
-}
-
 // chart of accounts
 // ====================================================================
 show_chart_browser = function(nm, chart_type){
diff --git a/erpnext/startup/toolbar.js b/erpnext/startup/toolbar.js
new file mode 100644
index 0000000..49738ce
--- /dev/null
+++ b/erpnext/startup/toolbar.js
@@ -0,0 +1,27 @@
+/* toolbar settings */
+wn.provide('erpnext.toolbar');
+
+erpnext.toolbar.setup = function() {
+	// profile
+	$('#toolbar-user').append('<li><a href="#profile-settings">Profile Settings</a></li>')
+
+	// help
+	$('.topbar .secondary-nav').append('<li class="dropdown">\
+		<a class="dropdown-toggle" href="#" onclick="return false;">Help</a>\
+		<ul class="dropdown-menu" id="toolbar-help">\
+		</ul></li>')
+
+	$('#toolbar-help').append('<li><a href="http://erpnext.blogspot.com/2011/03/erpnext-help.html" target="_blank">\
+		Documentation</a></li>')
+
+	$('#toolbar-help').append('<li><a href="http://groups.google.com/group/erpnext-user-forum" target="_blank">\
+		Forum</a></li>')
+
+	$('#toolbar-help').append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\
+		Live Chat (Office Hours)</a></li>')
+
+	// billing
+	if(pscript.is_erpnext_saas && is_system_manager) {
+		$('#toolbar-user').append('<li><a href="#billing">Billing</a></li>')
+	}
+}
\ No newline at end of file
diff --git a/erpnext/utilities/doctype/profile_control/profile_control.py b/erpnext/utilities/doctype/profile_control/profile_control.py
index 189d8b1..b8db231 100644
--- a/erpnext/utilities/doctype/profile_control/profile_control.py
+++ b/erpnext/utilities/doctype/profile_control/profile_control.py
@@ -22,66 +22,9 @@
     self.doc, self.doclist = d,dl
     self.last_profile = None
   
-  # Sync Profile with Gateway
-  # -------------------------
-  def sync_with_gateway(self,pid):
-    p = Document('Profile',pid)
-
-    # login to gateway
-    from webnotes.utils.webservice import FrameworkServer
-    fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
-
-    account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
-    
-    # call add profile
-    ret = fw.runserverobj('Profile Control','Profile Control','add_profile_gateway',str([p.first_name, p.middle_name, p.last_name, p.email, p.name, account_id]))
-    
-    if ret.get('exc'):
-      msgprint(ret['exc'])
-      raise Exception
-  
   def get_role_permission(self,role):
     perm = sql("select distinct t1.`parent`, t1.`read`, t1.`write`, t1.`create`, t1.`submit`,t1.`cancel`,t1.`amend` from `tabDocPerm` t1, `tabDocType` t2 where t1.`role` ='%s' and t1.docstatus !=2 and t1.permlevel = 0 and t1.`read` = 1 and t2.module != 'Recycle Bin' and t1.parent=t2.name "%role)
     return perm or ''
-  
-  
-  # Check if password is expired
-  # --------------------------------
-  def has_pwd_expired(self):
-    if session['user'] != 'Administrator' and session['user'].lower() != 'demo':
-      last_pwd_date = None
-      try:
-        last_pwd_date = sql("select password_last_updated from tabProfile where name=%s",session['user'])[0][0] or ''
-      except:
-        return 'No'
-      if cstr(last_pwd_date) == '':
-        sql("update tabProfile set password_last_updated = '%s' where name='%s'"% (nowdate(),session['user']))
-        return 'No'
-      else:
-        date_diff = (getdate(nowdate()) - last_pwd_date).days
-        expiry_period = sql("select value from tabSingles where doctype='Control Panel' and field='password_expiry_days'")
-        if expiry_period and cint(expiry_period[0][0]) and cint(expiry_period[0][0]) < date_diff:
-          return 'Yes'
-        return 'No'
-              
-  def reset_password(self,pwd):
-    if sql("select name from tabProfile where password=PASSWORD(%s) and name=%s", (pwd,session['user'])):
-      return 'Password cannot be same as old password'
-    sql("update tabProfile set password=PASSWORD(%s),password_last_updated=%s where name = %s", (pwd,nowdate(),session['user']))
-    return 'ok'
-  
-#-------------------------------------------------------------------------------------------------------
-  #functions for manage user page
-  #-----------Enable/Disable Profile-----------------------------------------------------------------------------------------------    
-  def change_login(self,args):
-    args = eval(args)
-    
-    if cint(args['set_disabled'])==0:
-      sql("update `tabProfile` set enabled=1 where name='%s'"%args['user'])
-    else:
-      sql("update `tabProfile` set enabled=0 where name='%s'"%args['user'])
-    
-    return 'ok'
 
 #------------return role list -------------------------------------------------------------------------------------------------
   # All roles of Role Master
@@ -113,75 +56,3 @@
       pr.parentfield = 'userroles'
       pr.save(1)
       
-
-
-  # Add new member
-  # ---------------
-  def add_profile(self,arg):
-    
-    # Check credit balance
-    get_obj('WN ERP Client Control').check_credit_balance()
-    
-    arg=eval(arg)
-    pr=Document('Profile')
-    for d in arg.keys():
-      if d!='role':
-        pr.fields[d] = arg[d]
-   
-    pr.enabled=0
-    pr.user_type='System User'
-    pr.save(1)
-    pr_obj = get_obj('Profile',pr.name)
-    if (pr.name):
-      msg="New member is added"
-      pr_obj.on_update()
-    else:
-      msg="Profile not created"
-    
-    return cstr(msg)
-
-  # to find currently login user 
-  def current_login(self):
-    cl_list=sql("select distinct user from tabSessions")
-    if cl_list:
-      cl_list=[x[0] for x in cl_list]
-    
-    return cl_list
-
-
-  # Remove Profile
-  # ---------------
-  def remove_profile(self, user):
-    # delete profile
-    webnotes.model.delete_doc('Profile',user)
-    
-    # Update WN ERP Client Control
-    sql("update tabSingles set value = value - 1 where field = 'total_users' and doctype = 'WN ERP Client Control'")
-
-    # login to gateway
-    from webnotes.utils.webservice import FrameworkServer
-    fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
-
-    account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
-
-    # call remove profile
-    ret = fw.runserverobj('Profile Control','Profile Control','remove_app_sub',str([user, account_id, session['user']]))
-    
-    if ret.get('exc'):
-      msgprint(ret['exc'])
-      raise Exception
-
-    return "User Removed Successfully"
-
-
-  # Create Profile
-  # ---------------
-  def create_profile(self, email):
-    if sql("select name from tabProfile where name = %s", email):
-      sql("update tabProfile set docstatus = 0 where name = %s", email)
-    else:
-      pr = Document('Profile')
-      pr.email = email
-      pr.enabled=0
-      pr.user_type='System User'
-      pr.save(1)
diff --git a/erpnext/utilities/doctype/sso_control/__init__.py b/erpnext/utilities/doctype/sso_control/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/utilities/doctype/sso_control/__init__.py
+++ /dev/null
diff --git a/erpnext/utilities/doctype/sso_control/sso_control.py b/erpnext/utilities/doctype/sso_control/sso_control.py
deleted file mode 100644
index bfc0e43..0000000
--- a/erpnext/utilities/doctype/sso_control/sso_control.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Please edit this list and import only required elements
-import webnotes
-
-from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
-from webnotes.model import db_exists
-from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
-from webnotes.model.doclist import getlist, copy_doclist
-from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
-from webnotes import session, form, is_testing, msgprint, errprint
-
-set = webnotes.conn.set
-sql = webnotes.conn.sql
-get_value = webnotes.conn.get_value
-in_transaction = webnotes.conn.in_transaction
-convert_to_lists = webnotes.conn.convert_to_lists
-	
-# -----------------------------------------------------------------------------------------
-
-
-class DocType:
-  def __init__(self, d, dl):
-    self.doc, self.doclist = d, dl
-
-  def logout_sso(self):
-    import webnotes
-    import webnotes.utils.webservice
-
-    if session['data'].get('login_from'):
-      sso = webnotes.utils.webservice.FrameworkServer(session['data'].get('login_from'), '/', '__system@webnotestech.com', 'password')
-      sso.runserverobj('SSO Control', 'SSO Control', 'logout_user', session['user'])
\ No newline at end of file
diff --git a/erpnext/utilities/doctype/sso_control/sso_control.txt b/erpnext/utilities/doctype/sso_control/sso_control.txt
deleted file mode 100644
index ee0224e..0000000
--- a/erpnext/utilities/doctype/sso_control/sso_control.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-# DocType, SSO Control
-[
-
-	# These values are common in all dictionaries
-	{
-		'creation': '2010-08-08 17:09:24',
-		'docstatus': 0,
-		'modified': '2010-12-20 19:44:29',
-		'modified_by': 'umair@iwebnotes.com',
-		'owner': 'Administrator'
-	},
-
-	# These values are common for all DocType
-	{
-		'colour': 'White:FFF',
-		'doctype': 'DocType',
-		'issingle': 1,
-		'module': 'Utilities',
-		'name': '__common__',
-		'section_style': 'Simple',
-		'server_code_error': ' ',
-		'version': 1
-	},
-
-	# DocType, SSO Control
-	{
-		'doctype': 'DocType',
-		'name': 'SSO Control'
-	}
-]
\ No newline at end of file
diff --git a/erpnext/utilities/doctype/wn_erp_client_control/__init__.py b/erpnext/utilities/doctype/wn_erp_client_control/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/utilities/doctype/wn_erp_client_control/__init__.py
+++ /dev/null
diff --git a/erpnext/utilities/doctype/wn_erp_client_control/wn_erp_client_control.py b/erpnext/utilities/doctype/wn_erp_client_control/wn_erp_client_control.py
deleted file mode 100644
index 288f305..0000000
--- a/erpnext/utilities/doctype/wn_erp_client_control/wn_erp_client_control.py
+++ /dev/null
@@ -1,141 +0,0 @@
-# Please edit this list and import only required elements
-import webnotes
-
-from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
-from webnotes.model import db_exists
-from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
-from webnotes.model.doclist import getlist, copy_doclist
-from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
-from webnotes import session, form, is_testing, msgprint, errprint
-
-set = webnotes.conn.set
-sql = webnotes.conn.sql
-get_value = webnotes.conn.get_value
-in_transaction = webnotes.conn.in_transaction
-convert_to_lists = webnotes.conn.convert_to_lists
-	
-# -----------------------------------------------------------------------------------------
-
-
-class DocType:
-  def __init__(self, doc, doclist):
-    self.doc, self.doclist = doc, doclist
-
-
-  # Check End of Trial Period
-  # -------------------------
-  def trial_payment_reminders(self):
-    if cint(self.doc.is_trial_account)==1:
-      # Trial Period Expiry
-      trial_end_date = add_days(self.doc.account_start_date, 30)
-      days = date_diff(trial_end_date, nowdate())
-      # check if trial period has expired
-      if days < 10 and days >= 0 and has_common(['System Manager'],webnotes.user.get_roles()):
-        return "Your Trial Period expires on '%s'. Please buy credits online using Manage Account." % (formatdate(trial_end_date))
-      
-      # trial period has already expired
-      elif days < 0 and days >= -6:
-        extended_days = 7 + days
-        return "Your Trial Period has expired on %s. However, your account will be live for %s days. Please contact your System Manager to buy credits." % (formatdate(trial_end_date),cstr(extended_days))
-      elif not has_common(['Administrator'],webnotes.user.get_roles()) and days < -6:
-        return "Stopped"
-    
-    # Account is not a trial account
-    else:
-      return self.account_expiry_reminder()
-      
-
-  # Account Expiry Reminder  
-  # -----------------------
-  def account_expiry_reminder(self):
-    import webnotes.utils
-    from datetime import datetime
-    # Payment Reminder in case of not enough balance
-    cr_reqd = cint(self.doc.total_users)
-    days_left = cint(self.calc_days())
-    # check if account balance is sufficient
-    if cint(self.doc.credit_balance)<(cr_reqd):
-      
-      # Difference between last payment date and current date
-      if self.doc.last_deduction_date: last_payment = date_diff(nowdate(),self.doc.last_deduction_date)
-      else: last_payment = -1
-
-      # 7 days extension
-      remaining_days = days_left - 24
-      if last_payment > 30 or last_payment == -1:
-        if remaining_days < 8 and remaining_days >= 1:
-          return "Your account will be de-activated in " + cstr(remaining_days) + " days. Please contact your System Manager to buy credits."
-        elif remaining_days==0:
-          return "Your account will be disabled from tomorrow. Please contact your System Manager to buy credits."
-        elif not has_common(['Administrator'],webnotes.user.get_roles()):
-          return "Stopped"
-
-      # check if user account is extended for seven days
-      if cint(self.doc.is_trial_account)==0:
-        if days_left < 10 and days_left >= 0:
-          return "You have only %s Credits in your account. Buy credits before %s." % (cint(self.doc.credit_balance),formatdate(self.next_bill_sdate))
-
-
-
-  # Calculate days between current date and billing cycle end date
-  # --------------------------------------------------------------
-  def calc_days(self):
-    if self.doc.billing_cycle_date:
-      next_bill_month = cint(nowdate().split('-')[1])
-      if cint(nowdate().split('-')[2]) > cint(self.doc.billing_cycle_date.split('-')[2]):
-        next_bill_month = cint(nowdate().split('-')[1]) + 1
-      next_bill_year = nowdate().split('-')[0]
-      if next_bill_month > 12:
-        next_bill_month = next_bill_month % 12
-        next_bill_year += 1
-      self.next_bill_sdate = cstr(next_bill_year)+'-'+cstr(next_bill_month)+'-'+(self.calc_next_day(next_bill_year,next_bill_month))
-      #msgprint("next_bill_month :::" + self.next_bill_sdate)
-      return date_diff(self.next_bill_sdate, nowdate())
-
-
-  # Calculate next billing date day
-  # --------------------------------
-  def calc_next_day(self, next_year, next_month):
-    bill_cycle_day = cstr(self.doc.billing_cycle_date).split('-')[2]
-    if cint(next_month) == 2 and next_year%4==0 and (next_year%100!=0 or next_year%400==0) and cint(bill_cycle_day) > 28:
-      bill_cycle_day = '28'
-    elif cint(bill_cycle_day) == 31 and cint(next_month) in (4,6,9,11):
-      bill_cycle_day = '30'
-    return bill_cycle_day
-
-
-  # Update acc credits and balance (making payment from gateway)
-  # -------------------------------------------------------------
-  def update_acc_bal(self,args):
-    args = eval(args)
-    self.doc.credit_balance = cint(self.doc.credit_balance) + cint(args.get('net_cr'))
-    self.doc.total_users = cint(self.doc.total_users) + cint(args.get('total_users'))
-    if cint(self.doc.is_trial_account) == 1:
-      if not self.doc.account_start_date:
-        self.doc.account_start_date = nowdate()
-      self.doc.is_trial_account = 0
-      self.doc.billing_cycle_date = nowdate()
-      self.doc.last_deduction_date = nowdate()
-    self.doc.save()
-
-
-  # Check Credit Balance
-  # ---------------------
-  def check_credit_balance(self):
-    if cint(self.doc.is_trial_account) == 0:
-      if cint(self.doc.credit_balance) < 1:
-        msgprint("You do not have enough credits to add new user. Please buy credits.")
-        raise Exception
-      else:
-        self.doc.credit_balance = cint(self.doc.credit_balance) - 1
-        msgprint("Your one credit is consumed. Balance Credits : %s" % (self.doc.credit_balance))
-    self.doc.total_users = cint(self.doc.total_users) + 1
-    self.doc.save()
-
-
-  # Monthly Deduction
-  # ------------------
-  def monthly_deduction(self, cr_ded):
-    self.doc.credit_balance = cint(self.doc.credit_balance) - cint(cr_ded)
-    self.doc.last_deduction_date = nowdate()
-    self.doc.save()
\ No newline at end of file
diff --git a/erpnext/utilities/doctype/wn_erp_client_control/wn_erp_client_control.txt b/erpnext/utilities/doctype/wn_erp_client_control/wn_erp_client_control.txt
deleted file mode 100644
index 1ab4ed8..0000000
--- a/erpnext/utilities/doctype/wn_erp_client_control/wn_erp_client_control.txt
+++ /dev/null
@@ -1,124 +0,0 @@
-# DocType, WN ERP Client Control
-[
-
-	# These values are common in all dictionaries
-	{
-		'creation': '2010-08-08 17:09:30',
-		'docstatus': 0,
-		'modified': '2010-09-20 14:06:57',
-		'modified_by': 'Administrator',
-		'owner': 'Administrator'
-	},
-
-	# These values are common for all DocType
-	{
-		'colour': 'White:FFF',
-		'doctype': 'DocType',
-		'issingle': 1,
-		'istable': 0,
-		'module': 'Utilities',
-		'name': '__common__',
-		'read_only': 1,
-		'section_style': 'Simple',
-		'server_code_error': ' ',
-		'show_in_menu': 1,
-		'version': 137
-	},
-
-	# These values are common for all DocField
-	{
-		'doctype': 'DocField',
-		'name': '__common__',
-		'parent': 'WN ERP Client Control',
-		'parentfield': 'fields',
-		'parenttype': 'DocType',
-		'permlevel': 0
-	},
-
-	# These values are common for all DocPerm
-	{
-		'doctype': 'DocPerm',
-		'name': '__common__',
-		'parent': 'WN ERP Client Control',
-		'parentfield': 'permissions',
-		'parenttype': 'DocType',
-		'read': 1,
-		'role': 'System Manager'
-	},
-
-	# DocType, WN ERP Client Control
-	{
-		'doctype': 'DocType',
-		'name': 'WN ERP Client Control'
-	},
-
-	# DocPerm
-	{
-		'create': 1,
-		'doctype': 'DocPerm',
-		'idx': 1,
-		'permlevel': 0,
-		'write': 1
-	},
-
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 2,
-		'permlevel': 1
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'account_start_date',
-		'fieldtype': 'Date',
-		'idx': 1,
-		'label': 'Account Start Date'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'billing_cycle_date',
-		'fieldtype': 'Date',
-		'idx': 2,
-		'label': 'Billing Cycle Date'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'total_users',
-		'fieldtype': 'Int',
-		'idx': 3,
-		'label': 'Total Users'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'credit_balance',
-		'fieldtype': 'Int',
-		'idx': 4,
-		'label': 'Credit Balance'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'is_trial_account',
-		'fieldtype': 'Check',
-		'idx': 5,
-		'label': 'Is Trial Account'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'last_deduction_date',
-		'fieldtype': 'Date',
-		'idx': 6,
-		'label': 'Last Credit Deduction Date'
-	}
-]
\ No newline at end of file
diff --git a/index.html b/index.html
index bc3673c..25f47d6 100644
--- a/index.html
+++ b/index.html
@@ -3,25 +3,130 @@
 	<meta charset="utf-8">
 	<title>ERPNext</title>
 	<meta name="author" content="">
-	<script type="text/javascript">window._version_number="49"
+	<script type="text/javascript">window._version_number="102";
+
+/*
+*	lib/js/wn/class.js
+*/
+/*
+
+Inheritence "Class"
+-------------------
+see: http://ejohn.org/blog/simple-javascript-inheritance/
+To subclass, use:
+
+	var MyClass = Class.extend({
+		init: function
+	})
+
+*/
+
+/* Simple JavaScript Inheritance
+ * By John Resig http://ejohn.org/
+ * MIT Licensed.
+ */
+// Inspired by base2 and Prototype
+
+(function(){
+	var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
+	// The base Class implementation (does nothing)
+	this.Class = function(){};
+	
+	// Create a new Class that inherits from this class
+	Class.extend = function(prop) {
+		var _super = this.prototype;
+		
+		// Instantiate a base class (but only create the instance,
+		// don't run the init constructor)
+		initializing = true;
+		var prototype = new this();
+		initializing = false;
+		
+		// Copy the properties over onto the new prototype
+		for (var name in prop) {
+			// Check if we're overwriting an existing function
+			prototype[name] = typeof prop[name] == "function" && 
+				typeof _super[name] == "function" && fnTest.test(prop[name]) ?
+				(function(name, fn){
+					return function() {
+						var tmp = this._super;
+						
+						// Add a new ._super() method that is the same method
+						// but on the super-class
+						this._super = _super[name];
+						
+						// The method only need to be bound temporarily, so we
+						// remove it when we're done executing
+						var ret = fn.apply(this, arguments);				
+						this._super = tmp;
+						
+						return ret;
+					};
+				})(name, prop[name]) :
+				prop[name];
+		}
+		
+		// The dummy class constructor
+		function Class() {
+			// All construction is actually done in the init method
+			if ( !initializing && this.init )
+				this.init.apply(this, arguments);
+		}
+		
+		// Populate our constructed prototype object
+		Class.prototype = prototype;
+		
+		// Enforce the constructor to be what we expect
+		Class.prototype.constructor = Class;
+
+		// And make this class extendable
+		Class.extend = arguments.callee;
+		
+		return Class;
+	};
+})();
+
+/*
+*	lib/js/wn/provide.js
+*/
 
 wn={}
 wn.provide=function(namespace){var nsl=namespace.split('.');var l=nsl.length;var parent=window;for(var i=0;i<l;i++){var n=nsl[i];if(!parent[n]){parent[n]={}}
 parent=parent[n];}}
-wn.provide('wn.settings');wn.provide('wn.ui');wn.xmlhttp={request:function(){if(window.XMLHttpRequest)
+wn.provide('wn.settings');wn.provide('wn.ui');
+/*
+*	lib/js/wn/xmlhttp.js
+*/
+
+wn.xmlhttp={request:function(){if(window.XMLHttpRequest)
 return new XMLHttpRequest();else if(window.ActiveXObject)
 return new ActiveXObject("MsXml2.XmlHttp");},complete:function(req,callback,url){if(req.status==200||req.status==304){callback(req.responseText);}else{alert(url+' request error: '+req.statusText+' ('+req.status+')');}},get:function(url,callback,args,async){if(async===null)async=true;var req=wn.xmlhttp.request();req.onreadystatechange=function(){if(req.readyState==4){wn.xmlhttp.complete(req,callback,url)}}
 var sep=((args&&args.indexOf('?'))==-1)?'?':'&';var u=args?(url+sep+args):url;req.open('GET',u,async);req.send(null);if(!async){wn.xmlhttp.complete(req,callback,url)}}}
+/*
+*	lib/js/wn/versions.js
+*/
+
 wn.versions={check:function(){if(localStorage){if(window._version_number==-1||parseInt(localStorage._version_number)!=parseInt(window._version_number)){localStorage.clear();}
 localStorage.setItem('_version_number',window._version_number);}}}
+/*
+*	lib/js/wn/assets.js
+*/
+
 wn.assets={executed_:{},exists:function(src){if('localStorage'in window&&localStorage.getItem(src))
 return true},add:function(src,txt){if('localStorage'in window){localStorage.setItem(src,txt);}},get:function(src){return localStorage.getItem(src);},extn:function(src){if(src.indexOf('?')!=-1){src=src.split('?').slice(-1)[0];}
-return src.split('.').slice(-1)[0];},html_src:function(src){if(src.indexOf('/')!=-1){var t=src.split('/').slice(0,-1);t.push('src');t=t.join('/')+'/'+a.split('/').slice(-1)[0];}else{var t='src/'+src;}
-return t;},load:function(src){var t=wn.assets.extn(src)=='html'?wn.assets.html_src(src):src;wn.xmlhttp.get(t,function(txt){wn.assets.add(src,txt);},'q='&Math.floor(Math.random()*1000),false)},execute:function(src){if(!wn.assets.exists(src)){wn.assets.load(src);}
+return src.split('.').slice(-1)[0];},load:function(src){var t=src;wn.xmlhttp.get(t,function(txt){wn.assets.add(src,txt);},'q='+Math.floor(Math.random()*1000),false)},execute:function(src){if(!wn.assets.exists(src)){wn.assets.load(src);}
 var type=wn.assets.extn(src);if(wn.assets.handler[type]){wn.assets.handler[type](wn.assets.get(src),src);wn.assets.executed_[src]=1;}},handler:{js:function(txt,src){wn.dom.eval(txt);},css:function(txt,src){var se=document.createElement('style');se.type="text/css";if(se.styleSheet){se.styleSheet.cssText=txt;}else{se.appendChild(document.createTextNode(txt));}
-document.getElementsByTagName('head')[0].appendChild(se);},html:function(txt,src){var page=wn.dom.add($('.outer .inner').get(0),'div','content',null,txt);page.setAttribute("_src",src);},cgi:function(txt,src){wn.dom.eval(txt)}}}
+document.getElementsByTagName('head')[0].appendChild(se);},cgi:function(txt,src){wn.dom.eval(txt)}}}
+/*
+*	lib/js/wn/require.js
+*/
+
 wn.require=function(items){if(typeof items==="string"){items=[items];}
 var l=items.length;for(var i=0;i<l;i++){var src=items[i];if(!(src in wn.assets.executed_)){wn.assets.execute(src);}}}
+/*
+*	lib/js/wn/dom.js
+*/
+
 wn.provide('wn.dom');wn.dom.by_id=function(id){return document.getElementById(id);}
 wn.dom.eval=function(txt){var el=document.createElement('script');el.appendChild(document.createTextNode(txt));document.getElementsByTagName('head')[0].appendChild(el);}
 wn.dom.add=function(parent,newtag,className,cs,innerHTML,onclick){if(parent&&parent.substr)parent=wn.dom.by_id(parent);var c=document.createElement(newtag);if(parent)
@@ -33,10 +138,18 @@
 wn.dom.css=function(ele,s){if(ele&&s){for(var i in s)ele.style[i]=s[i];};return ele;}
 wn.dom.hide=function(ele){ele.style.display='none';}
 wn.dom.show=function(ele,value){if(!value)value='block';ele.style.display=value;}
+/*
+*	lib/js/wn/page.js
+*/
+
 wn.page={set:function(src){var new_selection=$('.inner div.content[_src="'+src+'"]');if(!new_selection.length){wn.assets.execute(src);new_selection=$('.inner div.content[_src="'+src+'"]');}
 $('.inner .current_page').removeClass('current_page');new_selection.addClass('current_page');var title=$('nav ul li a[href*="'+src+'"]').attr('title')||'No Title'
 state=window.location.hash;if(state!=src){window.location.hash=state;}
 else{document.title=title;}}}
+/*
+*	lib/js/lib/json2.js
+*/
+
 var JSON;if(!JSON){JSON={};}
 (function(){"use strict";function f(n){return n<10?'0'+n:n;}
 if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
@@ -61,16 +174,20 @@
 text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
 ('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
 if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
-throw new SyntaxError('JSON.parse');};}}());wn.versions.check();wn.require("lib/js/lib/jquery.min.js");wn.require("lib/js/lib/history/history.min.js");$(document).bind('ready',function(){var base=window.location.href.split('#')[0];$.each($('a[softlink!="false"]'),function(i,v){if(v.href.substr(0,base.length)==base){var path=(v.href.substr(base.length));if(path.substr(0,1)!='#'){v.href=base+'#'+path;}}});if(!wn.settings.no_history&&window.location.hash){wn.page.set(window.location.hash.substr(1));}});</script>
+throw new SyntaxError('JSON.parse');};}}());
+/*
+*	lib/js/core.js
+*/
+
+wn.versions.check();wn.require("lib/js/lib/jquery.min.js");wn.require("lib/js/lib/history/history.min.js");$(document).bind('ready',function(){var base=window.location.href.split('#')[0];$.each($('a[softlink!="false"]'),function(i,v){if(v.href.substr(0,base.length)==base){var path=(v.href.substr(base.length));if(path.substr(0,1)!='#'){v.href=base+'#'+path;}}});if(!wn.settings.no_history&&window.location.hash){wn.page.set(window.location.hash.substr(1));}});</script>
 </head>
 <body>
+	<header></header>
 	<div id="startup_div" style="padding: 8px; font-size: 14px;"></div>
-
 	<!-- Main Starts -->
 	<div id="body_div"> 
-
 		<!--static (no script) content-->
-		<div class="no_script" style='font-family: verdana, sans'>
+		<div class="no_script" style='font-family: Lucida Grande, Verdana, Sans; font-size: 12px'>
 			Loading...
 		</div>
 	</div>
diff --git a/js/app.js b/js/app.js
index 5a8597d..4a27662 100644
--- a/js/app.js
+++ b/js/app.js
@@ -1,3 +1,12 @@
+wn.app = {
+	name: 'ERPNext',
+	license: 'GNU/GPL - Usage Condition: All "erpnext" branding must be kept as it is',
+	source: 'https://github.com/webnotes/erpnext',
+	publisher: 'Web Notes Technologies Pvt Ltd, Mumbai',
+	copyright: '&copy; Web Notes Technologies Pvt Ltd',
+	version: '2.' + window._version_number
+}
+
 wn.settings.no_history = true;
 
 wn.require('lib/js/lib/jquery.min.js');
@@ -11,4 +20,8 @@
 
 $(document).bind('ready', function() {
 	startup();
-});
\ No newline at end of file
+});
+
+$(document).bind('toolbar_setup', function() {
+	$('.brand').html('<b>erp</b>next');	
+})
\ No newline at end of file
diff --git a/templates/index.html b/templates/index.html
index af0b8e5..4a24783 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -6,13 +6,12 @@
 	<script type="text/javascript">%s</script>
 </head>
 <body>
+	<header></header>
 	<div id="startup_div" style="padding: 8px; font-size: 14px;"></div>
-
 	<!-- Main Starts -->
 	<div id="body_div"> 
-
 		<!--static (no script) content-->
-		<div class="no_script" style='font-family: verdana, sans'>
+		<div class="no_script" style='font-family: Lucida Grande, Verdana, Sans; font-size: 12px'>
 			Loading...
 		</div>
 	</div>
diff --git a/version.num b/version.num
index 2e66562..0aede4a 100644
--- a/version.num
+++ b/version.num
@@ -1 +1 @@
-49
\ No newline at end of file
+102
\ No newline at end of file