Merge branch 'master' into sync

Conflicts:
	version.num
diff --git a/build.json b/build.json
index 95a38d6..499d594 100644
--- a/build.json
+++ b/build.json
@@ -9,6 +9,7 @@
 			"lib/js/wn/require.js",
 			"lib/js/wn/dom.js",
 			"lib/js/wn/page.js",
+			"lib/js/wn/misc/user.js",
 			"lib/js/lib/json2.js",
 			"lib/js/core.js"
 		]
@@ -36,7 +37,6 @@
 	{
 		"css/all-web.css": [
 			"lib/css/legacy/body.css",
-			"lib/css/legacy/menus.css",
 			"lib/css/legacy/messages.css",
 			"lib/css/legacy/dialog.css",
 			"lib/css/bootstrap/headings.css",
@@ -52,7 +52,6 @@
 	{
 		"css/all-app.css": [
 			"lib/css/legacy/body.css",
-			"lib/css/legacy/menus.css",
 			"lib/css/legacy/messages.css",
 			"lib/css/legacy/forms.css",
 			"lib/css/legacy/grid.css",
@@ -75,13 +74,12 @@
 
 	{
 		"js/all-web.js": [
-			"lib/js/lib/jquery.min.js:concat",
 			"lib/js/lib/history/history.min.js:concat",
 			"lib/js/lib/bootstrap.min.js:concat",
+			"lib/js/lib/sprintf.js",
 			"lib/js/core.min.js:concat",
 			"lib/js/legacy/globals.js",
 			"lib/js/legacy/utils/datatype.js",
-			"lib/js/legacy/utils/browser_detect.js",
 			"lib/js/legacy/utils/datetime.js",
 			"lib/js/legacy/utils/dom.js",
 			"lib/js/legacy/utils/handler.js",
@@ -116,15 +114,14 @@
 	
 	{
 		"js/all-app.js": [
-			"lib/js/lib/jquery.min.js:concat",
 			"lib/js/lib/history/history.min.js:concat",
 			"lib/js/legacy/jquery/jquery-ui.min.js:concat",
 			"lib/js/legacy/tiny_mce_33/jquery.tinymce.js:concat",
 			"lib/js/lib/bootstrap.min.js:concat",
+			"lib/js/lib/sprintf.js",
 			"lib/js/core.min.js:concat",
 			"lib/js/legacy/globals.js",
 			"lib/js/legacy/utils/datatype.js",
-			"lib/js/legacy/utils/browser_detect.js",
 			"lib/js/legacy/utils/datetime.js",
 			"lib/js/legacy/utils/dom.js",
 			"lib/js/legacy/utils/handler.js",
@@ -175,9 +172,9 @@
 			"lib/js/legacy/app.js",
 			"js/app.js",
 			"erpnext/startup/startup.js",
-			"erpnext/startup/modules.js",
-			"erpnext/startup/toolbar.js",
-			"erpnext/startup/feature_setup.js"
+			"erpnext/startup/js/modules.js",
+			"erpnext/startup/js/toolbar.js",
+			"erpnext/startup/js/feature_setup.js"
 		]
 	}
 	
diff --git a/css/all-app.css b/css/all-app.css
index b2fd2e5..0dea8b7 100644
--- a/css/all-app.css
+++ b/css/all-app.css
@@ -230,59 +230,16 @@
   box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
 }
 
-/*
- *	lib/css/legacy/menus.css
- */
-/******** Menus - menu.js ************/
-
-ul.menu_toolbar {
-	z-index: 30;
-	padding: 0px;
-	margin: 0px;
-	margin-top: 1px;
+.avatar-small {
+	display: inline-block; 
+	min-width: 29px;
+}
+.avatar-small img {
+	height: 24px; 
+	margin-bottom: -7px;
+	max-width: 24px;
 }
 
-ul.menu_toolbar li {
-	list-style: none;
-	margin: 0px;
-	float: left;
-}
-
-.top_menu {
-	margin: 0px;
-	padding: 4px;
-	cursor: pointer;
-	color: #FFF;
-	margin-right: 8px;
-}
-
-.top_menu_mo {
-	background-color: #000;
-
-	-moz-border-radius: 5px;
-	-webkit-border-radius: 5px;
-}
-
-div.menu_toolbar_dropdown {
-	position: absolute;
-	margin-top: 4px;
-	margin-left: 8px;
-	width: 140px;
-	background-color: #FFF;
-	color: #000;
-	display: none;
-	border: 2px solid #333;
-	z-index: 31;
-	overflow-y: auto;
-	overflow-x: hidden;
-}
-
-div.dd_item {
-	cursor: pointer;
-	padding: 4px;
-	background-color: #FFF;
-}
-div.dd_item_mo { background-color: #FE8; }
 /*
  *	lib/css/legacy/messages.css
  */
@@ -1043,7 +1000,7 @@
 }
 
 div.dialog_body {
-	padding: 8px 4px 16px 4px;
+	padding: 8px 8px 16px;
 	border-radius: 5px;
 	-moz-border-radius: 5px;
 	-webkit-border-radius: 5px;	
@@ -2809,10 +2766,11 @@
 }
 
 body {
+	background: url(../images/stripedbg.png) repeat;
 }
 
 .erpnext-footer {
-	margin: 3px auto;
+	margin: 11px auto;
 	text-align: center;
 }
 
diff --git a/css/all-web.css b/css/all-web.css
index 9359de8..36d9cda 100644
--- a/css/all-web.css
+++ b/css/all-web.css
@@ -230,59 +230,16 @@
   box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
 }
 
-/*
- *	lib/css/legacy/menus.css
- */
-/******** Menus - menu.js ************/
-
-ul.menu_toolbar {
-	z-index: 30;
-	padding: 0px;
-	margin: 0px;
-	margin-top: 1px;
+.avatar-small {
+	display: inline-block; 
+	min-width: 29px;
+}
+.avatar-small img {
+	height: 24px; 
+	margin-bottom: -7px;
+	max-width: 24px;
 }
 
-ul.menu_toolbar li {
-	list-style: none;
-	margin: 0px;
-	float: left;
-}
-
-.top_menu {
-	margin: 0px;
-	padding: 4px;
-	cursor: pointer;
-	color: #FFF;
-	margin-right: 8px;
-}
-
-.top_menu_mo {
-	background-color: #000;
-
-	-moz-border-radius: 5px;
-	-webkit-border-radius: 5px;
-}
-
-div.menu_toolbar_dropdown {
-	position: absolute;
-	margin-top: 4px;
-	margin-left: 8px;
-	width: 140px;
-	background-color: #FFF;
-	color: #000;
-	display: none;
-	border: 2px solid #333;
-	z-index: 31;
-	overflow-y: auto;
-	overflow-x: hidden;
-}
-
-div.dd_item {
-	cursor: pointer;
-	padding: 4px;
-	background-color: #FFF;
-}
-div.dd_item_mo { background-color: #FE8; }
 /*
  *	lib/css/legacy/messages.css
  */
@@ -362,7 +319,7 @@
 }
 
 div.dialog_body {
-	padding: 8px 4px 16px 4px;
+	padding: 8px 8px 16px;
 	border-radius: 5px;
 	-moz-border-radius: 5px;
 	-webkit-border-radius: 5px;	
@@ -1617,10 +1574,11 @@
 }
 
 body {
+	background: url(../images/stripedbg.png) repeat;
 }
 
 .erpnext-footer {
-	margin: 3px auto;
+	margin: 11px auto;
 	text-align: center;
 }
 
diff --git a/data/master.sql.gz b/data/master.sql.gz
index 9f2ed7f..8b9fdb9 100644
--- a/data/master.sql.gz
+++ b/data/master.sql.gz
Binary files differ
diff --git a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt
index c628e83..510e922 100644
--- a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt
+++ b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt
@@ -3,26 +3,26 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2011-12-21 11:02:04',
+		'creation': '2012-01-13 11:41:18',
 		'docstatus': 0,
-		'modified': '2012-01-06 14:17:57',
-		'modified_by': 'Administrator',
-		'owner': 'Administrator'
+		'modified': '2012-03-01 13:36:06',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
 	},
 
 	# These values are common for all Print Format
 	{
-		'doc_type': 'Receivable Voucher',
+		'doc_type': u'Receivable Voucher',
 		'doctype': 'Print Format',
-		'html': '<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: "Georgia", serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: "Georgia", serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table thead {\n\t\tborder-bottom: 1px solid black;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px 0px;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t\'Receivable Voucher\',\n\t\t\t\tdoc.name,\n\t\t\t\t\'entries\',\n\t\t\t\t\'RV Detail\',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t\'SR\', \'item_name\', \'description\', \'qty\', \'stock_uom\',\n\t\t\t\t\t\'export_rate\', \'export_amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t\'Sr\', \'Item Name\', \'Description\', \'Qty\',\n\t\t\t\t\t\'UoM\', \'Basic Rate\', \'Amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t\'3%\', \'20%\', \'37%\', \'5%\',\n\t\t\t\t\t\'5%\', \'15%\', \'15%\'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t\'description\' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = \'<div style="padding-left: 15px;"><i>Discount: \' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + \'% on \' + doc.currency + \' \' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + \'</i></div>\';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = \'\';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t\'<div style = "page-break-after: always;" \\\n\t\t\t\t\t\tclass = "page_break"></div>\\\n\t\t\t\t\t\t<div class="page-settings"></div>\';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren(\'RV Tax Detail\', doc.name, \'other_charges\');\n\t\t\tvar rows = \'<table width=100%>\\n\';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t\'<tr>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td>\' + oc[i].description + \'</td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td></td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td width=38%>\' + fmt_money(oc[i].tax_amount) + \'</td>\\n\' +\n\t\t\t\t\t\t\'</tr>\\n\';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + \'</table>\\n\';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class=\'common page-header\'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class=\'header-table\' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td><script>\'<h1>\' + (doc.select_print_heading || \'Invoice\') + \'</h1>\'</script></td></tr>\n\t\t\t<tr><td><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.voucher_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class=\'common page-body\'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class=\'common page-footer\'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class=\'footer-table\' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style=\'padding-right: 10px;\'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style=\'font-weight: bold\'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n',
-		'module': 'Accounts',
+		'html': u'<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: "Georgia", serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: "Georgia", serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table thead {\n\t\tborder-bottom: 1px solid black;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px 0px;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t\'Receivable Voucher\',\n\t\t\t\tdoc.name,\n\t\t\t\t\'entries\',\n\t\t\t\t\'RV Detail\',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t\'SR\', \'item_name\', \'description\', \'qty\', \'stock_uom\',\n\t\t\t\t\t\'export_rate\', \'export_amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t\'Sr\', \'Item Name\', \'Description\', \'Qty\',\n\t\t\t\t\t\'UoM\', \'Basic Rate\', \'Amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t\'3%\', \'20%\', \'37%\', \'5%\',\n\t\t\t\t\t\'5%\', \'15%\', \'15%\'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t\'description\' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = \'<div style="padding-left: 15px;"><i>Discount: \' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + \'% on \' + doc.currency + \' \' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + \'</i></div>\';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = \'\';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t\'<div style = "page-break-after: always;" \\\n\t\t\t\t\t\tclass = "page_break"></div>\\\n\t\t\t\t\t\t<div class="page-settings"></div>\';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren(\'RV Tax Detail\', doc.name, \'other_charges\');\n\t\t\tvar rows = \'<table width=100%>\\n\';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t\'<tr>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td>\' + oc[i].description + \'</td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td></td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td width=38%>\' + fmt_money(oc[i].tax_amount) + \'</td>\\n\' +\n\t\t\t\t\t\t\'</tr>\\n\';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + \'</table>\\n\';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class=\'common page-header\'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class=\'header-table\' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td><script>\'<h1>\' + (doc.select_print_heading || \'Invoice\') + \'</h1>\'</script></td></tr>\n\t\t\t<tr><td><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.posting_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class=\'common page-body\'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class=\'common page-footer\'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class=\'footer-table\' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style=\'padding-right: 10px;\'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style=\'font-weight: bold\'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n',
+		'module': u'Accounts',
 		'name': '__common__',
-		'standard': 'Yes'
+		'standard': u'Yes'
 	},
 
 	# Print Format, Sales Invoice Classic
 	{
 		'doctype': 'Print Format',
-		'name': 'Sales Invoice Classic'
+		'name': u'Sales Invoice Classic'
 	}
 ]
\ No newline at end of file
diff --git a/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt b/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt
index 0b4c15c..3c44fc7 100644
--- a/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt
+++ b/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt
@@ -3,26 +3,26 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2011-12-21 11:02:04',
+		'creation': '2012-01-13 11:41:18',
 		'docstatus': 0,
-		'modified': '2012-01-06 14:18:11',
-		'modified_by': 'Administrator',
-		'owner': 'Administrator'
+		'modified': '2012-03-01 13:36:24',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
 	},
 
 	# These values are common for all Print Format
 	{
-		'doc_type': 'Receivable Voucher',
+		'doc_type': u'Receivable Voucher',
 		'doctype': 'Print Format',
-		'html': '<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: "Helvetica", "Arial", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: "Helvetica", "Arial", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t\tborder-style: none !important;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t\tborder-style: none !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h1 {\n\t\ttext-transform: uppercase;\n\t\tcolor: white;\n\t\tfont-size: 55px;\n\t\tfont-style: italic;\n\t}\n\n\ttable.header-table thead tr:nth-child(1) div {\n\t\theight: 24px;\n\t\tbackground-color: #696969;\n\t\tvertical-align: middle;\n\t\tpadding: 12px 0px 0px 0px;\n\t\twidth: 100%;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body table tr td {\n\t\tbackground-color: #DCDCDC !important;\n\t}\n\n\tdiv.page-body table tr:nth-child(1) td {\n\t\tbackground-color: #696969 !important;\n\t\tcolor: white !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table tfoot td {\n\t\tbackground-color: #696969;\n\t\theight: 10px;\n\t}\n\n\t.imp-details {\n\t\tbackground-color: #DCDCDC;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t\'Receivable Voucher\',\n\t\t\t\tdoc.name,\n\t\t\t\t\'entries\',\n\t\t\t\t\'RV Detail\',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t\'SR\', \'item_name\', \'description\', \'qty\', \'stock_uom\',\n\t\t\t\t\t\'export_rate\', \'export_amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t\'Sr\', \'Item Name\', \'Description\', \'Qty\',\n\t\t\t\t\t\'UoM\', \'Basic Rate\', \'Amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t\'3%\', \'20%\', \'37%\', \'5%\',\n\t\t\t\t\t\'5%\', \'15%\', \'15%\'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t\'description\' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = \'<div style="padding-left: 15px;"><i>Discount: \' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + \'% on \' + doc.currency + \' \' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + \'</i></div>\';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = \'\';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t\'<div style = "page-break-after: always;" \\\n\t\t\t\t\t\tclass = "page_break"></div>\\\n\t\t\t\t\t\t<div class="page-settings"></div>\';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren(\'RV Tax Detail\', doc.name, \'other_charges\');\n\t\t\tvar rows = \'<table width=100%>\\n\';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t\'<tr>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td>\' + oc[i].description + \'</td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td></td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td width=38%>\' + fmt_money(oc[i].tax_amount) + \'</td>\\n\' +\n\t\t\t\t\t\t\'</tr>\\n\';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + \'</table>\\n\';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class=\'common page-header\'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class=\'header-table\' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><div><script>\'<h1>\' + (doc.select_print_heading || \'Invoice\') + \'</h1>\'</script></div></td></tr>\n\t\t\t<tr><td colspan=2><div style="height:15px"></div></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr class=\'imp-details\'>\n\t\t\t\t\t\t<td><b>Invoice No.</b></td>\n\t\t\t\t\t\t<td><script>cur_frm.docname</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.voucher_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class=\'common page-body\'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class=\'common page-footer\'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class=\'footer-table\' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style=\'padding-right: 10px;\'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style=\'font-weight: bold\' class=\'imp-details\'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr><td colspan=2><div></div></td><tr>\n\t\t</tfoot>\n\t</table>\n</div>\n',
-		'module': 'Accounts',
+		'html': u'<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: "Helvetica", "Arial", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: "Helvetica", "Arial", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 10px 0px;\n\t}\n\n\ttable {\n\t\tborder-collapse: collapse;\n\t\twidth: 100%;\n\t\tvertical-align: top;\n\t\tborder-style: none !important;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t\tborder-style: none !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h1 {\n\t\ttext-transform: uppercase;\n\t\tcolor: white;\n\t\tfont-size: 55px;\n\t\tfont-style: italic;\n\t}\n\n\ttable.header-table thead tr:nth-child(1) div {\n\t\theight: 24px;\n\t\tbackground-color: #696969;\n\t\tvertical-align: middle;\n\t\tpadding: 12px 0px 0px 0px;\n\t\twidth: 100%;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body table tr td {\n\t\tbackground-color: #DCDCDC !important;\n\t}\n\n\tdiv.page-body table tr:nth-child(1) td {\n\t\tbackground-color: #696969 !important;\n\t\tcolor: white !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n\n\ttable.footer-table tfoot td {\n\t\tbackground-color: #696969;\n\t\theight: 10px;\n\t}\n\n\t.imp-details {\n\t\tbackground-color: #DCDCDC;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t\'Receivable Voucher\',\n\t\t\t\tdoc.name,\n\t\t\t\t\'entries\',\n\t\t\t\t\'RV Detail\',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t\'SR\', \'item_name\', \'description\', \'qty\', \'stock_uom\',\n\t\t\t\t\t\'export_rate\', \'export_amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t\'Sr\', \'Item Name\', \'Description\', \'Qty\',\n\t\t\t\t\t\'UoM\', \'Basic Rate\', \'Amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t\'3%\', \'20%\', \'37%\', \'5%\',\n\t\t\t\t\t\'5%\', \'15%\', \'15%\'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t\'description\' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = \'<div style="padding-left: 15px;"><i>Discount: \' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + \'% on \' + doc.currency + \' \' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + \'</i></div>\';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = \'\';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t\'<div style = "page-break-after: always;" \\\n\t\t\t\t\t\tclass = "page_break"></div>\\\n\t\t\t\t\t\t<div class="page-settings"></div>\';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren(\'RV Tax Detail\', doc.name, \'other_charges\');\n\t\t\tvar rows = \'<table width=100%>\\n\';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t\'<tr>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td>\' + oc[i].description + \'</td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td></td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td width=38%>\' + fmt_money(oc[i].tax_amount) + \'</td>\\n\' +\n\t\t\t\t\t\t\'</tr>\\n\';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + \'</table>\\n\';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class=\'common page-header\'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class=\'header-table\' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><div><script>\'<h1>\' + (doc.select_print_heading || \'Invoice\') + \'</h1>\'</script></div></td></tr>\n\t\t\t<tr><td colspan=2><div style="height:15px"></div></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr class=\'imp-details\'>\n\t\t\t\t\t\t<td><b>Invoice No.</b></td>\n\t\t\t\t\t\t<td><script>cur_frm.docname</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.posting_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class=\'common page-body\'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class=\'common page-footer\'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class=\'footer-table\' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style=\'padding-right: 10px;\'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style=\'font-weight: bold\' class=\'imp-details\'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\t<tr><td colspan=2><div></div></td><tr>\n\t\t</tfoot>\n\t</table>\n</div>\n',
+		'module': u'Accounts',
 		'name': '__common__',
-		'standard': 'Yes'
+		'standard': u'Yes'
 	},
 
 	# Print Format, Sales Invoice Modern
 	{
 		'doctype': 'Print Format',
-		'name': 'Sales Invoice Modern'
+		'name': u'Sales Invoice Modern'
 	}
 ]
\ No newline at end of file
diff --git a/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt b/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt
index dc85a5f..b91f5cd 100644
--- a/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt
+++ b/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt
@@ -3,26 +3,26 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2011-12-21 11:02:04',
+		'creation': '2012-01-13 11:41:18',
 		'docstatus': 0,
-		'modified': '2012-01-06 14:18:25',
-		'modified_by': 'Administrator',
-		'owner': 'Administrator'
+		'modified': '2012-03-01 13:36:52',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
 	},
 
 	# These values are common for all Print Format
 	{
-		'doc_type': 'Receivable Voucher',
+		'doc_type': u'Receivable Voucher',
 		'doctype': 'Print Format',
-		'html': '<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: "Arial", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: "Arial", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 0px;\n\t}\n\n\ttable {\n\t\twidth: 100% !important;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\n\ttable, td {\n\t\tborder-collapse: collapse !important;\n\t\tpadding: 0px;\n\t\tmargin: 0px !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px;\n\t}\n\n\ttable.header-table > thead,\n\ttable.header-table > tbody > tr > td,\n\ttable.footer-table > tbody > tr > td {\n\t\tborder: 1px solid black;\n\t\tpadding: 5px;\n\t}\n\n\ttable.footer-table > tbody,\n\ttable.header-table > thead {\n\t\tborder-bottom: 3px solid black;\n\t}\n\n\ttable.header-table > thead {\n\t\tborder-top: 3px solid black;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body td {\n\t\tbackground-color: white !important;\n\t\tborder: 1px solid black !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t\'Receivable Voucher\',\n\t\t\t\tdoc.name,\n\t\t\t\t\'entries\',\n\t\t\t\t\'RV Detail\',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t\'SR\', \'item_name\', \'description\', \'qty\', \'stock_uom\',\n\t\t\t\t\t\'export_rate\', \'export_amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t\'Sr\', \'Item Name\', \'Description\', \'Qty\',\n\t\t\t\t\t\'UoM\', \'Basic Rate\', \'Amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t\'3%\', \'20%\', \'37%\', \'5%\',\n\t\t\t\t\t\'5%\', \'15%\', \'15%\'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t\'description\' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = \'<div style="padding-left: 15px;"><i>Discount: \' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + \'% on \' + doc.currency + \' \' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + \'</i></div>\';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = \'\';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t\'<div style = "page-break-after: always;" \\\n\t\t\t\t\t\tclass = "page_break"></div>\\\n\t\t\t\t\t\t<div class="page-settings"></div>\';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren(\'RV Tax Detail\', doc.name, \'other_charges\');\n\t\t\tvar rows = \'<table width=100%>\\n\';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t\'<tr>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td>\' + oc[i].description + \'</td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td></td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td width=38%>\' + fmt_money(oc[i].tax_amount) + \'</td>\\n\' +\n\t\t\t\t\t\t\'</tr>\\n\';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + \'</table>\\n\';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class=\'common page-header\'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class=\'header-table\' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><script>\'<h1>\' + (doc.select_print_heading || \'Invoice\') + \'</h1>\'</script></td></tr>\n\t\t\t<tr><td colspan=2><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.voucher_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class=\'common page-body\'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class=\'common page-footer\'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class=\'footer-table\' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style=\'padding-right: 10px;\'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style=\'font-weight: bold\'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n',
-		'module': 'Accounts',
+		'html': u'<!--\n\tSample Print Format for ERPNext\n\tPlease use at your own discretion\n\tFor suggestions and contributions:\n\t\thttps://github.com/webnotes/erpnext-print-templates\n\n\tFreely usable under MIT license\n-->\n\n<!-- Style Settings -->\n<style>\n\t/*\n\t\tcommon style for whole page\n\t\tThis should include:\n\t\t+ page size related settings\n\t\t+ font family settings\n\t\t+ line spacing settings\n\t*/\n\t@media screen {\n\t\tbody {\n\t\t\twidth: 8.3in;\n\t\t}\n\t}\n\n\thtml, body, div, span, td {\n\t\tfont-family: "Arial", sans-serif;\n\t\tfont-size: 12px;\n\t}\n\n\tbody {\n\t\tpadding: 10px;\n\t\tmargin: auto;\n\t\tfont-size: 12px;\n\t\tline-height: 150%;\n\t}\n\n\t.common {\n\t\tfont-family: "Arial", sans-serif !important;\n\t\tfont-size: 12px;\n\t\tpadding: 0px;\n\t}\n\n\ttable {\n\t\twidth: 100% !important;\n\t\tvertical-align: top;\n\t}\n\n\ttable td {\n\t\tpadding: 2px 0px;\n\t}\n\n\ttable, td {\n\t\tborder-collapse: collapse !important;\n\t\tpadding: 0px;\n\t\tmargin: 0px !important;\n\t}\n\t\n\ttable h1, h2, h3, h4, h5, h6 {\n\t\tpadding: 0px;\n\t\tmargin: 0px;\n\t}\n\n\ttable.header-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.header-table h3 {\n\t\tcolor: gray;\n\t}\n\n\ttable.header-table thead td {\n\t\tpadding: 5px;\n\t}\n\n\ttable.header-table > thead,\n\ttable.header-table > tbody > tr > td,\n\ttable.footer-table > tbody > tr > td {\n\t\tborder: 1px solid black;\n\t\tpadding: 5px;\n\t}\n\n\ttable.footer-table > tbody,\n\ttable.header-table > thead {\n\t\tborder-bottom: 3px solid black;\n\t}\n\n\ttable.header-table > thead {\n\t\tborder-top: 3px solid black;\n\t}\n\n\tdiv.page-body table td:nth-child(6),\n\tdiv.page-body table td:nth-child(7) {\n\t\ttext-align: right;\n\t}\n\n\tdiv.page-body td {\n\t\tbackground-color: white !important;\n\t\tborder: 1px solid black !important;\n\t}\n\n\ttable.footer-table td {\n\t\tvertical-align: top;\n\t}\n\n\ttable.footer-table td table td:nth-child(2),\n\ttable.footer-table td table td:nth-child(3) {\n\t\ttext-align: right;\n\t}\n</style>\n\n\n<!-- Javascript -->\n<script>\n\tsi_std = {\n\t\tprint_item_table: function() {\n\t\t\tvar table = print_table(\n\t\t\t\t\'Receivable Voucher\',\n\t\t\t\tdoc.name,\n\t\t\t\t\'entries\',\n\t\t\t\t\'RV Detail\',\n\t\t\t\t[// Here specify the table columns to be displayed\n\t\t\t\t\t\'SR\', \'item_name\', \'description\', \'qty\', \'stock_uom\',\n\t\t\t\t\t\'export_rate\', \'export_amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the labels of column headings\n\t\t\t\t\t\'Sr\', \'Item Name\', \'Description\', \'Qty\',\n\t\t\t\t\t\'UoM\', \'Basic Rate\', \'Amount\'\n\t\t\t\t],\n\t\t\t\t[// Here specify the column widths\n\t\t\t\t\t\'3%\', \'20%\', \'37%\', \'5%\',\n\t\t\t\t\t\'5%\', \'15%\', \'15%\'\n\t\t\t\t],\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\t{\n\t\t\t\t\t\'description\' : function(data_row) {\n\t\t\t\t\t\tif(data_row.adj_rate) {\n\t\t\t\t\t\t\tvar to_append = \'<div style="padding-left: 15px;"><i>Discount: \' + \n\t\t\t\t\t\t\t\tdata_row.adj_rate + \'% on \' + doc.currency + \' \' +\n\t\t\t\t\t\t\t\tfmt_money(data_row.ref_rate) + \'</i></div>\';\n\t\t\t\t\t\t\tif(data_row.description.indexOf(to_append)==-1) {\n\t\t\t\t\t\t\t\treturn data_row.description + to_append;\n\t\t\t\t\t\t\t} else { return data_row.description; }\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn data_row.description;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t// This code takes care of page breaks\n\t\t\tif(table.appendChild) {\n\t\t\t\tout = table.innerHTML;\n\t\t\t} else {\n\t\t\t\tout = \'\';\n\t\t\t\tfor(var i=0; i < (table.length-1); i++) {\n\t\t\t\t\tout += table[i].innerHTML + \n\t\t\t\t\t\t\'<div style = "page-break-after: always;" \\\n\t\t\t\t\t\tclass = "page_break"></div>\\\n\t\t\t\t\t\t<div class="page-settings"></div>\';\n\t\t\t\t}\n\t\t\t\tout += table[table.length-1].innerHTML;\n\t\t\t}\n\t\t\treturn out;\n\t\t},\n\n\n\t\tprint_other_charges: function(parent) {\n\t\t\tvar oc = getchildren(\'RV Tax Detail\', doc.name, \'other_charges\');\n\t\t\tvar rows = \'<table width=100%>\\n\';\n\t\t\tfor(var i=0; i<oc.length; i++) {\n\t\t\t\tif(!oc[i].included_in_print_rate) {\n\t\t\t\t\trows +=\n\t\t\t\t\t\t\'<tr>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td>\' + oc[i].description + \'</td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td></td>\\n\' +\n\t\t\t\t\t\t\t\'\\t<td width=38%>\' + fmt_money(oc[i].tax_amount) + \'</td>\\n\' +\n\t\t\t\t\t\t\'</tr>\\n\';\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn rows + \'</table>\\n\';\n\t\t}\n\t};\n</script>\n\n\n<!-- Page Layout Settings -->\n<div class=\'common page-header\'>\n\t<!-- \n\t\tPage Header will contain\n\t\t\t+ table 1\n\t\t\t\t+ table 1a\n\t\t\t\t\t- Name\n\t\t\t\t\t- Address\n\t\t\t\t\t- Contact\n\t\t\t\t\t- Mobile No\n\t\t\t\t+ table 1b\n\t\t\t\t\t- Voucher Date\n\t\t\t\t\t- Due Date\n\t-->\n\t<table class=\'header-table\' cellspacing=0>\n\t\t<thead>\n\t\t\t<tr><td colspan=2><script>\'<h1>\' + (doc.select_print_heading || \'Invoice\') + \'</h1>\'</script></td></tr>\n\t\t\t<tr><td colspan=2><h3><script>cur_frm.docname</script></h3></td></tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60%><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=39%><b>Name</b></td>\n\t\t\t\t\t\t<td><script>doc.customer_name</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Address</b></td>\n\t\t\t\t\t\t<td><script>replace_newlines(doc.address_display)</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Contact</b></td>\n\t\t\t\t\t\t<td><script>doc.contact_display</script></td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody></table></td>\n\t\t\t\t<td><table width=100% cellspacing=0><tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td width=40%><b>Invoice Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.posting_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td><b>Due Date</b></td>\n\t\t\t\t\t\t<td><script>date.str_to_user(doc.due_date)</script></td>\n\t\t\t\t\t<tr>\t\t\t\t\t\n\t\t\t\t</tbody></table></td>\n\t\t\t</tr>\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n<div class=\'common page-body\'>\n\t<!-- \n\t\tPage Body will contain\n\t\t\t+ table 2\n\t\t\t\t- Sales Invoice Data\n\t-->\n\t<script>si_std.print_item_table()</script>\n</div>\n<div class=\'common page-footer\'>\n\t<!-- \n\t\tPage Footer will contain\n\t\t\t+ table 3\n\t\t\t\t- Terms and Conditions\n\t\t\t\t- Total Rounded Amount Calculation\n\t\t\t\t- Total Rounded Amount in Words\n\t-->\n\t<table class=\'footer-table\' width=100% cellspacing=0>\n\t\t<thead>\n\t\t\t\n\t\t</thead>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t<td width=60% style=\'padding-right: 10px;\'>\n\t\t\t\t\t<b>Terms, Conditions &amp; Other Information:</b><br />\n\t\t\t\t\t<script>doc.terms</script>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<table cellspacing=0 width=100%><tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Net Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td width=38%><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.net_total/doc.conversion_rate)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td colspan=3><script>si_std.print_other_charges()</script></td></tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>Grand Total</td>\n\t\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.grand_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr style=\'font-weight: bold\'>\n\t\t\t\t\t\t\t<td>Rounded Total</td>\n\t\t\t\t\t\t\t<td><script>doc.currency</script></td>\n\t\t\t\t\t\t\t<td><script>\n\t\t\t\t\t\t\t\tfmt_money(doc.rounded_total_export)\n\t\t\t\t\t\t\t</script></td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</tbody></table>\n\t\t\t\t\t<br /><b>In Words</b><br />\n\t\t\t\t\t<i><script>doc.in_words_export</script></i>\n\t\t\t\t</td>\n\t\t\t</tr>\t\t\n\t\t</tbody>\n\t\t<tfoot>\n\t\t\n\t\t</tfoot>\n\t</table>\n</div>\n',
+		'module': u'Accounts',
 		'name': '__common__',
-		'standard': 'Yes'
+		'standard': u'Yes'
 	},
 
 	# Print Format, Sales Invoice Spartan
 	{
 		'doctype': 'Print Format',
-		'name': 'Sales Invoice Spartan'
+		'name': u'Sales Invoice Spartan'
 	}
 ]
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/gl_control/gl_control.py b/erpnext/accounts/doctype/gl_control/gl_control.py
index c64d64e..93bef5d 100644
--- a/erpnext/accounts/doctype/gl_control/gl_control.py
+++ b/erpnext/accounts/doctype/gl_control/gl_control.py
@@ -177,7 +177,7 @@
 	#----------------------------------------------------------------------------
 	def make_single_entry(self,parent,d,le_map,cancel, merge_entries):
 		if self.get_val(le_map['account'], d, parent) and (self.get_val(le_map['debit'], d, parent) or self.get_val(le_map['credit'], d, parent)):
-			flist = ['account','cost_center','against','debit','credit','remarks','voucher_type','voucher_no','transaction_date','posting_date','fiscal_year','against_voucher','against_voucher_type','company','is_opening', 'aging_date']
+			flist = ['account','cost_center','against','debit','credit','remarks','voucher_type','voucher_no','posting_date','fiscal_year','against_voucher','against_voucher_type','company','is_opening', 'aging_date']
 
 			# Check budget before gl entry
 			#check budget only if account is expense account
@@ -536,7 +536,6 @@
 
 	# update new rv 
 
-	new_rv.doc.voucher_date = new_rv.doc.next_date
 	new_rv.doc.posting_date = new_rv.doc.next_date
 	new_rv.doc.aging_date = new_rv.doc.next_date
 	new_rv.doc.due_date = add_days(new_rv.doc.next_date, cint(date_diff(prev_rv.doc.due_date, prev_rv.doc.posting_date)))
diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index 00b6844..49b0593 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -52,10 +52,12 @@
 			msgprint("GL Entry: Debit or Credit amount is mandatory for %s" % self.doc.account)
 			raise Exception
 			
+			
+		# COMMMENTED below to allow zero amount (+ and -) entry in tax table
 		# Debit and credit can not done at the same time
-		if flt(self.doc.credit) != 0 and flt(self.doc.debit) != 0:
-			msgprint("Sorry you cannot credit and debit under same account head.")
-			raise Exception, "Validation Error."
+		#if flt(self.doc.credit) != 0 and flt(self.doc.debit) != 0:
+		#	msgprint("Sorry you cannot credit and debit under same account head.")
+		#	raise Exception, "Validation Error."
 		
 	# Cost center is required only if transaction made against pl account
 	#--------------------------------------------------------------------
@@ -152,11 +154,15 @@
 		amt = flt(self.doc.debit) - flt(self.doc.credit)
 		if det[0][2] == 'Credit': amt = -amt
 
-		debit = cancel and -1 * flt(self.doc.credit) or flt(self.doc.debit)
-		credit = cancel and -1 * flt(self.doc.debit) or flt(self.doc.credit)
-		
+		if cancel:
+			debit = -1 * flt(self.doc.credit)
+			credit = -1 * flt(self.doc.debit)
+		else:
+			debit = flt(self.doc.debit)
+			credit = flt(self.doc.credit)
+
 		self.create_new_balances(det)
-		
+
 		# build dict
 		p = {
 			'debit': self.doc.is_opening=='No' and flt(debit) or 0
@@ -197,7 +203,7 @@
 					and ifnull(a.is_pl_account, 'No') = 'No'
 					and ab.period = ab.fiscal_year
 					and fy.name = ab.fiscal_year
-					and fy.year_start_date > %(posting_date)s""" % p)
+					and fy.year_start_date > '%(posting_date)s'""" % p)
 
 		# Update balance for all period for future years
 		sql("""update `tabAccount Balance` ab, `tabAccount` a, `tabFiscal Year` fy 
@@ -209,7 +215,7 @@
 					and ab.account = a.name
 					and ifnull(a.is_pl_account, 'No') = 'No'
 					and fy.name = ab.fiscal_year
-					and fy.year_start_date > %(posting_date)s""" % p)
+					and fy.year_start_date > '%(posting_date)s'""" % p)
 
 
 
diff --git a/erpnext/accounts/doctype/payable_voucher/payable_voucher.js b/erpnext/accounts/doctype/payable_voucher/payable_voucher.js
index a465ec0..99bd24c 100644
--- a/erpnext/accounts/doctype/payable_voucher/payable_voucher.js
+++ b/erpnext/accounts/doctype/payable_voucher/payable_voucher.js
@@ -45,11 +45,14 @@
 //------------------------
 cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
 	var callback = function(doc, dt, dn) {
-		if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc,dt,dn);
+		var callback1 = function(doc, dt, dn) {
+			if(doc.__islocal && doc.supplier) cur_frm.cscript.supplier(doc,dt,dn);
+		}
+	
+		// defined in purchase_common.js
+		cur_frm.cscript.update_item_details(doc, dt, dn, callback1);
 	}
-		
-	// defined in purchase_common.js
-	cur_frm.cscript.update_item_details(doc, cdt, cdn, callback);
+	cur_frm.cscript.dynamic_label(doc, dt, dn, callback);
 }
 
 // Refresh
@@ -58,7 +61,7 @@
 	
 	cur_frm.clear_custom_buttons();
 
-	cur_frm.cscript.dynamic_label(doc, cdt, cdn);
+	if (!cur_frm.cscript.is_onload) cur_frm.cscript.dynamic_label(doc, dt, dn);
 
 
 	// Show / Hide button
diff --git a/erpnext/accounts/doctype/payable_voucher/payable_voucher.py b/erpnext/accounts/doctype/payable_voucher/payable_voucher.py
index fe733f7..1a09a45 100644
--- a/erpnext/accounts/doctype/payable_voucher/payable_voucher.py
+++ b/erpnext/accounts/doctype/payable_voucher/payable_voucher.py
@@ -168,9 +168,6 @@
 		return ret
 
 
-	def get_comp_base_currency(self):
-		return get_obj('Purchase Common').get_comp_base_currency(self.doc.company)
-	
 
 # *************************** Server Utility Functions *****************************
 	# Get Company abbr
diff --git a/erpnext/accounts/doctype/payable_voucher/payable_voucher.txt b/erpnext/accounts/doctype/payable_voucher/payable_voucher.txt
index 53466e1..f7d66ea 100755
--- a/erpnext/accounts/doctype/payable_voucher/payable_voucher.txt
+++ b/erpnext/accounts/doctype/payable_voucher/payable_voucher.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:11',
 		'docstatus': 0,
-		'modified': '2012-02-27 18:25:38',
+		'modified': '2012-03-02 12:28:23',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -24,7 +24,7 @@
 		'server_code_error': u' ',
 		'show_in_menu': 0,
 		'subject': u'From %(supplier_name)s worth %(grand_total)s due on %(due_date)s | %(outstanding_amount)s outstanding',
-		'version': 520
+		'version': 521
 	},
 
 	# These values are common for all DocField
@@ -310,22 +310,6 @@
 
 	# DocField
 	{
-		'default': u'Today',
-		'doctype': u'DocField',
-		'fieldname': u'voucher_date',
-		'fieldtype': u'Date',
-		'in_filter': 1,
-		'label': u'Voucher Date',
-		'no_copy': 0,
-		'oldfieldname': u'voucher_date',
-		'oldfieldtype': u'Date',
-		'permlevel': 0,
-		'reqd': 1,
-		'search_index': 1
-	},
-
-	# DocField
-	{
 		'doctype': u'DocField',
 		'fieldname': u'due_date',
 		'fieldtype': u'Date',
@@ -613,7 +597,7 @@
 		'label': u'More Info',
 		'oldfieldtype': u'Section Break',
 		'permlevel': 0,
-		'print_hide': 0
+		'print_hide': 1
 	},
 
 	# DocField
@@ -622,7 +606,7 @@
 		'fieldtype': u'Column Break',
 		'oldfieldtype': u'Column Break',
 		'permlevel': 0,
-		'print_hide': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -681,6 +665,7 @@
 		'fieldtype': u'Column Break',
 		'oldfieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -750,7 +735,7 @@
 		'label': u'Advances',
 		'oldfieldtype': u'Section Break',
 		'permlevel': 0,
-		'print_hide': 0
+		'print_hide': 1
 	},
 
 	# DocField
@@ -785,7 +770,8 @@
 		'fieldtype': u'Section Break',
 		'label': u'TDS',
 		'oldfieldtype': u'Section Break',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -793,6 +779,7 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -839,6 +826,7 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -894,6 +882,7 @@
 		'fieldtype': u'Column Break',
 		'oldfieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
diff --git a/erpnext/accounts/doctype/pv_detail/pv_detail.txt b/erpnext/accounts/doctype/pv_detail/pv_detail.txt
index 826ad8e..54f77bd 100755
--- a/erpnext/accounts/doctype/pv_detail/pv_detail.txt
+++ b/erpnext/accounts/doctype/pv_detail/pv_detail.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:17',
 		'docstatus': 0,
-		'modified': '2012-02-27 18:42:06',
+		'modified': '2012-03-05 10:54:12',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -22,7 +22,7 @@
 		'section_style': u'Tray',
 		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'version': 43
+		'version': 45
 	},
 
 	# These values are common for all DocField
@@ -100,10 +100,11 @@
 	# DocField
 	{
 		'doctype': u'DocField',
-		'fieldname': u'import_ref_rate',
+		'fieldname': u'purchase_ref_rate',
 		'fieldtype': u'Currency',
-		'label': u'Ref Rate ',
+		'label': u'Ref Rate *',
 		'permlevel': 0,
+		'print_hide': 1,
 		'trigger': u'Client'
 	},
 
@@ -114,42 +115,7 @@
 		'fieldtype': u'Currency',
 		'label': u'Discount %',
 		'permlevel': 0,
-		'trigger': u'Client'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'import_rate',
-		'fieldtype': u'Currency',
-		'label': u'Rate ',
-		'oldfieldname': u'import_rate',
-		'oldfieldtype': u'Currency',
-		'permlevel': 0,
-		'print_hide': 0,
-		'reqd': 1,
-		'trigger': u'Client'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'import_amount',
-		'fieldtype': u'Currency',
-		'label': u'Amount',
-		'oldfieldname': u'import_amount',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1,
-		'reqd': 1
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'purchase_ref_rate',
-		'fieldtype': u'Currency',
-		'label': u'Ref Rate *',
-		'permlevel': 0,
+		'print_hide': 1,
 		'trigger': u'Client'
 	},
 
@@ -182,6 +148,43 @@
 
 	# DocField
 	{
+		'doctype': u'DocField',
+		'fieldname': u'import_ref_rate',
+		'fieldtype': u'Currency',
+		'label': u'Ref Rate ',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': u'Client'
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'import_rate',
+		'fieldtype': u'Currency',
+		'label': u'Rate ',
+		'oldfieldname': u'import_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'print_hide': 0,
+		'reqd': 1,
+		'trigger': u'Client'
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'import_amount',
+		'fieldtype': u'Currency',
+		'label': u'Amount',
+		'oldfieldname': u'import_amount',
+		'oldfieldtype': u'Currency',
+		'permlevel': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
 		'colour': u'White:FFF',
 		'doctype': u'DocField',
 		'fieldname': u'expense_head',
diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
index bc0a145..391bbcd 100644
--- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
+++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
@@ -42,27 +42,31 @@
 }
 
 cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
-	var callback2 = null;
-	if(doc.customer && doc.__islocal) {
+	var callback = function(doc, dt, dn) {
 		// called from mapper, update the account names for items and customer
-		callback2 = function(doc, dt, dn) {
-			$c_obj(make_doclist(doc.doctype,doc.name),
-				'load_default_accounts','',
-				function(r,rt) {
-					refresh_field('entries');
-					cur_frm.cscript.customer(doc,dt,dn,onload=true);
-				}
-			);
+		var callback2 = function(doc, dt, dn) {
+			if(doc.customer && doc.__islocal) {
+				$c_obj(make_doclist(doc.doctype,doc.name),
+					'load_default_accounts','',
+					function(r,rt) {
+						refresh_field('entries');
+						cur_frm.cscript.customer(doc,dt,dn,onload=true);
+					}
+				);
+			}
 		}
-	}
-	// defined in sales_common.js
-	var callback1 = function(doc, dt, dn) {
-		//for previously created sales invoice, set required field related to pos	
-		cur_frm.cscript.update_item_details(doc, dt, dn, callback2);
-	}
+		// defined in sales_common.js
+		var callback1 = function(doc, dt, dn) {
+			//for previously created sales invoice, set required field related to pos	
+			cur_frm.cscript.update_item_details(doc, dt, dn, callback2);
+		}
 		
-	if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn,callback1);
-	else cur_frm.cscript.update_item_details(doc, dt, dn, callback2);
+		if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn,callback1);
+		else cur_frm.cscript.update_item_details(doc, dt, dn, callback2);
+	}
+
+	cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); 
+
 }
 
 
@@ -97,16 +101,11 @@
 cur_frm.cscript.refresh = function(doc, dt, dn) {
 	cur_frm.cscript.is_opening(doc, dt, dn);
 	cur_frm.cscript.hide_fields(doc, dt, dn);
-
-	var callback = function() {
-		cur_frm.cscript.dynamic_label(doc, dt, dn);
-	}
-	cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); 
-
-
 	// Show / Hide button
 	cur_frm.clear_custom_buttons();
 
+	if (!cur_frm.cscript.is_onload)	cur_frm.cscript.hide_price_list_currency(doc, dt, dn); 
+
 	if(doc.docstatus==1) {
 		cur_frm.add_custom_button('View Ledger', cur_frm.cscript['View Ledger Entry']);
 		cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py
index 03fd762..a3412dd 100644
--- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py
+++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py
@@ -66,11 +66,11 @@
 				
 			for i in lst:
 				val = pos and pos[0][i] or ''
-				webnotes.conn.set(self.doc,i,val)
+				self.doc.fields[i] = val
 			self.set_pos_item_values()
 			
 			val = pos and flt(pos[0]['conversion_rate']) or 0	
-			webnotes.conn.set(self.doc,'conversion_rate',val)
+			self.doc.conversion_rate = val
 
 			#fetch terms	
 			if self.doc.tc_name:	 self.get_tc_details()
@@ -167,16 +167,19 @@
 	# Item Details
 	# -------------
 	def get_item_details(self, args=None):
-		args = eval(args)
-		if args['item_code']:
+		args = args and eval(args) or {}
+		if args.get('item_code'):
 			ret = get_obj('Sales Common').get_item_details(args, self)
 			return self.get_pos_details(args, ret)
 		else:
 			obj = get_obj('Sales Common')
 			for doc in self.doclist:
 				if doc.fields.get('item_code'):
-					ret = obj.get_item_details(doc.item_code, self)
-					ret = self.get_pos_details(doc.item_code, ret)
+					arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), 
+						'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
+
+					ret = obj.get_item_details(arg, self)
+					ret = self.get_pos_details(arg, ret)
 					for r in ret:
 						if not doc.fields.get(r):
 							doc.fields[r] = ret[r]		
@@ -205,14 +208,6 @@
 		get_obj('Sales Common').get_adj_percent(self)
 
 
-	def get_comp_base_currency(self):
-		return get_obj('Sales Common').get_comp_base_currency(self.doc.company)
-
-	def get_price_list_currency(self):
-		return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company)
-
-
-
 	# Get tax rate if account type is tax
 	# ------------------------------------
 	def get_rate(self,arg):
@@ -538,7 +533,7 @@
 		self.values.append({
 			'item_code'					 : d.item_code,
 			'warehouse'					 : wh,
-			'transaction_date'		: self.doc.voucher_date,
+			'transaction_date'			: getdate(self.doc.modified).strftime('%Y-%m-%d'),
 			'posting_date'				: self.doc.posting_date,
 			'posting_time'				: self.doc.posting_time,
 			'voucher_type'				: 'Receivable Voucher',
diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt
index b2777e3..54794cf 100644
--- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt
+++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:18',
 		'docstatus': 0,
-		'modified': '2012-02-27 17:34:46',
+		'modified': '2012-03-02 12:22:21',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -21,7 +21,7 @@
 
 	# These values are common for all DocType
 	{
-		'_last_update': u'1330344021',
+		'_last_update': u'1330593645',
 		'change_log': u'1. Change in pull_details method dt.-26-06-2009',
 		'colour': u'White:FFF',
 		'default_print_format': u'Standard',
@@ -34,7 +34,7 @@
 		'server_code_error': u' ',
 		'show_in_menu': 0,
 		'subject': u'To %(customer_name)s worth %(currency)s %(grand_total_export)s due on %(due_date)s | %(outstanding_amount)s outstanding',
-		'version': 414
+		'version': 415
 	},
 
 	# These values are common for all DocFormat
@@ -176,6 +176,7 @@
 	# DocField
 	{
 		'colour': u'White:FFF',
+		'default': u'INV',
 		'depends_on': u'eval:doc.retail_transaction!="Yes"',
 		'description': u'To manage multiple series please go to Setup > Manage Series',
 		'doctype': u'DocField',
@@ -185,7 +186,7 @@
 		'no_copy': 1,
 		'oldfieldname': u'naming_series',
 		'oldfieldtype': u'Select',
-		'options': u'\nINV\nINV/10-11/',
+		'options': u'INV\nINV/10-11/',
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1
@@ -645,17 +646,6 @@
 
 	# DocField
 	{
-		'doctype': u'DocField',
-		'fieldtype': u'HTML',
-		'label': u'Rates HTML',
-		'oldfieldtype': u'HTML',
-		'options': u'* Rates in standard currency',
-		'permlevel': 0,
-		'print_hide': 1
-	},
-
-	# DocField
-	{
 		'colour': u'White:FFF',
 		'depends_on': u'eval:doc.is_pos==1',
 		'doctype': u'DocField',
@@ -1074,24 +1064,6 @@
 
 	# DocField
 	{
-		'colour': u'White:FFF',
-		'default': u'Today',
-		'description': u"This is the date on which this voucher is made in the system. Today's date comes by default.",
-		'doctype': u'DocField',
-		'fieldname': u'voucher_date',
-		'fieldtype': u'Date',
-		'in_filter': 1,
-		'label': u'Voucher Date',
-		'no_copy': 1,
-		'oldfieldname': u'voucher_date',
-		'oldfieldtype': u'Date',
-		'permlevel': 0,
-		'reqd': 1,
-		'search_index': 0
-	},
-
-	# DocField
-	{
 		'doctype': u'DocField',
 		'fieldname': u'aging_date',
 		'fieldtype': u'Date',
@@ -1180,7 +1152,8 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'oldfieldtype': u'Column Break',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -1390,7 +1363,8 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Section Break',
 		'options': u'Simple',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -1412,7 +1386,8 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Section Break',
 		'label': u'Recurring Invoice',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -1420,6 +1395,7 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -1473,6 +1449,7 @@
 		'fieldtype': u'Column Break',
 		'no_copy': 0,
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
diff --git a/erpnext/accounts/doctype/rv_detail/rv_detail.txt b/erpnext/accounts/doctype/rv_detail/rv_detail.txt
index a4bf824..7c599d1 100644
--- a/erpnext/accounts/doctype/rv_detail/rv_detail.txt
+++ b/erpnext/accounts/doctype/rv_detail/rv_detail.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:20',
 		'docstatus': 0,
-		'modified': '2012-02-24 16:14:38',
+		'modified': '2012-03-05 10:50:03',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -22,7 +22,7 @@
 		'section_style': u'Tray',
 		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'version': 25
+		'version': 28
 	},
 
 	# These values are common for all DocField
@@ -88,15 +88,6 @@
 	# DocField
 	{
 		'doctype': u'DocField',
-		'fieldname': u'stock_uom',
-		'fieldtype': u'Data',
-		'label': u'UOM',
-		'permlevel': 1
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
 		'fieldname': u'qty',
 		'fieldtype': u'Currency',
 		'label': u'Qty',
@@ -109,17 +100,23 @@
 
 	# DocField
 	{
-		'colour': u'White:FFF',
 		'doctype': u'DocField',
-		'fieldname': u'ref_rate',
+		'fieldname': u'stock_uom',
+		'fieldtype': u'Data',
+		'label': u'UOM',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'base_ref_rate',
 		'fieldtype': u'Currency',
-		'label': u'Price List Rate',
-		'oldfieldname': u'ref_rate',
+		'label': u'Price List Rate*',
+		'oldfieldname': u'base_ref_rate',
 		'oldfieldtype': u'Currency',
-		'permlevel': 0,
-		'print_hide': 1,
-		'reqd': 0,
-		'trigger': u'Client'
+		'permlevel': 1,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -138,43 +135,6 @@
 
 	# DocField
 	{
-		'doctype': u'DocField',
-		'fieldname': u'export_rate',
-		'fieldtype': u'Currency',
-		'label': u'Basic Rate',
-		'oldfieldname': u'export_rate',
-		'oldfieldtype': u'Currency',
-		'permlevel': 0,
-		'reqd': 1,
-		'trigger': u'Client'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'export_amount',
-		'fieldtype': u'Currency',
-		'label': u'Amount',
-		'oldfieldname': u'export_amount',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1,
-		'reqd': 1
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'base_ref_rate',
-		'fieldtype': u'Currency',
-		'label': u'Price List Rate*',
-		'oldfieldname': u'base_ref_rate',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1,
-		'print_hide': 1
-	},
-
-	# DocField
-	{
 		'colour': u'White:FFF',
 		'doctype': u'DocField',
 		'fieldname': u'basic_rate',
@@ -205,6 +165,46 @@
 
 	# DocField
 	{
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldname': u'ref_rate',
+		'fieldtype': u'Currency',
+		'label': u'Price List Rate',
+		'oldfieldname': u'ref_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'trigger': u'Client'
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'export_rate',
+		'fieldtype': u'Currency',
+		'label': u'Basic Rate',
+		'oldfieldname': u'export_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'reqd': 1,
+		'trigger': u'Client'
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'export_amount',
+		'fieldtype': u'Currency',
+		'label': u'Amount',
+		'oldfieldname': u'export_amount',
+		'oldfieldtype': u'Currency',
+		'permlevel': 1,
+		'reqd': 1
+	},
+
+	# DocField
+	{
 		'doctype': u'DocField',
 		'fieldname': u'warehouse',
 		'fieldtype': u'Link',
@@ -264,7 +264,7 @@
 		'oldfieldname': u'serial_no',
 		'oldfieldtype': u'Small Text',
 		'permlevel': 0,
-		'print_hide': 1
+		'print_hide': 0
 	},
 
 	# DocField
diff --git a/erpnext/accounts/page/accounts_home/accounts_home.html b/erpnext/accounts/page/accounts_home/accounts_home.html
index 12c80eb..8282ae8 100644
--- a/erpnext/accounts/page/accounts_home/accounts_home.html
+++ b/erpnext/accounts/page/accounts_home/accounts_home.html
@@ -62,6 +62,11 @@
 							title = "Analyze Sales and Purchase trends and slice them based on item, customer, groups etc"
 							href="#!Report/Profile/Trend Analyzer">Trend Analyzer</a>
 					</div>
+					<div class="section-item">
+						<a class="section-link" 
+							title = "Check your Balance Sheet and Profit & Loss Statement"
+							href="#!Financial Statements">Financial Statements</a>
+					</div>
 
 
 				</div>
@@ -141,4 +146,4 @@
 		</div>
 	</div>
 	<div style="clear: both;"></div>
-</div>
\ No newline at end of file
+</div>
diff --git a/erpnext/accounts/search_criteria/collection_report/collection_report.py b/erpnext/accounts/search_criteria/collection_report/collection_report.py
index fe0cb57..c0f6e61 100644
--- a/erpnext/accounts/search_criteria/collection_report/collection_report.py
+++ b/erpnext/accounts/search_criteria/collection_report/collection_report.py
@@ -66,7 +66,7 @@
 
 for r in res:
   if r[col_idx['Against Receivable']]:
-    dt=sql("select voucher_date, Aging_date from `tabReceivable Voucher` where name='%s'"%r[col_idx['Against Receivable']])
+    dt=sql("select date(modified), Aging_date from `tabReceivable Voucher` where name='%s'"%r[col_idx['Against Receivable']])
     r.append('')
     r.append(dt and cstr(dt[0][0]) or '')
     r.append(dt and cstr(dt[0][1]) or '')
@@ -103,4 +103,4 @@
   r.append(val_l2)
   r.append(val_l3)
   r.append(val_l4)
-  r.append(val_l5_above)
\ No newline at end of file
+  r.append(val_l5_above)
diff --git a/erpnext/accounts/search_criteria/payment_report/payment_report.py b/erpnext/accounts/search_criteria/payment_report/payment_report.py
index 8252103..cc025ba 100644
--- a/erpnext/accounts/search_criteria/payment_report/payment_report.py
+++ b/erpnext/accounts/search_criteria/payment_report/payment_report.py
@@ -66,7 +66,7 @@
 
 for r in res:
   if r[col_idx['Against Payable']]:
-    dt=sql("select voucher_date, aging_date from `tabPayable Voucher` where name='%s'"%r[col_idx['Against Payable']])
+    dt=sql("select date(modified), aging_date from `tabPayable Voucher` where name='%s'"%r[col_idx['Against Payable']])
     r.append('')
     r.append(dt and cstr(dt[0][0]) or '')
     r.append(dt and cstr(dt[0][1]) or '')
@@ -102,4 +102,4 @@
   r.append(val_l2)
   r.append(val_l3)
   r.append(val_l4)
-  r.append(val_l5_above)
\ No newline at end of file
+  r.append(val_l5_above)
diff --git a/erpnext/analysis/doctype/mis_control/mis_control.py b/erpnext/analysis/doctype/mis_control/mis_control.py
index 11e48f4..b2c85f8 100644
--- a/erpnext/analysis/doctype/mis_control/mis_control.py
+++ b/erpnext/analysis/doctype/mis_control/mis_control.py
@@ -61,7 +61,6 @@
     
     # ---- get companies ---------
     res = sql("select name from `tabCompany`")
-    comp.append('All')
     for r in res:
       comp.append(r[0])
     #comp.append(r[0] for r in res)
diff --git a/erpnext/buying/doctype/po_detail/po_detail.txt b/erpnext/buying/doctype/po_detail/po_detail.txt
index 49bed15..d903ef1 100755
--- a/erpnext/buying/doctype/po_detail/po_detail.txt
+++ b/erpnext/buying/doctype/po_detail/po_detail.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:12',
 		'docstatus': 0,
-		'modified': '2012-02-27 14:47:48',
+		'modified': '2012-03-05 10:50:51',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -22,7 +22,7 @@
 		'section_style': u'Tray',
 		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'version': 62
+		'version': 64
 	},
 
 	# These values are common for all DocField
@@ -121,10 +121,11 @@
 	# DocField
 	{
 		'doctype': u'DocField',
-		'fieldname': u'import_ref_rate',
+		'fieldname': u'purchase_ref_rate',
 		'fieldtype': u'Currency',
-		'label': u'Ref Rate ',
-		'permlevel': 0
+		'label': u'Ref Rate *',
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -134,45 +135,12 @@
 		'fieldtype': u'Currency',
 		'label': u'Discount %',
 		'permlevel': 0,
+		'print_hide': 1,
 		'trigger': u'Client'
 	},
 
 	# DocField
 	{
-		'doctype': u'DocField',
-		'fieldname': u'import_rate',
-		'fieldtype': u'Currency',
-		'hidden': 0,
-		'label': u'Rate ',
-		'oldfieldname': u'import_rate',
-		'oldfieldtype': u'Currency',
-		'permlevel': 0,
-		'print_hide': 0,
-		'trigger': u'Client'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'import_amount',
-		'fieldtype': u'Currency',
-		'label': u'Amount',
-		'oldfieldname': u'import_amount',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'purchase_ref_rate',
-		'fieldtype': u'Currency',
-		'label': u'Ref Rate *',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
 		'default': u'0.00',
 		'doctype': u'DocField',
 		'fieldname': u'purchase_rate',
@@ -204,6 +172,41 @@
 	# DocField
 	{
 		'doctype': u'DocField',
+		'fieldname': u'import_ref_rate',
+		'fieldtype': u'Currency',
+		'label': u'Ref Rate ',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'import_rate',
+		'fieldtype': u'Currency',
+		'hidden': 0,
+		'label': u'Rate ',
+		'oldfieldname': u'import_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'print_hide': 0,
+		'trigger': u'Client'
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'import_amount',
+		'fieldtype': u'Currency',
+		'label': u'Amount',
+		'oldfieldname': u'import_amount',
+		'oldfieldtype': u'Currency',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
 		'fieldname': u'warehouse',
 		'fieldtype': u'Link',
 		'hidden': 0,
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index 52f8e53..88fba5c 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -92,39 +92,38 @@
 
 
 var set_dynamic_label_child = function(doc, cdt, cdn, base_curr) {
-		// item table flds
-		item_cols_base = {'purchase_ref_rate': 'Ref Rate', 'amount': 'Amount'};
-		item_cols_import = {'import_rate': 'Rate', 'import_ref_rate': 'Ref Rate', 'import_amount': 'Amount'};
+	// item table flds
+	item_cols_base = {'purchase_ref_rate': 'Ref Rate', 'amount': 'Amount'};
+	item_cols_import = {'import_rate': 'Rate', 'import_ref_rate': 'Ref Rate', 'import_amount': 'Amount'};
 		
-		for (d in item_cols_base) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_base[d]+' ('+base_curr+')');
-		for (d in item_cols_import) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_import[d]+' ('+doc.currency+')');
+	for (d in item_cols_base) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_base[d]+' ('+base_curr+')');
+	for (d in item_cols_import) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_import[d]+' ('+doc.currency+')');
 		
-		var hide = (doc.currency == sys_defaults['currency']) ? false : true;
-		for (f in item_cols_base) cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(f, hide);
+	var hide = (doc.currency == sys_defaults['currency']) ? false : true;
+	for (f in item_cols_import) {
+		cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(f, hide);
+	}
+	if (doc.doctype == 'Payable Voucher') {
+		$('[data-grid-fieldname="'+cur_frm.cscript.tname+'-rate"]').html('Rate ('+base_curr+')');
+		//cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp('rate', hide);
+		// advance table flds
+		adv_cols = {'advance_amount': 'Advance Amount', 'allocated_amount': 'Allocated Amount', 'tds_amount': 'TDS Amount', 'tds_allocated': 'TDS Allocated'}
+		for (d in adv_cols) $('[data-grid-fieldname="Advance Allocation Detail-'+d+'"]').html(adv_cols[d]+' ('+base_curr+')');	
+	}
+	else {
+		$('[data-grid-fieldname="'+cur_frm.cscript.tname+'-purchase_rate"]').html('Rate ('+base_curr+')');
+		//cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp('purchase_rate', hide);
+	}
 
-		if (doc.doctype == 'Payable Voucher') {
-			$('[data-grid-fieldname="'+cur_frm.cscript.tname+'-rate"]').html('Rate ('+base_curr+')');
-			cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp('rate', hide);
-			// advance table flds
-			adv_cols = {'advance_amount': 'Advance Amount', 'allocated_amount': 'Allocated Amount', 'tds_amount': 'TDS Amount', 'tds_allocated': 'TDS Allocated'}
-			for (d in adv_cols) $('[data-grid-fieldname="Advance Allocation Detail-'+d+'"]').html(adv_cols[d]+' ('+base_curr+')');	
-		}
-		else {
-			$('[data-grid-fieldname="'+cur_frm.cscript.tname+'-purchase_rate"]').html('Rate ('+base_curr+')');
-			cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp('purchase_rate', hide);
-		}
-
-		//tax table flds
-		tax_cols = {'tax_amount': 'Amount', 'total': 'Aggregate Total'};
-		for (d in tax_cols) $('[data-grid-fieldname="Purchase Tax Detail-'+d+'"]').html(tax_cols[d]+' ('+base_curr+')');	
-
-
+	//tax table flds
+	tax_cols = {'tax_amount': 'Amount', 'total': 'Aggregate Total'};
+	for (d in tax_cols) $('[data-grid-fieldname="Purchase Tax Detail-'+d+'"]').html(tax_cols[d]+' ('+base_curr+')');	
 }
 
 // Change label dynamically based on currency
 //------------------------------------------------------------------
 
-cur_frm.cscript.dynamic_label = function(doc, cdt, cdn) {
+cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, callback1) {
 	var callback = function(r, rt) {
 		if (r.message) base_curr = r.message;
 		else base_curr = sys_defaults['currency'];
@@ -136,10 +135,16 @@
 
 		set_dynamic_label_par(doc, cdt, cdn, base_curr);
 		set_dynamic_label_child(doc, cdt, cdn, base_curr);
+
+		if(callback1) callback1(doc, cdt, cdn);
 	}
 
 	if (doc.company == sys_defaults['company']) callback('', '');
-	else $c_obj(make_doclist(doc.doctype, doc.name), 'get_comp_base_currency', '', callback);
+	else wn.call({
+		method: 'selling.doctype.sales_common.sales_common.get_comp_base_currency',
+		args: {company: doc.company},
+		callback: callback
+	});
 }
 
 cur_frm.cscript.currency = function(doc, cdt, cdn) {
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py
index 16afb02..ca9181f 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.py
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.py
@@ -197,11 +197,6 @@
 					msgprint("%s has no Last Purchase Rate."% d.item_code)
 
 
-	def get_comp_base_currency(self, comp):
-		""" get default currency of company"""
-		return webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", comp)[0][0]
-
-
 
 	# validation
 	# -------------------------------------------------------------------------------------------------------
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index 0a6c547..7af1204 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -41,9 +41,12 @@
 }
 
 cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
-	if(doc.__islocal){ 
-		cur_frm.cscript.get_default_schedule_date(doc);
-	}	
+	var callback = function(doc, cdt, cdn) {
+		if(doc.__islocal){ 
+			cur_frm.cscript.get_default_schedule_date(doc);
+		}	
+	}
+	cur_frm.cscript.dynamic_label(doc, cdt, cdn, callback);
 }
 
 // ================================== Refresh ==========================================
@@ -52,7 +55,7 @@
 	// ---------------------------------
 	cur_frm.clear_custom_buttons();
 
-	cur_frm.cscript.dynamic_label(doc, cdt, cdn);
+	if (!cur_frm.cscript.is_onload) cur_frm.cscript.dynamic_label(doc, cdt, cdn);
 
 	if(doc.docstatus == 1 && doc.status != 'Stopped'){
 		var ch = getchildren('PO Detail',doc.name,'po_details');
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index efa0524..7945807 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -100,10 +100,6 @@
 		return get_obj('Purchase Common').get_tc_details(self)
 
 
-	def get_comp_base_currency(self):
-		return get_obj('Purchase Common').get_comp_base_currency(self.doc.company)
-
-
 
 	# validate if indent has been pulled twice
 	def validate_prev_docname(self):
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.txt b/erpnext/buying/doctype/purchase_order/purchase_order.txt
index c73683e..0239370 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.txt
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:15',
 		'docstatus': 0,
-		'modified': '2012-02-27 17:51:53',
+		'modified': '2012-03-02 12:23:50',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -35,7 +35,7 @@
 		'server_code_error': u' ',
 		'show_in_menu': 0,
 		'subject': u'To %(supplier_name)s on %(transaction_date)s | %(per_received)s% delivered',
-		'version': 500
+		'version': 501
 	},
 
 	# These values are common for all DocFormat
@@ -573,17 +573,6 @@
 	{
 		'colour': u'White:FFF',
 		'doctype': u'DocField',
-		'fieldtype': u'HTML',
-		'label': u'Note HTML',
-		'options': u'<div style="margin-top:16px"><b>Note :</b> * In Base Currency\n</div>',
-		'permlevel': 1,
-		'print_hide': 1
-	},
-
-	# DocField
-	{
-		'colour': u'White:FFF',
-		'doctype': u'DocField',
 		'fieldtype': u'Section Break',
 		'label': u'Taxes',
 		'oldfieldtype': u'Section Break',
@@ -669,17 +658,6 @@
 	{
 		'colour': u'White:FFF',
 		'doctype': u'DocField',
-		'fieldtype': u'HTML',
-		'label': u'Note HTML',
-		'options': u'<div style="margin-top:16px"><b>Note :</b> * In Base Currency\n</div>',
-		'permlevel': 1,
-		'print_hide': 1
-	},
-
-	# DocField
-	{
-		'colour': u'White:FFF',
-		'doctype': u'DocField',
 		'fieldtype': u'Section Break',
 		'label': u'Totals',
 		'oldfieldtype': u'Section Break',
@@ -1019,6 +997,7 @@
 		'fieldtype': u'Column Break',
 		'oldfieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -1073,7 +1052,8 @@
 		'fieldtype': u'Section Break',
 		'label': u'Raw Material Details',
 		'oldfieldtype': u'Section Break',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
diff --git a/erpnext/home/page/activity/__init__.py b/erpnext/home/page/activity/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/home/page/activity/__init__.py
diff --git a/erpnext/home/page/activity/activity.css b/erpnext/home/page/activity/activity.css
new file mode 100644
index 0000000..f3988b2
--- /dev/null
+++ b/erpnext/home/page/activity/activity.css
@@ -0,0 +1,23 @@
+#activity-list .label {
+	display: inline-block;
+	width: 100px;
+	margin-right: 7px;
+}
+
+#activity-list .label-info {
+	cursor: pointer;
+}
+
+#activity-list .user-info {
+	float: right;
+	color: #777;
+	font-size: 10px;
+}
+
+#activity-list .date-sep {
+	margin-bottom: 11px;
+	padding: 5px 0px;
+	border-bottom: 1px solid #aaa;
+	color: #555;
+	font-size: 10px;
+}
\ No newline at end of file
diff --git a/erpnext/home/page/activity/activity.html b/erpnext/home/page/activity/activity.html
new file mode 100644
index 0000000..b348d95
--- /dev/null
+++ b/erpnext/home/page/activity/activity.html
@@ -0,0 +1,6 @@
+<div class="layout-wrapper">
+	<a class="close" onclick="window.history.back();">&times;</a>
+	<h1>Activity</h1>
+	<div id="activity-list">
+	</div>
+</div>
\ No newline at end of file
diff --git a/erpnext/home/page/activity/activity.js b/erpnext/home/page/activity/activity.js
new file mode 100644
index 0000000..62604b7
--- /dev/null
+++ b/erpnext/home/page/activity/activity.js
@@ -0,0 +1,64 @@
+wn.pages['activity'].onload = function(wrapper) {
+	var list = new wn.widgets.Listing({
+		method: 'home.page.activity.activity.get_feed',
+		parent: $('#activity-list'),
+		render_row: function(row, data) {
+			new erpnext.ActivityFeed(row, data);
+		}
+	});
+	list.run();
+}
+
+erpnext.last_feed_date = false;
+erpnext.ActivityFeed = Class.extend({
+	init: function(row, data) {
+		this.scrub_data(data);
+		this.add_date_separator(row, data);
+		$(row).append(sprintf('<div style="margin: 0px">\
+			<span class="avatar-small"><img src="%(imgsrc)s" /></span> \
+			<span %(onclick)s class="label %(add_class)s">%(feed_type)s</span>\
+			%(link)s %(subject)s <span class="user-info">%(by)s</span></div>', data));
+	},
+	scrub_data: function(data) {
+		data.by = wn.user_info(data.owner).fullname;
+		data.imgsrc = wn.user_info(data.owner).image;
+		
+		// feedtype
+		if(!data.feed_type) {
+			data.feed_type = get_doctype_label(data.doc_type);
+			data.add_class = "label-info";
+			data.onclick = repl('onclick="window.location.href=\'#!List/%(feed_type)s\';"', data)
+		}
+		
+		// color for comment
+		if(data.feed_type=='Comment') {
+			data.add_class = "label-important";
+		}
+		
+		if(data.feed_type=='Assignment') {
+			data.add_class = "label-warning";
+		}
+		
+		// link
+		if(data.doc_name && data.feed_type!='Login') {
+			data.link = repl('<a href="#!Form/%(doc_type)s/%(doc_name)s">%(doc_name)s</a>', data)
+		}
+	},
+	add_date_separator: function(row, data) {
+		var date = dateutil.str_to_obj(data.modified);
+		var last = erpnext.last_feed_date;
+		
+		if((last && dateutil.obj_to_str(last) != dateutil.obj_to_str(date)) || (!last)) {
+			var diff = dateutil.get_day_diff(new Date(), date);
+			if(diff < 1) {
+				pdate = 'Today';
+			} else if(diff < 2) {
+				pdate = 'Yesterday';
+			} else {
+				pdate = dateutil.global_date_format(date);
+			}
+			$(row).html(repl('<div class="date-sep">%(date)s</div>', {date: pdate}));
+		}
+		erpnext.last_feed_date = date;
+	}
+})
\ No newline at end of file
diff --git a/erpnext/home/page/activity/activity.py b/erpnext/home/page/activity/activity.py
new file mode 100644
index 0000000..8b8faf3
--- /dev/null
+++ b/erpnext/home/page/activity/activity.py
@@ -0,0 +1,16 @@
+import webnotes
+
+@webnotes.whitelist()
+def get_feed(arg=None):
+	"""get feed"""	
+	return webnotes.conn.sql("""select
+		distinct t1.name, t1.feed_type, t1.doc_type, t1.doc_name, t1.subject, t1.owner,
+		t1.modified
+		from tabFeed t1, tabDocPerm t2
+		where t1.doc_type = t2.parent
+		and t2.role in ('%s')
+		and ifnull(t2.`read`,0) = 1
+		order by t1.modified desc
+		limit %s, %s""" % ("','".join(webnotes.get_roles()), 
+			webnotes.form_dict['limit_start'], webnotes.form_dict['limit_page_length']), 
+			as_dict=1)
\ No newline at end of file
diff --git a/erpnext/home/page/activity/activity.txt b/erpnext/home/page/activity/activity.txt
new file mode 100644
index 0000000..e7f3963
--- /dev/null
+++ b/erpnext/home/page/activity/activity.txt
@@ -0,0 +1,28 @@
+# Page, activity
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2012-02-29 11:59:13',
+		'docstatus': 0,
+		'modified': '2012-02-29 12:11:46',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
+	},
+
+	# These values are common for all Page
+	{
+		'doctype': 'Page',
+		'module': u'Home',
+		'name': '__common__',
+		'page_name': u'activity',
+		'standard': u'Yes',
+		'title': u'Activity'
+	},
+
+	# Page, activity
+	{
+		'doctype': 'Page',
+		'name': u'activity'
+	}
+]
\ No newline at end of file
diff --git a/erpnext/home/page/attributions/__init__.py b/erpnext/home/page/attributions/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/home/page/attributions/__init__.py
diff --git a/erpnext/home/page/attributions/attributions.css b/erpnext/home/page/attributions/attributions.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/home/page/attributions/attributions.css
diff --git a/erpnext/home/page/attributions/attributions.html b/erpnext/home/page/attributions/attributions.html
new file mode 100644
index 0000000..72703c8
--- /dev/null
+++ b/erpnext/home/page/attributions/attributions.html
@@ -0,0 +1,91 @@
+<div class="layout-wrapper">
+	<a class="close" onclick="window.history.back();">&times;</a>
+	<h1>Attributions</h1>
+	<hr>
+	<p><b>Source Code:</b> <a href="https://github.com/webnotes/erpnext">
+				https://github.com/webnotes/erpnext</a></p>
+	<p><b>Website:</b> <a href="https://erpnext.com">
+				https://erpnext.com</a></p>
+	<hr>
+	<p class="help">ERPNext is an Open Source project and is possible because of the work of
+		thousands of software developers, companies and designers who have contributed their
+		work to the community. We have tried to list as many projects as possible that are
+		used by ERPNext, but this list may not be exhaustive.</p>
+
+
+	<h4>Server</h4>
+	<ul>
+		<li>Linux (GNU)</li>
+		<li>Apache HTTPD server (web server)</li>
+		<li>MySQL (database, Percona build)</li>
+		<li>Git (source code control via Github)</li>
+	</ul>
+		
+	<h4>Programming Languages & Libraries</h4>
+	<ul>
+		<li><a href="http://python.org">Python</a></li>
+		<ul>
+			<li>Python-MySQL</li>
+			<li>pytz (timezones)</li>
+			<li>jinja2 (templating)</li>
+			<li>markdown2 (markdown parser)</li>
+			<li>jsmin (javascript minifier)</li>
+		</ul>
+		<li>Javascript</li>
+		<ul>
+			<li>JQuery</li>
+			<li>JQuery UI (datepicker, sortable)</li>
+			<li>TinyMCE - text editor</li>
+			<li>Twitter Bootstrap</li>
+			<li>jQPlot - graphs</li>
+			<li>JSON2 - JSON builder, parser</li>
+			<li>JSColor - color picker</li>
+			<li>sprintf - string formatting</li>
+			<li>historyjs - AJAX history</li>
+		</ul>
+	</ul>
+
+	<h4>CSS Frameworks</h4>
+	<ul>
+		<li>Twitter Bootstrap</li>
+	</ul>
+		
+	<h4>Icons</h4>
+	<ul>
+		<li>The Noun Project</li>
+		<li>Glyphicons</li>
+	</ul>
+
+	<h4>Web Frameworks</h4>
+	<ul>
+		<li>wnframework</li>
+	</ul>
+
+	<h4>Web Browsers</h4>
+	<ul>
+		<li>Mozilla Firefox</li>
+		<ul>
+			<li>Firebug (debugger)</li>
+		</ul>
+		<li>Apple Safari</li>
+		<li>Google Chorme</li>
+	</ul>
+	<hr>
+	<h2>ERPNext License</h2>
+	<p><b>ERPNext - Open Source, web based ERP</b></p>
+	<p>Copyright &copy; 2008 onwards, Web Notes Technologies Pvt Ltd, India</p>
+
+	<p>This program is free software: you can redistribute it and/or modify
+	    it under the terms of the <b>GNU General Public License</b> as published by
+	    the Free Software Foundation, either version 3 of the License, or
+	    (at your option) any later version.</p>
+
+	    <p>This program is distributed in the hope that it will be useful,
+	    but WITHOUT ANY WARRANTY; without even the implied warranty of
+	    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+	    GNU General Public License for more details.</p>
+
+ 		<p>For complete license see <a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a></p>
+	<hr>
+	<p>For more information please write to us at support@erpnext.com</p>
+</div>
\ No newline at end of file
diff --git a/erpnext/home/page/attributions/attributions.js b/erpnext/home/page/attributions/attributions.js
new file mode 100644
index 0000000..fc56784
--- /dev/null
+++ b/erpnext/home/page/attributions/attributions.js
@@ -0,0 +1 @@
+wn.pages['attributions'].onload = function(wrapper) { }
\ No newline at end of file
diff --git a/erpnext/home/page/attributions/attributions.py b/erpnext/home/page/attributions/attributions.py
new file mode 100644
index 0000000..f807eb0
--- /dev/null
+++ b/erpnext/home/page/attributions/attributions.py
@@ -0,0 +1 @@
+import webnotes
\ No newline at end of file
diff --git a/erpnext/home/page/attributions/attributions.txt b/erpnext/home/page/attributions/attributions.txt
new file mode 100644
index 0000000..a15adb9
--- /dev/null
+++ b/erpnext/home/page/attributions/attributions.txt
@@ -0,0 +1,28 @@
+# Page, attributions
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2012-03-01 12:30:42',
+		'docstatus': 0,
+		'modified': '2012-03-01 12:30:42',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
+	},
+
+	# These values are common for all Page
+	{
+		'doctype': 'Page',
+		'module': u'Home',
+		'name': '__common__',
+		'page_name': u'attributions',
+		'standard': u'Yes',
+		'title': u'Attributions'
+	},
+
+	# Page, attributions
+	{
+		'doctype': 'Page',
+		'name': u'attributions'
+	}
+]
\ No newline at end of file
diff --git a/erpnext/home/page/desktop/desktop.css b/erpnext/home/page/desktop/desktop.css
index 0aede60..e460c11 100644
--- a/erpnext/home/page/desktop/desktop.css
+++ b/erpnext/home/page/desktop/desktop.css
@@ -41,10 +41,15 @@
 
 .case-border {
 	border-radius: 10px;
+	-moz-border-radius: 10px;
+	-webkit-border-radius: 10px;
 	width: 56px;
 	height: 56px;
 	border: 4px solid white;
 	box-shadow: 0 0 10px 1px black;
+	-moz-box-shadow: 0 0 10px 1px black;
+	-webkit-box-shadow: 0 0 10px 1px black;
+	-o-box-shadow: 0 0 10px 1px black;
 	margin: auto;
 }
 
@@ -66,6 +71,9 @@
 /* Hover and click effects */
 .case-border:hover, .circle:hover {
 	box-shadow: 0 0 2px 0px black, 0 0 10px 1px white;
+	-moz-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white;
+	-webkit-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white;
+	-o-box-shadow: 0 0 2px 0px black, 0 0 10px 1px white;
 }
 
 .case-border:active, .case-border:focus, .circle:active, .circle:focus {
@@ -77,8 +85,11 @@
 }
 
 .circle {
-	border-radius: 100%;
+	border-radius: 30px;
+	-moz-border-radius: 30px;
+	-webkit-border-radius: 30px;
 	height: 15px;
+	line-height: 12px;
 	min-width: 15px;
 	background: #B00D07;
 	padding: 3px;
@@ -88,6 +99,9 @@
 	margin-right: 10px;
 	border: 2px solid white;
 	box-shadow: 0 0 10px 1px black;
+	-moz-box-shadow: 0 0 10px 1px black;
+	-webkit-box-shadow: 0 0 10px 1px black;
+	-o-box-shadow: 0 0 10px 1px black;
 }
 
 .circle-text {
diff --git a/erpnext/home/page/desktop/desktop.js b/erpnext/home/page/desktop/desktop.js
index e2a8d53..dab1e76 100644
--- a/erpnext/home/page/desktop/desktop.js
+++ b/erpnext/home/page/desktop/desktop.js
@@ -43,36 +43,53 @@
 }
 
 erpnext.desktop.render = function() {
-	var icons = [
-		{ gradient: 'brown', sprite: 'feed', label: 'Activity', link: '#!Event Updates' },
-		{ gradient: 'blue', sprite: 'account', label: 'Accounts', link: '#!accounts-home' },
-		{ gradient: 'green', sprite: 'selling', label: 'Selling', link: '#!selling-home' },
-		{ gradient: 'yellow', sprite: 'stock', label: 'Stock', link: '#!stock-home' },
-		{ gradient: 'red', sprite: 'buying', label: 'Buying', link: '#!buying-home' },
-		{ gradient: 'purple', sprite: 'support', label: 'Support', link: '#!support-home' },
-		{ gradient: 'ocean', sprite: 'hr', label: 'Human<br />Resources', link: '#!hr-home' },
-		{ gradient: 'violet', sprite: 'project', label: 'Projects', link: '#!projects-home' },
-		{ gradient: 'dark-red', sprite: 'production', label: 'Production', link: '#!production-home' },
-		{ gradient: 'leaf-green', sprite: 'website', label: 'Website', link: '#!website-home' },
-		{ gradient: 'grey', sprite: 'setting', label: 'Settings', link: '#!Setup' },
-		{ gradient: 'bright-green', sprite: 'dashboard', label: 'Dashboard', link: '#!dashboard' },
-		//{ gradient: 'dark-blue', sprite: 'report', label: 'Report' },
-		{ gradient: 'pink', sprite: 'messages', label: 'Messages', link: '#!messages' },
-		{ gradient: 'bright-yellow', sprite: 'todo', label: 'To Do', link: '#!todo' },
-		{ gradient: 'peacock', sprite: 'calendar', label: 'Calendar', link: '#!calendar' },
-		{ gradient: 'ultra-dark-green', sprite: 'kb', label: 'Knowledge<br />Base', link: '#!questions' },
-	]
+	var icons = {
+		'Accounts': { gradient: 'blue', sprite: 'account', label: 'Accounts'},
+		'Selling': { gradient: 'green', sprite: 'selling', label: 'Selling'},
+		'Stock': { gradient: 'yellow', sprite: 'stock', label: 'Stock'},
+		'Buying': { gradient: 'red', sprite: 'buying', label: 'Buying'},
+		'Support': { gradient: 'purple', sprite: 'support', label: 'Support'},
+		'HR': { gradient: 'ocean', sprite: 'hr', label: 'Human<br />Resources'},
+		'Projects':	{ gradient: 'violet', sprite: 'project', label: 'Projects'},
+		'Production': { gradient: 'dark-red', sprite: 'production', label: 'Production'},
+		'Website': { gradient: 'leaf-green', sprite: 'website', label: 'Website'},
+		'Activity': { gradient: 'brown', sprite: 'feed', label: 'Activity'},
+		'Setup': { gradient: 'grey', sprite: 'setting', label: 'Setup'},
+		'Dashboard': { gradient: 'bright-green', sprite: 'dashboard', label: 'Dashboard'},
+		'To Do': { gradient: 'bright-yellow', sprite: 'todo', label: 'To Do'},
+		'Messages': { gradient: 'pink', sprite: 'messages', label: 'Messages'},
+		'Calendar': { gradient: 'peacock', sprite: 'calendar', label: 'Calendar'},
+		'Knowledge Base': { gradient: 'ultra-dark-green', sprite: 'kb', label: 'Knowledge<br />Base'}
+	}
+	
 
-	$.each(icons, function(i, v) {
-		var icon_case = $('#icon-grid').append(repl('\
-			<div id="%(sprite)s" class="case-wrapper"><a href="%(link)s">\
+	var add_icon = function(m) {
+		var icon = icons[m];
+		icon.link = erpnext.modules[m];
+		$('#icon-grid').append(repl('\
+			<div id="%(sprite)s" class="case-wrapper"><a href="#!%(link)s">\
 				<div class="case-border case-%(gradient)s">\
 					<div class="sprite-image sprite-%(sprite)s"></div>\
 				</div></a>\
 				<div class="case-label">%(label)s</div>\
-			</div>', v));
-	});
+			</div>', icon));		
+	}
+	
+	// setup
 
+	for(var i in wn.boot.modules_list) {
+		var m = wn.boot.modules_list[i];
+		if(m!='Setup' && wn.boot.profile.allow_modules.indexOf(m)!=-1)
+			add_icon(m);
+	}
+
+	if(user_roles.indexOf('Accounts Manager')!=-1)
+		add_icon('Dashboard')
+
+	if(user_roles.indexOf('System Manager')!=-1)
+		add_icon('Setup')
+
+	// apps
 	erpnext.desktop.show_pending_notifications();
 
 }
diff --git a/erpnext/home/page/event_updates/complete_registration.js b/erpnext/home/page/event_updates/complete_registration.js
deleted file mode 100644
index 8f7eed3..0000000
--- a/erpnext/home/page/event_updates/complete_registration.js
+++ /dev/null
@@ -1,124 +0,0 @@
-// ERPNext - web based ERP (http://erpnext.com)
-// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-// 
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-// complete my company registration
-// --------------------------------
-pscript.complete_registration = function(is_complete, profile) {
-	if(is_complete == 'No'){
-		var d = new Dialog(400, 200, "Setup your Account");
-		if(user != 'Administrator'){
-			d.no_cancel(); // Hide close image
-			$('header').toggle(false);
-		}
-
-		d.make_body([
-			['HTML', 'Your Profile Details', '<h4>Your Profile Details</h4>'],
-			['Data', 'First Name'],
-			['Data', 'Last Name'],
-			['HTML', 'Company Details', '<h4>Create your first company</h4>'],
-			['Data','Company Name','Example: Your Company LLC'],
-	  		['Data','Company Abbreviation', 'Example: YC (all your acconts will have this as a suffix)'],
-	  		['Select','Fiscal Year Start Date'],
-	  		['Select','Default Currency'],
-	  		['Button','Save'],
-		]);
-
-		// if company name is set, set the input value
-		// and disable it
-		if(wn.control_panel.company_name) {
-			d.widgets['Company Name'].value = wn.control_panel.company_name;
-			d.widgets['Company Name'].disabled = 1;
-		}
-		
-		if(profile && profile.length>0) {
-			if(profile[0].first_name && profile[0].first_name!='None') {
-				d.widgets['First Name'].value = profile[0].first_name;
-			}
-
-			if(profile[0].last_name && profile[0].last_name!='None') {
-				d.widgets['Last Name'].value = profile[0].last_name;
-			}
-		}
-
-
-		//d.widgets['Save'].disabled = true;	  // disable Save button
-		pscript.make_dialog_field(d);
-
-		// submit details
-		d.widgets['Save'].onclick = function()
-		{
-			d.widgets['Save'].set_working();
-			
-			flag = pscript.validate_fields(d);
-			if(flag)
-			{
-				var args = [
-					d.widgets['Company Name'].value,
-					d.widgets['Company Abbreviation'].value,
-					d.widgets['Fiscal Year Start Date'].value,
-					d.widgets['Default Currency'].value,
-					d.widgets['First Name'].value,
-					d.widgets['Last Name'].value
-				];
-				
-				$c_obj('Setup Control','setup_account',JSON.stringify(args),function(r, rt){
-					sys_defaults = r.message;
-					user_fullname = r.message.user_fullname;
-					d.hide();
-					$('header').toggle(true);
-					page_body.wntoolbar.set_user_name();
-				});
-			} else {
-				d.widgets['Save'].done_working();
-			}
-		}
-		d.show();
-	}
-}
-
-// make dialog fields
-// ------------------
-pscript.make_dialog_field = function(d)
-{
-	// fiscal year format 
-	fisc_format = d.widgets['Fiscal Year Start Date'];
-	add_sel_options(fisc_format, ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct']);
-  
-	// default currency
-	currency_list = ['', 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTN', 'BYR', 'BZD', 'CAD', 'CDF', 'CFA', 'CFP', 'CHF', 'CLP', 'CNY', 'COP', 'CRC', 'CUC', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EEK', 'EGP', 'ERN', 'ETB', 'EUR', 'EURO', 'FJD', 'FKP', 'FMG', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GQE', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LTL', 'LVL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR', 'MZM', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NRs', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RMB', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SCR', 'SDG', 'SDR', 'SEK', 'SGD', 'SHP', 'SOS', 'SRD', 'STD', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TRY', 'TTD', 'TWD', 'TZS', 'UAE', 'UAH', 'UGX', 'USD', 'USh', 'UYU', 'UZS', 'VEB', 'VND', 'VUV', 'WST', 'XAF', 'XCD', 'XDR', 'XOF', 'XPF', 'YEN', 'YER', 'YTL', 'ZAR', 'ZMK', 'ZWR'];
-	currency = d.widgets['Default Currency'];
-	add_sel_options(currency, currency_list);
-}
-
-
-// validate fields
-// ---------------
-pscript.validate_fields = function(d)
-{
-	var lst = ['First Name', 'Company Name', 'Company Abbreviation', 'Fiscal Year Start Date', 'Default Currency'];
-	var msg = 'Please enter the following fields';
-	var flag = 1;
-	for(var i=0; i<lst.length; i++)
-	{
-		if(!d.widgets[lst[i]].value || d.widgets[lst[i]].value=='None'){
-			flag = 0;
-			msg = msg + NEWLINE + lst[i];
-		}
-	}
-
-	if(!flag)  alert(msg);
-	return flag;
-}
diff --git a/erpnext/home/page/my_company/my_company.js b/erpnext/home/page/my_company/my_company.js
index 775c89e..8217cc7 100644
--- a/erpnext/home/page/my_company/my_company.js
+++ b/erpnext/home/page/my_company/my_company.js
@@ -758,253 +758,3 @@
 
 
 
-// ========================== Role object =====================================
-
-pscript.all_roles = null;
-
-RoleObj = function(profile_id){
-	this.roles_dict = {};
-	this.profile_id = profile_id;
-	this.setup_done = 0;
-
-	var d = new Dialog(500,500,'Assign Roles');
-	d.make_body([
-		['HTML','roles']
-	]);
-	
-	this.dialog = d;
-	this.make_role_body(profile_id);
-	this.make_help_body();
-	
-	this.body.innerHTML = '<span style="color:#888">Loading...</span> <img src="lib/images/ui/button-load.gif">'
-	var me=this;
-
-	d.onshow = function() {
-		if(!me.setup_done)
-			me.get_all_roles(me.profile_id);
-	}
-}
-
-// make role body
-RoleObj.prototype.make_role_body = function(id){
-	var me = this;
-	var d = this.dialog;
-	this.role_div = $a(d.widgets['roles'],'div');
-	
-	this.head = $a(this.role_div,'div','',{marginLeft:'4px', marginBottom:'4px',fontWeight:'bold'});
-	this.body = $a(this.role_div,'div');
-	this.footer = $a(this.role_div,'div');
-	
-	this.update_btn = $btn(this.footer,'Update',function() { me.update_roles(me.profile_id); },{marginRight:'4px'},'',1);	
-}
-
-// make help body
-RoleObj.prototype.make_help_body = function(){
-	var me = this;
-	
-	var d = this.dialog;
-	this.help_div = $a(d.widgets['roles'],'div');
-	
-	var head = $a(this.help_div,'div');	this.help_div.head = head;
-	var body = $a(this.help_div,'div');	this.help_div.body = body;
-	var tail = $a(this.help_div,'div');	this.help_div.tail = tail;
-	
-	var back_btn = $btn(tail,'Back', function() {
-		// back to assign roles
-		$(me.role_div).slideToggle('medium');
-		$(me.help_div).slideToggle('medium');
-	});
-	this.help_div.back_btn = back_btn;
-	$dh(this.help_div);
-}
-
-// get all roles
-RoleObj.prototype.get_all_roles = function(id){
-	if(pscript.all_roles) {
-		this.make_roles(id);
-		return;
-	}
-
-	var me = this;
-	var callback = function(r,rt){
-		pscript.all_roles = r.message;
-		me.make_roles(id);
-	}
-	$c_obj('Company Control','get_all_roles','',callback);
-}
-
-// make roles
-RoleObj.prototype.make_roles = function(id){
-	var me = this;
-	var list = pscript.all_roles;
-	me.setup_done = 1;
-	me.body.innerHTML = '';
-		
-	var tbl = make_table( me.body, cint(list.length / 2) + 1,4,'100%',['5%','45%','5%','45%'],{padding:'4px'});
-	var in_right = 0; var ridx = 0;
-
-	for(i=0;i<list.length;i++){
-		var cidx = in_right * 2;
-		
-		me.make_checkbox(tbl, ridx, cidx, list[i]);
-		me.make_label(tbl, ridx, cidx + 1, list[i]);
-
-		// change column
-		if(in_right) {in_right = 0; ridx++ } else in_right = 1;
-	}
-	me.get_user_roles(id);
-}
-
-// make checkbox
-RoleObj.prototype.make_checkbox = function(tbl,ridx,cidx, role){
-	var me = this;
-	
-	var a = $a_input($a($td(tbl, ridx, cidx),'div'),'checkbox');
-	a.role = role;
-	me.roles_dict[role] = a;
-	
-	$y(a,{width:'20px'});
-	$y($td(tbl, ridx, cidx),{textAlign:'right'});
-}
-
-
-// make label
-RoleObj.prototype.make_label = function(tbl, ridx, cidx, role){
-	var me = this;
-	
-	var t = make_table($td(tbl, ridx, cidx),1,2,null,['16px', null],{marginRight:'5px'});
-	var ic = $a($td(t,0,0), 'img','',{cursor:'pointer', marginRight:'5px'});
-	ic.src= 'lib/images/icons/help.png';
-	ic.role = role;
-		
-	ic.onclick = function(){
-		me.get_permissions(this.role);
-	}
-	$td(t,0,1).innerHTML= role;
-	
-}
-
-// get user roles
-RoleObj.prototype.get_user_roles = function(id){
-	var me = this;
-	me.head.innerHTML = 'Roles for ' + id;
-	
-	$ds(me.role_div);
-	$dh(me.help_div);
-	
-	var callback = function(r,rt){
-			me.set_user_roles(r.message);
-	}
-	$c_obj('Company Control','get_user_roles', id,callback);
-}
-
-
-// set user roles
-RoleObj.prototype.set_user_roles = function(list){
-	var me = this;
-	for(d in me.roles_dict){
-		me.roles_dict[d].checked = 0;
-	}
-	for(l=0; l<list.length; l++){
-		me.roles_dict[list[l]].checked = 1;
-	}
-}
-
-
-// update roles
-RoleObj.prototype.update_roles = function(id){
-	var me = this;
-	
-	
-	if(id == user && has_common(['System Manager'], user_roles) && !me.roles_dict['System Manager'].checked){
-		var callback = function(r,rt){
-			if(r.message){
-				if(r.message > 1){
-					var c = confirm("You have unchecked the System Manager role.\nYou will lose administrative rights and will not be able to set roles.\n\nDo you want to continue anyway?");
-					if(!c) return;
-				}
-				else{
-					var c = "There should be atleast one user with System Manager role.";
-					me.roles_dict['System Manager'].checked = 1;
-				}
-			}
-			me.set_roles(id);
-		}
-		$c_obj('Company Control','get_sm_count','',callback);
-	}
-	else{
-		me.set_roles(id);
-	}
-}
-
-// set roles
-RoleObj.prototype.set_roles = function(id){
-
-	var me = this;
-	var role_list = [];
-	
-	for(d in me.roles_dict){
-		if(me.roles_dict[d].checked){
-			role_list.push(d);
-		}
-	}
-
-	var callback = function(r,rt){
-		me.update_btn.done_working();
-		me.dialog.hide();
-	}
-	var arg = {'usr':id, 'role_list':role_list};
-	me.update_btn.set_working();
-	$c_obj('Company Control','update_roles',docstring(arg), callback);
-
-}
-
-// get permission
-RoleObj.prototype.get_permissions = function(role){
-	var me = this;
-	
-	var callback = function(r,rt){
-		$(me.help_div).slideToggle('medium');
-		$(me.role_div).slideToggle('medium');
-		me.set_permissions(r.message, role);
-	}
-	$c_obj('Company Control','get_permission',role,callback);
-}
-
-
-// set permission
-RoleObj.prototype.set_permissions = function(perm, role){
-	var me = this;
-	me.help_div.body.innerHTML ='';
-	
-	if(perm){
-		me.help_div.head.innerHTML = 'Permissions for ' + role + ':<br><br>';
-		
-		perm_tbl = make_table(me.help_div.body,cint(perm.length)+2,7,'100%',['30%','10%','10%','10%','10%','10%','10%'],{padding:'4px'});
-		
-		var head_lst = ['Document','Read','Write','Create','Submit','Cancel','Amend'];
-
-		for(var i=0; i<(head_lst.length-1);i++){
-			$td(perm_tbl,0,i).innerHTML= "<b>"+head_lst[i]+"</b>";
-		}
-		var accept_img1 = 'lib/images/icons/accept.gif';
-		var cancel_img1 =	'lib/images/icons/cancel.gif';
-
-		for(i=1; i<perm.length+1; i++){
-			$td(perm_tbl,i,0).innerHTML= get_doctype_label(perm[i-1][0]);
-			
-			for(var j=1;j<(head_lst.length-1);j++){
-				
-				if(perm[i-1][j]){
-					var accept_img = $a($td(perm_tbl,i,j), 'img');	accept_img.src= accept_img1;
-				}
-				else { 
-					var cancel_img = $a($td(perm_tbl,i,j), 'img'); cancel_img.src= cancel_img1;
-				}
-				$y($td(perm_tbl,i,j),{textAlign:'center'});
-			}
-		}
-	}
-	else
-		me.help_div.head.innerHTML = 'No Permission set for ' + role + '.<br><br>';
-}
diff --git a/erpnext/home/page/profile_settings/profile_settings.js b/erpnext/home/page/profile_settings/profile_settings.js
index 9dac7f6..f1ee6ff 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);
+		this.img = $a($td(this.tab, 0, 0), 'img', '', {width: '120px', maxHeight:'200px'});
+		this.img.src = wn.user_info(user).image;
 
-		$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,46 @@
 	//
 	
 	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) {
+	msgprint('File Uploaded');
+	if(fid) {
+		erpnext.set_user_background(fid);		
+		pscript.open_dialog.hide();
+	}
+}
+
 pscript.user_image_upload = function(fid) {
 	msgprint('File Uploaded');
-	
 	if(fid) {
-		pscript.myprofile.change_dialog.hide();
-		set_user_img(pscript.myprofile.img, user, null, fid);
+		pscript.open_dialog.hide();
+		wn.boot.user_info[user].image = 'files/' + fid;
+		pscript.myprofile.img.src = 'files/' + 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/add_roles_to_admin.py b/erpnext/patches/jan_mar_2012/add_roles_to_admin.py
new file mode 100644
index 0000000..402675a
--- /dev/null
+++ b/erpnext/patches/jan_mar_2012/add_roles_to_admin.py
@@ -0,0 +1,10 @@
+def execute():
+	"""
+		Adds various roles to Administrator. This patch is for making master db
+		ready for on premise installation
+	"""
+	import webnotes
+	from webnotes.model.code import get_obj
+	from webnotes.model.doc import Document
+	sc = get_obj('Setup Control', 'Setup Control')
+	sc.add_roles(Document('Profile', 'Administrator'))
diff --git a/erpnext/patches/jan_mar_2012/clear_session_cache.py b/erpnext/patches/jan_mar_2012/clear_session_cache.py
index 2071ae5..5ba2104 100644
--- a/erpnext/patches/jan_mar_2012/clear_session_cache.py
+++ b/erpnext/patches/jan_mar_2012/clear_session_cache.py
@@ -16,6 +16,4 @@
 
 def execute():
 	import webnotes
-	webnotes.conn.sql("""
-		delete from __SessionCache
-	""")
+	webnotes.clear_cache()
diff --git a/erpnext/patches/jan_mar_2012/dt_map_fix.py b/erpnext/patches/jan_mar_2012/dt_map_fix.py
new file mode 100644
index 0000000..f669009
--- /dev/null
+++ b/erpnext/patches/jan_mar_2012/dt_map_fix.py
@@ -0,0 +1,7 @@
+def execute():
+	import webnotes
+	from webnotes.modules.module_manager import reload_doc
+	webnotes.conn.sql("delete from `tabField Mapper Detail` where from_field = 'transaction_date' and parent in ('Sales Order-Delivery Note', 'Purchase Order-Purchase Receipt')")
+
+	reload_doc('stock', 'DocType Mapper', 'Sales Order-Delivery Note')
+	reload_doc('stock', 'DocType Mapper', 'Purchase Order-Purchase Receipt')
diff --git a/erpnext/patches/jan_mar_2012/label_cleanup.py b/erpnext/patches/jan_mar_2012/label_cleanup.py
index 885c83f..b40f36f 100644
--- a/erpnext/patches/jan_mar_2012/label_cleanup.py
+++ b/erpnext/patches/jan_mar_2012/label_cleanup.py
@@ -3,14 +3,14 @@
 	from webnotes.model import delete_doc
 	from webnotes.modules.module_manager import reload_doc
 
-	dt = [
+	dt = {
 		'selling':	['quotation', 'sales_order', 'quotation_detail', 'sales_order_detail'], 
 		'stock':	['delivery_note', 'delivery_note_detail', 'purchase_receipt', 'purchase_receipt_detail'],
 		'accounts': ['receivable_voucher', 'payable_voucher', 'rv_detail', 'pv_detail', 'rv_tax_detail', 'purchase_tax_detail'],
 		'buying':	['purchase_order', 'po_detail']
-	]
+	}
 	for m in dt:
-		for d in m:
+		for d in dt[m]:
 			reload_doc(m, 'doctype', d)
 
 
@@ -21,7 +21,7 @@
 
 	del_flds = {
 		'Sales Order Detail':	"'delivery_date', 'confirmation_date'", 
-		'Delivery Note':		"'supplier', 'supplier_address', 'purchase_receipt_no', 'purchase_order_no', 'transaction_date'"
+		'Delivery Note':		"'supplier', 'supplier_address', 'purchase_receipt_no', 'purchase_order_no', 'transaction_date'",
 		'Receivable Voucher':	"'voucher_date'",
 		'Payable Voucher':		"'voucher_date'",
 		'Purchase Receipt':		"'transaction_date'"
@@ -33,10 +33,15 @@
 	}
 
 	for d in del_flds:
-		webnotes.conn.sql("delete from `tabDocField` where fieldname in (%s) and parent = %s", (del_flds[d], d))
+		webnotes.conn.sql("delete from `tabDocField` where fieldname in (%s) and parent = '%s'"% (del_flds[d], d))
 
 	for d in del_labels:
-		webnotes.conn.sql("delete from `tabDocField` where label in (%s) and parent = %s", (del_labels[d], d))
+		webnotes.conn.sql("delete from `tabDocField` where label in (%s) and parent = '%s'"% (del_labels[d], d))
 
 	delete_doc('DocType', 'Update Delivery Date Detail')
-	delete_doc('DocType', 'Update Delivery Date'
+
+	# Reload print formats
+	reload_doc('accounts', 'Print Format', 'Sales Invoice Classic')
+	reload_doc('accounts', 'Print Format', 'Sales Invoice Modern')
+	reload_doc('accounts', 'Print Format', 'Sales Invoice Spartan')
+
diff --git a/erpnext/patches/jan_mar_2012/navupdate.py b/erpnext/patches/jan_mar_2012/navupdate.py
index d29a2cf..1cfa879 100644
--- a/erpnext/patches/jan_mar_2012/navupdate.py
+++ b/erpnext/patches/jan_mar_2012/navupdate.py
@@ -32,6 +32,17 @@
 	reload_doc('utilities', 'page', 'todo')
 	reload_doc('utilities', 'page', 'calendar')
 	reload_doc('utilities', 'page', 'messages')
+	reload_doc('setup', 'page', 'modules_setup')
+	reload_doc('utilities', 'page', 'users')
+	reload_doc('home', 'page', 'activity')
+	reload_doc('home', 'page', 'attributions')
+	reload_doc('core', 'doctype', 'profile')
+	
+	# update user_image in profile
+	for p in webnotes.conn.sql("""select name, file_list from tabProfile 
+		where ifnull(file_list,'')!=''"""):
+		fid = p[1].split('\n')[0].split(',')[1]
+		webnotes.conn.set_value('Profile', p[0], 'user_image', fid)
 	
 	webnotes.conn.set_value('Control Panel', 'Control Panel', 'home_page',
 			'desktop')
diff --git a/erpnext/patches/jan_mar_2012/reload_table.py b/erpnext/patches/jan_mar_2012/reload_table.py
new file mode 100644
index 0000000..14b8864
--- /dev/null
+++ b/erpnext/patches/jan_mar_2012/reload_table.py
@@ -0,0 +1,9 @@
+def execute():
+	import webnotes
+	from webnotes.modules.module_manager import reload_doc
+	reload_doc('selling', 'doctype', 'quotation_detail')
+	reload_doc('stock', 'doctype', 'delivery_note_detail')
+	reload_doc('stock', 'doctype', 'purchase_receipt_detail')
+	reload_doc('buying', 'doctype', 'po_detail')
+	reload_doc('accounts', 'doctype', 'rv_detail')
+	reload_doc('accounts', 'doctype', 'pv_detail')
diff --git a/erpnext/patches/jan_mar_2012/website/file_data_rename.py b/erpnext/patches/jan_mar_2012/website/file_data_rename.py
index 481a530..dc4110b 100644
--- a/erpnext/patches/jan_mar_2012/website/file_data_rename.py
+++ b/erpnext/patches/jan_mar_2012/website/file_data_rename.py
@@ -69,3 +69,12 @@
 			if file_list and "/" in file_list:
 				webnotes.conn.sql("UPDATE `%s` SET file_list='%s' WHERE name='%s'" \
 					% (tab, file_list.replace('/', '-'), name))
+
+	singles = webnotes.conn.sql("""SELECT doctype, value FROM `tabSingles`
+		WHERE field='file_list'""")
+	for doctype, file_list in singles:
+		if file_list and "/" in file_list:
+			webnotes.conn.sql("""UPDATE `tabSingles` SET value='%s'
+				WHERE doctype='%s' AND field='file_list'"""
+				% (file_list.replace('/', '-'), doctype))
+
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index dc9f1dd..7750962 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -121,4 +121,61 @@
 		'patch_file': 'fix_packing_slip',
 		'description': 'Update Mapper Delivery Note-Packing Slip'
 	},
+	{
+		'patch_module': 'patches.jan_mar_2012.apps',
+		'patch_file': 'todo_item',
+		'description': 'Reloads todo item'
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'convert_tables_to_utf8',
+		'description': 'Convert tables to UTF-8'
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'pending_patches',
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'pos_setting_patch',
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'reload_doctype',
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'reload_po_pr_mapper',
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'delete_pur_of_service',
+		'description': 'Deletes purpose of service'
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'navupdate',
+		'description': 'New Navigation Pages'
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'label_cleanup',
+		'description': 'Remove extra fields and new dynamic labels'
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'add_roles_to_admin',
+		'description': 'Add Roles to Administrator'
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'dt_map_fix',
+		'description': 'removed transaction date from dt_mapper'
+	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'reload_table',
+		'description': 'Relaod all item table: fld order changes' 
+	},
+
 ]
diff --git a/erpnext/patches/print_formats/SalesInvoiceClassic.html b/erpnext/patches/print_formats/SalesInvoiceClassic.html
index 78cb815..d40f801 100644
--- a/erpnext/patches/print_formats/SalesInvoiceClassic.html
+++ b/erpnext/patches/print_formats/SalesInvoiceClassic.html
@@ -200,7 +200,7 @@
 				<td><table width=100% cellspacing=0><tbody>
 					<tr>
 						<td width=40%><b>Invoice Date</b></td>
-						<td><script>date.str_to_user(doc.voucher_date)</script></td>
+						<td><script>date.str_to_user(doc.posting_date)</script></td>
 					<tr>					
 					<tr>
 						<td><b>Due Date</b></td>
diff --git a/erpnext/patches/print_formats/SalesInvoiceModern.html b/erpnext/patches/print_formats/SalesInvoiceModern.html
index cef84ac..ac66423 100644
--- a/erpnext/patches/print_formats/SalesInvoiceModern.html
+++ b/erpnext/patches/print_formats/SalesInvoiceModern.html
@@ -227,7 +227,7 @@
 					</tr>
 					<tr>
 						<td width=40%><b>Invoice Date</b></td>
-						<td><script>date.str_to_user(doc.voucher_date)</script></td>
+						<td><script>date.str_to_user(doc.posting_date)</script></td>
 					<tr>					
 					<tr>
 						<td><b>Due Date</b></td>
diff --git a/erpnext/patches/print_formats/SalesInvoiceSpartan.html b/erpnext/patches/print_formats/SalesInvoiceSpartan.html
index 7d13674..81e1c38 100644
--- a/erpnext/patches/print_formats/SalesInvoiceSpartan.html
+++ b/erpnext/patches/print_formats/SalesInvoiceSpartan.html
@@ -222,7 +222,7 @@
 				<td><table width=100% cellspacing=0><tbody>
 					<tr>
 						<td width=40%><b>Invoice Date</b></td>
-						<td><script>date.str_to_user(doc.voucher_date)</script></td>
+						<td><script>date.str_to_user(doc.posting_date)</script></td>
 					<tr>					
 					<tr>
 						<td><b>Due Date</b></td>
diff --git a/erpnext/selling/doctype/customer/customer.txt b/erpnext/selling/doctype/customer/customer.txt
index 24271ee..346b4d1 100644
--- a/erpnext/selling/doctype/customer/customer.txt
+++ b/erpnext/selling/doctype/customer/customer.txt
@@ -5,47 +5,48 @@
 	{
 		'creation': '2010-08-08 17:08:56',
 		'docstatus': 0,
-		'modified': '2011-07-20 10:42:05',
-		'modified_by': 'Administrator',
-		'owner': 'Administrator'
+		'modified': '2012-02-29 13:24:31',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1309508837',
+		'_last_update': u'1330501485',
 		'allow_print': 0,
 		'allow_trash': 1,
-		'colour': 'White:FFF',
+		'colour': u'White:FFF',
+		'default_print_format': u'Standard',
 		'doctype': 'DocType',
-		'document_type': 'Master',
-		'module': 'Selling',
+		'document_type': u'Master',
+		'module': u'Selling',
 		'name': '__common__',
-		'search_fields': 'customer_name,customer_group,country,territory',
-		'section_style': 'Tabbed',
-		'server_code_error': ' ',
+		'search_fields': u'customer_name,customer_group,country,territory',
+		'section_style': u'Tabbed',
+		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'subject': "eval:'%(customer_name)s'=='%(name)s' ? ' ' : '%(customer_name)s'",
-		'tag_fields': 'customer_group,customer_type',
-		'version': 433
+		'subject': u'eval:"%(customer_name)s"=="%(name)s" ? "" : "%(customer_name)s"',
+		'tag_fields': u'customer_group,customer_type',
+		'version': 434
 	},
 
 	# These values are common for all DocField
 	{
-		'doctype': 'DocField',
+		'doctype': u'DocField',
 		'name': '__common__',
-		'parent': 'Customer',
-		'parentfield': 'fields',
-		'parenttype': 'DocType'
+		'parent': u'Customer',
+		'parentfield': u'fields',
+		'parenttype': u'DocType'
 	},
 
 	# These values are common for all DocPerm
 	{
 		'amend': 0,
-		'doctype': 'DocPerm',
+		'doctype': u'DocPerm',
 		'name': '__common__',
-		'parent': 'Customer',
-		'parentfield': 'permissions',
-		'parenttype': 'DocType',
+		'parent': u'Customer',
+		'parentfield': u'permissions',
+		'parenttype': u'DocType',
 		'read': 1,
 		'submit': 0
 	},
@@ -53,17 +54,16 @@
 	# DocType, Customer
 	{
 		'doctype': 'DocType',
-		'name': 'Customer'
+		'name': u'Customer'
 	},
 
 	# DocPerm
 	{
 		'cancel': 0,
 		'create': 0,
-		'doctype': 'DocPerm',
-		'idx': 1,
+		'doctype': u'DocPerm',
 		'permlevel': 1,
-		'role': 'Sales Manager',
+		'role': u'Sales Manager',
 		'write': 0
 	},
 
@@ -71,10 +71,9 @@
 	{
 		'cancel': 0,
 		'create': 0,
-		'doctype': 'DocPerm',
-		'idx': 2,
+		'doctype': u'DocPerm',
 		'permlevel': 0,
-		'role': 'Sales Manager',
+		'role': u'Sales Manager',
 		'write': 0
 	},
 
@@ -82,10 +81,9 @@
 	{
 		'cancel': 0,
 		'create': 0,
-		'doctype': 'DocPerm',
-		'idx': 3,
+		'doctype': u'DocPerm',
 		'permlevel': 1,
-		'role': 'Sales User',
+		'role': u'Sales User',
 		'write': 0
 	},
 
@@ -93,10 +91,9 @@
 	{
 		'cancel': 0,
 		'create': 0,
-		'doctype': 'DocPerm',
-		'idx': 4,
+		'doctype': u'DocPerm',
 		'permlevel': 0,
-		'role': 'Sales User',
+		'role': u'Sales User',
 		'write': 0
 	},
 
@@ -104,10 +101,9 @@
 	{
 		'cancel': 1,
 		'create': 1,
-		'doctype': 'DocPerm',
-		'idx': 5,
+		'doctype': u'DocPerm',
 		'permlevel': 0,
-		'role': 'Sales Master Manager',
+		'role': u'Sales Master Manager',
 		'write': 1
 	},
 
@@ -115,38 +111,35 @@
 	{
 		'cancel': 0,
 		'create': 0,
-		'doctype': 'DocPerm',
-		'idx': 6,
+		'doctype': u'DocPerm',
 		'permlevel': 1,
-		'role': 'Sales Master Manager',
+		'role': u'Sales Master Manager',
 		'write': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': 'Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts',
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'idx': 1,
-		'label': 'Basic Info',
-		'oldfieldtype': 'Section Break',
+		'colour': u'White:FFF',
+		'description': u'Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts',
+		'doctype': u'DocField',
+		'fieldtype': u'Section Break',
+		'label': u'Basic Info',
+		'oldfieldtype': u'Section Break',
 		'permlevel': 0,
 		'reqd': 0
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'customer_name',
-		'fieldtype': 'Data',
+		'doctype': u'DocField',
+		'fieldname': u'customer_name',
+		'fieldtype': u'Data',
 		'hidden': 0,
-		'idx': 2,
 		'in_filter': 1,
-		'label': 'Customer Name',
+		'label': u'Customer Name',
 		'no_copy': 1,
-		'oldfieldname': 'customer_name',
-		'oldfieldtype': 'Data',
+		'oldfieldname': u'customer_name',
+		'oldfieldtype': u'Data',
 		'permlevel': 0,
 		'print_hide': 0,
 		'report_hide': 0,
@@ -156,330 +149,312 @@
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'customer_type',
-		'fieldtype': 'Select',
-		'idx': 3,
-		'label': 'Customer Type',
-		'oldfieldname': 'customer_type',
-		'oldfieldtype': 'Select',
-		'options': '\nCompany\nIndividual',
+		'doctype': u'DocField',
+		'fieldname': u'customer_type',
+		'fieldtype': u'Select',
+		'label': u'Customer Type',
+		'oldfieldname': u'customer_type',
+		'oldfieldtype': u'Select',
+		'options': u'\nCompany\nIndividual',
 		'permlevel': 0,
 		'reqd': 1
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'naming_series',
-		'fieldtype': 'Select',
-		'idx': 4,
-		'label': 'Series',
+		'doctype': u'DocField',
+		'fieldname': u'naming_series',
+		'fieldtype': u'Select',
+		'label': u'Series',
 		'no_copy': 1,
-		'options': '\nCUST\nCUSTMUM\nCUSTOM',
+		'options': u'\nCUST\nCUSTMUM',
 		'permlevel': 0,
 		'print_hide': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': 'Fetch lead which will be converted into customer.',
-		'doctype': 'DocField',
-		'fieldname': 'lead_name',
-		'fieldtype': 'Link',
+		'colour': u'White:FFF',
+		'description': u'Fetch lead which will be converted into customer.',
+		'doctype': u'DocField',
+		'fieldname': u'lead_name',
+		'fieldtype': u'Link',
 		'hidden': 0,
-		'idx': 5,
 		'in_filter': 1,
-		'label': 'Lead Ref',
+		'label': u'Lead Ref',
 		'no_copy': 1,
-		'oldfieldname': 'lead_name',
-		'oldfieldtype': 'Link',
-		'options': 'Lead',
+		'oldfieldname': u'lead_name',
+		'oldfieldtype': u'Link',
+		'options': u'Lead',
 		'permlevel': 0,
 		'print_hide': 1,
 		'report_hide': 1,
-		'trigger': 'Client'
+		'trigger': u'Client'
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldtype': 'Column Break',
-		'idx': 6,
+		'doctype': u'DocField',
+		'fieldtype': u'Column Break',
 		'permlevel': 0,
-		'width': '50%'
+		'width': u'50%'
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': '<a href="javascript:cur_frm.cscript.CGHelp();">To manage Customer Groups, click here</a>',
-		'doctype': 'DocField',
-		'fieldname': 'customer_group',
-		'fieldtype': 'Link',
+		'colour': u'White:FFF',
+		'description': u'<a href="javascript:cur_frm.cscript.CGHelp();">To manage Customer Groups, click here</a>',
+		'doctype': u'DocField',
+		'fieldname': u'customer_group',
+		'fieldtype': u'Link',
 		'hidden': 0,
-		'idx': 7,
 		'in_filter': 1,
-		'label': 'Customer Group',
-		'oldfieldname': 'customer_group',
-		'oldfieldtype': 'Link',
-		'options': 'Customer Group',
+		'label': u'Customer Group',
+		'oldfieldname': u'customer_group',
+		'oldfieldtype': u'Link',
+		'options': u'Customer Group',
 		'permlevel': 0,
 		'print_hide': 0,
 		'reqd': 1,
 		'search_index': 1,
-		'trigger': 'Client'
+		'trigger': u'Client'
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': '<a href="javascript:cur_frm.cscript.TerritoryHelp();">To manage Territory, click here</a>',
-		'doctype': 'DocField',
-		'fieldname': 'territory',
-		'fieldtype': 'Link',
-		'idx': 8,
-		'label': 'Territory',
-		'oldfieldname': 'territory',
-		'oldfieldtype': 'Link',
-		'options': 'Territory',
+		'colour': u'White:FFF',
+		'description': u'<a href="javascript:cur_frm.cscript.TerritoryHelp();">To manage Territory, click here</a>',
+		'doctype': u'DocField',
+		'fieldname': u'territory',
+		'fieldtype': u'Link',
+		'label': u'Territory',
+		'oldfieldname': u'territory',
+		'oldfieldtype': u'Link',
+		'options': u'Territory',
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1,
-		'trigger': 'Client'
+		'trigger': u'Client'
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'idx': 9,
-		'label': 'Address & Contacts',
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldtype': u'Section Break',
+		'label': u'Address & Contacts',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'depends_on': 'eval:doc.__islocal',
-		'doctype': 'DocField',
-		'fieldtype': 'HTML',
-		'idx': 10,
-		'label': 'Address Desc',
-		'options': '<em>Addresses will appear only when you save the customer</em>',
+		'colour': u'White:FFF',
+		'depends_on': u'eval:doc.__islocal',
+		'doctype': u'DocField',
+		'fieldtype': u'HTML',
+		'label': u'Address Desc',
+		'options': u'<em>Addresses will appear only when you save the customer</em>',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldtype': 'HTML',
-		'idx': 11,
-		'label': 'Address HTML',
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldtype': u'HTML',
+		'label': u'Address HTML',
 		'permlevel': 1
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldtype': 'Column Break',
-		'idx': 12,
+		'doctype': u'DocField',
+		'fieldtype': u'Column Break',
 		'permlevel': 0,
-		'width': '50%'
+		'width': u'50%'
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'depends_on': 'eval:doc.__islocal',
-		'doctype': 'DocField',
-		'fieldtype': 'HTML',
-		'idx': 13,
-		'label': 'Contact Desc',
-		'options': '<em>Contact Details will appear only when you save the customer</em>',
+		'colour': u'White:FFF',
+		'depends_on': u'eval:doc.__islocal',
+		'doctype': u'DocField',
+		'fieldtype': u'HTML',
+		'label': u'Contact Desc',
+		'options': u'<em>Contact Details will appear only when you save the customer</em>',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldtype': 'HTML',
-		'idx': 14,
-		'label': 'Contact HTML',
-		'oldfieldtype': 'HTML',
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldtype': u'HTML',
+		'label': u'Contact HTML',
+		'oldfieldtype': u'HTML',
 		'permlevel': 1
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'idx': 15,
-		'label': 'More Info',
-		'oldfieldtype': 'Section Break',
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldtype': u'Section Break',
+		'label': u'More Info',
+		'oldfieldtype': u'Section Break',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': 'To create an Account Head under a different company, then set the company and click the button below.',
-		'doctype': 'DocField',
-		'fieldname': 'company',
-		'fieldtype': 'Link',
-		'idx': 16,
+		'doctype': u'DocField',
+		'fieldtype': u'Column Break',
+		'permlevel': 0,
+		'width': u'50%'
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		'description': u'To create an Account Head under a different company, select the company and save customer.',
+		'doctype': u'DocField',
+		'fieldname': u'company',
+		'fieldtype': u'Link',
 		'in_filter': 1,
-		'label': 'Company',
-		'oldfieldname': 'company',
-		'oldfieldtype': 'Link',
-		'options': 'Company',
+		'label': u'Company',
+		'oldfieldname': u'company',
+		'oldfieldtype': u'Link',
+		'options': u'Company',
 		'permlevel': 0,
 		'reqd': 1,
-		'search_index': 0
+		'search_index': 1
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': "Your Customer's TAX registration numbers (if applicable) or any general information",
-		'doctype': 'DocField',
-		'fieldname': 'customer_details',
-		'fieldtype': 'Text',
-		'idx': 17,
-		'label': 'Customer Details',
-		'oldfieldname': 'customer_details',
-		'oldfieldtype': 'Code',
+		'colour': u'White:FFF',
+		'description': u"Your Customer's TAX registration numbers (if applicable) or any general information",
+		'doctype': u'DocField',
+		'fieldname': u'customer_details',
+		'fieldtype': u'Text',
+		'label': u'Customer Details',
+		'oldfieldname': u'customer_details',
+		'oldfieldtype': u'Code',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldtype': 'Column Break',
-		'idx': 18,
+		'doctype': u'DocField',
+		'fieldtype': u'Column Break',
 		'permlevel': 0,
-		'width': '50%'
+		'width': u'50%'
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'credit_days',
-		'fieldtype': 'Int',
-		'idx': 19,
-		'label': 'Credit Days',
-		'oldfieldname': 'credit_days',
-		'oldfieldtype': 'Int',
+		'doctype': u'DocField',
+		'fieldname': u'credit_days',
+		'fieldtype': u'Int',
+		'label': u'Credit Days',
+		'oldfieldname': u'credit_days',
+		'oldfieldtype': u'Int',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'credit_limit',
-		'fieldtype': 'Currency',
-		'idx': 20,
-		'label': 'Credit Limit',
-		'oldfieldname': 'credit_limit',
-		'oldfieldtype': 'Currency',
+		'doctype': u'DocField',
+		'fieldname': u'credit_limit',
+		'fieldtype': u'Currency',
+		'label': u'Credit Limit',
+		'oldfieldname': u'credit_limit',
+		'oldfieldtype': u'Currency',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'website',
-		'fieldtype': 'Data',
-		'idx': 21,
-		'label': 'Website',
+		'doctype': u'DocField',
+		'fieldname': u'website',
+		'fieldtype': u'Data',
+		'label': u'Website',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'idx': 22,
-		'label': 'Sales Team',
-		'oldfieldtype': 'Section Break',
+		'doctype': u'DocField',
+		'fieldtype': u'Section Break',
+		'label': u'Sales Team',
+		'oldfieldtype': u'Section Break',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'default_sales_partner',
-		'fieldtype': 'Link',
-		'idx': 23,
-		'label': 'Default Sales Partner',
-		'oldfieldname': 'default_sales_partner',
-		'oldfieldtype': 'Link',
-		'options': 'Sales Partner',
+		'doctype': u'DocField',
+		'fieldname': u'default_sales_partner',
+		'fieldtype': u'Link',
+		'label': u'Default Sales Partner',
+		'oldfieldname': u'default_sales_partner',
+		'oldfieldtype': u'Link',
+		'options': u'Sales Partner',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'default_commission_rate',
-		'fieldtype': 'Currency',
-		'idx': 24,
-		'label': 'Default Commission Rate',
-		'oldfieldname': 'default_commission_rate',
-		'oldfieldtype': 'Currency',
+		'doctype': u'DocField',
+		'fieldname': u'default_commission_rate',
+		'fieldtype': u'Currency',
+		'label': u'Default Commission Rate',
+		'oldfieldname': u'default_commission_rate',
+		'oldfieldtype': u'Currency',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'sales_team',
-		'fieldtype': 'Table',
-		'idx': 25,
-		'label': 'Sales Team Details',
-		'oldfieldname': 'sales_team',
-		'oldfieldtype': 'Table',
-		'options': 'Sales Team',
+		'doctype': u'DocField',
+		'fieldname': u'sales_team',
+		'fieldtype': u'Table',
+		'label': u'Sales Team Details',
+		'oldfieldname': u'sales_team',
+		'oldfieldtype': u'Table',
+		'options': u'Sales Team',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'depends_on': 'eval:!doc.__islocal',
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'idx': 26,
-		'label': 'Transaction History',
+		'colour': u'White:FFF',
+		'depends_on': u'eval:!doc.__islocal',
+		'doctype': u'DocField',
+		'fieldtype': u'Section Break',
+		'label': u'Transaction History',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'depends_on': 'eval:!doc.__islocal',
-		'doctype': 'DocField',
-		'fieldtype': 'HTML',
-		'idx': 27,
-		'label': 'History HTML',
+		'colour': u'White:FFF',
+		'depends_on': u'eval:!doc.__islocal',
+		'doctype': u'DocField',
+		'fieldtype': u'HTML',
+		'label': u'History HTML',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldname': 'trash_reason',
-		'fieldtype': 'Small Text',
-		'idx': 28,
-		'label': 'Trash Reason',
-		'oldfieldname': 'trash_reason',
-		'oldfieldtype': 'Small Text',
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldname': u'trash_reason',
+		'fieldtype': u'Small Text',
+		'label': u'Trash Reason',
+		'oldfieldname': u'trash_reason',
+		'oldfieldtype': u'Small Text',
 		'permlevel': 1
 	}
 ]
\ No newline at end of file
diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js
index 2a130a5..7f40782 100644
--- a/erpnext/selling/doctype/quotation/quotation.js
+++ b/erpnext/selling/doctype/quotation/quotation.js
@@ -50,8 +50,11 @@
 }
 
 cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
-	// defined in sales_common.js
-	cur_frm.cscript.update_item_details(doc, cdt, cdn);
+	var callback = function(doc, dt, dn) {
+		// defined in sales_common.js
+		cur_frm.cscript.update_item_details(doc, dt, dn);
+	}
+	cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); 
 }
 
 // hide - unhide fields based on lead or customer..
@@ -83,10 +86,7 @@
 
 	cur_frm.clear_custom_buttons();
 
-	var callback = function() {
-		cur_frm.cscript.dynamic_label(doc, cdt, cdn);
-	}
-	cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback); 
+	if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn); 
 
 
 	if(doc.docstatus == 1 && doc.status!='Order Lost') {
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 531de21..de4056d 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -77,14 +77,16 @@
 	# Get Item Details
 	# -----------------
 	def get_item_details(self, args=None):
-		args = eval(args)
-		if args['item_code']:
+		args = args and eval(args) or {}
+		if args.get('item_code'):
 			return get_obj('Sales Common').get_item_details(args, self)
 		else:
 			obj = get_obj('Sales Common')
 			for doc in self.doclist:
 				if doc.fields.get('item_code'):
-					ret = obj.get_item_details(doc.item_code, self)
+					arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), 
+						'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
+					ret = obj.get_item_details(arg, self)
 					for r in ret:
 						if not doc.fields.get(r):
 							doc.fields[r] = ret[r]					
@@ -96,11 +98,6 @@
 		get_obj('Sales Common').get_adj_percent(self)
 
 	
-	def get_comp_base_currency(self):
-		return get_obj('Sales Common').get_comp_base_currency(self.doc.company)
-
-	def get_price_list_currency(self):
-		return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company)
 		
 
 # OTHER CHARGES TRIGGER FUNCTIONS
diff --git a/erpnext/selling/doctype/quotation/quotation.txt b/erpnext/selling/doctype/quotation/quotation.txt
index 07642e8..32784a8 100644
--- a/erpnext/selling/doctype/quotation/quotation.txt
+++ b/erpnext/selling/doctype/quotation/quotation.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:17',
 		'docstatus': 0,
-		'modified': '2012-02-27 17:14:54',
+		'modified': '2012-03-02 12:20:40',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -41,7 +41,7 @@
 		'show_in_menu': 0,
 		'subject': u'To %(customer_name)s on %(transaction_date)s worth %(currency)s %(grand_total_export)s',
 		'tag_fields': u'status',
-		'version': 617
+		'version': 618
 	},
 
 	# These values are common for all DocFormat
@@ -679,18 +679,6 @@
 	{
 		'colour': u'White:FFF',
 		'doctype': u'DocField',
-		'fieldtype': u'HTML',
-		'label': u'Note HTML',
-		'oldfieldtype': u'HTML',
-		'options': u'<div style="margin-top:16px"><b>Note :</b> * In Base Currency\n</div>',
-		'permlevel': 0,
-		'print_hide': 1
-	},
-
-	# DocField
-	{
-		'colour': u'White:FFF',
-		'doctype': u'DocField',
 		'fieldtype': u'Section Break',
 		'label': u'Taxes',
 		'oldfieldtype': u'Section Break',
diff --git a/erpnext/selling/doctype/quotation_detail/quotation_detail.txt b/erpnext/selling/doctype/quotation_detail/quotation_detail.txt
index 8c78f48..81bf64d 100644
--- a/erpnext/selling/doctype/quotation_detail/quotation_detail.txt
+++ b/erpnext/selling/doctype/quotation_detail/quotation_detail.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:18',
 		'docstatus': 0,
-		'modified': '2012-02-24 13:21:21',
+		'modified': '2012-03-05 10:48:27',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -23,7 +23,7 @@
 		'section_style': u'Tray',
 		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'version': 30
+		'version': 32
 	},
 
 	# These values are common for all DocField
@@ -94,20 +94,35 @@
 	{
 		'default': u'0.00',
 		'doctype': u'DocField',
-		'fieldname': u'ref_rate',
+		'fieldname': u'qty',
 		'fieldtype': u'Currency',
-		'label': u'Price List Rate',
-		'oldfieldname': u'ref_rate',
+		'in_filter': 0,
+		'label': u'Quantity',
+		'oldfieldname': u'qty',
 		'oldfieldtype': u'Currency',
 		'permlevel': 0,
-		'print_hide': 1,
-		'reqd': 0,
+		'print_hide': 0,
+		'reqd': 1,
+		'search_index': 0,
 		'trigger': u'Client',
 		'width': u'100px'
 	},
 
 	# DocField
 	{
+		'doctype': u'DocField',
+		'fieldname': u'base_ref_rate',
+		'fieldtype': u'Currency',
+		'label': u'Price List Rate*',
+		'oldfieldname': u'base_ref_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'width': u'100px'
+	},
+
+	# DocField
+	{
 		'default': u'0.00',
 		'doctype': u'DocField',
 		'fieldname': u'adj_rate',
@@ -116,7 +131,59 @@
 		'oldfieldname': u'adj_rate',
 		'oldfieldtype': u'Float',
 		'permlevel': 0,
-		'print_hide': 0,
+		'print_hide': 1,
+		'trigger': u'Client',
+		'width': u'100px'
+	},
+
+	# DocField
+	{
+		'default': u'0.00',
+		'doctype': u'DocField',
+		'fieldname': u'basic_rate',
+		'fieldtype': u'Currency',
+		'in_filter': 0,
+		'label': u'Basic Rate*',
+		'oldfieldname': u'basic_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'search_index': 0,
+		'trigger': u'Client',
+		'width': u'100px'
+	},
+
+	# DocField
+	{
+		'default': u'0.00',
+		'doctype': u'DocField',
+		'fieldname': u'amount',
+		'fieldtype': u'Currency',
+		'in_filter': 0,
+		'label': u'Amount*',
+		'oldfieldname': u'amount',
+		'oldfieldtype': u'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 0,
+		'search_index': 0,
+		'trigger': u'Client',
+		'width': u'100px'
+	},
+
+	# DocField
+	{
+		'default': u'0.00',
+		'doctype': u'DocField',
+		'fieldname': u'ref_rate',
+		'fieldtype': u'Currency',
+		'label': u'Price List Rate',
+		'oldfieldname': u'ref_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
 		'trigger': u'Client',
 		'width': u'100px'
 	},
@@ -143,24 +210,6 @@
 	{
 		'default': u'0.00',
 		'doctype': u'DocField',
-		'fieldname': u'qty',
-		'fieldtype': u'Currency',
-		'in_filter': 0,
-		'label': u'Quantity',
-		'oldfieldname': u'qty',
-		'oldfieldtype': u'Currency',
-		'permlevel': 0,
-		'print_hide': 0,
-		'reqd': 1,
-		'search_index': 0,
-		'trigger': u'Client',
-		'width': u'100px'
-	},
-
-	# DocField
-	{
-		'default': u'0.00',
-		'doctype': u'DocField',
 		'fieldname': u'export_amount',
 		'fieldtype': u'Currency',
 		'in_filter': 0,
@@ -176,37 +225,6 @@
 
 	# DocField
 	{
-		'doctype': u'DocField',
-		'fieldname': u'base_ref_rate',
-		'fieldtype': u'Currency',
-		'label': u'Price List Rate*',
-		'oldfieldname': u'base_ref_rate',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1,
-		'print_hide': 1,
-		'width': u'100px'
-	},
-
-	# DocField
-	{
-		'default': u'0.00',
-		'doctype': u'DocField',
-		'fieldname': u'basic_rate',
-		'fieldtype': u'Currency',
-		'in_filter': 0,
-		'label': u'Basic Rate*',
-		'oldfieldname': u'basic_rate',
-		'oldfieldtype': u'Currency',
-		'permlevel': 0,
-		'print_hide': 1,
-		'reqd': 0,
-		'search_index': 0,
-		'trigger': u'Client',
-		'width': u'100px'
-	},
-
-	# DocField
-	{
 		'colour': u'White:FFF',
 		'doctype': u'DocField',
 		'fieldname': u'stock_uom',
@@ -222,24 +240,6 @@
 
 	# DocField
 	{
-		'default': u'0.00',
-		'doctype': u'DocField',
-		'fieldname': u'amount',
-		'fieldtype': u'Currency',
-		'in_filter': 0,
-		'label': u'Amount*',
-		'oldfieldname': u'amount',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1,
-		'print_hide': 1,
-		'reqd': 0,
-		'search_index': 0,
-		'trigger': u'Client',
-		'width': u'100px'
-	},
-
-	# DocField
-	{
 		'doctype': u'DocField',
 		'fieldname': u'item_group',
 		'fieldtype': u'Link',
diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js
index 5d88c30..97b20eb 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.js
+++ b/erpnext/selling/doctype/sales_common/sales_common.js
@@ -26,13 +26,15 @@
 	// run if this is not executed from dt_map...
 	doc = locals[doc.doctype][doc.name];
 	if(doc.customer || getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length) {
-		if(callback) callback(doc, cdt, cdn);
-		return;
+		if(callback) {
+			callback(doc, cdt, cdn);
+		}
+	} else {
+		$c_obj([doc],'load_default_taxes','',function(r,rt){
+			refresh_field('other_charges');
+			if(callback) callback(doc, cdt, cdn);
+		});
 	}
-	$c_obj([doc],'load_default_taxes','',function(r,rt){
-		refresh_field('other_charges');
-		if(callback) callback(doc, cdt, cdn);
-	});
 }
 
 
@@ -75,7 +77,6 @@
 
 
 
-
 // ============== Customer and its primary contact Details ============================
 cur_frm.cscript.customer = function(doc, cdt, cdn) {
 	if(doc.customer){
@@ -120,7 +121,9 @@
 	for (d in item_cols_export) $('[data-grid-fieldname="'+cur_frm.cscript.tname+'-'+d+'"]').html(item_cols_export[d]+' ('+doc.currency+')');	
 
 	var hide = (doc.currency == sys_defaults['currency']) ? false : true;
-	for (f in item_cols_base) cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(f, hide);
+	for (f in item_cols_export) {
+		cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(f, hide);
+	}
 
 	//tax table flds
 	tax_cols = {'tax_amount': 'Amount', 'total': 'Total'};
@@ -136,17 +139,11 @@
 // Change label dynamically based on currency
 //------------------------------------------------------------------
 
-cur_frm.cscript.dynamic_label = function(doc, cdt, cdn) {
-	var callback = function(r, rt) {
-		if (r.message) base_curr = r.message;
-		else base_curr = sys_defaults['currency'];
+cur_frm.cscript.dynamic_label = function(doc, cdt, cdn, base_curr, callback) {
+	set_dynamic_label_par(doc, cdt, cdn, base_curr);
+	set_dynamic_label_child(doc, cdt, cdn, base_curr);
 
-		set_dynamic_label_par(doc, cdt, cdn, base_curr);
-		set_dynamic_label_child(doc, cdt, cdn, base_curr);
-	}
-
-	if (doc.company == sys_defaults['company']) callback('', '');
-	else $c_obj(make_doclist(doc.doctype, doc.name), 'get_comp_base_currency', '', callback);
+	if (callback) callback(doc, cdt, cdn);
 }
 
 
@@ -155,27 +152,30 @@
 
 cur_frm.cscript.hide_price_list_currency = function(doc, cdt, cdn, callback1) {
 	if (doc.price_list_name && doc.currency) {
-		var callback = function(r, rt) {
-			pl_currency = r.message[0]?r.message[0]:[];
-			if (pl_currency.length==1) {
-				if (pl_currency[0] == doc.currency) set_multiple(cdt, cdn, {price_list_currency:doc.currency, plc_conversion_rate:doc.conversion_rate});
-				else if (pl_currency[0] = r.message[1]) set_multiple(cdt, cdn, {price_list_currency:pl_currency[0], plc_conversion_rate:1})
-				hide_field(['price_list_currency', 'plc_conversion_rate']);
-			} else unhide_field(['price_list_currency', 'plc_conversion_rate']);
+		wn.call({
+			method: 'selling.doctype.sales_common.sales_common.get_price_list_currency',
+			args: {'price_list':doc.price_list_name, 'company': doc.company},
+			callback: function(r, rt) {
+				pl_currency = r.message[0]?r.message[0]:[];
+				if (pl_currency.length==1) {
+					if (pl_currency[0] == doc.currency) set_multiple(cdt, cdn, {price_list_currency:doc.currency, plc_conversion_rate:doc.conversion_rate});
+					else if (pl_currency[0] = r.message[1]) set_multiple(cdt, cdn, {price_list_currency:pl_currency[0], plc_conversion_rate:1})
+					hide_field(['price_list_currency', 'plc_conversion_rate']);
+				} else unhide_field(['price_list_currency', 'plc_conversion_rate']);
 
-			if (r.message[1] == doc.currency) {
-				set_multiple(cdt, cdn, {conversion_rate:1});
-				hide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']);
-			} else unhide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']);
+				if (r.message[1] == doc.currency) {
+					set_multiple(cdt, cdn, {conversion_rate:1});
+					hide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']);
+				} else unhide_field(['conversion_rate', 'grand_total_export', 'in_words_export', 'rounded_total_export']);
 
-			if (r.message[1] == doc.price_list_currency) {
-				set_multiple(cdt, cdn, {plc_conversion_rate:1});
-				hide_field('plc_conversion_rate');
-			} else unhide_field('plc_conversion_rate');
-
-			callback1()
-		}
-		$c_obj(make_doclist(doc.doctype, doc.name), 'get_price_list_currency', '', callback);
+				if (r.message[1] == doc.price_list_currency) {
+					set_multiple(cdt, cdn, {plc_conversion_rate:1});
+					hide_field('plc_conversion_rate');
+				} else unhide_field('plc_conversion_rate');
+				
+				cur_frm.cscript.dynamic_label(doc, cdt, cdn, r.message[1], callback1);	
+			}
+		})
 	}
 }
 
@@ -213,12 +213,15 @@
 cur_frm.cscript.plc_conversion_rate = cur_frm.cscript.currency;
 
 cur_frm.cscript.company = function(doc, dt, dn) {
-	var callback = function(r, rt) {
-		var doc = locals[dt][dn];
-		set_multiple(doc.doctype, doc.name, {currency:r.message,price_list_currency:r.message});
-		cur_frm.cscript.currency(doc, cdt, cdn);
-	}
-	$c_obj(make_doclist(doc.doctype, doc.name), 'get_comp_base_currency', '', callback);
+	wn.call({
+		method: 'selling.doctype.sales_common.sales_common.get_comp_base_currency',
+		args: {company:doc.company},
+		callback: function(r, rt) {
+			var doc = locals[dt][dn];
+			set_multiple(doc.doctype, doc.name, {currency:r.message, price_list_currency:r.message});
+			cur_frm.cscript.currency(doc, cdt, cdn);
+		}
+	});
 }
 
 
@@ -234,7 +237,6 @@
 					refresh_field(fname);
 					var doc = locals[cdt][cdn];
 					cur_frm.cscript.recalc(doc,3);		//this is to re-calculate BASIC RATE and AMOUNT on basis of changed REF RATE
-					cur_frm.cscript.dynamic_label(doc, cdt, cdn);	
 				}
 			);
 		}
@@ -557,11 +559,9 @@
 	var tax_list = getchildren('RV Tax Detail', doc.name, other_fname, doc.doctype);
 	for(var i=0; i<tax_list.length; i++) {
 		if(tax_list[i].included_in_print_rate) {
-			//console.log('consider incl rate');
 			return true;
 		}
 	}
-	//console.log('do not consider incl rate');
 	return false;
 }
 
diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py
index 003c3bd..9186bb8 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.py
+++ b/erpnext/selling/doctype/sales_common/sales_common.py
@@ -32,6 +32,23 @@
 
 from utilities.transaction_base import TransactionBase
 
+
+@webnotes.whitelist()
+def get_comp_base_currency(arg=None):
+	""" get default currency of company"""
+	res = webnotes.conn.sql("""select default_currency from `tabCompany`
+			where name = %s""", webnotes.form_dict.get('company'))
+	return res and res[0][0] or None
+
+@webnotes.whitelist()
+def get_price_list_currency(arg=None):
+	""" Get all currency in which price list is maintained"""
+	plc = webnotes.conn.sql("select distinct ref_currency from `tabRef Rate Detail` where price_list_name = %s", webnotes.form_dict['price_list'])
+	plc = [d[0] for d in plc]
+	base_currency = get_comp_base_currency(webnotes.form_dict['company'])
+	return plc, base_currency
+
+
 class DocType(TransactionBase):
 	def __init__(self,d,dl):
 		self.doc, self.doclist = d,dl
@@ -178,18 +195,6 @@
 			d.export_amount = flt(d.qty)*flt(base_ref_rate)/flt(obj.doc.conversion_rate)
 
 
-	def get_comp_base_currency(self, comp):
-		""" get default currency of company"""
-		return webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", comp)[0][0]
-
-	def get_price_list_currency(self, price_list, comp):
-		""" Get all currency in which price list is maintained"""
-		plc = webnotes.conn.sql("select distinct ref_currency from `tabRef Rate Detail` where price_list_name = %s", price_list)
-		plc = [d[0] for d in plc]
-		base_currency = self.get_comp_base_currency(comp)
-		return plc, base_currency
-	
-
 	# Load Default Taxes
 	# ====================
 	def load_default_taxes(self, obj):
@@ -781,3 +786,4 @@
 						where
 							name="%(name)s"
 					""" % args)
+
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 4a724d2..a04423d 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -41,10 +41,15 @@
 }
 
 cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
-	if(doc.__islocal) {
-		// defined in sales_common.js
-		cur_frm.cscript.update_item_details(doc, cdt, cdn);
+	var callback = function(doc, cdt, cdn) {
+		if(doc.__islocal) {
+			// defined in sales_common.js
+			cur_frm.cscript.update_item_details(doc, cdt, cdn);
+		}
 	}
+	
+	cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback); 
+
 }
 
 
@@ -52,10 +57,8 @@
 //==================
 cur_frm.cscript.refresh = function(doc, cdt, cdn) {
 	cur_frm.clear_custom_buttons();
-	var callback = function() {
-		cur_frm.cscript.dynamic_label(doc, cdt, cdn);
-	}
-	cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback); 
+
+	if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn); 
 
 
 	if(doc.docstatus==1) {
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 943a1fd..c886ec3 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -102,14 +102,16 @@
 	# Get Item Details
 	# ----------------
 	def get_item_details(self, args=None):
-		args = eval(args)
-		if args['item_code']:
+		args = args and eval(args) or {}
+		if args.get('item_code'):
 			return get_obj('Sales Common').get_item_details(args, self)
 		else:
 			obj = get_obj('Sales Common')
 			for doc in self.doclist:
 				if doc.fields.get('item_code'):
-					ret = obj.get_item_details(doc.item_code, self)
+					arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), 
+						'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
+					ret = obj.get_item_details(arg, self)
 					for r in ret:
 						if not doc.fields.get(r):
 							doc.fields[r] = ret[r]					
@@ -120,13 +122,6 @@
 	def get_adj_percent(self, arg=''):
 		get_obj('Sales Common').get_adj_percent(self)
 
-	def get_comp_base_currency(self):
-		return get_obj('Sales Common').get_comp_base_currency(self.doc.company)
-
-	def get_price_list_currency(self):
-		return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company)
-
-
 
 
 	# Get projected qty of item based on warehouse selected
diff --git a/erpnext/selling/doctype/sales_order/sales_order.txt b/erpnext/selling/doctype/sales_order/sales_order.txt
index a72b8df..a82f970 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.txt
+++ b/erpnext/selling/doctype/sales_order/sales_order.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:21',
 		'docstatus': 0,
-		'modified': '2012-02-27 17:07:40',
+		'modified': '2012-03-02 14:34:02',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -21,7 +21,7 @@
 
 	# These values are common for all DocType
 	{
-		'_last_update': u'1330082514',
+		'_last_update': u'1330670942',
 		'allow_attach': 0,
 		'colour': u'White:FFF',
 		'default_print_format': u'Standard',
@@ -38,7 +38,7 @@
 		'show_in_menu': 0,
 		'subject': u'From %(customer_name)s on %(transaction_date)s worth %(currency)s %(grand_total_export)s | %(per_delivered)s% delivered | %(per_billed)s% billed',
 		'tag_fields': u'delivery_status,billing_status',
-		'version': 629
+		'version': 631
 	},
 
 	# These values are common for all DocFormat
@@ -325,6 +325,36 @@
 	# DocField
 	{
 		'doctype': u'DocField',
+		'fieldname': u'territory',
+		'fieldtype': u'Link',
+		'in_filter': 1,
+		'label': u'Territory',
+		'options': u'Territory',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		'description': u'Category of customer as entered in Customer master',
+		'doctype': u'DocField',
+		'fieldname': u'customer_group',
+		'fieldtype': u'Link',
+		'in_filter': 1,
+		'label': u'Customer Group',
+		'options': u'Customer Group',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'oldfieldtype': u'Column Break',
 		'permlevel': 0,
@@ -362,6 +392,7 @@
 		'oldfieldtype': u'Select',
 		'options': u'\nSales\nMaintenance',
 		'permlevel': 0,
+		'print_hide': 1,
 		'reqd': 1
 	},
 
@@ -491,36 +522,6 @@
 	# DocField
 	{
 		'doctype': u'DocField',
-		'fieldname': u'territory',
-		'fieldtype': u'Link',
-		'in_filter': 1,
-		'label': u'Territory',
-		'options': u'Territory',
-		'permlevel': 0,
-		'print_hide': 1,
-		'reqd': 1,
-		'search_index': 1
-	},
-
-	# DocField
-	{
-		'colour': u'White:FFF',
-		'description': u'Category of customer as entered in Customer master',
-		'doctype': u'DocField',
-		'fieldname': u'customer_group',
-		'fieldtype': u'Link',
-		'in_filter': 1,
-		'label': u'Customer Group',
-		'options': u'Customer Group',
-		'permlevel': 0,
-		'print_hide': 1,
-		'reqd': 1,
-		'search_index': 1
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
 		'fieldname': u'shipping_address',
 		'fieldtype': u'Small Text',
 		'in_filter': 0,
@@ -545,6 +546,40 @@
 	# DocField
 	{
 		'colour': u'White:FFF',
+		'description': u'Purchase Order sent by customer',
+		'doctype': u'DocField',
+		'fieldname': u'po_no',
+		'fieldtype': u'Data',
+		'hidden': 0,
+		'label': u'P.O. No',
+		'oldfieldname': u'po_no',
+		'oldfieldtype': u'Data',
+		'permlevel': 0,
+		'print_hide': 0,
+		'reqd': 0,
+		'width': u'100px'
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		'depends_on': u'eval:doc.po_no',
+		'doctype': u'DocField',
+		'fieldname': u'po_date',
+		'fieldtype': u'Date',
+		'hidden': 0,
+		'label': u'P.O. Date',
+		'oldfieldname': u'po_date',
+		'oldfieldtype': u'Date',
+		'permlevel': 0,
+		'print_hide': 0,
+		'reqd': 0,
+		'width': u'100px'
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
 		'doctype': u'DocField',
 		'fieldtype': u'Section Break',
 		'label': u'Items',
@@ -965,7 +1000,7 @@
 		'oldfieldtype': u'Button',
 		'options': u'get_tc_details',
 		'permlevel': 0,
-		'print_hide': 0
+		'print_hide': 1
 	},
 
 	# DocField
@@ -1061,40 +1096,6 @@
 
 	# DocField
 	{
-		'colour': u'White:FFF',
-		'description': u'Purchase Order sent by customer',
-		'doctype': u'DocField',
-		'fieldname': u'po_no',
-		'fieldtype': u'Data',
-		'hidden': 0,
-		'label': u'P.O. No',
-		'oldfieldname': u'po_no',
-		'oldfieldtype': u'Data',
-		'permlevel': 0,
-		'print_hide': 0,
-		'reqd': 0,
-		'width': u'100px'
-	},
-
-	# DocField
-	{
-		'colour': u'White:FFF',
-		'depends_on': u'eval:doc.po_no',
-		'doctype': u'DocField',
-		'fieldname': u'po_date',
-		'fieldtype': u'Date',
-		'hidden': 0,
-		'label': u'P.O. Date',
-		'oldfieldname': u'po_date',
-		'oldfieldtype': u'Date',
-		'permlevel': 0,
-		'print_hide': 0,
-		'reqd': 0,
-		'width': u'100px'
-	},
-
-	# DocField
-	{
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'oldfieldtype': u'Column Break',
@@ -1240,6 +1241,7 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -1267,6 +1269,7 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -1302,7 +1305,8 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Section Break',
 		'options': u'Simple',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
diff --git a/erpnext/selling/doctype/sales_order_detail/sales_order_detail.txt b/erpnext/selling/doctype/sales_order_detail/sales_order_detail.txt
index 25521c4..3205d6e 100644
--- a/erpnext/selling/doctype/sales_order_detail/sales_order_detail.txt
+++ b/erpnext/selling/doctype/sales_order_detail/sales_order_detail.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:22',
 		'docstatus': 0,
-		'modified': '2012-02-24 10:38:06',
+		'modified': '2012-03-02 15:49:26',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -22,7 +22,7 @@
 		'section_style': u'Tray',
 		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'version': 49
+		'version': 53
 	},
 
 	# These values are common for all DocField
@@ -117,18 +117,15 @@
 
 	# DocField
 	{
-		'default': u'0.00',
 		'doctype': u'DocField',
-		'fieldname': u'ref_rate',
+		'fieldname': u'base_ref_rate',
 		'fieldtype': u'Currency',
-		'label': u'Price List Rate',
-		'oldfieldname': u'ref_rate',
+		'label': u'Price List Rate*',
+		'oldfieldname': u'base_ref_rate',
 		'oldfieldtype': u'Currency',
-		'permlevel': 0,
+		'permlevel': 1,
 		'print_hide': 1,
-		'reqd': 0,
-		'trigger': u'Client',
-		'width': u'70px'
+		'width': u'100px'
 	},
 
 	# DocField
@@ -150,49 +147,6 @@
 	{
 		'default': u'0.00',
 		'doctype': u'DocField',
-		'fieldname': u'export_rate',
-		'fieldtype': u'Currency',
-		'label': u'Rate',
-		'oldfieldname': u'export_rate',
-		'oldfieldtype': u'Currency',
-		'permlevel': 0,
-		'reqd': 0,
-		'trigger': u'Client',
-		'width': u'100px'
-	},
-
-	# DocField
-	{
-		'default': u'0.00',
-		'doctype': u'DocField',
-		'fieldname': u'export_amount',
-		'fieldtype': u'Currency',
-		'label': u'Amount',
-		'no_copy': 0,
-		'oldfieldname': u'export_amount',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1,
-		'reqd': 0,
-		'width': u'100px'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'base_ref_rate',
-		'fieldtype': u'Currency',
-		'label': u'Price List Rate*',
-		'oldfieldname': u'base_ref_rate',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1,
-		'print_hide': 1,
-		'width': u'100px'
-	},
-
-	# DocField
-	{
-		'default': u'0.00',
-		'doctype': u'DocField',
 		'fieldname': u'basic_rate',
 		'fieldtype': u'Currency',
 		'label': u'Basic Rate*',
@@ -223,6 +177,52 @@
 
 	# DocField
 	{
+		'default': u'0.00',
+		'doctype': u'DocField',
+		'fieldname': u'ref_rate',
+		'fieldtype': u'Currency',
+		'label': u'Price List Rate',
+		'oldfieldname': u'ref_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'trigger': u'Client',
+		'width': u'70px'
+	},
+
+	# DocField
+	{
+		'default': u'0.00',
+		'doctype': u'DocField',
+		'fieldname': u'export_rate',
+		'fieldtype': u'Currency',
+		'label': u'Rate',
+		'oldfieldname': u'export_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'reqd': 0,
+		'trigger': u'Client',
+		'width': u'100px'
+	},
+
+	# DocField
+	{
+		'default': u'0.00',
+		'doctype': u'DocField',
+		'fieldname': u'export_amount',
+		'fieldtype': u'Currency',
+		'label': u'Amount',
+		'no_copy': 0,
+		'oldfieldname': u'export_amount',
+		'oldfieldtype': u'Currency',
+		'permlevel': 1,
+		'reqd': 0,
+		'width': u'100px'
+	},
+
+	# DocField
+	{
 		'doctype': u'DocField',
 		'fieldname': u'reserved_warehouse',
 		'fieldtype': u'Link',
@@ -401,41 +401,6 @@
 	# DocField
 	{
 		'colour': u'White:FFF',
-		'description': u'required for production. will be used later.',
-		'doctype': u'DocField',
-		'fieldname': u'delivery_date',
-		'fieldtype': u'Date',
-		'hidden': 1,
-		'label': u'Expected Delivery Date',
-		'oldfieldname': u'delivery_date',
-		'oldfieldtype': u'Date',
-		'permlevel': 1,
-		'print_hide': 1,
-		'report_hide': 1
-	},
-
-	# DocField
-	{
-		'allow_on_submit': 1,
-		'colour': u'White:FFF',
-		'description': u'required for production. will be used later.',
-		'doctype': u'DocField',
-		'fieldname': u'confirmation_date',
-		'fieldtype': u'Date',
-		'hidden': 0,
-		'in_filter': 1,
-		'label': u'Confirmed Delivery Date',
-		'oldfieldname': u'confirmation_date',
-		'oldfieldtype': u'Date',
-		'permlevel': 0,
-		'print_hide': 1,
-		'report_hide': 1,
-		'search_index': 0
-	},
-
-	# DocField
-	{
-		'colour': u'White:FFF',
 		'doctype': u'DocField',
 		'fieldname': u'item_tax_rate',
 		'fieldtype': u'Small Text',
diff --git a/erpnext/selling/search_criteria/variance_report/variance_report.py b/erpnext/selling/search_criteria/variance_report/variance_report.py
index e4ebf33..6948eac 100644
--- a/erpnext/selling/search_criteria/variance_report/variance_report.py
+++ b/erpnext/selling/search_criteria/variance_report/variance_report.py
@@ -60,7 +60,7 @@
 
 if under == 'Receivable Voucher':
   under_detail = 'RV'
-  dt = 'voucher_date'
+  dt = 'posting_date'
 else:
   under_detail = under
   dt = "transaction_date"
@@ -516,4 +516,4 @@
     tot_target = 0
 
   elif tl == 1:
-    out.append(r)
\ No newline at end of file
+    out.append(r)
diff --git a/erpnext/setup/doctype/contact_control/__init__.py b/erpnext/setup/doctype/contact_control/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/setup/doctype/contact_control/__init__.py
diff --git a/erpnext/setup/doctype/contact_control/contact_control.js b/erpnext/setup/doctype/contact_control/contact_control.js
new file mode 100755
index 0000000..b6825eb
--- /dev/null
+++ b/erpnext/setup/doctype/contact_control/contact_control.js
@@ -0,0 +1,562 @@
+// common partner functions
+// =========================
+
+/*
+// make shipping list body
+// ------------------------
+cur_frm.cscript.make_sl_body = function(){
+	cur_frm.fields_dict['Shipping HTML'].wrapper.innerHTML = '';
+	cur_frm.shipping_html = $a(cur_frm.fields_dict['Shipping HTML'].wrapper,'div');
+}
+*/
+
+// make history list body
+// -----------------------
+cur_frm.cscript.make_hl_body = function(){
+	cur_frm.fields_dict['History HTML'].wrapper.innerHTML = '';
+	cur_frm.history_html = $a(cur_frm.fields_dict['History HTML'].wrapper,'div');
+}
+
+
+/*
+// set shipping list message
+// --------------------------
+cur_frm.cscript.set_sl_msg = function(doc){
+	cur_frm.shipping_html.innerHTML = 'Shipping Address Details will appear only when you save the ' + doc.doctype.toLowerCase();
+}
+*/
+/*
+// set history list message
+// -------------------------
+cur_frm.cscript.set_hl_msg = function(doc){
+	cur_frm.history_html.innerHTML= 'History Details will appear only when you save the ' + doc.doctype.toLowerCase();
+}
+*/
+
+
+/*
+// make shipping address
+// -------------
+cur_frm.cscript.make_shipping_address = function(doc, dt, dn){
+  	cur_frm.shipping_html.innerHTML = '';
+
+	var dsn = cur_frm.doc.customer_name;
+	var dsa = cur_frm.doc.address;
+	cl = new AddressList(cur_frm.shipping_html,dt,dn,dsn,dsa);
+}
+*/
+
+
+// make history
+// -------------
+cur_frm.cscript.make_history = function(doc,dt,dn){
+	cur_frm.history_html.innerHTML = '';
+	cur_frm.cscript.make_history_list(cur_frm.history_html,doc);
+}
+
+// make history list
+// ------------------
+cur_frm.cscript.make_history_list = function(parent,doc){
+
+	var sel = $a(parent,'select');
+	
+	var ls = ['Select Transaction..'];
+	for(d in cur_frm.history_dict){
+		ls.push(d);
+	}
+	
+	add_sel_options(sel,ls,'Select..');
+	
+	var body = $a(parent,'div');
+	body.innerHTML = '<div class="help_box">Please select a transaction type to see History</div>';
+	
+	sel.body = body;
+	sel.doc = doc;
+	
+	sel.onchange = function(){
+		for(d in cur_frm.history_dict){
+			if(sel_val(this) == d){
+				this.body.innerHTML = '';
+				eval(cur_frm.history_dict[d]);
+				return;
+			}
+			else{
+				// pass
+			}
+		}
+	}
+}
+
+// run list
+// ---------
+cur_frm.cscript.run_list = function(lst,parent,q,q_max,doc,dn,nm){
+	
+	parent.innerHTML = '';
+	$dh(parent);
+	
+	lst.doc = doc;
+	lst.dn = dn;
+	lst.nm = nm;
+	lst.page_len = 10;
+	
+	lst.get_query = function(){
+		this.query = q;
+		this.query_max = q_max;
+	}
+	
+	lst.make(parent);
+	lst.run();
+	
+	lst.onrun = function(){
+		$ds(parent);
+		if(!this.has_data()){
+			parent.innerHTML = '';
+			var dv = $a(parent,'div','help_box');
+			$a(dv,'span').innerHTML = "No " + this.dn + " found. ";
+			
+			var lbl = 'Create the <b>first</b> ' + this.dn + ' for ' + this.doc.name;
+			var sp = $a(dv,'span');
+			sp.nm = this.nm;
+			$(sp).html(lbl).addClass('link_type').click(function(){ newdoc(this.nm); });
+		}
+	}
+}
+
+
+// get sates on country trigger
+// -----------------------------
+cur_frm.cscript.get_states=function(doc,dt,dn){
+   $c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])},
+    function(r,rt){
+      if(r.message) {
+        set_field_options('state', r.message);
+      }
+    }  
+  );
+
+}
+
+cur_frm.cscript.country = function(doc, dt, dn) {
+  cur_frm.cscript.get_states(doc, dt, dn);
+}
+
+// territory help - cutsomer + sales partner
+// -----------------------------------------
+cur_frm.cscript.TerritoryHelp = function(doc,dt,dn){
+  var call_back = function(){
+
+    var sb_obj = new SalesBrowser();        
+    sb_obj.set_val('Territory');
+  }
+  loadpage('Sales Browser',call_back);
+}
+
+// get query select Territory
+// ---------------------------
+if(cur_frm.fields_dict['territory']){
+	cur_frm.fields_dict['territory'].get_query = function(doc,dt,dn) {
+		return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s"  ORDER BY  `tabTerritory`.`name` ASC LIMIT 50';
+	}
+}
+
+
+// =======================================================================================================
+
+// contact list
+// --------------
+ContactList = function(parent,dt,dn,dsn){
+	
+	var me = this;
+	
+	this.dt = dt;
+	this.dn = dn;
+	this.dsn = dsn ? dsn : dn;
+
+	this.wrapper = $a(parent,'div');
+	me.get_list();
+}
+
+// add contact
+// ------------
+ContactList.prototype.add_contact = function(){
+	var me = this;
+	
+	// onload - set default values
+	var cont = LocalDB.create('Contact');
+
+	var c = locals['Contact'][cont];
+	
+	if(me.dt == 'Customer')	{
+		c.is_customer = 1;
+		c.customer = me.dn;
+		c.customer_name = me.dsn;
+	}
+	else if(me.dt == 'Supplier'){
+		c.is_supplier = 1;
+		c.supplier = me.dn;
+		c.supplier_name = me.dsn;
+	}
+	else if(me.dt == 'Sales Partner'){
+		c.is_sales_partner = 1;
+		c.sales_partner = me.dn;
+		//c.sales_partner_name = me.dsn;
+	}
+	
+	loaddoc('Contact',c.name);
+}
+
+// get contact list
+// -----------------
+ContactList.prototype.get_list = function(){
+	var me = this;
+	
+	me.make_list();
+	
+	var dt = me.dt.toLowerCase().split(' ').join('_');
+	
+	// build query
+	me.lst.get_query = function(){
+		this.query = repl("select name, first_name, last_name, concat_ws(' ', first_name, last_name), email_id, contact_no, department, designation, is_primary_contact, has_login, disable_login from tabContact where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
+
+		this.query_max = repl("select count(name) from tabContact where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
+	}
+	
+	// render list ui
+	me.lst.show_cell = function(cell,ri,ci,d){
+		me.render_list(cell,ri,ci,d);
+	}
+	
+	// run query
+	me.lst.run();
+	
+	// onrun
+	me.lst.onrun = function(){
+		if(!this.has_data()){
+			this.rec_label.innerHTML = '';
+			
+			$a(this.rec_label,'span').innerHTML = "You do not have any contact. ";
+			$($a(this.rec_label,'span')).html('Add a new contact').addClass('link_type').click(function(){ me.add_contact(); });
+			
+			$dh(this.results);
+		}
+		else{
+			$ds(this.results);
+		}
+	}	
+}
+
+// make list
+// -----------
+ContactList.prototype.make_list = function(){
+	var me = this;
+	
+	var l = new Listing();
+	l.colwidths = ['5%','30%','30%','20%','20%'];
+	l.colnames = ['Sr.','Contact Name','Email Id','Contact No', 'Action'];
+	l.page_len = 10;
+  
+	me.lst = l;
+	
+	l.make(me.wrapper);
+	
+	// Add contact button
+	me.add_btn = $btn(l.btn_area,'+ Add Contact', function(){ me.add_contact();}, {fontWeight:'bold'});
+}
+
+// make contact cell
+// ------------------
+ContactList.prototype.render_list = function(cell,ri,ci,d){
+	var me = this;
+
+	// name
+	if(ci == 0){
+		var nm = $a($a(cell,'div'),'span','',{cursor:'pointer'});
+		nm.innerHTML = d[ri][3];
+		nm.id = d[ri][0];
+		
+		nm.onclick = function(){
+			loaddoc('Contact', this.id);
+			
+			// on save callback - refresh list
+		}
+
+		// department and designation
+		var des = d[ri][7] ? d[ri][7] : '';
+		var dep = d[ri][6] ? d[ri][6] : '';
+		
+		var sp = $a(cell,'div','comment');
+		sp.innerHTML = des + (dep ? (', ' + dep) : ''); 
+	}
+	
+	// email id, contact no, department, designation
+	// -----------------------------------------------------
+	if(ci == 1) cell.innerHTML = d[ri][4] ? d[ri][4] : '-';
+	if(ci == 2) cell.innerHTML = d[ri][5] ? d[ri][5] : '-';
+	
+	// actions
+	// --------------------------------------
+	if(ci== 3) me.make_actions(cell,ri,ci,d);
+}
+
+// make actions
+// ---------------
+ContactList.prototype.make_actions = function(cell,ri,ci,d){
+	var me = this;
+	
+	var tab = make_table(cell,1,2,'100%',['40%','60%']);
+
+	// Edit and Delete
+	var t = make_table($td(tab,0,0),1,2);
+	
+	var edit = $a($td(t,0,0),'div','wn-icon ic-doc_edit');
+	$(edit).click(function(){ loaddoc('Contact',d[ri][0]); });
+	
+	edit.setAttribute('title','Edit');
+
+// Below code should be uncommented once customer/venodr invitation process is stable
+// ===========================================================================
+/* 
+	var del = $a($td(t,0,1),'div','wn-icon ic-trash');
+	$(del).click(function(){ me.delete_contact(d[ri][0],d[ri][4]) });
+
+	set_custom_tooltip(del, 'Delete');
+	
+	//  Invite, Enable and Disable - Integrate after gateway logic incorporated
+
+	if(d[ri][9] == 'Yes')	{
+		if(d[ri][10] == 'Yes'){
+			var enb = $a($td(tab,0,1),'div','wn-icon ic-checkmark');
+			$(enb).click(function(){ me.enable_login(d[ri][0], d[ri][4]); });
+		}
+		else{
+			var dsb = $a($td(tab,0,1),'div','wn-icon ic-delete');
+			$(dsb).click(function(){ me.disable_login(d[ri][0], d[ri][4]) });
+		}
+	}
+	else{
+		var inv = $a($td(tab,0,1),'div','wn-icon ic-mail');
+		$(inv).click(function(){ me.invite_contact(d[ri][0], d[ri][4], d[ri][1], d[ri][2]) });
+	}*/
+}
+
+// enable login
+// ----------------------------------------------------------
+ContactList.prototype.enable_login = function(id, email_id){
+	var me = this;
+	
+	var callback = function(r,rt){
+		me.get_list();
+		
+		if(!r.exc) msgprint('Login for contact enabled',1);
+		else errprint(r.exc);
+	}
+	
+	var args = {};
+	args.contact = id;
+	args.email = email_id;
+	
+	$c_obj('Contact Control','enable_login',JSON.stringify(args),callback);
+}
+
+// disable login
+// -------------------------------------------------------------
+ContactList.prototype.disable_login = function(id, email_id){
+	var me = this;
+	
+	var callback = function(r,rt){
+		me.get_list();
+		
+		if(!r.exc) msgprint('Login for contact disabled',1);
+		else errprint(r.exc);
+	}
+
+	var args = {};
+	args.contact = id;
+	args.email = email_id;
+		
+	$c_obj('Contact Control','disable_login',JSON.stringify(args),callback);
+}
+
+// delete contact
+// -----------------
+ContactList.prototype.delete_contact = function(id,email_id,has_login){
+	var me = this;
+	
+	var callback = function(r,rt){
+		me.get_list();
+		
+		if(!r.exc) msgprint('Contact deleted successfully');
+		else errprint(r.exc);
+	}
+	
+	var args = {};
+	args.contact = id;
+	args.email = email_id;
+	args.has_login = has_login;
+	
+	$c_obj('Contact Control','delete_contact',JSON.stringify(args),callback);
+}
+
+// invite user
+// --------------------------------------------------------
+ContactList.prototype.invite_contact = function(id,email_id,first_name,last_name){
+	var me = this;
+
+	if(!email_id){
+		msgprint("Please add email id and save the contact first. You can then invite contact to view transactions.")
+	}
+	else{
+		var callback = function(r,rt){
+			if(!r.exc) msgprint('Invitation sent');
+			else errprint(r.exc);
+		}
+	
+		var args = {
+			'contact' : id,
+			'email' : email_id,
+			'first_name' : first_name ? first_name : '',
+			'last_name' : last_name ? last_name : '',
+			'usert_type' : 'Partner'
+		};
+		
+		$c_obj('Contact Control','invite_contact',JSON.stringify(args),callback);	
+	}
+}
+
+
+// address list
+// --------------
+AddressList = function(parent,dt,dn,dsn,dsa){
+	
+	var me = this;
+	
+	this.dt = dt;
+	this.dn = dn;
+	this.dsn = dsn ? dsn : dn;
+        this.dsa = dsa ? dsa : '';
+
+	this.wrapper = $a(parent,'div');
+	me.get_addr_list();
+}
+
+
+// add contact
+// ------------
+AddressList.prototype.add_address = function(){
+	var me = this;
+	
+	// onload - set default values
+	var addr = LocalDB.create('Shipping Address');
+
+	var a = locals['Shipping Address'][addr];
+	
+	a.customer = me.dn;
+	a.customer_name = me.dsn;
+        a.customer_address = me.dsa;	
+	loaddoc('Shipping Address',a.name);
+}
+
+
+// get address list
+// -----------------
+AddressList.prototype.get_addr_list = function(){
+	var me = this;
+	
+	me.make_addr_list();
+	
+	var dt = me.dt.toLowerCase().split(' ').join('_');
+	
+	// build query
+	me.lst.get_query = function(){
+		this.query = repl("select name, ship_to, shipping_address, is_primary_address, shipping_details from `tabShipping Address` where %(dt)s = '%(dn)s' and docstatus != 2",{'dt':dt, 'dn':me.dn});
+
+		this.query_max = repl("select count(name) from `tabShipping Address` where %(dt)s = '%(dn)s'",{'dt':dt, 'dn':me.dn});
+	}
+	
+	// render list ui
+	me.lst.show_cell = function(cell,ri,ci,d){
+		me.render_list(cell,ri,ci,d);
+	}
+	
+	// run query
+	me.lst.run();
+	
+	// onrun
+	me.lst.onrun = function(){
+		if(!this.has_data()){
+			this.rec_label.innerHTML = '';
+			
+			$a(this.rec_label,'span').innerHTML = "You do not have any shipping address.";
+			$($a(this.rec_label,'span')).html('Add a new address').addClass('link_type').click(function(){ me.add_address(); });
+			
+			$dh(this.results);
+		}
+		else{
+			$ds(this.results);
+		}
+	}	
+}
+
+
+// make list
+// -----------
+AddressList.prototype.make_addr_list = function(){
+	var me = this;
+	
+	var l = new Listing();
+	l.colwidths = ['5%', '15%', '25%','10%','35%','10%'];
+	l.colnames = ['Sr.', 'Ship To', 'Shipping Address','Primary Address', 'Shipping Details', 'Action'];
+    l.page_len = 10;
+  
+	me.lst = l;
+	
+	l.make(me.wrapper);
+	
+	// Add address button
+	me.add_btn = $btn(l.btn_area,'+ Add Address', function(){ me.add_address();}, {fontWeight:'bold'});
+}
+
+
+
+// make address cell
+// ------------------
+AddressList.prototype.render_list = function(cell,ri,ci,d){
+	var me = this;
+
+	// name
+	if(ci == 0){
+		var nm = $a($a(cell,'div'),'span','',{cursor:'pointer'});
+		nm.innerHTML = d[ri][1];
+		nm.id = d[ri][0];
+		
+		nm.onclick = function(){
+			loaddoc('Shipping Address', this.id);
+		}
+	}
+	
+	// shipping address, primary address, shipping details
+	// ----------------------------------------------------
+	if(ci == 1) cell.innerHTML = d[ri][2] ? d[ri][2] : '-';
+	if(ci == 2) cell.innerHTML = d[ri][3] ? d[ri][3] : '-';
+	if(ci == 3) cell.innerHTML = d[ri][4] ? d[ri][4] : '-';
+	
+	// actions
+	// --------------------------------------
+	if(ci== 4) me.make_actions(cell,ri,ci,d);
+}
+
+// make actions
+// ---------------
+AddressList.prototype.make_actions = function(cell,ri,ci,d){
+	var me = this;
+	
+	var tab = make_table(cell,1,2,'100%',['40%','60%']);
+
+	// Edit and Delete
+	var t = make_table($td(tab,0,0),1,2);
+	
+	var edit = $a($td(t,0,0),'div','wn-icon ic-doc_edit');
+	$(edit).click(function(){ loaddoc('Shipping Address',d[ri][0]); });
+	
+	edit.setAttribute('title','Edit');
+}
diff --git a/erpnext/setup/doctype/contact_control/contact_control.py b/erpnext/setup/doctype/contact_control/contact_control.py
new file mode 100644
index 0000000..3c25d7f
--- /dev/null
+++ b/erpnext/setup/doctype/contact_control/contact_control.py
@@ -0,0 +1,103 @@
+# 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 = doc
+    self.doclist = doclist
+    
+  def enable_login(self,arg):
+    arg = eval(arg)
+    sql("update tabContact set disable_login = 'No' where name=%s",arg['contact'])
+    sql("update tabProfile set enabled=1 where name=%s",arg['email'])
+    
+  def disable_login(self,arg):
+    arg = eval(arg)
+    sql("update tabContact set disable_login = 'Yes' where name=%s",arg['contact'])
+    sql("update tabProfile set enabled=0 where name=%s",arg['email'])
+    
+  def create_login(self,arg):
+    arg = eval(arg)
+    cont_det = sql("select * from tabContact where name=%s",(arg['contact']),as_dict=1)
+    if cont_det[0]['docstatus'] !=0:
+      msgprint('Please save the corresponding contact first')
+      raise Exception
+      
+    if sql("select name from tabProfile where name=%s",cont_det[0]['email_id']):
+      msgprint('Profile with same name already exist.')
+      raise Exception
+    else:
+      p = Document('Profile')
+      p.name = cont_det[0]['email_id']
+      p.first_name = cont_det[0]['first_name']
+      p.last_name = cont_det[0]['last_name']
+      p.email = cont_det[0]['email_id']
+      p.cell_no = cont_det[0]['contact_no']
+      p.password = 'password'
+      p.enabled = 1
+      p.user_type = 'Partner';
+      p.save(1)
+      
+      get_obj(doc=p).on_update()
+      
+      role = []
+      if cont_det[0]['contact_type'] == 'Individual':
+        role = ['Customer']
+      else:
+        if cont_det[0]['is_customer']:
+          role.append('Customer')
+        if cont_det[0]['is_supplier']:
+          role.append('Supplier')
+        if cont_det[0]['is_sales_partner']:
+          role.append('Partner')
+
+      if role:
+        prof_nm = p.name
+        for i in role:
+          r = Document('UserRole')
+          r.parent = p.name
+          r.role = i
+          r.parenttype = 'Profile'
+          r.parentfield = 'userroles'
+          r.save(1)
+        
+          if i == 'Customer':
+            def_keys = ['from_company','customer_name','customer']
+            def_val = cont_det[0]['customer_name']
+            self.set_default_val(def_keys,def_val,prof_nm)
+
+          if i == 'Supplier':
+            def_keys = ['supplier_name','supplier']
+            def_val = cont_det[0]['supplier_name']
+            self.set_default_val(def_keys,def_val,prof_nm)
+
+      sql("update tabContact set has_login = 'Yes' where name=%s",cont_det[0]['name'])
+      sql("update tabContact set disable_login = 'No' where name=%s",cont_det[0]['name'])
+      msgprint('User login is created.')
+      
+ #------set default values---------
+  def set_default_val(self,def_keys,def_val,prof_nm):
+    for d in def_keys:
+      kv = Document('DefaultValue')
+      kv.defkey = d
+      kv.defvalue = def_val
+      kv.parent = prof_nm
+      kv.parenttype = 'Profile'
+      kv.parentfield = 'defaults'
+      kv.save(1)
\ No newline at end of file
diff --git a/erpnext/setup/doctype/contact_control/contact_control.txt b/erpnext/setup/doctype/contact_control/contact_control.txt
new file mode 100644
index 0000000..b9e84ad
--- /dev/null
+++ b/erpnext/setup/doctype/contact_control/contact_control.txt
@@ -0,0 +1,88 @@
+# DocType, Contact Control
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2010-08-08 17:08:56',
+		'docstatus': 0,
+		'modified': '2010-09-20 14:06:57',
+		'modified_by': 'yogesh@webnotestech.com',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocType',
+		'in_create': 1,
+		'issingle': 1,
+		'module': 'Setup',
+		'name': '__common__',
+		'read_only': 1,
+		'section_style': 'Simple',
+		'server_code_error': ' ',
+		'show_in_menu': 0,
+		'version': 25
+	},
+
+	# These values are common for all DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Text',
+		'name': '__common__',
+		'parent': 'Contact Control',
+		'parentfield': 'fields',
+		'parenttype': 'DocType',
+		'permlevel': 0
+	},
+
+	# These values are common for all DocPerm
+	{
+		'create': 0,
+		'doctype': 'DocPerm',
+		'idx': 1,
+		'name': '__common__',
+		'parent': 'Contact Control',
+		'parentfield': 'permissions',
+		'parenttype': 'DocType',
+		'permlevel': 0,
+		'read': 1,
+		'role': 'System Manager',
+		'write': 1
+	},
+
+	# DocType, Contact Control
+	{
+		'doctype': 'DocType',
+		'name': 'Contact Control'
+	},
+
+	# DocPerm
+	{
+		'doctype': 'DocPerm'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'header',
+		'idx': 1,
+		'label': 'Header'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'customer_intro',
+		'idx': 2,
+		'label': 'Customer Intro'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldname': 'supplier_intro',
+		'idx': 3,
+		'label': 'Supplier Intro'
+	}
+]
\ No newline at end of file
diff --git a/erpnext/setup/doctype/customer_group/customer_group.py b/erpnext/setup/doctype/customer_group/customer_group.py
index 30885eb..cc4a9e0 100644
--- a/erpnext/setup/doctype/customer_group/customer_group.py
+++ b/erpnext/setup/doctype/customer_group/customer_group.py
@@ -34,26 +34,32 @@
 
 
 class DocType:
-  def __init__(self, doc, doclist=[]):
-    self.doc = doc
-    self.doclist = doclist
-    self.nsm_parent_field = 'parent_customer_group';
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+		self.nsm_parent_field = 'parent_customer_group';
 
 
-  # update Node Set Model
-  def update_nsm_model(self):
-    import webnotes
-    import webnotes.utils.nestedset
-    webnotes.utils.nestedset.update_nsm(self)
+	# update Node Set Model
+	def update_nsm_model(self):
+		import webnotes
+		import webnotes.utils.nestedset
+		webnotes.utils.nestedset.update_nsm(self)
 
-  # ON UPDATE
-  #--------------------------------------
-  def on_update(self):
-    # update nsm
-    self.update_nsm_model()   
+	# ON UPDATE
+	#--------------------------------------
+	def on_update(self):
+		# update nsm
+		self.update_nsm_model()   
 
 
-  def validate(self): 
+	def validate(self): 
+		if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", (self.doc.customer_group_name)):
+			msgprint("""Another %s record is trashed. 
+				To untrash please go to Setup & click on Trash."""%(self.doc.customer_group_name), raise_exception = 1)
 
-    if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", (self.doc.customer_group_name)):
-      msgprint("%s record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.customer_group_name), raise_exception = 1)
+	def on_trash(self):
+		cust = sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s", self.doc.name)
+		if cust:
+			msgprint("""Customer Group: %s can not be trashed/deleted because it is used in customer: %s. 
+				To trash/delete this, remove/change customer group in customer master""" % (self.doc.name, cust[0][0] or ''), raise_exception=1)
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index ba49117..b43523d 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -8,11 +8,11 @@
 # 
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
 # GNU General Public License for more details.
 # 
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.	If not, see <http://www.gnu.org/licenses/>.
 
 # Please edit this list and import only required elements
 import webnotes
@@ -34,30 +34,36 @@
 
 
 class DocType:
-  def __init__(self,d,dl):
-    self.doc, self.doclist = d,dl
-    self.nsm_parent_field = 'parent_item_group';
+	def __init__(self,d,dl):
+		self.doc, self.doclist = d,dl
+		self.nsm_parent_field = 'parent_item_group';
 
-  # update Node Set Model
-  def update_nsm_model(self):
-    import webnotes
-    import webnotes.utils.nestedset
-    webnotes.utils.nestedset.update_nsm(self)
+	# update Node Set Model
+	def update_nsm_model(self):
+		import webnotes
+		import webnotes.utils.nestedset
+		webnotes.utils.nestedset.update_nsm(self)
 
-  # ON UPDATE
-  #--------------------------------------
-  def on_update(self):
-    # update nsm
-    self.update_nsm_model()   
+	# ON UPDATE
+	#--------------------------------------
+	def on_update(self):
+		# update nsm
+		self.update_nsm_model()	 
 
-  def validate(self): 
-    if self.doc.lft and self.doc.rgt:
-      res = sql("select name from `tabItem Group` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(self.doc.rgt,self.doc.lft,self.doc.parent_item_group,self.doc.item_group_name))
-      if not res:
-        msgprint("Please enter proper parent item group.") 
-        raise Exception
-    
-    r = sql("select name from `tabItem Group` where name = '%s' and docstatus = 2"%(self.doc.item_group_name))
-    if r:
-      msgprint("'%s' record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.item_group_name))
-      raise Exception
\ No newline at end of file
+	def validate(self): 
+		if self.doc.lft and self.doc.rgt:
+			res = sql("select name from `tabItem Group` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(self.doc.rgt,self.doc.lft,self.doc.parent_item_group,self.doc.item_group_name))
+			if not res:
+				msgprint("Please enter proper parent item group.") 
+				raise Exception
+		
+		r = sql("select name from `tabItem Group` where name = '%s' and docstatus = 2"%(self.doc.item_group_name))
+		if r:
+			msgprint("'%s' record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.item_group_name))
+			raise Exception
+	
+	def on_trash(self):
+		ig = sql("select name from `tabItem` where ifnull(item_group, '') = %s", self.doc.name)
+		if ig:
+			msgprint("""Item Group: %s can not be trashed/deleted because it is used in item: %s. 
+				To trash/delete this, remove/change item group in item master""" % (self.doc.name, ig[0][0] or ''), raise_exception=1)
diff --git a/erpnext/setup/doctype/setup_control/setup_control.py b/erpnext/setup/doctype/setup_control/setup_control.py
index beb3cc6..50b9bb0 100644
--- a/erpnext/setup/doctype/setup_control/setup_control.py
+++ b/erpnext/setup/doctype/setup_control/setup_control.py
@@ -14,24 +14,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# 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
+from webnotes.utils import cint, cstr, flt, getdate, now, nowdate
+from webnotes.model.doc import Document, addchild
+from webnotes.model.code import get_obj
+from webnotes import session, form, msgprint
 
-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):
@@ -58,8 +48,8 @@
 		args = json.loads(args)
 
 		self.set_cp_defaults(args['company'], args['industry'], args['time_zone'], args['country'], args['account_name'])
-		self.create_profile(args['user'], args['first_name'], args['last_name'], args.get('pwd'))	
-	
+		self.create_profile(args['user'], args['first_name'], args['last_name'], args.get('pwd'))
+
 		# Domain related updates
 		try:
 			from server_tools.gateway_utils import add_domain_map
@@ -68,38 +58,48 @@
 			pass
 
 		# add record in domain_list of Website Settings
-		webnotes.conn.set_value('Website Settings', 'Website Settings', 'subdomain', args['url_name'] + ".erpnext.com")
+		account_url = args['url_name'] + '.erpnext.com'
+		webnotes.conn.set_value('Website Settings', 'Website Settings',
+				'subdomain', account_url)
 		
 	
 	# Account Setup
 	# ---------------
 	def setup_account(self, args):
-		import webnotes
-		company_name, comp_abbr, fy_start, currency, first_name, last_name = eval(args)
-		curr_fiscal_year,fy_start_date = self.get_fy_details(fy_start)
-		self.currency = currency
+		import webnotes, json
+		args = json.loads(args)
+
+		curr_fiscal_year, fy_start_date, fy_abbr = self.get_fy_details(args.get('fy_start'))
+
+		args['name'] = webnotes.session.get('user')
 
 		# Update Profile
-		if last_name=='None': last_name = None
+		if not args.get('last_name') or args.get('last_name')=='None': args['last_name'] = None
 		webnotes.conn.sql("""\
-			UPDATE `tabProfile` SET first_name=%s, last_name=%s
-			WHERE name=%s AND docstatus<2""", (first_name, last_name, webnotes.user.name))
+			UPDATE `tabProfile` SET first_name=%(first_name)s,
+			last_name=%(last_name)s
+			WHERE name=%(name)s AND docstatus<2""", args)
 			
 		
 		# Fiscal Year
-		master_dict = {'Fiscal Year':{'year':curr_fiscal_year, 'year_start_date':fy_start_date}}
+		master_dict = {'Fiscal Year':{
+			'year': curr_fiscal_year,
+			'year_start_date': fy_start_date,
+			'abbreviation': fy_abbr,
+			'company': args.get('company_name'),
+			'is_fiscal_year_closed': 'No'}}
 		self.create_records(master_dict)
 		
 		# Company
-		master_dict = {'Company':{'company_name':company_name,
-								  'abbr':comp_abbr,
-								  'default_currency':currency
-															}}
+		master_dict = {'Company':{'company_name':args.get('company_name'),
+								  'abbr':args.get('company_abbr'),
+								  'default_currency':args.get('currency')
+								}}
 		self.create_records(master_dict)
 		
 		def_args = {'current_fiscal_year':curr_fiscal_year,
-								'default_currency': currency,
-								'default_company':company_name,
+								'default_currency': args.get('currency'),
+								'default_company':args.get('company_name'),
 								'default_valuation_method':'FIFO',
 								'default_stock_uom':'Nos',
 								'date_format':'dd-mm-yyyy',
@@ -111,21 +111,51 @@
 								'emp_created_by':'Naming Series',
 								'cust_master_name':'Customer Name', 
 								'supp_master_name':'Supplier Name',
-								'default_currency_format': (currency=='INR') and 'Lacs' or 'Millions'
+								'default_currency_format': \
+										(args.get('currency')=='INR') and 'Lacs' or 'Millions'
 					}
 
 		# Set 
 		self.set_defaults(def_args)
 
-		# Set Registration Complete
-		set_default('registration_complete','1')
+		self.create_feed_and_todo()
 
-		msgprint("Great! Your company has now been created")
+		webnotes.clear_cache()
+		msgprint("Company setup is complete")
 		
 		import webnotes.utils
-		user_fullname = (first_name or '') + (last_name and (" " + last_name) or '')
+		user_fullname = (args.get('first_name') or '') + (args.get('last_name')
+				and (" " + args.get('last_name')) or '')
 		return {'sys_defaults': webnotes.utils.get_defaults(), 'user_fullname': user_fullname}
 
+	def create_feed_and_todo(self):
+		"""update activty feed and create todo for creation of item, customer, vendor"""
+		import home
+		home.make_feed('Comment', 'ToDo Item', '', webnotes.session['user'],
+			'<i>"' + 'Setup Complete. Please check your <a href="#!todo">\
+			To Do List</a>' + '"</i>', '#6B24B3')
+
+		d = Document('ToDo Item')
+		d.description = 'Create your first Customer'
+		d.priority = 'High'
+		d.date = nowdate()
+		d.reference_type = 'Customer'
+		d.save(1)
+
+		d = Document('ToDo Item')
+		d.description = 'Create your first Item'
+		d.priority = 'High'
+		d.date = nowdate()
+		d.reference_type = 'Item'
+		d.save(1)
+
+		d = Document('ToDo Item')
+		d.description = 'Create your first Supplier'
+		d.priority = 'High'
+		d.date = nowdate()
+		d.reference_type = 'Supplier'
+		d.save(1)
+
 		
 	# Get Fiscal year Details
 	# ------------------------
@@ -138,9 +168,11 @@
 		#eddt = sql("select DATE_FORMAT(DATE_SUB(DATE_ADD('%s', INTERVAL 1 YEAR), INTERVAL 1 DAY),'%%d-%%m-%%Y')" % (stdt.split('-')[2]+ '-' + stdt.split('-')[1] + '-' + stdt.split('-')[0]))
 		if(fy_start == '1st Jan'):
 			fy = cstr(getdate(nowdate()).year)
+			abbr = cstr(fy)[-2:]
 		else:
 			fy = cstr(curr_year) + '-' + cstr(curr_year+1)
-		return fy,stdt
+			abbr = cstr(curr_year)[-2:] + '-' + cstr(curr_year+1)[-2:]
+		return fy, stdt, abbr
 
 
 	# Create Company and Fiscal Year
@@ -207,14 +239,6 @@
 			d = addchild(pr,'userroles', 'UserRole', 1)
 			d.role = r
 			d.save(1)
-			
-
-	# Sync DB
-	# -------
-	def sync_db(arg=''):
-		import webnotes.model.db_schema
-		sql("delete from `tabDocType Update Register`")
-		webnotes.model.db_schema.sync_all()
 		
 	
 	def is_setup_okay(self, args):
@@ -224,21 +248,14 @@
 
 		from server_tools.gateway_utils import get_total_users
 		
-		args = eval(args)
-		#webnotes.logger.error("args in set_account_details of setup_control: " + str(args))
-		
+		args = eval(args)		
 		cp_defaults = webnotes.conn.get_value('Control Panel', None, 'account_id')
-		
 		user_profile = webnotes.conn.get_value('Profile', args['user'], 'name')
 		
 		from webnotes.utils import cint
 		
 		total_users = get_total_users()
-		
-		#webnotes.logger.error("setup_control.is_setup_okay: " + cp_defaults + " " + user_profile + " " + str(total_users))
-		
-		#webnotes.logger.error("setup_control.is_setup_okay: Passed Values:" + args['account_name'] + " " + args['user'] + " " + str(args['total_users']))
-		
+						
 		if (cp_defaults==args['account_name']) and user_profile and \
 		   (total_users==cint(args['total_users'])):
 		   return 'True'
diff --git a/erpnext/setup/doctype/territory/territory.py b/erpnext/setup/doctype/territory/territory.py
index 461b447..8017ad5 100644
--- a/erpnext/setup/doctype/territory/territory.py
+++ b/erpnext/setup/doctype/territory/territory.py
@@ -74,4 +74,11 @@
     for d in getlist(self.doclist, 'target_details'):
       if not flt(d.target_qty) and not flt(d.target_amount):
         msgprint("Either target qty or target amount is mandatory.")
-        raise Exception
\ No newline at end of file
+        raise Exception
+
+
+	def on_trash(self):
+		terr = sql("select name from `tabCustomer` where ifnull(territory, '') = %s", self.doc.name)
+		if terr:
+			msgprint("""Territory: %s can not be trashed/deleted because it is used in territory: %s. 
+				To trash/delete this, remove/change territory in customer master""" % (self.doc.name, terr[0][0] or ''), raise_exception=1)
diff --git a/erpnext/setup/page/modules_setup/__init__.py b/erpnext/setup/page/modules_setup/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/setup/page/modules_setup/__init__.py
diff --git a/erpnext/setup/page/modules_setup/modules_setup.css b/erpnext/setup/page/modules_setup/modules_setup.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/setup/page/modules_setup/modules_setup.css
diff --git a/erpnext/setup/page/modules_setup/modules_setup.html b/erpnext/setup/page/modules_setup/modules_setup.html
new file mode 100644
index 0000000..ea136ff
--- /dev/null
+++ b/erpnext/setup/page/modules_setup/modules_setup.html
@@ -0,0 +1,14 @@
+<div class="layout-wrapper">
+	<a class="close" onclick="window.history.back();">&times;</a>		
+	<h1>Modules Setup</h1>
+	<hr>
+	<div class="help" style="width: 300px; float: right">
+		Select checkbox to show / hide module. Drag around to move order.
+	</div>
+	<div id="modules-list">
+	</div>
+	<div>
+		<button class="btn btn-small btn-primary" id="modules-update" 
+			onclick="wn.pages.modules_setup.update()">Update</button>
+	</div>
+</div>
\ No newline at end of file
diff --git a/erpnext/setup/page/modules_setup/modules_setup.js b/erpnext/setup/page/modules_setup/modules_setup.js
new file mode 100644
index 0000000..af7522f
--- /dev/null
+++ b/erpnext/setup/page/modules_setup/modules_setup.js
@@ -0,0 +1,50 @@
+wn.require('lib/js/lib/jquery-ui-sortable.min.js');
+
+$.extend(wn.pages.modules_setup, {
+	modules: ['Activity', 'Accounts', 'Selling', 'Buying', 'Stock', 'Production', 'Projects', 
+		'Support', 'HR', 'Website', 'To Do', 'Messages', 'Calendar', 'Knowledge Base'],	
+	onload: function(wrapper) {
+		wn.pages.modules_setup.refresh(wn.boot.modules_list);
+	},
+	refresh: function(ml) {
+		$('#modules-list').empty();
+				
+		// checked modules
+		for(i in ml) {
+			$('#modules-list').append(repl('<p style="cursor:move;">\
+				<input type="checkbox" data-module="%(m)s"> \
+				%(m)s</p>', {m:ml[i]}));
+		}
+		$('#modules-list [data-module]').attr('checked', true);
+		
+		// unchecked modules
+		var all = wn.pages.modules_setup.modules;
+		for(i in all) {
+			if(!$('#modules-list [data-module="'+all[i]+'"]').length) {
+				$('#modules-list').append(repl('<p style="cursor:move;">\
+					<input type="checkbox" data-module="%(m)s"> \
+					%(m)s</p>', {m:all[i]}));				
+			}
+		}
+		
+		$('#modules-list').sortable();
+		
+	},
+	update: function() {
+		var ml = [];
+		$('#modules-list [data-module]').each(function() {
+			if($(this).attr('checked')) 
+				ml.push($(this).attr('data-module'));
+		});
+		
+		wn.call({
+			method: 'setup.page.modules_setup.modules_setup.update',
+			args: {
+				ml: JSON.stringify(ml)
+			},
+			callback: function(r) {
+			},
+			btn: $('#modules-update').get(0)
+		});
+	}
+});
\ No newline at end of file
diff --git a/erpnext/setup/page/modules_setup/modules_setup.py b/erpnext/setup/page/modules_setup/modules_setup.py
new file mode 100644
index 0000000..ee36dfa
--- /dev/null
+++ b/erpnext/setup/page/modules_setup/modules_setup.py
@@ -0,0 +1,8 @@
+import webnotes
+
+@webnotes.whitelist()
+def update(arg=None):
+	"""update modules"""
+	webnotes.conn.set_global('modules_list', webnotes.form_dict['ml'])
+	webnotes.msgprint('Updated')
+	webnotes.clear_cache()
\ No newline at end of file
diff --git a/erpnext/setup/page/modules_setup/modules_setup.txt b/erpnext/setup/page/modules_setup/modules_setup.txt
new file mode 100644
index 0000000..70c6a90
--- /dev/null
+++ b/erpnext/setup/page/modules_setup/modules_setup.txt
@@ -0,0 +1,28 @@
+# Page, modules_setup
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2012-02-28 17:48:39',
+		'docstatus': 0,
+		'modified': '2012-02-28 17:48:39',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
+	},
+
+	# These values are common for all Page
+	{
+		'doctype': 'Page',
+		'module': u'Setup',
+		'name': '__common__',
+		'page_name': u'modules_setup',
+		'standard': u'Yes',
+		'title': u'Modules Setup'
+	},
+
+	# Page, modules_setup
+	{
+		'doctype': 'Page',
+		'name': u'modules_setup'
+	}
+]
\ No newline at end of file
diff --git a/erpnext/setup/page/setup/setup.html b/erpnext/setup/page/setup/setup.html
index 7963cb9..50ef112 100644
--- a/erpnext/setup/page/setup/setup.html
+++ b/erpnext/setup/page/setup/setup.html
@@ -20,7 +20,7 @@
 	<div class="setup-column">
 		<h3>Users and Permissions</h3>
 		<p>
-			<b><a href="#!My Company">Users</a></b><br>
+			<b><a href="#!users">Users</a></b><br>
 			<span class="help">Add/remove users, set roles, passwords etc</span>
 		</p>
 		<p>
@@ -31,6 +31,10 @@
 			<b><a href="#!List/Authorization Rule">Amount based Authorization Rules</a></b><br>
 			<span class="help">Restrict submission rights based on amount</span>
 		</p>
+		<p>
+			<b><a href="#!modules_setup">Modules Setup</a></b><br>
+			<span class="help">Show, hide modules</span>
+		</p>
 	</div>
 	<div class="setup-column">
 		<h3>Data</h3>
diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py
index 5f0cc23..7db56bd 100644
--- a/erpnext/startup/event_handlers.py
+++ b/erpnext/startup/event_handlers.py
@@ -48,7 +48,7 @@
 				sid!=%s""", \
 			(webnotes.session['user'], webnotes.session['sid']), as_list=1)
 
-	if webnotes.session['user'] not in ('Guest') and webnotes.conn.cur_db_name!='accounts':
+	if webnotes.session['user'] not in ('Guest', 'demo@webnotestech.com') and webnotes.conn.cur_db_name!='accounts':
 		# create feed
 		from webnotes.utils import nowtime
 		home.make_feed('Login', 'Profile', login_manager.user, login_manager.user,
@@ -87,6 +87,14 @@
 
 		import webnotes.model.doctype
 		bootinfo['docs'] += webnotes.model.doctype.get('Event')
+		
+		bootinfo['modules_list'] = webnotes.conn.get_global('modules_list')
+		
+		# 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/js/complete_setup.js b/erpnext/startup/js/complete_setup.js
new file mode 100644
index 0000000..ac89aff
--- /dev/null
+++ b/erpnext/startup/js/complete_setup.js
@@ -0,0 +1,93 @@
+// ERPNext - web based ERP (http://erpnext.com)
+// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+// 
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+// complete my company registration
+// --------------------------------
+
+erpnext.complete_setup = function() {
+	var currency_list = ['', 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AZN', 
+	'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTN', 'BYR', 
+	'BZD', 'CAD', 'CDF', 'CFA', 'CFP', 'CHF', 'CLP', 'CNY', 'COP', 'CRC', 'CUC', 'CZK', 'DJF', 
+	'DKK', 'DOP', 'DZD', 'EEK', 'EGP', 'ERN', 'ETB', 'EUR', 'EURO', 'FJD', 'FKP', 'FMG', 'GBP', 
+	'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GQE', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 
+	'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 
+	'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LTL', 'LVL', 'LYD', 
+	'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR', 
+	'MZM', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NRs', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 
+	'PKR', 'PLN', 'PYG', 'QAR', 'RMB', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SCR', 'SDG', 'SDR', 
+	'SEK', 'SGD', 'SHP', 'SOS', 'SRD', 'STD', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TRY', 
+	'TTD', 'TWD', 'TZS', 'UAE', 'UAH', 'UGX', 'USD', 'USh', 'UYU', 'UZS', 'VEB', 'VND', 'VUV', 
+	'WST', 'XAF', 'XCD', 'XDR', 'XOF', 'XPF', 'YEN', 'YER', 'YTL', 'ZAR', 'ZMK', 'ZWR'];
+	
+	var d = new wn.widgets.Dialog({
+		title: "Setup",
+		fields: [
+			{fieldname:'first_name', label:'Your First Name', fieldtype:'Data', reqd: 1},
+			{fieldname:'last_name', label:'Your Last Name', fieldtype:'Data'},
+			{fieldname:'company_name', label:'Company Name', fieldtype:'Data', reqd:1,
+				description: 'e.g. "My Company LLC"'},
+			{fieldname:'company_abbr', label:'Company Abbreviation', fieldtype:'Data',
+				description:'e.g. "MC"',reqd:1},
+			{fieldname:'fy_start', label:'Financial Year Start Date', fieldtype:'Select',
+				description:'Your financial year begins on"', reqd:1,
+				options: ['', '1st Jan', '1st Apr', '1st Jul', '1st Oct'].join('\n')},
+			{fieldname:'currency', label: 'Default Currency', reqd:1,
+				options: currency_list.join('\n'), fieldtype: 'Select'},
+			{fieldname:'update', label:'Setup',fieldtype:'Button'}
+		]
+	})
+	
+	// prepare
+	if(user != 'Administrator'){
+		d.no_cancel(); // Hide close image
+		$('header').toggle(false); // hide toolbar
+	}
+	
+	// company name already set
+	if(wn.control_panel.company_name) {
+		var inp = d.fields_dict.company_name.input;
+		inp.value = wn.control_panel.company_name;
+		inp.disabled = true;
+	}
+	
+	// set first name, last name
+	if(user_fullname) {
+		u = user_fullname.split(' ');
+		if(u[0]) {
+			d.fields_dict.first_name.input.value = u[0];
+		}
+		if(u[1]) {
+			d.fields_dict.last_name.input.value = u[1];			
+		}
+	}
+	
+	// setup
+	d.fields_dict.update.input.onclick = function() {
+		var data = d.get_values();
+		if(!data) return;
+		$(this).set_working();
+		$c_obj('Setup Control','setup_account',data,function(r, rt){
+			sys_defaults = r.message;
+			user_fullname = r.message.user_fullname;
+			wn.boot.user_info[user].fullname = user_fullname;
+			d.hide();
+			$('header').toggle(true);
+			page_body.wntoolbar.set_user_name();
+		});
+	}
+	
+	d.show();
+}
diff --git a/erpnext/startup/feature_setup.js b/erpnext/startup/js/feature_setup.js
similarity index 95%
rename from erpnext/startup/feature_setup.js
rename to erpnext/startup/js/feature_setup.js
index 8644c1d..c5518ab 100644
--- a/erpnext/startup/feature_setup.js
+++ b/erpnext/startup/js/feature_setup.js
@@ -122,13 +122,13 @@
 		'Sales Order': {'sales_order_details':['page_break']}
 	},
 	'fs_exports': {
-		'Delivery Note': {'fields':['Note','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'delivery_note_details':['base_ref_rate','export_amount','export_rate']},
+		'Delivery Note': {'fields':['Note','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'delivery_note_details':['ref_rate','export_amount','export_rate']},
 		'POS Setting': {'fields':['conversion_rate','currency']},
-		'Quotation': {'fields':['Note HTML','OT Notes','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'quotation_details':['base_ref_rate','export_amount','export_rate']},
-		'Receivable Voucher': {'fields':['conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'entries':['base_ref_rate','export_amount','export_rate']},
+		'Quotation': {'fields':['Note HTML','OT Notes','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'quotation_details':['ref_rate','export_amount','export_rate']},
+		'Receivable Voucher': {'fields':['conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'entries':['ref_rate','export_amount','export_rate']},
 		'Item': {'ref_rate_details':['ref_currency']},
 		'Sales BOM': {'fields':['currency']},
-		'Sales Order': {'fields':['Note1','OT Notes','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'sales_order_details':['base_ref_rate','export_amount','export_rate']}
+		'Sales Order': {'fields':['Note1','OT Notes','conversion_rate','currency','grand_total_export','in_words_export','rounded_total_export'],'sales_order_details':['ref_rate','export_amount','export_rate']}
 	},
 	'fs_imports': {
 		'Payable Voucher': {'fields':['conversion_rate','currency','grand_total_import','in_words_import','net_total_import','other_charges_added_import','other_charges_deducted_import'],'entries':['import_amount','import_rate']},
@@ -149,7 +149,6 @@
 		'Sales Order': {'fields':['sales_team','Packing List']}
 	},
 	'fs_more_info': {
-		'Customer': {'fields':['More Info']},
 		'Delivery Note': {'fields':['More Info']},
 		'Enquiry': {'fields':['More Info']},
 		'Indent': {'fields':['More Info']},
@@ -160,8 +159,6 @@
 		'Quotation': {'fields':['More Info']},
 		'Receivable Voucher': {'fields':['More Info']},
 		'Sales Order': {'fields':['More Info']},
-		'Serial No': {'fields':['More Info']},
-		'Supplier': {'fields':['More Info']}
 	},
 	'fs_quality': {
 		'Item': {'fields':['Item Inspection Criteria','inspection_required']},
diff --git a/erpnext/startup/modules.js b/erpnext/startup/js/modules.js
similarity index 89%
rename from erpnext/startup/modules.js
rename to erpnext/startup/js/modules.js
index dbd11b0..d43b021 100644
--- a/erpnext/startup/modules.js
+++ b/erpnext/startup/js/modules.js
@@ -32,7 +32,7 @@
 	$(wrapper).find('[href*="List/"]').each(function() {
 		var href = $(this).attr('href');
 		var dt = href.split('/')[1];
-		if(wn.boot.profile.can_read.indexOf(get_label_doctype(dt))==-1) {
+		if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) {
 			var txt = $(this).text();
 			$(this).parent().css('color', '#999').html(txt);
 		}
@@ -41,7 +41,7 @@
 	// reports
 	$(wrapper).find('[data-doctype]').each(function() {
 		var dt = $(this).attr('data-doctype');
-		if(wn.boot.profile.can_read.indexOf(dt)==-1) {
+		if(wn.boot.profile.all_read.indexOf(dt)==-1) {
 			var txt = $(this).text();
 			$(this).parent().css('color', '#999').html(txt);
 		}
@@ -51,7 +51,7 @@
 	$(wrapper).find('[href*="Form/"]').each(function() {
 		var href = $(this).attr('href');
 		var dt = href.split('/')[1];
-		if(wn.boot.profile.can_read.indexOf(get_label_doctype(dt))==-1) {
+		if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) {
 			var txt = $(this).text();
 			$(this).parent().css('color', '#999').html(txt);
 		}
@@ -73,7 +73,10 @@
 		args: {
 			module: module
 		},
-		no_refresh: true
+		no_refresh: true,
+		callback: function(r) {
+			erpnext.module_page.hide_links(wrapper)
+		}
 	});
 	wrapper.list.run();	
 }
\ No newline at end of file
diff --git a/erpnext/startup/toolbar.js b/erpnext/startup/js/toolbar.js
similarity index 72%
rename from erpnext/startup/toolbar.js
rename to erpnext/startup/js/toolbar.js
index 7eda493..7bf9c6a 100644
--- a/erpnext/startup/toolbar.js
+++ b/erpnext/startup/js/toolbar.js
@@ -73,20 +73,43 @@
 	$('<li class="dropdown">\
 		<a class="dropdown-toggle" data-toggle="dropdown" href="#"\
 			onclick="return false;">Modules<b class="caret"></b></a>\
-		<ul class="dropdown-menu">\
-			<li><a href="#!accounts-home" data-module="Accounts">Accounts</a></li>\
-			<li><a href="#!selling-home" data-module="Selling">Selling</a></li>\
-			<li><a href="#!stock-home" data-module="Stock">Stock</a></li>\
-			<li><a href="#!buying-home" data-module="Buying">Buying</a></li>\
-			<li><a href="#!support-home" data-module="Support">Support</a></li>\
-			<li><a href="#!hr-home" data-module="HR">Human Resources</a></li>\
-			<li><a href="#!projects-home" data-module="Projects">Projects</a></li>\
-			<li><a href="#!production-home" data-module="Production">Production</a></li>\
-			<li><a href="#!website-home" data-module="Website">Website</a></li>\
-			<li class="divider"></li>\
-			<li><a href="#!Setup" data-module="Setup">Setup</a></li>\
+		<ul class="dropdown-menu modules">\
 		</ul>\
 		</li>').prependTo('.navbar .nav:first');
-	$('.navbar .nav:first')	
+	
+	// if no modules list then show all
+	if(wn.boot.modules_list)
+		wn.boot.modules_list = JSON.parse(wn.boot.modules_list);
+	else
+		wn.boot.modules_list = keys(erpnext.modules).sort();
+
+	// add to dropdown
+	for(var i in wn.boot.modules_list) {
+		var m = wn.boot.modules_list[i]
+		
+		if(m!='Setup' && wn.boot.profile.allow_modules.indexOf(m)!=-1) {
+			args = {
+				module: m,
+				module_page: erpnext.modules[m],
+				module_label: m=='HR' ? 'Human Resources' : m
+			}
+
+			$('.navbar .modules').append(repl('<li><a href="#!%(module_page)s" \
+				data-module="%(module)s">%(module_label)s</a></li>', args));			
+		}
+	}
+
+	// dasboard for accounts system manager
+	if(user_roles.indexOf("Accounts Manager")!=-1) {
+		$('.navbar .modules').append('<li><a href="#!dashboard" \
+			data-module="Dashboard">Dashboard</a></li>');
+	}
+	
+	// setup for system manager
+	if(user_roles.indexOf("System Manager")!=-1) {
+		$('.navbar .modules').append('<li class="divider"></li>\
+		<li><a href="#!Setup" data-module="Setup">Setup</a></li>');
+	}
+	
 }
 
diff --git a/erpnext/startup/startup.css b/erpnext/startup/startup.css
index ae0ef60..225e444 100644
--- a/erpnext/startup/startup.css
+++ b/erpnext/startup/startup.css
@@ -13,10 +13,11 @@
 }
 
 body {
+	background: url(../images/stripedbg.png) repeat;
 }
 
 .erpnext-footer {
-	margin: 3px auto;
+	margin: 11px auto;
 	text-align: center;
 }
 
diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js
index 83b1685..0a2ac23 100644
--- a/erpnext/startup/startup.js
+++ b/erpnext/startup/startup.js
@@ -19,6 +19,25 @@
 
 wn.provide('erpnext.startup');
 
+erpnext.modules = {
+	'Selling': 'selling-home',
+	'Accounts': 'accounts-home',
+	'Stock': 'stock-home',
+	'Buying': 'buying-home',
+	'Support': 'support-home',
+	'Projects': 'projects-home',
+	'Production': 'production-home',
+	'Website': 'website-home',
+	'HR': 'hr-home',
+	'Setup': 'Setup',
+	'Activity': 'activity',
+	'To Do': 'todo',
+	'Calendar': 'calendar',
+	'Messages': 'messages',
+	'Knowledge Base': 'questions',
+	'Dashboard': 'dashboard'
+}
+
 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;
@@ -27,27 +46,42 @@
 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 {
+		// always allow apps
+		wn.boot.profile.allow_modules = wn.boot.profile.allow_modules.concat(
+			['To Do', 'Knowledge Base', 'Calendar', 'Activity', 'Messages'])
+		
 		// setup toolbar
 		erpnext.toolbar.setup();
-		
+				
 		// set interval for updates
 		erpnext.startup.set_periodic_updates();
 
 		// border to the body
 		// ------------------
 		$('footer').html('<div class="web-footer erpnext-footer">\
-			Powered by <a href="https://erpnext.com">ERPNext</a></div>');
+			<a href="#!attributions">ERPNext | Attributions and License</a></div>');
+
+		// complete registration
+		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);
@@ -69,53 +103,36 @@
 }
 
 
-// Module Page
-// ====================================================================
-
-ModulePage = function(parent, module_name, module_label, help_page, callback) {
-	this.parent = parent;
-
-	// add to current page
-	page_body.cur_page.module_page = this;
-
-	this.wrapper = $a(parent,'div');
-	this.module_name = module_name;
-	this.transactions = [];
-	this.page_head = new PageHeader(this.wrapper, module_label);
-
-	if(help_page) {
-		var btn = this.page_head.add_button('Help', function() { loadpage(this.help_page) }, 1, 'ui-icon-help')
-		btn.help_page = help_page;
-	}
-
-	if(callback) this.callback = function(){ callback(); }
-}
-
 // ========== Update Messages ============
-var update_messages = function() {
+var update_messages = function(reset) {
 	// Updates Team Messages
 	
 	if(inList(['Guest'], user)) { return; }
-	
-	$c_page('home', 'event_updates', 'get_unread_messages', null,
-		function(r,rt) {
-			if(!r.exc) {
-				// This function is defined in toolbar.js
-				page_body.wntoolbar.set_new_comments(r.message);
-				var circle = $('#msg_count')
-				if(circle) {
-					if(r.message.length) {
-						circle.find('span:first').text(r.message.length);
-						circle.toggle(true);
-					} else {
-						circle.toggle(false);
+
+	if(!reset) {
+		$c_page('home', 'event_updates', 'get_unread_messages', null,
+			function(r,rt) {
+				if(!r.exc) {
+					// This function is defined in toolbar.js
+					page_body.wntoolbar.set_new_comments(r.message);
+					var circle = $('#msg_count')
+					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);
 				}
-			} else {
-				clearInterval(wn.updates.id);
 			}
-		}
-	);
+		);
+	} else {
+		page_body.wntoolbar.set_new_comments(0);
+		$('#msg_count').toggle(false);
+	}
 }
 
 erpnext.startup.set_periodic_updates = function() {
@@ -129,7 +146,9 @@
 	wn.updates.id = setInterval(update_messages, 60000);
 }
 
-// =======================================
+erpnext.set_user_background = function(src) {
+	set_style(repl('body { background: url("files/%(src)s") repeat;}', {src:src}))
+}
 
 // start
 $(document).bind('startup', function() {
diff --git a/erpnext/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt b/erpnext/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt
index 3c50836..e3f0dc9 100644
--- a/erpnext/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt
+++ b/erpnext/stock/DocType Mapper/Purchase Order-Purchase Receipt/Purchase Order-Purchase Receipt.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:35',
 		'docstatus': 0,
-		'modified': '2012-02-07 13:28:20',
+		'modified': '2012-03-01 17:58:16',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
diff --git a/erpnext/stock/DocType Mapper/Sales Order-Delivery Note/Sales Order-Delivery Note.txt b/erpnext/stock/DocType Mapper/Sales Order-Delivery Note/Sales Order-Delivery Note.txt
index 561019b..fcadcd4 100644
--- a/erpnext/stock/DocType Mapper/Sales Order-Delivery Note/Sales Order-Delivery Note.txt
+++ b/erpnext/stock/DocType Mapper/Sales Order-Delivery Note/Sales Order-Delivery Note.txt
@@ -5,273 +5,263 @@
 	{
 		'creation': '2010-08-08 17:09:35',
 		'docstatus': 0,
-		'modified': '2011-09-14 12:36:25',
-		'modified_by': 'Administrator',
-		'owner': 'Administrator'
+		'modified': '2012-03-01 17:58:16',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
 	},
 
 	# These values are common for all Table Mapper Detail
 	{
-		'doctype': 'Table Mapper Detail',
+		'doctype': u'Table Mapper Detail',
 		'name': '__common__',
-		'parent': 'Sales Order-Delivery Note',
-		'parentfield': 'table_mapper_details',
-		'parenttype': 'DocType Mapper'
+		'parent': u'Sales Order-Delivery Note',
+		'parentfield': u'table_mapper_details',
+		'parenttype': u'DocType Mapper'
 	},
 
 	# These values are common for all Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
+		'doctype': u'Field Mapper Detail',
 		'name': '__common__',
-		'parent': 'Sales Order-Delivery Note',
-		'parentfield': 'field_mapper_details',
-		'parenttype': 'DocType Mapper'
+		'parent': u'Sales Order-Delivery Note',
+		'parentfield': u'field_mapper_details',
+		'parenttype': u'DocType Mapper'
 	},
 
 	# These values are common for all DocType Mapper
 	{
 		'doctype': u'DocType Mapper',
-		'from_doctype': 'Sales Order',
-		'module': 'Stock',
+		'from_doctype': u'Sales Order',
+		'module': u'Stock',
 		'name': '__common__',
 		'ref_doc_submitted': 1,
-		'to_doctype': 'Delivery Note'
+		'to_doctype': u'Delivery Note'
 	},
 
 	# DocType Mapper, Sales Order-Delivery Note
 	{
 		'doctype': u'DocType Mapper',
-		'name': 'Sales Order-Delivery Note'
+		'name': u'Sales Order-Delivery Note'
 	},
 
 	# Field Mapper Detail
 	{
-		'checking_operator': '>=',
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'transaction_date',
-		'map': 'No',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'name',
+		'map': u'Yes',
 		'match_id': 0,
-		'to_field': 'transaction_date'
+		'to_field': u'sales_order_no'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'name',
-		'map': 'Yes',
+		'checking_operator': u'=',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'company',
+		'map': u'Yes',
 		'match_id': 0,
-		'to_field': 'sales_order_no'
+		'to_field': u'company'
 	},
 
 	# Field Mapper Detail
 	{
-		'checking_operator': '=',
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'company',
-		'map': 'Yes',
+		'checking_operator': u'=',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'currency',
+		'map': u'Yes',
 		'match_id': 0,
-		'to_field': 'company'
+		'to_field': u'currency'
 	},
 
 	# Field Mapper Detail
 	{
-		'checking_operator': '=',
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'currency',
-		'map': 'Yes',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'shipping_address_name',
+		'map': u'Yes',
 		'match_id': 0,
-		'to_field': 'currency'
+		'to_field': u'customer_address'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'shipping_address_name',
-		'map': 'Yes',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'shipping_address',
+		'map': u'Yes',
 		'match_id': 0,
-		'to_field': 'customer_address'
+		'to_field': u'address_display'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'shipping_address',
-		'map': 'Yes',
-		'match_id': 0,
-		'to_field': 'address_display'
-	},
-
-	# Field Mapper Detail
-	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'parent',
-		'map': 'Yes',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'parent',
+		'map': u'Yes',
 		'match_id': 1,
-		'to_field': 'prevdoc_docname'
+		'to_field': u'prevdoc_docname'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'parenttype',
-		'map': 'Yes',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'parenttype',
+		'map': u'Yes',
 		'match_id': 1,
-		'to_field': 'prevdoc_doctype'
+		'to_field': u'prevdoc_doctype'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'name',
-		'map': 'Yes',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'name',
+		'map': u'Yes',
 		'match_id': 1,
-		'to_field': 'prevdoc_detail_docname'
+		'to_field': u'prevdoc_detail_docname'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)',
-		'map': 'Yes',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)',
+		'map': u'Yes',
 		'match_id': 1,
-		'to_field': 'export_amount'
+		'to_field': u'export_amount'
 	},
 
 	# Field Mapper Detail
 	{
-		'checking_operator': '=',
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'basic_rate',
-		'map': 'Yes',
+		'checking_operator': u'=',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'basic_rate',
+		'map': u'Yes',
 		'match_id': 1,
-		'to_field': 'basic_rate'
+		'to_field': u'basic_rate'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'eval: flt(obj.qty) - flt(obj.delivered_qty)',
-		'map': 'Yes',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'eval: flt(obj.qty) - flt(obj.delivered_qty)',
+		'map': u'Yes',
 		'match_id': 1,
-		'to_field': 'qty'
+		'to_field': u'qty'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate)',
-		'map': 'Yes',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'eval: (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate)',
+		'map': u'Yes',
 		'match_id': 1,
-		'to_field': 'amount'
+		'to_field': u'amount'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'reserved_warehouse',
-		'map': 'Yes',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'reserved_warehouse',
+		'map': u'Yes',
 		'match_id': 1,
-		'to_field': 'warehouse'
+		'to_field': u'warehouse'
 	},
 
 	# Field Mapper Detail
 	{
-		'checking_operator': '=',
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'project_name',
-		'map': 'Yes',
+		'checking_operator': u'=',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'project_name',
+		'map': u'Yes',
 		'match_id': 0,
-		'to_field': 'project_name'
+		'to_field': u'project_name'
 	},
 
 	# Field Mapper Detail
 	{
-		'checking_operator': '=',
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'customer',
-		'map': 'Yes',
+		'checking_operator': u'=',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'customer',
+		'map': u'Yes',
 		'match_id': 0,
-		'to_field': 'customer'
+		'to_field': u'customer'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'naming_series',
-		'map': 'No',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'naming_series',
+		'map': u'No',
 		'match_id': 0,
-		'to_field': 'naming_series'
+		'to_field': u'naming_series'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'status',
-		'map': 'No',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'status',
+		'map': u'No',
 		'match_id': 0,
-		'to_field': 'status'
+		'to_field': u'status'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'incentives',
-		'map': 'No',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'incentives',
+		'map': u'No',
 		'match_id': 3,
-		'to_field': 'incentives'
+		'to_field': u'incentives'
 	},
 
 	# Field Mapper Detail
 	{
-		'doctype': 'Field Mapper Detail',
-		'from_field': 'allocated_amount',
-		'map': 'Yes',
+		'doctype': u'Field Mapper Detail',
+		'from_field': u'allocated_amount',
+		'map': u'Yes',
 		'match_id': 0,
-		'to_field': 'customer_mobile_no'
+		'to_field': u'customer_mobile_no'
 	},
 
 	# Table Mapper Detail
 	{
-		'doctype': 'Table Mapper Detail',
-		'from_field': 'sales_team',
-		'from_table': 'Sales Team',
+		'doctype': u'Table Mapper Detail',
+		'from_field': u'sales_team',
+		'from_table': u'Sales Team',
 		'match_id': 3,
-		'to_field': 'sales_team',
-		'to_table': 'Sales Team',
-		'validation_logic': 'name is not null'
+		'to_field': u'sales_team',
+		'to_table': u'Sales Team',
+		'validation_logic': u'name is not null'
 	},
 
 	# Table Mapper Detail
 	{
-		'doctype': 'Table Mapper Detail',
-		'from_field': 'other_charges',
-		'from_table': 'RV Tax Detail',
+		'doctype': u'Table Mapper Detail',
+		'from_field': u'other_charges',
+		'from_table': u'RV Tax Detail',
 		'match_id': 2,
-		'to_field': 'other_charges',
-		'to_table': 'RV Tax Detail',
-		'validation_logic': 'name is not null'
+		'to_field': u'other_charges',
+		'to_table': u'RV Tax Detail',
+		'validation_logic': u'name is not null'
 	},
 
 	# Table Mapper Detail
 	{
-		'doctype': 'Table Mapper Detail',
-		'from_field': 'sales_order_details',
-		'from_table': 'Sales Order Detail',
+		'doctype': u'Table Mapper Detail',
+		'from_field': u'sales_order_details',
+		'from_table': u'Sales Order Detail',
 		'match_id': 1,
-		'reference_doctype_key': 'prevdoc_doctype',
-		'reference_key': 'prevdoc_detail_docname',
-		'to_field': 'delivery_note_details',
-		'to_table': 'Delivery Note Detail',
-		'validation_logic': 'qty > ifnull(delivered_qty,0) and docstatus = 1'
+		'reference_doctype_key': u'prevdoc_doctype',
+		'reference_key': u'prevdoc_detail_docname',
+		'to_field': u'delivery_note_details',
+		'to_table': u'Delivery Note Detail',
+		'validation_logic': u'qty > ifnull(delivered_qty,0) and docstatus = 1'
 	},
 
 	# Table Mapper Detail
 	{
-		'doctype': 'Table Mapper Detail',
-		'from_table': 'Sales Order',
+		'doctype': u'Table Mapper Detail',
+		'from_table': u'Sales Order',
 		'match_id': 0,
-		'reference_key': 'prevdoc_docname',
-		'to_table': 'Delivery Note',
-		'validation_logic': 'docstatus = 1'
+		'reference_key': u'prevdoc_docname',
+		'to_table': u'Delivery Note',
+		'validation_logic': u'docstatus = 1'
 	}
 ]
\ No newline at end of file
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index 3a8931e..1f5170b 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -30,7 +30,7 @@
 	if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
 	if(!doc.transaction_date) set_multiple(dt,dn,{transaction_date:get_today()});
 	if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
-	if(doc.__islocal && doc.customer) cur_frm.cscript.pull_item_details_onload(doc,dt,dn);
+	if(doc.__islocal && doc.customer) cur_frm.cscript.customer(doc,dt,dn,onload=true);
 	if(!doc.price_list_currency) {
 		set_multiple(dt, dn, {price_list_currency: doc.currency, plc_conversion_rate:1});
 	}
@@ -43,17 +43,19 @@
 
 cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
 	// defined in sales_common.js
-	if(doc.__islocal) cur_frm.cscript.update_item_details(doc, dt, dn);
+	var callback = function(doc, dt, dn) {
+		if(doc.__islocal) cur_frm.cscript.update_item_details(doc, dt, dn);
+	}
+
+	cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback); 
 } 
 
 // REFRESH
 // ================================================================================================
 cur_frm.cscript.refresh = function(doc, cdt, cdn) { 
 	cur_frm.clear_custom_buttons();
-	var callback = function() {
-		cur_frm.cscript.dynamic_label(doc, cdt, cdn);
-	}
-	cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback); 
+	
+	if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn); 
 
  
 	if(doc.per_billed < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
@@ -123,16 +125,6 @@
 }
 
 
-//RV-DN : Pull Item details - UOM, Item Group as it was not in Sales Invoice
-//---------------------------------------------------------------------
-cur_frm.cscript.pull_item_details_onload = function(doc,dt,dn){
-	var callback = function(r,rt){
-		refresh_field('delivery_note_details');
-		cur_frm.cscript.customer(doc,dt,dn,onload=true);
-	} 
-	$c_obj(make_doclist(dt,dn),'set_item_details','',callback);
-}
-
 //================ create new contact ============================================================================
 cur_frm.cscript.new_contact = function(){
 	tn = createLocal('Contact');
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index a94531b..3d8a101 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -74,16 +74,6 @@
 
 		return cstr(self.doc.sales_order_no)
 
-
-
-	#-------------------set item details -uom and item group----------------
-	def set_item_details(self):
-		for d in getlist(self.doclist,'delivery_note_details'):
-			res = sql("select stock_uom, item_group from `tabItem` where name ='%s'"%d.item_code)
-			if not d.stock_uom:		d.stock_uom = res and cstr(res[0][0]) or ''
-			if not d.item_group:	 d.item_group = res and cstr(res[0][1]) or ''
-			d.save()
-
 	# ::::: Validates that Sales Order is not pulled twice :::::::
 	def validate_prev_docname(self):
 		for d in getlist(self.doclist, 'delivery_note_details'):
@@ -117,14 +107,16 @@
 
 	# ***************** Get Item Details ******************************
 	def get_item_details(self, args=None):
-		args = eval(args)
-		if args['item_code']:
+		args = args and eval(args) or {}
+		if args.get('item_code'):
 			return get_obj('Sales Common').get_item_details(args, self)
 		else:
 			obj = get_obj('Sales Common')
 			for doc in self.doclist:
 				if doc.fields.get('item_code'):
-					ret = obj.get_item_details(doc.item_code, self)
+					arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'), 
+						'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
+					ret = obj.get_item_details(arg, self)
 					for r in ret:
 						if not doc.fields.get(r):
 							doc.fields[r] = ret[r]					
@@ -135,13 +127,6 @@
 		get_obj('Sales Common').get_adj_percent(self)
 
 
-	def get_comp_base_currency(self):
-		return get_obj('Sales Common').get_comp_base_currency(self.doc.company)
-
-	def get_price_list_currency(self):
-		return get_obj('Sales Common').get_price_list_currency(self.doc.price_list_name, self.doc.company)
-
-
 	# ********** Get Actual Qty of item in warehouse selected *************
 	def get_actual_qty(self,args):
 		args = eval(args)
@@ -245,9 +230,9 @@
 
 			if prevdoc_docname and prevdoc:
 				# ::::::::::: Validates Transaction Date of DN and previous doc (i.e. SO , PO, PR) *********
-				trans_date = sql("select transaction_date from `tab%s` where name = '%s'" %(prevdoc,prevdoc_docname))[0][0]
-				if trans_date and getdate(self.doc.transaction_date) < (trans_date):
-					msgprint("Your Voucher Date cannot be before "+cstr(prevdoc)+" Date.")
+				trans_date = sql("select posting_date from `tab%s` where name = '%s'" %(prevdoc,prevdoc_docname))[0][0]
+				if trans_date and getdate(self.doc.posting_date) < (trans_date):
+					msgprint("Your Posting Date cannot be before "+cstr(prevdoc)+" Date.")
 					raise Exception
 				# ::::::::: Validates DN and previous doc details ::::::::::::::::::
 				get_name = sql("select name from `tab%s` where name = '%s'" % (prevdoc, prevdoc_docname))
@@ -356,16 +341,17 @@
 		"""
 			Validate that if packed qty exists, it should be equal to qty
 		"""
-		if not any([d.fields.get('packed_qty') for d in self.doclist]):
+		if not any([flt(d.fields.get('packed_qty')) for d in self.doclist if
+				d.doctype=='Delivery Note Detail']):
 			return
 		packing_error_list = []
 		for d in self.doclist:
 			if d.doctype != 'Delivery Note Detail': continue
-			if d.fields.get('qty') != d.fields.get('packed_qty'):
+			if flt(d.fields.get('qty')) != flt(d.fields.get('packed_qty')):
 				packing_error_list.append([
 					d.fields.get('item_code', ''),
-					d.fields.get('qty', ''),
-					d.fields.get('packed_qty', '')
+					d.fields.get('qty', 0),
+					d.fields.get('packed_qty', 0)
 				])
 		if packing_error_list:
 			from webnotes.utils import cstr
@@ -457,7 +443,7 @@
 		self.values.append({
 			'item_code'					 : d[1],
 			'warehouse'					 : wh,
-			'transaction_date'		: self.doc.transaction_date,
+			'transaction_date'		: getdate(self.doc.modified).strftime('%Y-%m-%d'),
 			'posting_date'				: self.doc.posting_date,
 			'posting_time'				: self.doc.posting_time,
 			'voucher_type'				: 'Delivery Note',
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.txt b/erpnext/stock/doctype/delivery_note/delivery_note.txt
index 6570b0c..314d0d9 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.txt
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2011-04-18 15:58:20',
 		'docstatus': 0,
-		'modified': '2012-02-27 17:35:31',
+		'modified': '2012-03-02 12:15:44',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -21,7 +21,7 @@
 
 	# These values are common for all DocType
 	{
-		'_last_update': u'1330343754',
+		'_last_update': u'1330593645',
 		'colour': u'White:FFF',
 		'default_print_format': u'Standard',
 		'doctype': 'DocType',
@@ -37,7 +37,7 @@
 		'show_in_menu': 0,
 		'subject': u'To %(customer_name)s on %(transaction_date)s | %(per_billed)s% billed',
 		'tag_fields': u'billing_status',
-		'version': 474
+		'version': 475
 	},
 
 	# These values are common for all DocFormat
@@ -285,29 +285,37 @@
 	# DocField
 	{
 		'doctype': u'DocField',
-		'fieldtype': u'Column Break',
-		'oldfieldtype': u'Column Break',
-		'permlevel': 0
+		'fieldname': u'territory',
+		'fieldtype': u'Link',
+		'hidden': 0,
+		'in_filter': 1,
+		'label': u'Territory',
+		'options': u'Territory',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 1,
+		'search_index': 1
 	},
 
 	# DocField
 	{
-		'colour': u'White:FFF',
-		'default': u'Today',
-		'description': u'The date at which current entry is made in system.',
 		'doctype': u'DocField',
-		'fieldname': u'transaction_date',
-		'fieldtype': u'Date',
+		'fieldname': u'customer_group',
+		'fieldtype': u'Link',
 		'in_filter': 1,
-		'label': u'Voucher Date',
-		'no_copy': 1,
-		'oldfieldname': u'transaction_date',
-		'oldfieldtype': u'Date',
+		'label': u'Customer Group',
+		'options': u'Customer Group',
 		'permlevel': 0,
 		'print_hide': 1,
-		'reqd': 1,
-		'search_index': 1,
-		'width': u'100px'
+		'search_index': 1
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldtype': u'Column Break',
+		'oldfieldtype': u'Column Break',
+		'permlevel': 0
 	},
 
 	# DocField
@@ -467,30 +475,41 @@
 
 	# DocField
 	{
+		'colour': u'White:FFF',
+		'description': u'Track this Delivery Note against any Project',
 		'doctype': u'DocField',
-		'fieldname': u'territory',
+		'fieldname': u'project_name',
 		'fieldtype': u'Link',
-		'hidden': 0,
 		'in_filter': 1,
-		'label': u'Territory',
-		'options': u'Territory',
+		'label': u'Project Name',
+		'oldfieldname': u'project_name',
+		'oldfieldtype': u'Link',
+		'options': u'Project',
 		'permlevel': 0,
-		'print_hide': 1,
-		'reqd': 1,
-		'search_index': 1
+		'search_index': 1,
+		'trigger': u'Client'
 	},
 
 	# DocField
 	{
 		'doctype': u'DocField',
-		'fieldname': u'customer_group',
-		'fieldtype': u'Link',
-		'in_filter': 1,
-		'label': u'Customer Group',
-		'options': u'Customer Group',
-		'permlevel': 0,
-		'print_hide': 1,
-		'search_index': 1
+		'fieldname': u'challan_no',
+		'fieldtype': u'Data',
+		'label': u'Challan No',
+		'oldfieldname': u'challan_no',
+		'oldfieldtype': u'Data',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'challan_date',
+		'fieldtype': u'Date',
+		'label': u'Challan Date',
+		'oldfieldname': u'challan_date',
+		'oldfieldtype': u'Date',
+		'permlevel': 0
 	},
 
 	# DocField
@@ -885,6 +904,7 @@
 		'oldfieldtype': u'Button',
 		'options': u'get_tc_details',
 		'permlevel': 0,
+		'print_hide': 1,
 		'trigger': u'Server'
 	},
 
@@ -917,7 +937,8 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Section Break',
 		'label': u'Transporter Info',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -925,6 +946,7 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -981,43 +1003,14 @@
 
 	# DocField
 	{
-		'doctype': u'DocField',
-		'fieldtype': u'Column Break',
-		'permlevel': 0,
-		'width': u'50%'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'challan_no',
-		'fieldtype': u'Data',
-		'label': u'Challan No',
-		'oldfieldname': u'challan_no',
-		'oldfieldtype': u'Data',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'challan_date',
-		'fieldtype': u'Date',
-		'label': u'Challan Date',
-		'oldfieldname': u'challan_date',
-		'oldfieldtype': u'Date',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
 		'colour': u'White:FFF',
 		'description': u'Filling in Additional Information about the Delivery Note will help you analyze your data better.',
 		'doctype': u'DocField',
 		'fieldtype': u'Section Break',
 		'label': u'More Info',
 		'oldfieldtype': u'Section Break',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -1058,27 +1051,11 @@
 
 	# DocField
 	{
-		'colour': u'White:FFF',
-		'description': u'Track this Delivery Note against any Project',
-		'doctype': u'DocField',
-		'fieldname': u'project_name',
-		'fieldtype': u'Link',
-		'in_filter': 1,
-		'label': u'Project Name',
-		'oldfieldname': u'project_name',
-		'oldfieldtype': u'Link',
-		'options': u'Project',
-		'permlevel': 0,
-		'search_index': 1,
-		'trigger': u'Client'
-	},
-
-	# DocField
-	{
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'oldfieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -1244,7 +1221,8 @@
 		'fieldtype': u'Section Break',
 		'label': u'Packing List',
 		'oldfieldtype': u'Section Break',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -1268,7 +1246,7 @@
 		'label': u'Sales Team',
 		'oldfieldtype': u'Section Break',
 		'permlevel': 0,
-		'print_hide': 0
+		'print_hide': 1
 	},
 
 	# DocField
@@ -1276,6 +1254,7 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -1300,6 +1279,7 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -1338,7 +1318,8 @@
 		'doctype': u'DocField',
 		'fieldtype': u'Section Break',
 		'options': u'Simple',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
diff --git a/erpnext/stock/doctype/delivery_note_detail/delivery_note_detail.txt b/erpnext/stock/doctype/delivery_note_detail/delivery_note_detail.txt
index 78fea52..a5f82f4 100644
--- a/erpnext/stock/doctype/delivery_note_detail/delivery_note_detail.txt
+++ b/erpnext/stock/doctype/delivery_note_detail/delivery_note_detail.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:08:58',
 		'docstatus': 0,
-		'modified': '2012-02-24 11:33:58',
+		'modified': '2012-03-05 10:49:39',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -23,7 +23,7 @@
 		'section_style': u'Tray',
 		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'version': 53
+		'version': 55
 	},
 
 	# These values are common for all DocField
@@ -117,18 +117,14 @@
 
 	# DocField
 	{
-		'default': u'0.00',
 		'doctype': u'DocField',
-		'fieldname': u'ref_rate',
+		'fieldname': u'base_ref_rate',
 		'fieldtype': u'Currency',
-		'label': u'Price List Rate',
-		'no_copy': 0,
-		'oldfieldname': u'ref_rate',
+		'label': u'Price List Rate*',
+		'oldfieldname': u'base_ref_rate',
 		'oldfieldtype': u'Currency',
-		'permlevel': 0,
+		'permlevel': 1,
 		'print_hide': 1,
-		'reqd': 0,
-		'trigger': u'Client',
 		'width': u'100px'
 	},
 
@@ -149,6 +145,53 @@
 
 	# DocField
 	{
+		'default': u'0.00',
+		'doctype': u'DocField',
+		'fieldname': u'basic_rate',
+		'fieldtype': u'Currency',
+		'label': u'Rate*',
+		'oldfieldname': u'basic_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'trigger': u'Client',
+		'width': u'150px'
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'amount',
+		'fieldtype': u'Currency',
+		'label': u'Amount*',
+		'oldfieldname': u'amount',
+		'oldfieldtype': u'Currency',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 0,
+		'width': u'100px'
+	},
+
+	# DocField
+	{
+		'default': u'0.00',
+		'doctype': u'DocField',
+		'fieldname': u'ref_rate',
+		'fieldtype': u'Currency',
+		'label': u'Price List Rate',
+		'no_copy': 0,
+		'oldfieldname': u'ref_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'trigger': u'Client',
+		'width': u'100px'
+	},
+
+	# DocField
+	{
 		'doctype': u'DocField',
 		'fieldname': u'export_rate',
 		'fieldtype': u'Currency',
@@ -179,49 +222,6 @@
 	# DocField
 	{
 		'doctype': u'DocField',
-		'fieldname': u'base_ref_rate',
-		'fieldtype': u'Currency',
-		'label': u'Price List Rate*',
-		'oldfieldname': u'base_ref_rate',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1,
-		'print_hide': 1,
-		'width': u'100px'
-	},
-
-	# DocField
-	{
-		'default': u'0.00',
-		'doctype': u'DocField',
-		'fieldname': u'basic_rate',
-		'fieldtype': u'Currency',
-		'label': u'Rate*',
-		'oldfieldname': u'basic_rate',
-		'oldfieldtype': u'Currency',
-		'permlevel': 0,
-		'print_hide': 1,
-		'reqd': 0,
-		'trigger': u'Client',
-		'width': u'150px'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'amount',
-		'fieldtype': u'Currency',
-		'label': u'Amount*',
-		'oldfieldname': u'amount',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1,
-		'print_hide': 1,
-		'reqd': 0,
-		'width': u'100px'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
 		'fieldname': u'warehouse',
 		'fieldtype': u'Link',
 		'label': u'Warehouse',
@@ -245,7 +245,7 @@
 		'oldfieldname': u'serial_no',
 		'oldfieldtype': u'Text',
 		'permlevel': 0,
-		'print_hide': 1,
+		'print_hide': 0,
 		'trigger': u'Client'
 	},
 
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index 0f6d1a8..7ad9d91 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -40,12 +40,15 @@
 
 cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
 	var callback = function(doc, dt, dn) {
-		if(doc.__islocal){ 
-			cur_frm.cscript.get_default_schedule_date(doc);
+		var callback1 = function(doc, dt, dn) {
+			if(doc.__islocal){ 
+				cur_frm.cscript.get_default_schedule_date(doc);
+			}
 		}
+		// defined in purchase_common.js
+		cur_frm.cscript.update_item_details(doc, dt, dn, callback1);	
 	}
-	// defined in purchase_common.js
-	cur_frm.cscript.update_item_details(doc, cdt, cdn, callback);	
+	cur_frm.cscript.dynamic_label(doc, dt, dn, callback);
 }
 
 //========================== Refresh ===============================================================
@@ -55,7 +58,8 @@
 	// ---------------------------------
 	cur_frm.clear_custom_buttons();
 
-	cur_frm.cscript.dynamic_label(doc, cdt, cdn);
+	if (!cur_frm.cscript.is_onload) cur_frm.cscript.dynamic_label(doc, cdt, cdn);
+
 
 	if(doc.docstatus == 1){
 		var ch = getchildren('Purchase Receipt Detail',doc.name,'purchase_receipt_details');
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 530afcf..88cfbe3 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -57,7 +57,7 @@
 
 #-----------------Validation For Fiscal Year------------------------
 	def validate_fiscal_year(self):
-		get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Transaction Date')
+		get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Transaction Date')
 
 
 	# Get Item Details
@@ -88,10 +88,6 @@
 	def get_tc_details(self):
 		return get_obj('Purchase Common').get_tc_details(self)
 
-	def get_comp_base_currency(self):
-		return get_obj('Purchase Common').get_comp_base_currency(self.doc.company)
-
-
 
 	# get available qty at warehouse
 	def get_bin_details(self, arg = ''):
@@ -230,7 +226,7 @@
 
 					ord_qty = -flt(curr_qty)
 					# update order qty in bin
-					bin = get_obj('Warehouse', d.warehouse).update_bin(0, 0, (is_submit and 1 or -1) * flt(ord_qty), 0, 0, d.item_code, self.doc.transaction_date)
+					bin = get_obj('Warehouse', d.warehouse).update_bin(0, 0, (is_submit and 1 or -1) * flt(ord_qty), 0, 0, d.item_code, self.doc.posting_date)
 
 				# UPDATE actual qty to warehouse by pr_qty
 				self.make_sl_entry(d, d.warehouse, flt(pr_qty), d.valuation_rate, is_submit)
@@ -249,7 +245,7 @@
 		self.values.append({
 			'item_code'					 : d.fields.has_key('item_code') and d.item_code or d.rm_item_code,
 			'warehouse'					 : wh,
-			'transaction_date'		: self.doc.transaction_date,
+			'transaction_date'			: getdate(self.doc.modified).strftime('%Y-%m-%d'),
 			'posting_date'				: self.doc.posting_date,
 			'posting_time'				: self.doc.posting_time,
 			'voucher_type'				: 'Purchase Receipt',
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.txt b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.txt
index 2666f08..525bcfc 100755
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.txt
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.txt
@@ -5,14 +5,14 @@
 	{
 		'creation': '2010-08-08 17:09:15',
 		'docstatus': 0,
-		'modified': '2012-02-27 17:54:59',
+		'modified': '2012-03-02 12:26:39',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': u'1330345245',
+		'_last_update': u'1330593645',
 		'colour': u'White:FFF',
 		'default_print_format': u'Standard',
 		'doctype': 'DocType',
@@ -26,7 +26,7 @@
 		'server_code_error': u' ',
 		'show_in_menu': 0,
 		'subject': u'From %(supplier_name)s against %(purchase_order)s on %(transaction_date)s',
-		'version': 324
+		'version': 325
 	},
 
 	# These values are common for all DocField
@@ -305,25 +305,6 @@
 	# DocField
 	{
 		'colour': u'White:FFF',
-		'description': u'The date at which current entry is made in system.',
-		'doctype': u'DocField',
-		'fieldname': u'transaction_date',
-		'fieldtype': u'Date',
-		'in_filter': 1,
-		'label': u'Transaction Date',
-		'no_copy': 1,
-		'oldfieldname': u'transaction_date',
-		'oldfieldtype': u'Date',
-		'permlevel': 0,
-		'reqd': 1,
-		'search_index': 1,
-		'trigger': u'Client',
-		'width': u'100px'
-	},
-
-	# DocField
-	{
-		'colour': u'White:FFF',
 		'description': u'The date at which current entry will get or has actually executed.',
 		'doctype': u'DocField',
 		'fieldname': u'posting_date',
@@ -948,6 +929,7 @@
 		'fieldtype': u'Column Break',
 		'oldfieldtype': u'Column Break',
 		'permlevel': 0,
+		'print_hide': 1,
 		'width': u'50%'
 	},
 
@@ -1120,7 +1102,8 @@
 		'fieldtype': u'Section Break',
 		'label': u'Raw Material Details',
 		'oldfieldtype': u'Section Break',
-		'permlevel': 1
+		'permlevel': 1,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -1130,7 +1113,8 @@
 		'label': u'Get Current Stock',
 		'oldfieldtype': u'Button',
 		'options': u'get_current_stock',
-		'permlevel': 0
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
diff --git a/erpnext/stock/doctype/purchase_receipt_detail/purchase_receipt_detail.txt b/erpnext/stock/doctype/purchase_receipt_detail/purchase_receipt_detail.txt
index 7f63644..4ebd28c 100755
--- a/erpnext/stock/doctype/purchase_receipt_detail/purchase_receipt_detail.txt
+++ b/erpnext/stock/doctype/purchase_receipt_detail/purchase_receipt_detail.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:16',
 		'docstatus': 0,
-		'modified': '2012-02-27 18:43:39',
+		'modified': '2012-03-05 10:51:18',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -22,7 +22,7 @@
 		'section_style': u'Tray',
 		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'version': 74
+		'version': 76
 	},
 
 	# These values are common for all DocField
@@ -95,6 +95,7 @@
 		'oldfieldname': u'received_qty',
 		'oldfieldtype': u'Currency',
 		'permlevel': 0,
+		'print_hide': 1,
 		'reqd': 1,
 		'trigger': u'Client',
 		'width': u'100px'
@@ -125,6 +126,7 @@
 		'oldfieldname': u'rejected_qty',
 		'oldfieldtype': u'Currency',
 		'permlevel': 0,
+		'print_hide': 1,
 		'search_index': 0,
 		'trigger': u'Client',
 		'width': u'100px'
@@ -133,10 +135,11 @@
 	# DocField
 	{
 		'doctype': u'DocField',
-		'fieldname': u'import_ref_rate',
+		'fieldname': u'purchase_ref_rate',
 		'fieldtype': u'Currency',
-		'label': u'Ref Rate ',
-		'permlevel': 0
+		'label': u'Ref Rate *',
+		'permlevel': 0,
+		'print_hide': 1
 	},
 
 	# DocField
@@ -145,43 +148,8 @@
 		'fieldname': u'discount_rate',
 		'fieldtype': u'Currency',
 		'label': u'Discount  %',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'colour': u'White:FFF',
-		'default': u'0.00',
-		'doctype': u'DocField',
-		'fieldname': u'import_rate',
-		'fieldtype': u'Currency',
-		'label': u'Rate',
-		'oldfieldname': u'import_rate',
-		'oldfieldtype': u'Currency',
 		'permlevel': 0,
-		'print_hide': 0,
-		'trigger': u'Client',
-		'width': u'100px'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'import_amount',
-		'fieldtype': u'Currency',
-		'label': u'Amount',
-		'oldfieldname': u'import_amount',
-		'oldfieldtype': u'Currency',
-		'permlevel': 1
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'purchase_ref_rate',
-		'fieldtype': u'Currency',
-		'label': u'Ref Rate *',
-		'permlevel': 0
+		'print_hide': 1
 	},
 
 	# DocField
@@ -220,6 +188,43 @@
 	# DocField
 	{
 		'doctype': u'DocField',
+		'fieldname': u'import_ref_rate',
+		'fieldtype': u'Currency',
+		'label': u'Ref Rate ',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		'default': u'0.00',
+		'doctype': u'DocField',
+		'fieldname': u'import_rate',
+		'fieldtype': u'Currency',
+		'label': u'Rate',
+		'oldfieldname': u'import_rate',
+		'oldfieldtype': u'Currency',
+		'permlevel': 0,
+		'print_hide': 0,
+		'trigger': u'Client',
+		'width': u'100px'
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'import_amount',
+		'fieldtype': u'Currency',
+		'label': u'Amount',
+		'oldfieldname': u'import_amount',
+		'oldfieldtype': u'Currency',
+		'permlevel': 1
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
 		'fieldname': u'warehouse',
 		'fieldtype': u'Link',
 		'hidden': 0,
@@ -228,7 +233,7 @@
 		'oldfieldtype': u'Link',
 		'options': u'Warehouse',
 		'permlevel': 0,
-		'print_hide': 0,
+		'print_hide': 1,
 		'width': u'100px'
 	},
 
@@ -243,6 +248,7 @@
 		'oldfieldtype': u'Link',
 		'options': u'UOM',
 		'permlevel': 0,
+		'print_hide': 1,
 		'reqd': 1,
 		'trigger': u'Client',
 		'width': u'100px'
@@ -441,7 +447,7 @@
 		'oldfieldtype': u'Link',
 		'options': u'Purchase Order',
 		'permlevel': 1,
-		'print_hide': 0,
+		'print_hide': 1,
 		'reqd': 0,
 		'search_index': 1,
 		'width': u'150px'
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 0eb78df..1e558c9 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -51,7 +51,7 @@
     hide_field(lst);
     unhide_field(['supplier','supplier_name','supplier_address','purchase_receipt_no']);
   }
-  if(doc.purpose == 'Sales Return'){
+  else if(doc.purpose == 'Sales Return'){
     doc.supplier=doc.supplier_name = doc.supplier_address=doc.purchase_receipt_no='';
     hide_field(lst);
     unhide_field(['customer','customer_name','customer_address','delivery_note_no', 'sales_invoice_no']);
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 6d080a8..530c5e6 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -453,8 +453,8 @@
 					if self.doc.purpose == 'Purchase Return':
 						#delete_doc("Serial No", serial_no)
 						serial_doc = Document("Serial No", serial_no)
-						serial_doc.status = 'Purchase Returned'
-						serial_doc.docstatus = 2
+						serial_doc.status = is_submit and 'Purchase Returned' or 'In Store'
+						serial_doc.docstatus = is_submit and 2 or 0
 						serial_doc.save()
 
 
diff --git a/erpnext/stock/page/stock_home/stock_home.html b/erpnext/stock/page/stock_home/stock_home.html
index 9ba21a4..bab93dc 100644
--- a/erpnext/stock/page/stock_home/stock_home.html
+++ b/erpnext/stock/page/stock_home/stock_home.html
@@ -4,7 +4,7 @@
 		<h1>Stock</h1>
 		<hr>
 		<div style="width: 48%; float: left;">
-			<h4><a ahref="#!List/Stock Entry">Stock Entry</a></h4>
+			<h4><a href="#!List/Stock Entry">Stock Entry</a></h4>
 			<p class="help">Transfer stock from one warehouse to another</p>
 			<h4><a href="#!List/Delivery Note">Delivery Note</a></h4>
 			<p class="help">Delivery (shipment) to customers</p>
diff --git a/erpnext/support/doctype/customer_issue/customer_issue.py b/erpnext/support/doctype/customer_issue/customer_issue.py
index b00a6a0..af839cf 100644
--- a/erpnext/support/doctype/customer_issue/customer_issue.py
+++ b/erpnext/support/doctype/customer_issue/customer_issue.py
@@ -15,6 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # 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
diff --git a/erpnext/support/doctype/support_ticket/__init__.py b/erpnext/support/doctype/support_ticket/__init__.py
index c9d1958..ca27a61 100644
--- a/erpnext/support/doctype/support_ticket/__init__.py
+++ b/erpnext/support/doctype/support_ticket/__init__.py
@@ -29,6 +29,7 @@
 
 		# extract email settings
 		self.email_settings = Document('Email Settings','Email Settings')
+		if not self.email_settings.fields.get('sync_support_mails'): return
 		
 		s = Document('Support Email Settings')
 		s.use_ssl = self.email_settings.support_use_ssl
diff --git a/erpnext/support/doctype/support_ticket/support_ticket.js b/erpnext/support/doctype/support_ticket/support_ticket.js
index 02c9a5d..86264a6 100644
--- a/erpnext/support/doctype/support_ticket/support_ticket.js
+++ b/erpnext/support/doctype/support_ticket/support_ticket.js
@@ -178,7 +178,8 @@
 		// email text
 		this.message = $a(w, 'div', '', 
 			// style
-			{lineHeight:'1.7em', display:'none', padding: '7px'}, 
+			{lineHeight:'1.7em', display:'none', padding: '7px', width: '575px',
+				wordWrap: 'break-word', textWrap: 'normal', overflowX: 'auto'}, 
 			
 			// newlines for text email
 			(this.content_type=='text/plain' ? this.mail
diff --git a/erpnext/utilities/__init__.py b/erpnext/utilities/__init__.py
index 28eacce..d57f0de 100644
--- a/erpnext/utilities/__init__.py
+++ b/erpnext/utilities/__init__.py
@@ -23,6 +23,7 @@
 		distinct criteria_name, doc_type, parent_doc_type
 		from `tabSearch Criteria` 
 		where module='%(module)s' 
-		and docstatus in (0, NULL) 
+		and docstatus in (0, NULL)
+		and ifnull(disabled, 0) = 0 
 		order by criteria_name 
 		limit %(limit_start)s, %(limit_page_length)s""" % webnotes.form_dict, as_dict=True)
\ No newline at end of file
diff --git a/erpnext/utilities/page/messages/messages.js b/erpnext/utilities/page/messages/messages.js
index 39f7974..6937796 100644
--- a/erpnext/utilities/page/messages/messages.js
+++ b/erpnext/utilities/page/messages/messages.js
@@ -1,8 +1,25 @@
+// ERPNext - web based ERP (http://erpnext.com)
+// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+// 
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
 wn.provide('erpnext.messages');
 
 wn.pages.messages.onload = function(wrapper) {
 	erpnext.messages.show_active_users();
 	erpnext.messages.make_list();
+	update_messages('reset'); //Resets notification icons
 	
 	// post message
 	$('#message-post').click(function() {
@@ -49,7 +66,7 @@
 		$(wn.pages.messages).find('.well').toggle(contact==user ? false : true);
 
 		$(wn.pages.messages).find('h1:first').html('Messages: ' 
-			+ (user==contact ? 'From everyone' : wn.boot.user_fullnames[contact]))
+			+ (user==contact ? 'From everyone' : wn.user_info(contact).fullname));
 
 		erpnext.messages.contact = contact;
 		erpnext.messages.list.opts.args.contact = contact;
@@ -82,7 +99,7 @@
 			},
 			render_row: function(wrapper, data) {
 				data.creation = dateutil.comment_when(data.creation);
-				data.comment_by_fullname = wn.boot.user_fullnames[data.owner];
+				data.comment_by_fullname = wn.user_info(data.owner).fullname;
 
 				data.reply_html = '';
 				if(data.owner==user) {
@@ -127,7 +144,7 @@
 				var $body = $(wn.pages.messages).find('.section-body');
 				for(var i in r.message) {
 					var p = r.message[i];
-					p.fullname = wn.boot.user_fullnames[p.name];
+					p.fullname = wn.user_info(p.name).fullname;
 					p.name = p.name.replace('@', '__at__');
 					$body.append(repl('<div class="section-item">\
 						<a href="#!messages/%(name)s">%(fullname)s</a></div>', p))
diff --git a/erpnext/utilities/page/messages/messages.py b/erpnext/utilities/page/messages/messages.py
index d7c6026..b282991 100644
--- a/erpnext/utilities/page/messages/messages.py
+++ b/erpnext/utilities/page/messages/messages.py
@@ -1,3 +1,19 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
 import webnotes
 
 @webnotes.whitelist()
@@ -32,7 +48,8 @@
 @webnotes.whitelist()
 def get_active_users(arg=None):
 	return webnotes.conn.sql("""select name from tabProfile 
-		where enabled=1 and
+		where ifnull(enabled,0)=1 and
+		docstatus < 2 and 
 		name not in ('Administrator', 'Guest') 
 		order by first_name""", as_dict=1)
 
diff --git a/erpnext/utilities/page/todo/todo.js b/erpnext/utilities/page/todo/todo.js
index 77e4625..dfaa7cd 100644
--- a/erpnext/utilities/page/todo/todo.js
+++ b/erpnext/utilities/page/todo/todo.js
@@ -1,3 +1,19 @@
+// ERPNext - web based ERP (http://erpnext.com)
+// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+// 
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
 wn.provide('erpnext.todo');
 
 erpnext.todo.refresh = function() {
@@ -30,14 +46,22 @@
 		}
 		todo.labelclass = label_map[todo.priority];
 		todo.userdate = dateutil.str_to_user(todo.date);
+		if(todo.reference_name && todo.reference_type) {
+			todo.link = repl('<a href="#!Form/%(reference_type)s/%(reference_name)s">\
+						%(reference_name)s</a>', todo);
+		} else if(todo.reference_type) {
+			todo.link = repl('<a href="#!List/%(reference_type)s">\
+						%(reference_type)s</a>', todo);
+		} else {
+			todo.link = '';
+		}
 		$('#todo-list').append(repl('<div class="todoitem">\
 				<span class="description">\
 					<span class="label %(labelclass)s">%(priority)s</span>\
 					<span class="help" style="margin-right: 7px">%(userdate)s</span>\
 					%(description)s</span>\
 					<span class="ref_link">&rarr;\
-					<a href="#!Form/%(reference_type)s/%(reference_name)s">\
-						[%(reference_name)s]</a></span>\
+					%(link)s</span>\
 					<a href="#" class="close">&times;</a>\
 		</div>', todo));
 		$todo = $('div.todoitem:last');
@@ -46,7 +70,7 @@
 			$todo.find('.description').css('text-decoration', 'line-through');
 		}
 		
-		if(!todo.reference_name)
+		if(!todo.reference_type)
 			$todo.find('.ref_link').toggle(false);
 		
 		$todo.find('.description')
@@ -129,4 +153,4 @@
 wn.pages.todo.onload = function() {
 	// load todos
 	erpnext.todo.refresh();
-}
\ No newline at end of file
+}
diff --git a/erpnext/utilities/page/todo/todo.py b/erpnext/utilities/page/todo/todo.py
index c10809e..05d55fe 100644
--- a/erpnext/utilities/page/todo/todo.py
+++ b/erpnext/utilities/page/todo/todo.py
@@ -1,3 +1,19 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
 import webnotes
 from webnotes.model.doc import Document
 
diff --git a/erpnext/utilities/page/users/__init__.py b/erpnext/utilities/page/users/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/utilities/page/users/__init__.py
diff --git a/erpnext/utilities/page/users/users.css b/erpnext/utilities/page/users/users.css
new file mode 100644
index 0000000..1a85d15
--- /dev/null
+++ b/erpnext/utilities/page/users/users.css
@@ -0,0 +1,35 @@
+.user-card {
+	border-radius: 5px;
+	width: 200px;
+	margin: 11px;
+	padding: 11px;
+	background-color: #FFEDBD;
+	box-shadow: 3px 3px 5px #888;
+	float: left;
+	overflow: hidden;
+}
+
+.user-card.disabled {
+	background-color: #eee;
+}
+
+.user-card img {
+	height: 60px;
+}
+
+.user-role {
+	padding: 5px;
+	width: 45%;
+	float: left;
+}
+
+table.user-perm {
+	border-collapse: collapse;
+}
+
+table.user-perm td, table.user-perm th {
+	padding: 5px;
+	text-align: center;
+	border-bottom: 1px solid #aaa;
+	min-width: 30px;
+}
\ No newline at end of file
diff --git a/erpnext/utilities/page/users/users.html b/erpnext/utilities/page/users/users.html
new file mode 100644
index 0000000..fe2f000
--- /dev/null
+++ b/erpnext/utilities/page/users/users.html
@@ -0,0 +1,13 @@
+<div class="layout-wrapper">
+	<a class="close" onclick="window.history.back();">&times;</a>		
+	<h1>Users</h1>
+	<hr>
+	<div class="help" style="margin-bottom: 20px">Add, disable, delete users and change their roles, passwords and security settings</div>
+	<div style="margin: 11px">
+		<button class="btn btn-small add-user" onclick="wn.pages.users.add_user()"
+			><i class="icon-plus"></i> Add User</button>
+	</div>
+	<div class="users-area">
+	</div>
+	<div style="clear: both"></div>
+</div>
\ No newline at end of file
diff --git a/erpnext/utilities/page/users/users.js b/erpnext/utilities/page/users/users.js
new file mode 100644
index 0000000..130e538
--- /dev/null
+++ b/erpnext/utilities/page/users/users.js
@@ -0,0 +1,378 @@
+// ERPNext - web based ERP (http://erpnext.com)
+// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+// 
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+$.extend(wn.pages.users, {
+	onload: function(wrapper) {
+		wn.pages.users.profiles = {};
+		wn.pages.users.refresh();
+		wn.pages.users.setup();
+		wn.pages.users.role_editor = new erpnext.RoleEditor();
+	},
+	setup: function() {
+		// set roles
+		$('.users-area').on('click', '.btn.user-roles', function() {
+			var uid = $(this).parent().parent().attr('data-name');
+			wn.pages.users.role_editor.show(uid);
+		});
+
+		// settings
+		$('.users-area').on('click', '.btn.user-settings', function() {
+			var uid = $(this).parent().parent().attr('data-name');
+			wn.pages.users.show_settings(uid);
+		});
+		
+		// delete
+		$('.users-area').on('click', 'a.close', function() {
+			$card = $(this).parent();
+			var uid = $card.attr('data-name');
+			$card.css('opacity', 0.6);
+			wn.call({
+				method: 'utilities.page.users.users.delete',
+				args: {'uid': uid},
+				callback: function(r,rt) {
+					if(!r.exc)
+						$card.fadeOut()
+				}
+			});
+		})
+		
+	},
+	refresh: function() {
+		// make the list
+		wn.call({
+			method:'utilities.page.users.users.get',
+			callback: function(r, rt) {
+				$('.users-area').empty();
+				for(var i in r.message) {
+					var p = r.message[i];
+					wn.pages.users.profiles[p.name] = p;
+					wn.pages.users.render(p);
+				}
+			}
+		});
+	},
+	render: function(data) {
+		if(data.file_list) {
+			data.imgsrc = 'files/' + data.file_list.split('\n')[0].split(',')[1];
+		} else {
+			data.imgsrc = 'lib/images/ui/no_img_' + (data.gender=='Female' ? 'f' : 'm') + '.gif';
+		}
+		data.fullname = wn.user_info(data.name).fullname;
+		data.delete_html = '';
+		if(!data.enabled) 
+			data.delete_html = '<a class="close" title="delete">&times;</a>';
+		
+		$('.users-area').append(repl('<div class="user-card" data-name="%(name)s">\
+			%(delete_html)s\
+			<img src="%(imgsrc)s">\
+			<div class="user-info">\
+				<b class="user-fullname">%(fullname)s</b><br>\
+				%(name)s<br>\
+				<button class="btn btn-small user-roles"><i class="icon-user"></i> Roles</button>\
+				<button class="btn btn-small user-settings"><i class="icon-cog"></i> Settings</button>\
+			</div>\
+		</div>', data));
+		
+		if(!data.enabled) {
+			$('.users-area .user-card:last')
+				.addClass('disabled')
+				.find('.user-fullname').html('Disabled');
+		}
+	},
+	show_settings: function(uid) {
+		var me = wn.pages.users;
+		if(!me.settings_dialog)
+			me.make_settings_dialog();
+		
+		var p = me.profiles[uid];
+		me.uid = uid;
+		
+		me.settings_dialog.set_values({
+			restrict_ip: p.restrict_ip || '',
+			login_before: p.login_before || '',
+			login_after: p.login_after || '',
+			enabled: p.enabled || 0,
+			new_password: ''
+		});
+		
+		me.settings_dialog.show();
+
+	},
+	make_settings_dialog: function() {
+		var me = wn.pages.users;
+		me.settings_dialog = new wn.widgets.Dialog({
+			title: 'Set User Security',
+			width: 500,
+			fields: [
+				{
+					label:'Enabled',
+					description: 'Uncheck to disable',
+					fieldtype: 'Check', fieldname: 'enabled'
+				},
+				{
+					label:'IP Address', 
+					description: 'Restrict user login by IP address, partial ips (111.111.111), \
+					multiple addresses (separated by commas) allowed', 
+					fieldname:'restrict_ip', fieldtype:'Data'
+				},
+				{
+					label:'Login After',
+					description: 'User can only login after this hour (0-24)',
+					fieldtype: 'Int', fieldname: 'login_after'
+				},
+				{
+					label:'Login Before',
+					description: 'User can only login before this hour (0-24)',
+					fieldtype: 'Int', fieldname: 'login_before'
+				},
+				{
+					label:'New Password',
+					description: 'Update the current user password',
+					fieldtype: 'Data', fieldname: 'new_password'
+				},
+				{
+					label:'Update', fieldtype:'Button', fieldname:'update'
+				}
+			]
+		});
+
+		this.settings_dialog.fields_dict.update.input.onclick = function() {
+			var btn = this;
+			var args = me.settings_dialog.get_values();
+			args.user = me.uid;
+
+			if (args.new_password) {
+				me.get_password(btn, args);
+			} else {
+				me.update_security(btn, args);
+			}
+		};
+		
+	},
+	update_security: function(btn, args) {
+		var me = wn.pages.users;
+		$(btn).set_working();
+		$c_page('utilities', 'users', 'update_security', JSON.stringify(args), function(r,rt) {
+			$(btn).done_working();
+			if(r.exc) {
+				msgprint(r.exc);				
+				return;
+			}
+			me.settings_dialog.hide();
+			$.extend(me.profiles[me.uid], me.settings_dialog.get_values());
+			me.refresh();
+		});
+	},
+	get_password: function(btn, args) {
+		var me = wn.pages.users;
+		var pass_d = new wn.widgets.Dialog({
+			title: 'Your Password',
+			width: 300,
+			fields: [
+				{
+					label: 'Please Enter <b style="color: black">Your Password</b>',
+					description: "Your password is required to update the user's password",
+					fieldtype: 'Password', fieldname: 'sys_admin_pwd', reqd: 1		
+				},
+				{
+					label: 'Continue', fieldtype: 'Button', fieldname: 'continue'
+				}
+			]
+		});
+
+		pass_d.fields_dict.continue.input.onclick = function() {
+			btn.pwd_dialog.hide();					
+			args.sys_admin_pwd = btn.pwd_dialog.get_values().sys_admin_pwd;					
+			btn.set_working();					
+			me.update_security(btn, args);
+			btn.done_working();
+		}
+
+		pass_d.show();
+		btn.pwd_dialog = pass_d;
+		btn.done_working();	
+	},
+	add_user: function() {
+		var me = wn.pages.users;
+		var d = new wn.widgets.Dialog({
+			title: 'Add User',
+			width: 400,
+			fields: [{
+					fieldtype: 'Data', fieldname: 'user', reqd: 1, 
+					label: 'Email Id of the user to add'
+				}, {
+					fieldtype: 'Data', fieldname: 'first_name', reqd: 1, label: 'First Name'
+				}, {
+					fieldtype: 'Data', fieldname: 'last_name', label: 'Last Name'
+				}, {
+					fieldtype: 'Data', fieldname: 'password', reqd: 1, label: 'Password'
+				}, {
+					fieldtype: 'Button', label: 'Add', fieldname: 'add'
+				}]
+		});
+		
+		d.make();
+		d.fields_dict.add.input.onclick = function() {
+			v = d.get_values();
+			if(v) {
+				d.fields_dict.add.input.set_working();
+				$c_page('utilities', 'users', 'add_user', v, function(r,rt) {
+					if(r.exc) { msgprint(r.exc); return; }
+					else {
+						wn.boot.user_info[v.user] = {fullname:v.first_name + ' ' + v.last_name};
+						d.hide();
+						me.refresh();
+					}
+				})
+			}
+		}
+		d.show();		
+	}
+});
+
+erpnext.RoleEditor = Class.extend({
+	init: function() {
+		this.dialog = new wn.widgets.Dialog({
+			title: 'Set Roles'
+		});
+		var me = this;
+		$(this.dialog.body).html('<div class="help">Loading...</div>')
+		wn.call({
+			method:'utilities.page.users.users.get_roles',
+			callback: function(r) {
+				me.roles = r.message;
+				me.show_roles();
+			}
+		});
+	},
+	show_roles: function() {
+		var me = this;
+		$(this.dialog.body).empty();
+		for(var i in this.roles) {
+			$(this.dialog.body).append(repl('<div class="user-role" \
+				data-user-role="%(role)s">\
+				<input type="checkbox"> \
+				<a href="#"><i class="icon-question-sign"></i></a> %(role)s\
+			</div>', {role: this.roles[i]}));
+		}
+		$(this.dialog.body).append('<div style="clear: both">\
+			<button class="btn btn-small btn-primary">Save</button></div>');
+		$(this.dialog.body).find('button.btn-primary').click(function() {
+			me.save();
+		});
+		$(this.dialog.body).find('.user-role a').click(function() {
+			me.show_permissions($(this).parent().attr('data-user-role'))
+			return false;
+		})
+	},
+	show: function(uid) {
+		var me = this;
+		this.uid = uid;
+		this.dialog.show();
+		// set user roles
+		wn.call({
+			method:'utilities.page.users.users.get_user_roles',
+			args: {uid:uid},
+			callback: function(r, rt) {
+				$(me.dialog.body).find('input[type="checkbox"]').attr('checked', false);
+				for(var i in r.message) {
+					$(me.dialog.body)
+						.find('[data-user-role="'+r.message[i]
+							+'"] input[type="checkbox"]').attr('checked',true);
+				}
+			}
+		})
+	},
+	save: function() {
+		var set_roles = [];
+		var unset_roles = [];
+		$(this.dialog.body).find('[data-user-role]').each(function() {
+			var $check = $(this).find('input[type="checkbox"]');
+			if($check.attr('checked')) {
+				set_roles.push($(this).attr('data-user-role'));
+			} else {
+				unset_roles.push($(this).attr('data-user-role'));
+			}
+		})
+		wn.call({
+			method:'utilities.page.users.users.update_roles',
+			args: {
+				set_roles: JSON.stringify(set_roles),
+				unset_roles: JSON.stringify(unset_roles),
+				uid: this.uid
+			},
+			btn: $(this.dialog.body).find('.btn-primary').get(0),
+			callback: function() {
+				
+			}
+		})
+	},
+	show_permissions: function(role) {
+		// show permissions for a role
+		var me = this;
+		if(!this.perm_dialog)
+			this.make_perm_dialog()
+		$(this.perm_dialog.body).empty();
+		wn.call({
+			method:'utilities.page.users.users.get_perm_info',
+			args: {role: role},
+			callback: function(r) {
+				var $body = $(me.perm_dialog.body);
+				$body.append('<table class="user-perm"><tbody><tr>\
+					<th style="text-align: left">Document Type</th>\
+					<th>Level</th>\
+					<th>Read</th>\
+					<th>Write</th>\
+					<th>Submit</th>\
+					<th>Cancel</th>\
+					<th>Amend</th></tr></tbody></table>');
+				for(var i in r.message) {
+					var perm = r.message[i];
+					
+					// if permission -> icon
+					for(key in perm) {
+						if(key!='parent' && key!='permlevel') {
+							if(perm[key]) {
+								perm[key] = '<i class="icon-ok"></i>';
+							} else {
+								perm[key] = '';
+							}							
+						}
+					}
+					
+					$body.find('tbody').append(repl('<tr>\
+						<td style="text-align: left">%(parent)s</td>\
+						<td>%(permlevel)s</td>\
+						<td>%(read)s</td>\
+						<td>%(write)s</td>\
+						<td>%(submit)s</td>\
+						<td>%(cancel)s</td>\
+						<td>%(amend)s</td>\
+						</tr>', perm))
+				}
+				
+				me.perm_dialog.show();
+			}
+		});
+		
+	},
+	make_perm_dialog: function() {
+		this.perm_dialog = new wn.widgets.Dialog({
+			title:'Role Permissions',
+			width: 500
+		});
+	}
+})
diff --git a/erpnext/utilities/page/users/users.py b/erpnext/utilities/page/users/users.py
new file mode 100644
index 0000000..f2bb1a5
--- /dev/null
+++ b/erpnext/utilities/page/users/users.py
@@ -0,0 +1,193 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import webnotes
+import json
+
+from webnotes.model.doc import Document
+from webnotes.utils import cint
+
+@webnotes.whitelist()
+def get(arg=None):
+	"""return all users"""
+	return webnotes.conn.sql("""select name, file_list, enabled, gender,
+	 	restrict_ip, login_before, login_after from tabProfile
+		where docstatus<2 and name not in ('Administrator', 'Guest') order by
+		ifnull(enabled,0) desc, name""", as_dict=1)
+
+@webnotes.whitelist()
+def get_roles(arg=None):
+	"""return all roles"""
+	return [r[0] for r in webnotes.conn.sql("""select name from tabRole
+		where name not in ('Administrator', 'Guest', 'All') order by name""")]
+
+@webnotes.whitelist()
+def get_user_roles(arg=None):
+	"""get roles for a user"""
+	return [r[0] for r in webnotes.conn.sql("""select role from tabUserRole
+		where parent=%s""", webnotes.form_dict['uid'])]
+
+@webnotes.whitelist()
+def get_perm_info(arg=None):
+	"""get permission info"""
+	return webnotes.conn.sql("""select parent, permlevel, `read`, `write`, submit,
+		cancel, amend from tabDocPerm where role=%s 
+		and docstatus<2 order by parent, permlevel""", 
+			webnotes.form_dict['role'], as_dict=1)
+
+@webnotes.whitelist()
+def update_roles(arg=None):
+	"""update set and unset roles"""
+	# remove roles
+	unset = json.loads(webnotes.form_dict['unset_roles'])
+	webnotes.conn.sql("""delete from tabUserRole where parent='%s' 
+		and role in ('%s')""" % (webnotes.form_dict['uid'], "','".join(unset)))
+
+	# check for 1 system manager
+	if not webnotes.conn.sql("""select parent from tabUserRole where role='System Manager'
+		and docstatus<2"""):
+		webnotes.msgprint("Sorry there must be atleast one 'System Manager'")
+		raise webnotes.ValidationError
+
+	# add roles
+	roles = get_user_roles()
+	toset = json.loads(webnotes.form_dict['set_roles'])
+	for role in toset:
+		if not role in roles:
+			d = Document('UserRole')
+			d.role = role
+			d.parent = webnotes.form_dict['uid']
+			d.save()
+	
+	webnotes.msgprint('Roles Updated')
+
+@webnotes.whitelist()
+def update_security(args=''):
+	args = json.loads(args)
+	webnotes.conn.set_value('Profile', args['user'], 'restrict_ip', args.get('restrict_ip'))
+	webnotes.conn.set_value('Profile', args['user'], 'login_after', args.get('login_after'))
+	webnotes.conn.set_value('Profile', args['user'], 'login_before', args.get('login_before'))
+	webnotes.conn.set_value('Profile', args['user'], 'enabled', int(args.get('enabled',0)) or 0)
+
+	if args.get('new_password') and args.get('sys_admin_pwd'):
+		if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
+			import server_tools.gateway_utils
+			res = server_tools.gateway_utils.change_password('', args['new_password'], 
+				args['user'], args['sys_admin_pwd'])
+			if 'Traceback' not in res['message']:
+				webnotes.msgprint(res['message'])
+		webnotes.conn.sql("update tabProfile set password=password(%s) where name=%s", 
+			(args['new_password'], args['user']))
+	else: 
+		webnotes.msgprint('Settings Updated')
+
+
+
+#
+# user addition
+#
+
+@webnotes.whitelist()
+def add_user(args):
+	args = json.loads(args)
+	# erpnext-saas
+	if cint(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')):
+		from server_tools.gateway_utils import add_user_gateway
+		add_user_gateway(args)
+	
+	add_profile(args)
+	
+@webnotes.whitelist()
+def add_profile(args):
+	from webnotes.utils import validate_email_add, now
+	email = args['user']
+			
+	sql = webnotes.conn.sql
+	
+	if not email:
+		email = webnotes.form_dict.get('user')
+	if not validate_email_add(email):
+		raise Exception
+		return 'Invalid Email Id'
+	
+	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 with new password')
+	else:
+		# does not exist, create it!
+		pr = Document('Profile')
+		pr.name = email
+		pr.email = email
+		pr.first_name = args.get('first_name')
+		pr.last_name = args.get('last_name')
+		pr.enabled = 1
+		pr.user_type = 'System User'
+		pr.save(1)
+
+	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)
+
+@webnotes.whitelist()
+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': args.get('password'),
+		'account_url': webnotes.conn.get_value('Website Settings',
+			'Website Settings', 'subdomain') or ""
+	})
+	if not args.get('last_name'): args['last_name'] = ''
+	sendmail_md(pr.email, subject="Welcome to ERPNext", msg=welcome_txt % args, from_defs=1)
+
+#
+# delete user
+#
+@webnotes.whitelist()
+def delete(arg=None):
+	"""delete user"""
+	webnotes.conn.sql("update tabProfile set enabled=0, docstatus=2 where name=%s", 
+		webnotes.form_dict['uid'])
+	# erpnext-saas
+	if int(webnotes.conn.get_value('Control Panel', None, 'sync_with_gateway')):
+		from server_tools.gateway_utils import remove_user_gateway
+		remove_user_gateway(webnotes.form_dict['uid'])
+
+	webnotes.login_manager.logout(user=webnotes.form_dict['uid'])
+	
+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: %(user)s
+password: %(password)s
+
+To login to your new ERPNext account, please go to:
+
+%(account_url)s
+"""
diff --git a/erpnext/utilities/page/users/users.txt b/erpnext/utilities/page/users/users.txt
new file mode 100644
index 0000000..165cc16
--- /dev/null
+++ b/erpnext/utilities/page/users/users.txt
@@ -0,0 +1,28 @@
+# Page, users
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2012-02-28 10:29:39',
+		'docstatus': 0,
+		'modified': '2012-02-28 10:29:39',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
+	},
+
+	# These values are common for all Page
+	{
+		'doctype': 'Page',
+		'module': u'Utilities',
+		'name': '__common__',
+		'page_name': u'users',
+		'standard': u'Yes',
+		'title': u'Users'
+	},
+
+	# Page, users
+	{
+		'doctype': 'Page',
+		'name': u'users'
+	}
+]
\ No newline at end of file
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/erpnext/website/page/website_home/website_home.html b/erpnext/website/page/website_home/website_home.html
index 747ca5a..f7bb208 100644
--- a/erpnext/website/page/website_home/website_home.html
+++ b/erpnext/website/page/website_home/website_home.html
@@ -1,10 +1,10 @@
 <div class="layout-wrapper layout-wrapper-background">
 	<div class="layout-main-section">
 		<a class="close" onclick="window.history.back();">&times;</a>
-		<h1>Support</h1>
+		<h1>Website</h1>
 		<hr>
 		<div style="width: 48%; float: left;">
-			<h4><a ahref="#!List/Web Page">Web Page</a></h4>
+			<h4><a href="#!List/Web Page">Web Page</a></h4>
 			<p class="help">Static (content) web page</p>
 			<h4><a href="#!List/Product">Product</a></h4>
 			<p class="help">Product listed in catolog</p>
diff --git a/images/stripedbg.png b/images/stripedbg.png
new file mode 100755
index 0000000..64ece57
--- /dev/null
+++ b/images/stripedbg.png
Binary files differ
diff --git a/index.cgi b/index.cgi
index e7a1d57..ed766eb 100755
--- a/index.cgi
+++ b/index.cgi
@@ -38,10 +38,25 @@
 	# init request
 	try:
 		webnotes.http_request = webnotes.auth.HTTPRequest()
+		return True
 	except webnotes.AuthenticationError, e:
-		pass
+		return True
 	except webnotes.UnknownDomainError, e:
 		print "Location: " + (webnotes.defs.redirect_404)
+	except webnotes.SessionStopped, e:
+		if 'cmd' in webnotes.form_dict:
+			webnotes.handler.print_json()
+		else:
+			print "Content-Type: text/html"
+			print
+			print """<html>
+				<body style="background-color: #EEE;">
+					<h3 style="width: 900px; background-color: #FFF; border: 2px solid #AAA; padding: 20px; font-family: Arial; margin: 20px auto">
+						Updating.
+						We will be back in a few moments...
+					</h3>
+				</body>
+				</html>"""
 
 def respond():
 	import webnotes
@@ -55,5 +70,5 @@
 		print webnotes.cms.index.get()
 
 if __name__=="__main__":
-	init()
-	respond()
+	if init():
+		respond()
diff --git a/js/all-app.js b/js/all-app.js
index 952f248..aa26778 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 c34d582..a9f04e6 100644
--- a/js/all-web.js
+++ b/js/all-web.js
@@ -1,11 +1,5 @@
 
 /*
- *	lib/js/lib/jquery.min.js
- *//*! jQuery v1.7.1 jquery.com | jquery.org/license */
-(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>"),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g<i;g++){if(g===1)for(h in a.converters)typeof h=="string"&&(e[h.toLowerCase()]=a.converters[h]);l=k,k=d[g];if(k==="*")k=l;else if(l!=="*"&&l!==k){m=l+" "+k,n=e[m]||e["* "+k];if(!n){p=b;for(o in e){j=o.split(" ");if(j[0]===l||j[0]==="*"){p=e[j[1]+" "+k];if(p){o=e[o],o===!0?n=p:p===!0&&(n=o);break}}}}!n&&!p&&f.error("No conversion from "+m.replace(" "," to ")),n!==!0&&(c=n?n(c):p(o(c)))}}return c}function cb(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j){j!==f[0]&&f.unshift(j);return d[j]}}function ca(a,b,c,d){if(f.isArray(b))f.each(b,function(b,e){c||bE.test(a)?d(a,e):ca(a+"["+(typeof e=="object"||f.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)ca(a+"["+e+"]",b[e],c,d);else d(a,b)}function b_(a,c){var d,e,g=f.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((g[d]?a:e||(e={}))[d]=c[d]);e&&f.extend(!0,a,e)}function b$(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===bT,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=b$(a,c,d,e,l,g)));(k||!l)&&!g["*"]&&(l=b$(a,c,d,e,"*",g));return l}function bZ(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(f.isFunction(c)){var d=b.toLowerCase().split(bP),e=0,g=d.length,h,i,j;for(;e<g;e++)h=d[e],j=/^\+/.test(h),j&&(h=h.substr(1)||"*"),i=a[h]=a[h]||[],i[j?"unshift":"push"](c)}}}function bC(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?bx:by,g=0,h=e.length;if(d>0){if(c!=="border")for(;g<h;g++)c||(d-=parseFloat(f.css(a,"padding"+e[g]))||0),c==="margin"?d+=parseFloat(f.css(a,c+e[g]))||0:d-=parseFloat(f.css(a,"border"+e[g]+"Width"))||0;return d+"px"}d=bz(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0;if(c)for(;g<h;g++)d+=parseFloat(f.css(a,"padding"+e[g]))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+e[g]+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+e[g]))||0);return d+"px"}function bp(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bf,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bo(a){var b=c.createElement("div");bh.appendChild(b),b.innerHTML=a.outerHTML;return b.firstChild}function bn(a){var b=(a.nodeName||"").toLowerCase();b==="input"?bm(a):b!=="script"&&typeof a.getElementsByTagName!="undefined"&&f.grep(a.getElementsByTagName("input"),bm)}function bm(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bl(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function bk(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(f.expando)}}function bj(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c,d,e,g=f._data(a),h=f._data(b,g),i=g.events;if(i){delete h.handle,h.events={};for(c in i)for(d=0,e=i[c].length;d<e;d++)f.event.add(b,c+(i[c][d].namespace?".":"")+i[c][d].namespace,i[c][d],i[c][d].data)}h.data&&(h.data=f.extend({},h.data))}}function bi(a,b){return f.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function U(a){var b=V.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function T(a,b,c){b=b||0;if(f.isFunction(b))return f.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return f.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=f.grep(a,function(a){return a.nodeType===1});if(O.test(b))return f.filter(b,d,!c);b=f.filter(b,d)}return f.grep(a,function(a,d){return f.inArray(a,b)>=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var c=a.document,d=a.navigator,e=a.location,f=function(){function J(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(J,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){d=i[c],f=a[c];if(i===f)continue;l&&f&&(e.isPlainObject(f)||(g=e.isArray(f)))?(g?(g=!1,h=d&&e.isArray(d)?d:[]):h=d&&e.isPlainObject(d)?d:{},i[c]=e.extend(l,h,f)):f!==b&&(i[c]=f)}return i},e.extend({noConflict:function(b){a.$===e&&(a.$=g),b&&a.jQuery===e&&(a.jQuery=f);return e},isReady:!1,readyWait:1,holdReady:function(a){a?e.readyWait++:e.ready(!0)},ready:function(a){if(a===!0&&!--e.readyWait||a!==!0&&!e.isReady){if(!c.body)return setTimeout(e.ready,1);e.isReady=!0;if(a!==!0&&--e.readyWait>0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g<h;)if(c.apply(a[g++],d)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:G?function(a){return a==null?"":G.call(a)}:function(a){return a==null?"":(a+"").replace(k,"").replace(l,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var d=e.type(a);a.length==null||d==="string"||d==="function"||d==="regexp"||e.isWindow(a)?E.call(c,a):e.merge(c,a)}return c},inArray:function(a,b,c){var d;if(b){if(H)return H.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];a.length=d;return a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,d){var f,g,h=[],i=0,j=a.length,k=a instanceof e||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,d),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,d),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var d=a[c];c=a,a=d}if(!e.isFunction(a))return b;var f=F.call(arguments,2),g=function(){return a.apply(c,f.concat(F.call(arguments)))};g.guid=a.guid=a.guid||g.guid||e.guid++;return g},access:function(a,c,d,f,g,h){var i=a.length;if(typeof c=="object"){for(var j in c)e.access(a,j,c[j],f,g,d);return a}if(d!==b){f=!h&&f&&e.isFunction(d);for(var k=0;k<i;k++)g(a[k],c,f?d.call(a[k],k,g(a[k],c)):d,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=r.exec(a)||s.exec(a)||t.exec(a)||a.indexOf("compatible")<0&&u.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}e.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(d,f){f&&f instanceof e&&!(f instanceof a)&&(f=a(f));return e.fn.init.call(this,d,f,b)},a.fn.init.prototype=a.fn;var b=a(c);return a},browser:{}}),e.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){I["[object "+b+"]"]=b.toLowerCase()}),z=e.uaMatch(y),z.browser&&(e.browser[z.browser]=!0,e.browser.version=z.version),e.browser.webkit&&(e.browser.safari=!0),j.test(" ")&&(k=/^[\s\xA0]+/,l=/[\s\xA0]+$/),h=e(c),c.addEventListener?B=function(){c.removeEventListener("DOMContentLoaded",B,!1),e.ready()}:c.attachEvent&&(B=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",B),e.ready())});return e}(),g={};f.Callbacks=function(a){a=a?g[a]||h(a):{};var c=[],d=[],e,i,j,k,l,m=function(b){var d,e,g,h,i;for(d=0,e=b.length;d<e;d++)g=b[d],h=f.type(g),h==="array"?m(g):h==="function"&&(!a.unique||!o.has(g))&&c.push(g)},n=function(b,f){f=f||[],e=!a.memory||[b,f],i=!0,l=j||0,j=0,k=c.length;for(;c&&l<k;l++)if(c[l].apply(b,f)===!1&&a.stopOnFalse){e=!0;break}i=!1,c&&(a.once?e===!0?o.disable():c=[]:d&&d.length&&(e=d.shift(),o.fireWith(e[0],e[1])))},o={add:function(){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},remove:function(){if(c){var b=arguments,d=0,e=b.length;for(;d<e;d++)for(var f=0;f<c.length;f++)if(b[d]===c[f]){i&&f<=k&&(k--,f<=l&&l--),c.splice(f--,1);if(a.unique)break}}return this},has:function(a){if(c){var b=0,d=c.length;for(;b<d;b++)if(a===c[b])return!0}return!1},empty:function(){c=[];return this},disable:function(){c=d=e=b;return this},disabled:function(){return!c},lock:function(){d=b,(!e||e===!0)&&o.disable();return this},locked:function(){return!d},fireWith:function(b,c){d&&(i?a.once||d.push([b,c]):(!a.once||!e)&&n(b,c));return this},fire:function(){o.fireWith(this,arguments);return this},fired:function(){return!!e}};return o};var i=[].slice;f.extend({Deferred:function(a){var b=f.Callbacks("once memory"),c=f.Callbacks("once memory"),d=f.Callbacks("memory"),e="pending",g={resolve:b,reject:c,notify:d},h={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){i.done(a).fail(b).progress(c);return this},always:function(){i.done.apply(i,arguments).fail.apply(i,arguments);return this},pipe:function(a,b,c){return f.Deferred(function(d){f.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],g;f.isFunction(c)?i[a](function(){g=c.apply(this,arguments),g&&f.isFunction(g.promise)?g.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===i?d:this,[g])}):i[a](d[e])})}).promise()},promise:function(a){if(a==null)a=h;else for(var b in h)a[b]=h[b];return a}},i=h.promise({}),j;for(j in g)i[j]=g[j].fire,i[j+"With"]=g[j].fireWith;i.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(i,i);return i},when:function(a){function m(a){return function(b){e[a]=arguments.length>1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c<d;c++)b[c]&&b[c].promise&&f.isFunction(b[c].promise)?b[c].promise().then(l(c),j.reject,m(c)):--g;g||j.resolveWith(j,b)}else j!==a&&j.resolveWith(j,d?[a]:[]);return k}}),f.support=function(){var b,d,e,g,h,i,j,k,l,m,n,o,p,q=c.createElement("div"),r=c.documentElement;q.setAttribute("className","t"),q.innerHTML="   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="<div "+n+"><div></div></div>"+"<table "+n+" cellpadding='0' cellspacing='0'>"+"<tr><td></td></tr></table>",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="<div style='width:4px;'></div>",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e<g;e++)delete d[b[e]];if(!(c?m:f.isEmptyObject)(d))return}}if(!c){delete j[k].data;if(!m(j[k]))return}f.support.deleteExpando||!j.setInterval?delete j[k]:j[k]=null,i&&(f.support.deleteExpando?delete a[h]:a.removeAttribute?a.removeAttribute(h):a[h]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d,e,g,h=null;if(typeof a=="undefined"){if(this.length){h=f.data(this[0]);if(this[0].nodeType===1&&!f._data(this[0],"parsedAttrs")){e=this[0].attributes;for(var i=0,j=e.length;i<j;i++)g=e[i].name,g.indexOf("data-")===0&&(g=f.camelCase(g.substring(5)),l(this[0],g,h[g]));f._data(this[0],"parsedAttrs",!0)}}return h}if(typeof a=="object")return this.each(function(){f.data(this,a)});d=a.split("."),d[1]=d[1]?"."+d[1]:"";if(c===b){h=this.triggerHandler("getData"+d[1]+"!",[d[0]]),h===b&&this.length&&(h=f.data(this[0],a),h=l(this[0],a,h));return h===b&&d[1]?this.data(d[0]):h}return this.each(function(){var b=f(this),e=[d[0],c];b.triggerHandler("setData"+d[1]+"!",e),f.data(this,a,c),b.triggerHandler("changeData"+d[1]+"!",e)})},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){typeof a!="string"&&(c=a,a="fx");if(c===b)return f.queue(this[0],a);return this.each(function(){var b=f.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&f.dequeue(this,a)})},dequeue:function(a){return this.each(function(){f.dequeue(this,a)})},delay:function(a,b){a=f.fx?f.fx.speeds[a]||a:a,b=b||"fx";return this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function m(){--h||d.resolveWith(e,[e])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var d=f.Deferred(),e=this,g=e.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=f.data(e[g],i,b,!0)||(f.data(e[g],j,b,!0)||f.data(e[g],k,b,!0))&&f.data(e[g],i,f.Callbacks("once memory"),!0))h++,l.add(m);m();return d.promise()}});var o=/[\n\t\r]/g,p=/\s+/,q=/\r/g,r=/^(?:button|input)$/i,s=/^(?:button|input|object|select|textarea)$/i,t=/^a(?:rea)?$/i,u=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,v=f.support.getSetAttribute,w,x,y;f.fn.extend({attr:function(a,b){return f.access(this,a,b,!0,f.attr)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,a,b,!0,f.prop)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{g=" "+e.className+" ";for(h=0,i=b.length;h<i;h++)~g.indexOf(" "+b[h]+" ")||(g+=b[h]+" ");e.className=f.trim(g)}}}return this},removeClass:function(a){var c,d,e,g,h,i,j;if(f.isFunction(a))return this.each(function(b){f(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(p);for(d=0,e=this.length;d<e;d++){g=this[d];if(g.nodeType===1&&g.className)if(a){h=(" "+g.className+" ").replace(o," ");for(i=0,j=c.length;i<j;i++)h=h.replace(" "+c[i]+" "," ");g.className=f.trim(h)}else g.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";if(f.isFunction(a))return this.each(function(c){f(this).toggleClass(a.call(this,c,this.className,b),b)});return this.each(function(){if(c==="string"){var e,g=0,h=f(this),i=b,j=a.split(p);while(e=j[g++])i=d?i:!h.hasClass(e),h[i?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&f._data(this,"__className__",this.className),this.className=this.className||a===!1?"":f._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(o," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c<d;c++){e=i[c];if(e.selected&&(f.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!f.nodeName(e.parentNode,"optgroup"))){b=f(e).val();if(j)return b;h.push(b)}}if(j&&!h.length&&i.length)return f(i[g]).val();return h},set:function(a,b){var c=f.makeArray(b);f(a).find("option").each(function(){this.selected=f.inArray(f(this).val(),c)>=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h<g;h++)e=d[h],e&&(c=f.propFix[e]||e,f.attr(a,e,""),a.removeAttribute(v?e:c),u.test(e)&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(r.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(w&&f.nodeName(a,"button"))return w.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(w&&f.nodeName(a,"button"))return w.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,g,h,i=a.nodeType;if(!!a&&i!==3&&i!==8&&i!==2){h=i!==1||!f.isXMLDoc(a),h&&(c=f.propFix[c]||c,g=f.propHooks[c]);return d!==b?g&&"set"in g&&(e=g.set(a,d,c))!==b?e:a[c]=d:g&&"get"in g&&(e=g.get(a,c))!==null?e:a[c]}},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):s.test(a.nodeName)||t.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabindex=f.propHooks.tabIndex,x={get:function(a,c){var d,e=f.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},v||(y={name:!0,id:!0},w=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&(y[c]?d.nodeValue!=="":d.specified)?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.attrHooks.tabindex.set=w.set,f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})}),f.attrHooks.contenteditable={get:w.get,set:function(a,b,c){b===""&&(b="false"),w.set(a,b,c)}}),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.enctype||(f.propFix.enctype="encoding"),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};
-f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k<c.length;k++){l=A.exec(c[k])||[],m=l[1],n=(l[2]||"").split(".").sort(),s=f.event.special[m]||{},m=(g?s.delegateType:s.bindType)||m,s=f.event.special[m]||{},o=f.extend({type:m,origType:l[1],data:e,handler:d,guid:d.guid,selector:g,quick:G(g),namespace:n.join(".")},p),r=j[m];if(!r){r=j[m]=[],r.delegateCount=0;if(!s.setup||s.setup.call(a,e,n,i)===!1)a.addEventListener?a.addEventListener(m,i,!1):a.attachEvent&&a.attachEvent("on"+m,i)}s.add&&(s.add.call(a,o),o.handler.guid||(o.handler.guid=d.guid)),g?r.splice(r.delegateCount++,0,o):r.push(o),f.event.global[m]=!0}a=null}},global:{},remove:function(a,b,c,d,e){var g=f.hasData(a)&&f._data(a),h,i,j,k,l,m,n,o,p,q,r,s;if(!!g&&!!(o=g.events)){b=f.trim(I(b||"")).split(" ");for(h=0;h<b.length;h++){i=A.exec(b[h])||[],j=k=i[1],l=i[2];if(!j){for(j in o)f.event.remove(a,j+b[h],c,d,!0);continue}p=f.event.special[j]||{},j=(d?p.delegateType:p.bindType)||j,r=o[j]||[],m=r.length,l=l?new RegExp("(^|\\.)"+l.split(".").sort().join("\\.(?:.*\\.)?")+"(\\.|$)"):null;for(n=0;n<r.length;n++)s=r[n],(e||k===s.origType)&&(!c||c.guid===s.guid)&&(!l||l.test(s.namespace))&&(!d||d===s.selector||d==="**"&&s.selector)&&(r.splice(n--,1),s.selector&&r.delegateCount--,p.remove&&p.remove.call(a,s));r.length===0&&m!==r.length&&((!p.teardown||p.teardown.call(a,l)===!1)&&f.removeEvent(a,j,g.handle),delete o[j])}f.isEmptyObject(o)&&(q=g.handle,q&&(q.elem=null),f.removeData(a,["events","handle"],!0))}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,g){if(!e||e.nodeType!==3&&e.nodeType!==8){var h=c.type||c,i=[],j,k,l,m,n,o,p,q,r,s;if(E.test(h+f.event.triggered))return;h.indexOf("!")>=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;l<r.length&&!c.isPropagationStopped();l++)m=r[l][0],c.type=r[l][1],q=(f._data(m,"events")||{})[c.type]&&f._data(m,"handle"),q&&q.apply(m,d),q=o&&m[o],q&&f.acceptData(m)&&q.apply(m,d)===!1&&c.preventDefault();c.type=h,!g&&!c.isDefaultPrevented()&&(!p._default||p._default.apply(e.ownerDocument,d)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)&&o&&e[h]&&(h!=="focus"&&h!=="blur"||c.target.offsetWidth!==0)&&!f.isWindow(e)&&(n=e[o],n&&(e[o]=null),f.event.triggered=h,e[h](),f.event.triggered=b,n&&(e[o]=n));return c.result}},dispatch:function(c){c=f.event.fix(c||a.event);var d=(f._data(this,"events")||{})[c.type]||[],e=d.delegateCount,g=[].slice.call(arguments,0),h=!c.exclusive&&!c.namespace,i=[],j,k,l,m,n,o,p,q,r,s,t;g[0]=c,c.delegateTarget=this;if(e&&!c.target.disabled&&(!c.button||c.type!=="click")){m=f(this),m.context=this.ownerDocument||this;for(l=c.target;l!=this;l=l.parentNode||this){o={},q=[],m[0]=l;for(j=0;j<e;j++)r=d[j],s=r.selector,o[s]===b&&(o[s]=r.quick?H(l,r.quick):m.is(s)),o[s]&&q.push(r);q.length&&i.push({elem:l,matches:q})}}d.length>e&&i.push({elem:this,matches:d.slice(e)});for(j=0;j<i.length&&!c.isPropagationStopped();j++){p=i[j],c.currentTarget=p.elem;for(k=0;k<p.matches.length&&!c.isImmediatePropagationStopped();k++){r=p.matches[k];if(h||!c.namespace&&!r.namespace||c.namespace_re&&c.namespace_re.test(r.namespace))c.data=r.data,c.handleObj=r,n=((f.event.special[r.origType]||{}).handle||r.handler).apply(p.elem,g),n!==b&&(c.result=n,n===!1&&(c.preventDefault(),c.stopPropagation()))}}return c.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode);return a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,d){var e,f,g,h=d.button,i=d.fromElement;a.pageX==null&&d.clientX!=null&&(e=a.target.ownerDocument||c,f=e.documentElement,g=e.body,a.pageX=d.clientX+(f&&f.scrollLeft||g&&g.scrollLeft||0)-(f&&f.clientLeft||g&&g.clientLeft||0),a.pageY=d.clientY+(f&&f.scrollTop||g&&g.scrollTop||0)-(f&&f.clientTop||g&&g.clientTop||0)),!a.relatedTarget&&i&&(a.relatedTarget=i===a.target?d.toElement:i),!a.which&&h!==b&&(a.which=h&1?1:h&2?3:h&4?2:0);return a}},fix:function(a){if(a[f.expando])return a;var d,e,g=a,h=f.event.fixHooks[a.type]||{},i=h.props?this.props.concat(h.props):this.props;a=f.Event(g);for(d=i.length;d;)e=i[--d],a[e]=g[e];a.target||(a.target=g.srcElement||c),a.target.nodeType===3&&(a.target=a.target.parentNode),a.metaKey===b&&(a.metaKey=a.ctrlKey);return h.filter?h.filter(a,g):a},special:{ready:{setup:f.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){f.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}},simulate:function(a,b,c,d){var e=f.extend(new f.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?f.event.trigger(e,null,b):f.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},f.event.handle=f.event.dispatch,f.removeEvent=c.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},f.Event=function(a,b){if(!(this instanceof f.Event))return new f.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?K:J):this.type=a,b&&f.extend(this,b),this.timeStamp=a&&a.timeStamp||f.now(),this[f.expando]=!0},f.Event.prototype={preventDefault:function(){this.isDefaultPrevented=K;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=K;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=K,this.stopPropagation()},isDefaultPrevented:J,isPropagationStopped:J,isImmediatePropagationStopped:J},f.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){f.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c=this,d=a.relatedTarget,e=a.handleObj,g=e.selector,h;if(!d||d!==c&&!f.contains(c,d))a.type=e.origType,h=e.handler.apply(this,arguments),a.type=b;return h}}}),f.support.submitBubbles||(f.event.special.submit={setup:function(){if(f.nodeName(this,"form"))return!1;f.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=f.nodeName(c,"input")||f.nodeName(c,"button")?c.form:b;d&&!d._submit_attached&&(f.event.add(d,"submit._submit",function(a){this.parentNode&&!a.isTrigger&&f.event.simulate("submit",this.parentNode,a,!0)}),d._submit_attached=!0)})},teardown:function(){if(f.nodeName(this,"form"))return!1;f.event.remove(this,"._submit")}}),f.support.changeBubbles||(f.event.special.change={setup:function(){if(z.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")f.event.add(this,"propertychange._change",function(a){a.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),f.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1,f.event.simulate("change",this,a,!0))});return!1}f.event.add(this,"beforeactivate._change",function(a){var b=a.target;z.test(b.nodeName)&&!b._change_attached&&(f.event.add(b,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&f.event.simulate("change",this.parentNode,a,!0)}),b._change_attached=!0)})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){f.event.remove(this,"._change");return z.test(this.nodeName)}}),f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){var d=0,e=function(a){f.event.simulate(b,a.target,f.event.fix(a),!0)};f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.fn.extend({on:function(a,c,d,e,g){var h,i;if(typeof a=="object"){typeof c!="string"&&(d=c,c=b);for(i in a)this.on(i,c,d,a[i],g);return this}d==null&&e==null?(e=c,d=c=b):e==null&&(typeof c=="string"?(e=d,d=b):(e=d,d=c,c=b));if(e===!1)e=J;else if(!e)return this;g===1&&(h=e,e=function(a){f().off(a);return h.apply(this,arguments)},e.guid=h.guid||(h.guid=f.guid++));return this.each(function(){f.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on.call(this,a,b,c,d,1)},off:function(a,c,d){if(a&&a.preventDefault&&a.handleObj){var e=a.handleObj;f(a.delegateTarget).off(e.namespace?e.type+"."+e.namespace:e.type,e.selector,e.handler);return this}if(typeof a=="object"){for(var g in a)this.off(g,c,a[g]);return this}if(c===!1||typeof c=="function")d=c,c=b;d===!1&&(d=J);return this.each(function(){f.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){f(this.context).on(a,this.selector,b,c);return this},die:function(a,b){f(this.context).off(a,this.selector||"**",b);return this},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):this.off(b,a,c)},trigger:function(a,b){return this.each(function(){f.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return f.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||f.guid++,d=0,e=function(c){var e=(f._data(this,"lastToggle"+a.guid)||0)%d;f._data(this,"lastToggle"+a.guid,e+1),c.preventDefault();return b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),f.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){f.fn[b]=function(a,c){c==null&&(c=a,a=null);return arguments.length>0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h<i;h++){var j=e[h];if(j){var k=!1;j=j[a];while(j){if(j[d]===c){k=e[j.sizset];break}if(j.nodeType===1){g||(j[d]=c,j.sizset=h);if(typeof b!="string"){if(j===b){k=!0;break}}else if(m.filter(b,[j]).length>0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h<i;h++){var j=e[h];if(j){var k=!1;j=j[a];while(j){if(j[d]===c){k=e[j.sizset];break}j.nodeType===1&&!g&&(j[d]=c,j.sizset=h);if(j.nodeName.toLowerCase()===b){k=j;break}j=j[a]}e[h]=k}}}var a=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},m.matches=function(a,b){return m(a,null,null,b)},m.matchesSelector=function(a,b){return m(b,null,null,[a]).length>0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e<f;e++){h=o.order[e];if(g=o.leftMatch[h].exec(a)){i=g[1],g.splice(1,1);if(i.substr(i.length-1)!=="\\"){g[1]=(g[1]||"").replace(j,""),d=o.find[h](g,b,c);if(d!=null){a=a.replace(o.match[h],"");break}}}}d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]);return{set:d,expr:a}},m.filter=function(a,c,d,e){var f,g,h,i,j,k,l,n,p,q=a,r=[],s=c,t=c&&c[0]&&m.isXML(c[0]);while(a&&c.length){for(h in o.filter)if((f=o.leftMatch[h].exec(a))!=null&&f[2]){k=o.filter[h],l=f[1],g=!1,f.splice(1,1);if(l.substr(l.length-1)==="\\")continue;s===r&&(r=[]);if(o.preFilter[h]){f=o.preFilter[h](f,s,d,r,e,t);if(!f)g=i=!0;else if(f===!0)continue}if(f)for(n=0;(j=s[n])!=null;n++)j&&(i=k(j,f,n,s),p=e^i,d&&i!=null?p?g=!0:s[n]=!1:p&&(r.push(j),g=!0));if(i!==b){d||(s=r),a=a.replace(o.match[h],"");if(!g)return[];break}}if(a===q)if(g==null)m.error(a);else break;q=a}return s},m.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)};var n=m.getText=function(a){var b,c,d=a.nodeType,e="";if(d){if(d===1||d===9){if(typeof a.textContent=="string")return a.textContent;if(typeof a.innerText=="string")return a.innerText.replace(k,"");for(a=a.firstChild;a;a=a.nextSibling)e+=n(a)}else if(d===3||d===4)return a.nodeValue}else for(b=0;c=a[b];b++)c.nodeType!==8&&(e+=n(c));return e},o=m.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!l.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&m.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&m.filter(b,a,!0)}},"":function(a,b,c){var d,f=e++,g=x;typeof b=="string"&&!l.test(b)&&(b=b.toLowerCase(),d=b,g=w),g("parentNode",b,f,a,d,c)},"~":function(a,b,c){var d,f=e++,g=x;typeof b=="string"&&!l.test(b)&&(b=b.toLowerCase(),d=b,g=w),g("previousSibling",b,f,a,d,c)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(j,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}m.error(e)},CHILD:function(a,b){var c,e,f,g,h,i,j,k=b[1],l=a;switch(k){case"only":case"first":while(l=l.previousSibling)if(l.nodeType===1)return!1;if(k==="first")return!0;l=a;case"last":while(l=l.nextSibling)if(l.nodeType===1)return!1;return!0;case"nth":c=b[2],e=b[3];if(c===1&&e===0)return!0;f=b[0],g=a.parentNode;if(g&&(g[d]!==f||!a.nodeIndex)){i=0;for(l=g.firstChild;l;l=l.nextSibling)l.nodeType===1&&(l.nodeIndex=++i);g[d]=f}j=a.nodeIndex-e;return c===0?j===0:j%c===0&&j/c>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c<e;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var u,v;c.documentElement.compareDocumentPosition?u=function(a,b){if(a===b){h=!0;return 0}if(!a.compareDocumentPosition||!b.compareDocumentPosition)return a.compareDocumentPosition?-1:1;return a.compareDocumentPosition(b)&4?-1:1}:(u=function(a,b){if(a===b){h=!0;return 0}if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],g=a.parentNode,i=b.parentNode,j=g;if(g===i)return v(a,b);if(!g)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return v(e[k],f[k]);return k===c?v(a,f[k],-1):v(e[k],b,1)},v=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),function(){var a=c.createElement("div"),d="script"+(new Date).getTime(),e=c.documentElement;a.innerHTML="<a name='"+d+"'/>",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h<i;h++)m(a,g[h],e,c);return m.filter(f,e)};m.attr=f.attr,m.selectors.attrMap={},f.find=m,f.expr=m.selectors,f.expr[":"]=f.expr.filters,f.unique=m.uniqueSort,f.text=m.getText,f.isXMLDoc=m.isXML,f.contains=m.contains}();var L=/Until$/,M=/^(?:parents|prevUntil|prevAll)/,N=/,/,O=/^.[^:#\[\.,]*$/,P=Array.prototype.slice,Q=f.expr.match.POS,R={children:!0,contents:!0,next:!0,prev:!0};f.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return f(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(f.contains(b[c],this))return!0});var e=this.pushStack("","find",a),g,h,i;for(c=0,d=this.length;c<d;c++){g=e.length,f.find(a,this[c],e);if(c>0)for(h=g;h<e.length;h++)for(i=0;i<g;i++)if(e[i]===e[h]){e.splice(h--,1);break}}return e},has:function(a){var b=f(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(f.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(T(this,a,!1),"not",a)},filter:function(a){return this.pushStack(T(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?Q.test(a)?f(a,this.context).index(this[0])>=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d<a.length;d++)f(g).is(a[d])&&c.push({selector:a[d],elem:g,level:h});g=g.parentNode,h++}return c}var i=Q.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){g=this[d];while(g){if(i?i.index(g)>-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/<tbody/i,_=/<|&#?\w+;/,ba=/<(?:script|style)/i,bb=/<(?:script|object|embed|option|style)/i,bc=new RegExp("<(?:"+V+")","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*<!(?:\[CDATA\[|\-\-)/,bg={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div<div>","</div>"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function()
-{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1></$2>");try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(f.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else f.isFunction(a)?this.each(function(b){var c=f(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&this[0].parentNode){if(f.isFunction(a))return this.each(function(b){var c=f(this),d=c.html();c.replaceWith(a.call(this,b,d))});typeof a!="string"&&(a=f(a).detach());return this.each(function(){var b=this.nextSibling,c=this.parentNode;f(this).remove(),b?f(b).before(a):f(c).append(a)})}return this.length?this.pushStack(f(f.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,g,h,i,j=a[0],k=[];if(!f.support.checkClone&&arguments.length===3&&typeof j=="string"&&bd.test(j))return this.each(function(){f(this).domManip(a,c,d,!0)});if(f.isFunction(j))return this.each(function(e){var g=f(this);a[0]=j.call(this,e,c?g.html():b),g.domManip(a,c,d)});if(this[0]){i=j&&j.parentNode,f.support.parentNode&&i&&i.nodeType===11&&i.childNodes.length===this.length?e={fragment:i}:e=f.buildFragment(a,this,k),h=e.fragment,h.childNodes.length===1?g=h=h.firstChild:g=h.firstChild;if(g){c=c&&f.nodeName(g,"tr");for(var l=0,m=this.length,n=m-1;l<m;l++)d.call(c?bi(this[l],g):this[l],e.cacheable||m>1&&l<n?f.clone(h,!0,!0):h)}k.length&&f.each(k,bp)}return this}}),f.buildFragment=function(a,b,d){var e,g,h,i,j=a[0];b&&b[0]&&(i=b[0].ownerDocument||b[0]),i.createDocumentFragment||(i=c),a.length===1&&typeof j=="string"&&j.length<512&&i===c&&j.charAt(0)==="<"&&!bb.test(j)&&(f.support.checkClone||!bd.test(j))&&(f.support.html5Clone||!bc.test(j))&&(g=!0,h=f.fragments[j],h&&h!==1&&(e=h)),e||(e=i.createDocumentFragment(),f.clean(a,i,e,d)),g&&(f.fragments[j]=h?e:1);return{fragment:e,cacheable:g}},f.fragments={},f.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){f.fn[a]=function(c){var d=[],e=f(c),g=this.length===1&&this[0].parentNode;if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1){e[b](this[0]);return this}for(var h=0,i=e.length;h<i;h++){var j=(h>0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1></$2>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]==="<table>"&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i<r;i++)bn(k[i]);else bn(k);k.nodeType?h.push(k):h=f.merge(h,k)}if(d){g=function(a){return!a.type||be.test(a.type)};for(j=0;h[j];j++)if(e&&f.nodeName(h[j],"script")&&(!h[j].type||h[j].type.toLowerCase()==="text/javascript"))e.push(h[j].parentNode?h[j].parentNode.removeChild(h[j]):h[j]);else{if(h[j].nodeType===1){var s=f.grep(h[j].getElementsByTagName("script"),g);h.splice.apply(h,[j+1,0].concat(s))}d.appendChild(h[j])}}return h},cleanData:function(a){var b,c,d=f.cache,e=f.event.special,g=f.support.deleteExpando;for(var h=0,i;(i=a[h])!=null;h++){if(i.nodeName&&f.noData[i.nodeName.toLowerCase()])continue;c=i[f.expando];if(c){b=d[c];if(b&&b.events){for(var j in b.events)e[j]?f.event.remove(i,j):f.removeEvent(i,j,b.handle);b.handle&&(b.handle.elem=null)}g?delete i[f.expando]:i.removeAttribute&&i.removeAttribute(f.expando),delete d[c]}}}});var bq=/alpha\([^)]*\)/i,br=/opacity=([^)]*)/,bs=/([A-Z]|^ms)/g,bt=/^-?\d+(?:px)?$/i,bu=/^-?\d/,bv=/^([\-+])=([\-+.\de]+)/,bw={position:"absolute",visibility:"hidden",display:"block"},bx=["Left","Right"],by=["Top","Bottom"],bz,bA,bB;f.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return f.access(this,a,c,!0,function(a,c,d){return d!==b?f.style(a,c,d):f.css(a,c)})},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bz(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bv.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(bz)return bz(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]}}),f.curCSS=f.css,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){var e;if(c){if(a.offsetWidth!==0)return bC(a,b,d);f.swap(a,bw,function(){e=bC(a,b,d)});return e}},set:function(a,b){if(!bt.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("<div>").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g<h;g++)d=this[g],d.style&&(e=d.style.display,!f._data(d,"olddisplay")&&e==="none"&&(e=d.style.display=""),e===""&&f.css(d,"display")==="none"&&f._data(d,"olddisplay",cv(d.nodeName)));for(g=0;g<h;g++){d=this[g];if(d.style){e=d.style.display;if(e===""||e==="none")d.style.display=f._data(d,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(cu("hide",3),a,b,c);var d,e,g=0,h=this.length;for(;g<h;g++)d=this[g],d.style&&(e=f.css(d,"display"),e!=="none"&&!f._data(d,"olddisplay")&&f._data(d,"olddisplay",e));for(g=0;g<h;g++)this[g].style&&(this[g].style.display="none");return this},_toggle:f.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";f.isFunction(a)&&f.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:f(this).is(":hidden");f(this)[b?"show":"hide"]()}):this.animate(cu("toggle",3),a,b,c);return this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){function g(){e.queue===!1&&f._mark(this);var b=f.extend({},e),c=this.nodeType===1,d=c&&f(this).is(":hidden"),g,h,i,j,k,l,m,n,o;b.animatedProperties={};for(i in a){g=f.camelCase(i),i!==g&&(a[g]=a[i],delete a[i]),h=a[g],f.isArray(h)?(b.animatedProperties[g]=h[1],h=a[g]=h[0]):b.animatedProperties[g]=b.specialEasing&&b.specialEasing[g]||b.easing||"swing";if(h==="hide"&&d||h==="show"&&!d)return b.complete.call(this);c&&(g==="height"||g==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],f.css(this,"display")==="inline"&&f.css(this,"float")==="none"&&(!f.support.inlineBlockNeedsLayout||cv(this.nodeName)==="inline"?this.style.display="inline-block":this.style.zoom=1))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)j=new f.fx(this,b,i),h=a[i],cn.test(h)?(o=f._data(this,"toggle"+i)||(h==="toggle"?d?"show":"hide":0),o?(f._data(this,"toggle"+i,o==="show"?"hide":"show"),j[o]()):j[h]()):(k=co.exec(h),l=j.cur(),k?(m=parseFloat(k[2]),n=k[3]||(f.cssNumber[i]?"":"px"),n!=="px"&&(f.style(this,i,(m||1)+n),l=(m||1)/j.cur()*l,f.style(this,i,l+n)),k[1]&&(m=(k[1]==="-="?-1:1)*m+l),j.custom(l,m,n)):j.custom(l,h,""));return!0}var e=f.speed(b,c,d);if(f.isEmptyObject(a))return this.each(e.complete,[!1]);a=f.extend({},a);return e.queue===!1?this.each(g):this.queue(e.queue,g)},stop:function(a,c,d){typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]);return this.each(function(){function h(a,b,c){var e=b[c];f.removeData(a,c,!0),e.stop(d)}var b,c=!1,e=f.timers,g=f._data(this);d||f._unmark(!0,this);if(a==null)for(b in g)g[b]&&g[b].stop&&b.indexOf(".run")===b.length-4&&h(this,g,b);else g[b=a+".run"]&&g[b].stop&&h(this,g,b);for(b=e.length;b--;)e[b].elem===this&&(a==null||e[b].queue===a)&&(d?e[b](!0):e[b].saveState(),c=!0,e.splice(b,1));(!d||!c)&&f.dequeue(this,a)})}}),f.each({slideDown:cu("show",1),slideUp:cu("hide",1),slideToggle:cu("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){f.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),f.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?f.extend({},a):{complete:c||!c&&b||f.isFunction(a)&&a,duration:a,easing:c&&b||b&&!f.isFunction(b)&&b};d.duration=f.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in f.fx.speeds?f.fx.speeds[d.duration]:f.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";d.old=d.complete,d.complete=function(a){f.isFunction(d.old)&&d.old.call(this),d.queue?f.dequeue(this,d.queue):a!==!1&&f._unmark(this)};return d},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),f.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(f.fx.step[this.prop]||f.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=f.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,c,d){function h(a){return e.step(a)}var e=this,g=f.fx;this.startTime=cr||cs(),this.end=c,this.now=this.start=a,this.pos=this.state=0,this.unit=d||this.unit||(f.cssNumber[this.prop]?"":"px"),h.queue=this.options.queue,h.elem=this.elem,h.saveState=function(){e.options.hide&&f._data(e.elem,"fxshow"+e.prop)===b&&f._data(e.elem,"fxshow"+e.prop,e.start)},h()&&f.timers.push(h)&&!cp&&(cp=setInterval(g.tick,g.interval))},show:function(){var a=f._data(this.elem,"fxshow"+this.prop);this.options.orig[this.prop]=a||f.style(this.elem,this.prop),this.options.show=!0,a!==b?this.custom(this.cur(),a):this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),f(this.elem).show()},hide:function(){this.options.orig[this.prop]=f._data(this.elem,"fxshow"+this.prop)||f.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b,c,d,e=cr||cs(),g=!0,h=this.elem,i=this.options;if(a||e>=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||f.fx.stop()},interval:13,stop:function(){clearInterval(cp),cp=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=a.now+a.unit:a.elem[a.prop]=a.now}}}),f.each(["width","height"],function(a,b){f.fx.step[b]=function(a){f.style(a.elem,b,Math.max(0,a.now)+a.unit)}}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cw=/^t(?:able|d|h)$/i,cx=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?f.fn.offset=function(a){var b=this[0],c;if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);try{c=b.getBoundingClientRect()}catch(d){}var e=b.ownerDocument,g=e.documentElement;if(!c||!f.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};var h=e.body,i=cy(e),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||f.support.boxModel&&g.scrollTop||h.scrollTop,m=i.pageXOffset||f.support.boxModel&&g.scrollLeft||h.scrollLeft,n=c.top+l-j,o=c.left+m-k;return{top:n,left:o}}:f.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);var c,d=b.offsetParent,e=b,g=b.ownerDocument,h=g.documentElement,i=g.body,j=g.defaultView,k=j?j.getComputedStyle(b,null):b.currentStyle,l=b.offsetTop,m=b.offsetLeft;while((b=b.parentNode)&&b!==i&&b!==h){if(f.support.fixedPosition&&k.position==="fixed")break;c=j?j.getComputedStyle(b,null):b.currentStyle,l-=b.scrollTop,m-=b.scrollLeft,b===d&&(l+=b.offsetTop,m+=b.offsetLeft,f.support.doesNotAddBorder&&(!f.support.doesAddBorderForTableAndCells||!cw.test(b.nodeName))&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),f.support.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),k=c}if(k.position==="relative"||k.position==="static")l+=i.offsetTop,m+=i.offsetLeft;f.support.fixedPosition&&k.position==="fixed"&&(l+=Math.max(h.scrollTop,i.scrollTop),m+=Math.max(h.scrollLeft,i.scrollLeft));return{top:l,left:m}},f.offset={bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window);
-/*
  *	lib/js/lib/history/history.min.js
  *//*
  * jQuery hashchange event - v1.3 - 7/21/2010
@@ -38,6 +32,33 @@
  *	lib/js/lib/bootstrap.min.js
  */!function(a){a(function(){"use strict",a.support.transition=function(){var b=document.body||document.documentElement,c=b.style,d=c.transition!==undefined||c.WebkitTransition!==undefined||c.MozTransition!==undefined||c.MsTransition!==undefined||c.OTransition!==undefined;return d&&{end:function(){var b="TransitionEnd";return a.browser.webkit?b="webkitTransitionEnd":a.browser.mozilla?b="transitionend":a.browser.opera&&(b="oTransitionEnd"),b}()}}()})}(window.jQuery),!function(a){"use strict";var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype={constructor:c,close:function(b){function f(){e.remove(),e.trigger("closed")}var c=a(this),d=c.attr("data-target"),e;d||(d=c.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),e=a(d),e.trigger("close"),b&&b.preventDefault(),e.length||(e=c.hasClass("alert")?c:c.parent()),e.removeClass("in"),a.support.transition&&e.hasClass("fade")?e.on(a.support.transition.end,f):f()}},a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("alert");e||d.data("alert",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.alert.Constructor=c,a(function(){a("body").on("click.alert.data-api",b,c.prototype.close)})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.button.defaults,c)};b.prototype={constructor:b,setState:function(a){var b="disabled",c=this.$element,d=c.data(),e=c.is("input")?"val":"html";a+="Text",d.resetText||c.data("resetText",c[e]()),c[e](d[a]||this.options[a]),setTimeout(function(){a=="loadingText"?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},toggle:function(){var a=this.$element.parent('[data-toggle="buttons-radio"]');a&&a.find(".active").removeClass("active"),this.$element.toggleClass("active")}},a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("button"),f=typeof c=="object"&&c;e||d.data("button",e=new b(this,f)),c=="toggle"?e.toggle():c&&e.setState(c)})},a.fn.button.defaults={loadingText:"loading..."},a.fn.button.Constructor=b,a(function(){a("body").on("click.button.data-api","[data-toggle^=button]",function(b){a(b.target).button("toggle")})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.carousel.defaults,c),this.options.slide&&this.slide(this.options.slide)};b.prototype={cycle:function(){return this.interval=setInterval(a.proxy(this.next,this),this.options.interval),this},to:function(b){var c=this.$element.find(".active"),d=c.parent().children(),e=d.index(c),f=this;if(b>d.length-1||b<0)return;return this.sliding?this.$element.one("slid",function(){f.to(b)}):e==b?this.pause().cycle():this.slide(b>e?"next":"prev",a(d[b]))},pause:function(){return clearInterval(this.interval),this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(b,c){var d=this.$element.find(".active"),e=c||d[b](),f=this.interval,g=b=="next"?"left":"right",h=b=="next"?"first":"last",i=this;return this.sliding=!0,f&&this.pause(),e=e.length?e:this.$element.find(".item")[h](),!a.support.transition&&this.$element.hasClass("slide")?(this.$element.trigger("slide"),d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger("slid")):(e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),this.$element.trigger("slide"),this.$element.one(a.support.transition.end,function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger("slid")},0)})),f&&this.cycle(),this}},a.fn.carousel=function(c){return this.each(function(){var d=a(this),e=d.data("carousel"),f=typeof c=="object"&&c;e||d.data("carousel",e=new b(this,f)),typeof c=="number"?e.to(c):typeof c=="string"||(c=f.slide)?e[c]():e.cycle()})},a.fn.carousel.defaults={interval:5e3},a.fn.carousel.Constructor=b,a(function(){a("body").on("click.carousel.data-api","[data-slide]",function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=!e.data("modal")&&a.extend({},e.data(),c.data());e.carousel(f),b.preventDefault()})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.collapse.defaults,c),this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.prototype={constructor:b,dimension:function(){var a=this.$element.hasClass("width");return a?"width":"height"},show:function(){var b=this.dimension(),c=a.camelCase(["scroll",b].join("-")),d=this.$parent&&this.$parent.find(".in"),e;d&&d.length&&(e=d.data("collapse"),d.collapse("hide"),e||d.data("collapse",null)),this.$element[b](0),this.transition("addClass","show","shown"),this.$element[b](this.$element[0][c])},hide:function(){var a=this.dimension();this.reset(this.$element[a]()),this.transition("removeClass","hide","hidden"),this.$element[a](0)},reset:function(a){var b=this.dimension();this.$element.removeClass("collapse")[b](a||"auto")[0].offsetWidth,this.$element.addClass("collapse")},transition:function(b,c,d){var e=this,f=function(){c=="show"&&e.reset(),e.$element.trigger(d)};this.$element.trigger(c)[b]("in"),a.support.transition&&this.$element.hasClass("collapse")?this.$element.one(a.support.transition.end,f):f()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}},a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("collapse"),f=typeof c=="object"&&c;e||d.data("collapse",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.collapse.defaults={toggle:!0},a.fn.collapse.Constructor=b,a(function(){a("body").on("click.collapse.data-api","[data-toggle=collapse]",function(b){var c=a(this),d,e=c.attr("data-target")||b.preventDefault()||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),f=a(e).data("collapse")?"toggle":c.data();a(e).collapse(f)})})}(window.jQuery),!function(a){function d(){a(b).parent().removeClass("open")}"use strict";var b='[data-toggle="dropdown"]',c=function(b){var c=a(b).on("click.dropdown.data-api",this.toggle);a("html").on("click.dropdown.data-api",function(){c.parent().removeClass("open")})};c.prototype={constructor:c,toggle:function(b){var c=a(this),e=c.attr("data-target"),f,g;return e||(e=c.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,"")),f=a(e),f.length||(f=c.parent()),g=f.hasClass("open"),d(),!g&&f.toggleClass("open"),!1}},a.fn.dropdown=function(b){return this.each(function(){var d=a(this),e=d.data("dropdown");e||d.data("dropdown",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.dropdown.Constructor=c,a(function(){a("html").on("click.dropdown.data-api",d),a("body").on("click.dropdown.data-api",b,c.prototype.toggle)})}(window.jQuery),!function(a){function c(){var b=this,c=setTimeout(function(){b.$element.off(a.support.transition.end),d.call(b)},500);this.$element.one(a.support.transition.end,function(){clearTimeout(c),d.call(b)})}function d(a){this.$element.hide().trigger("hidden"),e.call(this)}function e(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var e=a.support.transition&&d;this.$backdrop=a('<div class="modal-backdrop '+d+'" />').appendTo(document.body),this.options.backdrop!="static"&&this.$backdrop.click(a.proxy(this.hide,this)),e&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),e?this.$backdrop.one(a.support.transition.end,b):b()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(a.support.transition.end,a.proxy(f,this)):f.call(this)):b&&b()}function f(){this.$backdrop.remove(),this.$backdrop=null}function g(){var b=this;this.isShown&&this.options.keyboard?a(document).on("keyup.dismiss.modal",function(a){a.which==27&&b.hide()}):this.isShown||a(document).off("keyup.dismiss.modal")}"use strict";var b=function(b,c){this.options=a.extend({},a.fn.modal.defaults,c),this.$element=a(b).delegate('[data-dismiss="modal"]',"click.dismiss.modal",a.proxy(this.hide,this))};b.prototype={constructor:b,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var b=this;if(this.isShown)return;a("body").addClass("modal-open"),this.isShown=!0,this.$element.trigger("show"),g.call(this),e.call(this,function(){var c=a.support.transition&&b.$element.hasClass("fade");!b.$element.parent().length&&b.$element.appendTo(document.body),b.$element.show(),c&&b.$element[0].offsetWidth,b.$element.addClass("in"),c?b.$element.one(a.support.transition.end,function(){b.$element.trigger("shown")}):b.$element.trigger("shown")})},hide:function(b){b&&b.preventDefault();if(!this.isShown)return;var e=this;this.isShown=!1,a("body").removeClass("modal-open"),g.call(this),this.$element.trigger("hide").removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?c.call(this):d.call(this)}},a.fn.modal=function(c){return this.each(function(){var d=a(this),e=d.data("modal"),f=typeof c=="object"&&c;e||d.data("modal",e=new b(this,f)),typeof c=="string"?e[c]():e.show()})},a.fn.modal.defaults={backdrop:!0,keyboard:!0},a.fn.modal.Constructor=b,a(function(){a("body").on("click.modal.data-api",'[data-toggle="modal"]',function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=e.data("modal")?"toggle":a.extend({},e.data(),c.data());b.preventDefault(),e.modal(f)})})}(window.jQuery),!function(a){"use strict";var b=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){var e,f;this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.enabled=!0,this.options.trigger!="manual"&&(e=this.options.trigger=="hover"?"mouseenter":"focus",f=this.options.trigger=="hover"?"mouseleave":"blur",this.$element.on(e,this.options.selector,a.proxy(this.enter,this)),this.$element.on(f,this.options.selector,a.proxy(this.leave,this))),this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(b){return b=a.extend({},a.fn[this.type].defaults,b,this.$element.data()),b.delay&&typeof b.delay=="number"&&(b.delay={show:b.delay,hide:b.delay}),b},enter:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);!c.options.delay||!c.options.delay.show?c.show():(c.hoverState="in",setTimeout(function(){c.hoverState=="in"&&c.show()},c.options.delay.show))},leave:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);!c.options.delay||!c.options.delay.hide?c.hide():(c.hoverState="out",setTimeout(function(){c.hoverState=="out"&&c.hide()},c.options.delay.hide))},show:function(){var a,b,c,d,e,f,g;if(this.hasContent()&&this.enabled){a=this.tip(),this.setContent(),this.options.animation&&a.addClass("fade"),f=typeof this.options.placement=="function"?this.options.placement.call(this,a[0],this.$element[0]):this.options.placement,b=/in/.test(f),a.remove().css({top:0,left:0,display:"block"}).appendTo(b?this.$element:document.body),c=this.getPosition(b),d=a[0].offsetWidth,e=a[0].offsetHeight;switch(b?f.split(" ")[1]:f){case"bottom":g={top:c.top+c.height,left:c.left+c.width/2-d/2};break;case"top":g={top:c.top-e,left:c.left+c.width/2-d/2};break;case"left":g={top:c.top+c.height/2-e/2,left:c.left-d};break;case"right":g={top:c.top+c.height/2-e/2,left:c.left+c.width}}a.css(g).addClass(f).addClass("in")}},setContent:function(){var a=this.tip();a.find(".tooltip-inner").html(this.getTitle()),a.removeClass("fade in top bottom left right")},hide:function(){function d(){var b=setTimeout(function(){c.off(a.support.transition.end).remove()},500);c.one(a.support.transition.end,function(){clearTimeout(b),c.remove()})}var b=this,c=this.tip();c.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?d():c.remove()},fixTitle:function(){var a=this.$element;(a.attr("title")||typeof a.attr("data-original-title")!="string")&&a.attr("data-original-title",a.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(b){return a.extend({},b?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||(typeof c.title=="function"?c.title.call(b[0]):c.title),a=a.toString().replace(/(^\s*|\s*$)/,""),a},tip:function(){return this.$tip=this.$tip||a(this.options.template)},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(){this[this.tip().hasClass("in")?"hide":"show"]()}},a.fn.tooltip=function(c){return this.each(function(){var d=a(this),e=d.data("tooltip"),f=typeof c=="object"&&c;e||d.data("tooltip",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.tooltip.Constructor=b,a.fn.tooltip.defaults={animation:!0,delay:0,selector:!1,placement:"top",trigger:"hover",title:"",template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'}}(window.jQuery),!function(a){"use strict";var b=function(a,b){this.init("popover",a,b)};b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype,{constructor:b,setContent:function(){var b=this.tip(),c=this.getTitle(),d=this.getContent();b.find(".popover-title")[a.type(c)=="object"?"append":"html"](c),b.find(".popover-content > *")[a.type(d)=="object"?"append":"html"](d),b.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-content")||(typeof c.content=="function"?c.content.call(b[0]):c.content),a=a.toString().replace(/(^\s*|\s*$)/,""),a},tip:function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip}}),a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("popover"),f=typeof c=="object"&&c;e||d.data("popover",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.defaults=a.extend({},a.fn.tooltip.defaults,{placement:"right",content:"",template:'<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'})}(window.jQuery),!function(a){function b(b,c){var d=a.proxy(this.process,this),e=a(b).is("body")?a(window):a(b),f;this.options=a.extend({},a.fn.scrollspy.defaults,c),this.$scrollElement=e.on("scroll.scroll.data-api",d),this.selector=(this.options.target||(f=a(b).attr("href"))&&f.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.$body=a("body").on("click.scroll.data-api",this.selector,d),this.refresh(),this.process()}"use strict",b.prototype={constructor:b,refresh:function(){this.targets=this.$body.find(this.selector).map(function(){var b=a(this).attr("href");return/^#\w/.test(b)&&a(b).length?b:null}),this.offsets=a.map(this.targets,function(b){return a(b).position().top})},process:function(){var a=this.$scrollElement.scrollTop()+this.options.offset,b=this.offsets,c=this.targets,d=this.activeTarget,e;for(e=b.length;e--;)d!=c[e]&&a>=b[e]&&(!b[e+1]||a<=b[e+1])&&this.activate(c[e])},activate:function(a){var b;this.activeTarget=a,this.$body.find(this.selector).parent(".active").removeClass("active"),b=this.$body.find(this.selector+'[href="'+a+'"]').parent("li").addClass("active"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active")}},a.fn.scrollspy=function(c){return this.each(function(){var d=a(this),e=d.data("scrollspy"),f=typeof c=="object"&&c;e||d.data("scrollspy",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.scrollspy.Constructor=b,a.fn.scrollspy.defaults={offset:10},a(function(){a('[data-spy="scroll"]').each(function(){var b=a(this);b.scrollspy(b.data())})})}(window.jQuery),!function(a){"use strict";var b=function(b){this.element=a(b)};b.prototype={constructor:b,show:function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.attr("data-target"),e,f;d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,""));if(b.parent("li").hasClass("active"))return;e=c.find(".active a").last()[0],b.trigger({type:"show",relatedTarget:e}),f=a(d),this.activate(b.parent("li"),c),this.activate(f,f.parent(),function(){b.trigger({type:"shown",relatedTarget:e})})},activate:function(b,c,d){function g(){e.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),f?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var e=c.find("> .active"),f=d&&a.support.transition&&e.hasClass("fade");f?e.one(a.support.transition.end,g):g(),e.removeClass("in")}},a.fn.tab=function(c){return this.each(function(){var d=a(this),e=d.data("tab");e||d.data("tab",e=new b(this)),typeof c=="string"&&e[c]()})},a.fn.tab.Constructor=b,a(function(){a("body").on("click.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(b){b.preventDefault(),a(this).tab("show")})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.typeahead.defaults,c),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.$menu=a(this.options.menu).appendTo("body"),this.source=this.options.source,this.shown=!1,this.listen()};b.prototype={constructor:b,select:function(){var a=this.$menu.find(".active").attr("data-value");return this.$element.val(a),this.hide()},show:function(){var b=a.extend({},this.$element.offset(),{height:this.$element[0].offsetHeight});return this.$menu.css({top:b.top+b.height,left:b.left}),this.$menu.show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(b){var c=this,d,e;return this.query=this.$element.val(),this.query?(d=a.grep(this.source,function(a){if(c.matcher(a))return a}),d=this.sorter(d),d.length?this.render(d.slice(0,this.options.items)).show():this.shown?this.hide():this):this.shown?this.hide():this},matcher:function(a){return~a.toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(a){var b=[],c=[],d=[],e;while(e=a.shift())e.toLowerCase().indexOf(this.query.toLowerCase())?~e.indexOf(this.query)?c.push(e):d.push(e):b.push(e);return b.concat(c,d)},highlighter:function(a){return a.replace(new RegExp("("+this.query+")","ig"),function(a,b){return"<strong>"+b+"</strong>"})},render:function(b){var c=this;return b=a(b).map(function(b,d){return b=a(c.options.item).attr("data-value",d),b.find("a").html(c.highlighter(d)),b[0]}),b.first().addClass("active"),this.$menu.html(b),this},next:function(b){var c=this.$menu.find(".active").removeClass("active"),d=c.next();d.length||(d=a(this.$menu.find("li")[0])),d.addClass("active")},prev:function(a){var b=this.$menu.find(".active").removeClass("active"),c=b.prev();c.length||(c=this.$menu.find("li").last()),c.addClass("active")},listen:function(){this.$element.on("blur",a.proxy(this.blur,this)).on("keypress",a.proxy(this.keypress,this)).on("keyup",a.proxy(this.keyup,this)),(a.browser.webkit||a.browser.msie)&&this.$element.on("keydown",a.proxy(this.keypress,this)),this.$menu.on("click",a.proxy(this.click,this)).on("mouseenter","li",a.proxy(this.mouseenter,this))},keyup:function(a){a.stopPropagation(),a.preventDefault();switch(a.keyCode){case 40:case 38:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:this.hide();break;default:this.lookup()}},keypress:function(a){a.stopPropagation();if(!this.shown)return;switch(a.keyCode){case 9:case 13:case 27:a.preventDefault();break;case 38:a.preventDefault(),this.prev();break;case 40:a.preventDefault(),this.next()}},blur:function(a){var b=this;a.stopPropagation(),a.preventDefault(),setTimeout(function(){b.hide()},150)},click:function(a){a.stopPropagation(),a.preventDefault(),this.select()},mouseenter:function(b){this.$menu.find(".active").removeClass("active"),a(b.currentTarget).addClass("active")}},a.fn.typeahead=function(c){return this.each(function(){var d=a(this),e=d.data("typeahead"),f=typeof c=="object"&&c;e||d.data("typeahead",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.typeahead.defaults={source:[],items:8,menu:'<ul class="typeahead dropdown-menu"></ul>',item:'<li><a href="#"></a></li>'},a.fn.typeahead.Constructor=b,a(function(){a("body").on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(b){var c=a(this);if(c.data("typeahead"))return;b.preventDefault(),c.typeahead(c.data())})})}(window.jQuery);
 /*
+ *	lib/js/lib/sprintf.js
+ */
+var sprintf=(function(){function get_type(variable){return Object.prototype.toString.call(variable).slice(8,-1).toLowerCase();}
+function str_repeat(input,multiplier){for(var output=[];multiplier>0;output[--multiplier]=input){}
+return output.join('');}
+var str_format=function(){if(!str_format.cache.hasOwnProperty(arguments[0])){str_format.cache[arguments[0]]=str_format.parse(arguments[0]);}
+return str_format.format.call(null,str_format.cache[arguments[0]],arguments);};str_format.format=function(parse_tree,argv){var cursor=1,tree_length=parse_tree.length,node_type='',arg,output=[],i,k,match,pad,pad_character,pad_length;for(i=0;i<tree_length;i++){node_type=get_type(parse_tree[i]);if(node_type==='string'){output.push(parse_tree[i]);}
+else if(node_type==='array'){match=parse_tree[i];if(match[2]){arg=argv[cursor];for(k=0;k<match[2].length;k++){if(!arg.hasOwnProperty(match[2][k])){arg='';}else{arg=arg[match[2][k]];}}}
+else if(match[1]){arg=argv[match[1]];}
+else{arg=argv[cursor++];}
+if(/[^s]/.test(match[8])&&(get_type(arg)!='number')){throw(sprintf('[sprintf] expecting number but found %s',get_type(arg)));}
+switch(match[8]){case'b':arg=arg.toString(2);break;case'c':arg=String.fromCharCode(arg);break;case'd':arg=parseInt(arg,10);break;case'e':arg=match[7]?arg.toExponential(match[7]):arg.toExponential();break;case'f':arg=match[7]?parseFloat(arg).toFixed(match[7]):parseFloat(arg);break;case'o':arg=arg.toString(8);break;case's':arg=((arg=String(arg))&&match[7]?arg.substring(0,match[7]):arg);break;case'u':arg=Math.abs(arg);break;case'x':arg=arg.toString(16);break;case'X':arg=arg.toString(16).toUpperCase();break;}
+arg=(/[def]/.test(match[8])&&match[3]&&arg>=0?'+'+arg:arg);pad_character=match[4]?match[4]=='0'?'0':match[4].charAt(1):' ';pad_length=match[6]-String(arg).length;pad=match[6]?str_repeat(pad_character,pad_length):'';output.push(match[5]?arg+pad:pad+arg);}}
+return output.join('');};str_format.cache={};str_format.parse=function(fmt){var _fmt=fmt,match=[],parse_tree=[],arg_names=0;while(_fmt){if((match=/^[^\x25]+/.exec(_fmt))!==null){parse_tree.push(match[0]);}
+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{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{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);};
+/*
  *	lib/js/core.min.js
  */
 /*
@@ -101,6 +122,15 @@
 state=window.location.hash;if(state!=src){window.location.hash=state;}
 else{document.title=title;}}}
 /*
+ *	lib/js/wn/misc/user.js
+ */
+wn.user_info=function(uid){var def={'fullname':uid,'image':'lib/images/ui/no_img_m.gif'}
+if(!wn.boot.user_info)return def
+if(!wn.boot.user_info[uid])return def
+if(!wn.boot.user_info[uid].fullname)
+wn.boot.user_info[uid].fullname=uid;if(!wn.boot.user_info[uid].image)
+wn.boot.user_info[uid].image=def.image;return wn.boot.user_info[uid];}
+/*
  *	lib/js/lib/json2.js
  */
 var JSON;if(!JSON){JSON={};}
@@ -165,6 +195,7 @@
 function $p(ele,top,left){ele.style.position='absolute';ele.style.top=top+'px';ele.style.left=left+'px';}
 function replace_newlines(t){return t?t.replace(/\n/g,'<br>'):'';}
 function cstr(s){if(s==null)return'';return s+'';}
+function nth(number){number=cint(number);var s='th';if((number+'').substr(-1)=='1')s='st';if((number+'').substr(-1)=='2')s='nd';if((number+'').substr(-1)=='3')s='rd';return number+s;}
 function flt(v,decimals){if(v==null||v=='')return 0;v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v))
 v=0;if(decimals!=null)
 return v.toFixed(decimals);return v;}
@@ -188,8 +219,7 @@
 function has_common(list1,list2){if(!list1||!list2)return false;for(var i=0;i<list1.length;i++){if(in_list(list2,list1[i]))return true;}
 return false;}
 var inList=in_list;function add_lists(l1,l2){var l=[];for(var k in l1)l.push(l1[k]);for(var k in l2)l.push(l2[k]);return l;}
-function docstring(obj){var l=[];for(key in obj){var v=obj[key];if(v!=null){if(typeof(v)==typeof(1)){l[l.length]="'"+key+"':"+(v+'');}else{v=v+'';l[l.length]="'"+key+"':'"+v.replace(/'/g,"\\'").replace(/\n/g,"\\n")+"'";}}}
-return"{"+l.join(',')+'}';}
+function docstring(obj){return JSON.stringify(obj);}
 function DocLink(p,doctype,name,onload){var a=$a(p,'span','link_type');a.innerHTML=a.dn=name;a.dt=doctype;a.onclick=function(){loaddoc(this.dt,this.dn,onload)};return a;}
 var doc_link=DocLink;var known_numbers={0:'zero',1:'one',2:'two',3:'three',4:'four',5:'five',6:'six',7:'seven',8:'eight',9:'nine',10:'ten',11:'eleven',12:'twelve',13:'thirteen',14:'fourteen',15:'fifteen',16:'sixteen',17:'seventeen',18:'eighteen',19:'nineteen',20:'twenty',30:'thirty',40:'forty',50:'fifty',60:'sixty',70:'seventy',80:'eighty',90:'ninety'}
 function in_words(n){var is_million=wn.control_panel.currency_format=='Millions'?1:0;n=cint(n)
@@ -203,21 +233,13 @@
 return bestguess+comma+' '+in_words(remainder);}else{return bestguess;}}
 function roundNumber(num,dec){var result=Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);return result;}
 /*
- *	lib/js/legacy/utils/browser_detect.js
- */
-var appVer=navigator.appVersion.toLowerCase();var is_minor=parseFloat(appVer);var is_major=parseInt(is_minor);var iePos=appVer.indexOf('msie');if(iePos!=-1){is_minor=parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
-is_major=parseInt(is_minor);}
-var isIE=(iePos!=-1);var isIE6=(isIE&&is_major<=6);var isIE7=(isIE&&is_major>=7);if(/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){var isFF=1;var ffversion=new Number(RegExp.$1)
-if(ffversion>=3)var isFF3=1;else if(ffversion>=2)var isFF2=1;else if(ffversion>=1)var isFF1=1;}
-var isSafari=navigator.userAgent.indexOf('Safari')!=-1?1:0;var isChrome=navigator.userAgent.indexOf('Chrome')!=-1?1:0;
-/*
  *	lib/js/legacy/utils/datetime.js
  */
 function same_day(d1,d2){if(d1.getFullYear()==d2.getFullYear()&&d1.getMonth()==d2.getMonth()&&d1.getDate()==d2.getDate())return true;else return false;}
 var month_list=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];var month_last={1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
 var month_list_full=['January','February','March','April','May','June','July','August','September','October','November','December'];var week_list=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];var week_list_full=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];function int_to_str(i,len){i=''+i;if(i.length<len)for(c=0;c<(len-i.length);c++)i='0'+i;return i}
 wn.datetime={str_to_obj:function(d){if(!d)return new Date();var tm=[null,null];if(d.search(' ')!=-1){var tm=d.split(' ')[1].split(':');var d=d.split(' ')[0];}
-if(d.search('-')!=-1){var t=d.split('-');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else if(d.search('/')!=-1){var t=d.split('/');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else{return new Date();}},obj_to_str:function(d){return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-'+int_to_str(d.getDate(),2);},obj_to_user:function(d){return dateutil.str_to_user(dateutil.obj_to_str(d));},get_diff:function(d1,d2){return((d1-d2)/86400000);},add_days:function(d,days){d.setTime(d.getTime()+(days*24*60*60*1000));return d},add_months:function(d,months){dt=dateutil.str_to_obj(d)
+if(d.search('-')!=-1){var t=d.split('-');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else if(d.search('/')!=-1){var t=d.split('/');return new Date(t[0],t[1]-1,t[2],tm[0],tm[1]);}else{return new Date();}},obj_to_str:function(d){return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-'+int_to_str(d.getDate(),2);},obj_to_user:function(d){return dateutil.str_to_user(dateutil.obj_to_str(d));},get_diff:function(d1,d2){return((d1-d2)/86400000);},get_day_diff:function(d1,d2){return dateutil.get_diff(new Date(d1.getYear(),d1.getMonth(),d1.getDate(),0,0),new Date(d2.getYear(),d2.getMonth(),d2.getDate(),0,0))},add_days:function(d,days){d.setTime(d.getTime()+(days*24*60*60*1000));return d},add_months:function(d,months){dt=dateutil.str_to_obj(d)
 new_dt=new Date(dt.getFullYear(),dt.getMonth()+months,dt.getDate())
 if(new_dt.getDate()!=dt.getDate()){return dateutil.month_end(new Date(dt.getFullYear(),dt.getMonth()+months,1))}
 return dateutil.obj_to_str(new_dt);},month_start:function(){var d=new Date();return d.getFullYear()+'-'+int_to_str(d.getMonth()+1,2)+'-01';},month_end:function(d){if(!d)var d=new Date();var m=d.getMonth()+1;var y=d.getFullYear();last_date=month_last[m];if(m==2&&(y%4)==0&&((y%100)!=0||(y%400)==0))
@@ -234,7 +256,7 @@
 else if(user_fmt=='dd/mm/yyyy'){var d=d.split('/');return d[2]+'-'+d[1]+'-'+d[0];}
 else if(user_fmt=='yyyy-mm-dd'){return d;}
 else if(user_fmt=='mm/dd/yyyy'){var d=d.split('/');return d[2]+'-'+d[0]+'-'+d[1];}
-else if(user_fmt=='mm-dd-yyyy'){var d=d.split('-');return d[2]+'-'+d[0]+'-'+d[1];}},global_date_format:function(d){if(d.substr)d=this.str_to_obj(d);return d.getDate()+' '+month_list_full[d.getMonth()]+' '+d.getFullYear();},get_today:function(){var today=new Date();var m=(today.getMonth()+1)+'';if(m.length==1)m='0'+m;var d=today.getDate()+'';if(d.length==1)d='0'+d;return today.getFullYear()+'-'+m+'-'+d;},get_cur_time:function(){var d=new Date();var hh=d.getHours()+''
+else if(user_fmt=='mm-dd-yyyy'){var d=d.split('-');return d[2]+'-'+d[0]+'-'+d[1];}},global_date_format:function(d){if(d.substr)d=this.str_to_obj(d);return nth(d.getDate())+' '+month_list_full[d.getMonth()]+' '+d.getFullYear();},get_today:function(){var today=new Date();var m=(today.getMonth()+1)+'';if(m.length==1)m='0'+m;var d=today.getDate()+'';if(d.length==1)d='0'+d;return today.getFullYear()+'-'+m+'-'+d;},get_cur_time:function(){var d=new Date();var hh=d.getHours()+''
 var mm=cint(d.getMinutes()/5)*5+''
 return(hh.length==1?'0'+hh:hh)+':'+(mm.length==1?'0'+mm:mm);}}
 wn.datetime.only_date=function(val){if(val==null||val=='')return null;if(val.search(':')!=-1){var tmp=val.split(' ');var d=tmp[0].split('-');}else{var d=val.split('-');}
@@ -246,7 +268,8 @@
 wn.datetime.time_to_hhmm=function(hh,mm,am){if(am=='AM'&&hh=='12'){hh='00';}else if(am=='PM'&&hh!='12'){hh=cint(hh)+12;}
 return hh+':'+mm;}
 function prettyDate(time){if(!time)return''
-var date=new Date((time||"").replace(/-/g,"/").replace(/[TZ]/g," ").replace(/\.[0-9]*/,"")),diff=(((new Date()).getTime()-date.getTime())/1000),day_diff=Math.floor(diff/86400);if(isNaN(day_diff)||day_diff<0)
+var date=time;if(typeof(time)=="string")
+date=new Date((time||"").replace(/-/g,"/").replace(/[TZ]/g," ").replace(/\.[0-9]*/,""));var diff=(((new Date()).getTime()-date.getTime())/1000),day_diff=Math.floor(diff/86400);if(isNaN(day_diff)||day_diff<0)
 return'';return day_diff==0&&(diff<60&&"just now"||diff<120&&"1 minute ago"||diff<3600&&Math.floor(diff/60)+" minutes ago"||diff<7200&&"1 hour ago"||diff<86400&&Math.floor(diff/3600)+" hours ago")||day_diff==1&&"Yesterday"||day_diff<7&&day_diff+" days ago"||day_diff<31&&Math.ceil(day_diff/7)+" weeks ago"||day_diff<365&&Math.ceil(day_diff/30)+" months ago"||"more than "+Math.floor(day_diff/365)+" year(s) ago";}
 if(typeof jQuery!="undefined")
 jQuery.fn.prettyDate=function(){return this.each(function(){var date=prettyDate(this.title);if(date)
@@ -336,7 +359,7 @@
 return"";else
 return decodeURIComponent(results[1]);},get_dict:function(){var d={}
 var t=window.location.href.split('?')[1];if(!t)return d;if(t.indexOf('#')!=-1)t=t.split('#')[0];if(!t)return d;t=t.split('&');for(var i=0;i<t.length;i++){var a=t[i].split('=');d[decodeURIComponent(a[0])]=decodeURIComponent(a[1]);}
-return d;},get_base_url:function(){var url=window.location.href.split('#')[0].split('?')[0].split('index.html')[0];if(url.substr(url.length-1,1)=='/')url=url.substr(0,url.length-1)
+return d;},get_base_url:function(){var url=window.location.href.split('#')[0].split('?')[0].split('index.cgi')[0];if(url.substr(url.length-1,1)=='/')url=url.substr(0,url.length-1)
 return url},get_file_url:function(file_id){return repl('files/%(fn)s',{fn:file_id})}}
 get_url_arg=wn.urllib.get_arg;get_url_dict=wn.urllib.get_dict;var user_img={}
 var user_img_queue={};var user_img_loading=[];set_user_img=function(img,username,get_latest,img_id){function set_it(i){if(user_img[username]=='no_img_m')
@@ -353,7 +376,7 @@
 var outUrl="index.cgi";var NULL_CHAR='^\5*';function checkResponse(r,on_timeout,no_spinner,freeze_msg){try{if(r.readyState==4&&r.status==200)return true;else return false;}catch(e){msgprint("error:Request timed out, try again");if(on_timeout)
 on_timeout();hide_loading();if(freeze_msg)
 unfreeze();return false;}}
-var pending_req=0;function newHttpReq(){if(!isIE)
+var pending_req=0;function newHttpReq(){if(!$.browser.msie)
 var r=new XMLHttpRequest();else if(window.ActiveXObject)
 var r=new ActiveXObject("Microsoft.XMLHTTP");return r;}
 function $c(command,args,fn,on_timeout,no_spinner,freeze_msg,btn){var req=newHttpReq();ret_fn=function(){if(checkResponse(req,on_timeout,no_spinner,freeze_msg)){if(btn)$(btn).done_working();if(!no_spinner)
@@ -678,8 +701,8 @@
 this.clear=function(){this.results_area.innerHTML='';this.table=null;$ds(this.results_area);$dh(this.no_results_area);}
 this.make_results=function(r,rt){if(this.start==0)this.clear();$dh(this.more_button_area);if(this.loading_img)$dh(this.loading_img)
 if(r.message)r.values=r.message;if(r.values&&r.values.length){this.values=r.values;var m=Math.min(r.values.length,this.page_length);for(var i=0;i<m;i++){var row=this.add_row();this.opts.render_row(row,r.values[i],this,i);}
-this.start+=m;if(r.values.length>this.page_length)$ds(this.more_button_area);}else{if(this.start==0){$dh(this.results_area);$ds(this.no_results_area);}}
-if(this.onrun)this.onrun();if(this.opts.onrun)this.opts.onrun();}
+this.start+=m;if(r.values.length>=this.page_length)$ds(this.more_button_area);}else{if(this.start==0){$dh(this.results_area);$ds(this.no_results_area);}}
+if(this.onrun)this.onrun();if(this.opts.onrun)this.opts.onrun();if(this.opts.callback)this.opts.callback(r);}
 this.add_row=function(){return $a(this.results_area,'div','',(opts.cell_style?opts.cell_style:{padding:'3px 0px'}));}
 this.run=function(callback,append){if(callback)
 this.onrun=callback;if(!append)
@@ -798,7 +821,7 @@
 /*
  *	lib/js/legacy/webpage/freeze_page.js
  */
-var fcount=0;var frozen=0;var dialog_message;var dialog_back;function freeze(msg,do_freeze){if(!dialog_back){dialog_back=$a($i('body_div'),'div','dialog_back');if(isIE)dialog_back.style['filter']='alpha(opacity=60)';}
+var fcount=0;var frozen=0;var dialog_message;var dialog_back;function freeze(msg,do_freeze){if(!dialog_back){dialog_back=$a($i('body_div'),'div','dialog_back');$(dialog_back).css('opacity',0.6);}
 $ds(dialog_back);fcount++;frozen=1;}
 function unfreeze(){if(dialog_message)
 $dh(dialog_message);if(!fcount)return;fcount--;if(!fcount){$dh(dialog_back);frozen=0;}}
@@ -1000,7 +1023,7 @@
 /*
  *	lib/js/legacy/app.js
  */
-var popup_cont;var session={};var start_sid=null;if(!wn)var wn={};function startup(){start_sid=get_cookie('sid');popup_cont=$a(document.getElementsByTagName('body')[0],'div');var setup_globals=function(r){wn.boot=r;profile=r.profile;user=r.profile.name;user_fullname=wn.boot.user_fullnames?wn.boot.user_fullnames[user]:'Guest';user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;home_page=r.home_page;_p.letter_heads=r.letter_heads;sys_defaults=r.sysdefaults;session.rt=profile.can_read;if(r.ipinfo)session.ipinfo=r.ipinfo;session.dt_labels=r.dt_labels;session.rev_dt_labels={}
+var popup_cont;var session={};var start_sid=null;if(!wn)var wn={};function startup(){start_sid=get_cookie('sid');popup_cont=$a(document.getElementsByTagName('body')[0],'div');var setup_globals=function(r){wn.boot=r;profile=r.profile;user=r.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;home_page=r.home_page;_p.letter_heads=r.letter_heads;sys_defaults=r.sysdefaults;session.rt=profile.can_read;if(r.ipinfo)session.ipinfo=r.ipinfo;session.dt_labels=r.dt_labels;session.rev_dt_labels={}
 if(r.dt_labels){for(key in r.dt_labels)session.rev_dt_labels[r.dt_labels[key]]=key;}
 wn.control_panel=r.control_panel;}
 var setup_history=function(r){rename_observers.push(nav_obj);}
@@ -1040,24 +1063,25 @@
 /*
  *	erpnext/startup/startup.js
  */
-var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.startup.set_globals=function(){pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway)
+var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions','Dashboard':'dashboard'}
+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(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(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{wn.boot.profile.allow_modules=wn.boot.profile.allow_modules.concat(['To Do','Knowledge Base','Calendar','Activity','Messages'])
+erpnext.toolbar.setup();erpnext.startup.set_periodic_updates();$('footer').html('<div class="web-footer erpnext-footer">\
+   <a href="#!attributions">ERPNext | Attributions and License</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);}
 show_chart_browser=function(nm,chart_type){var call_back=function(){if(nm=='Sales Browser'){var sb_obj=new SalesBrowser();sb_obj.set_val(chart_type);}
 else if(nm=='Accounts Browser')
 pscript.make_chart(chart_type);}
 loadpage(nm,call_back);}
-ModulePage=function(parent,module_name,module_label,help_page,callback){this.parent=parent;page_body.cur_page.module_page=this;this.wrapper=$a(parent,'div');this.module_name=module_name;this.transactions=[];this.page_head=new PageHeader(this.wrapper,module_label);if(help_page){var btn=this.page_head.add_button('Help',function(){loadpage(this.help_page)},1,'ui-icon-help')
-btn.help_page=help_page;}
-if(callback)this.callback=function(){callback();}}
-var update_messages=function(){if(inList(['Guest'],user)){return;}
-$c_page('home','event_updates','get_unread_messages',null,function(r,rt){if(!r.exc){page_body.wntoolbar.set_new_comments(r.message);var circle=$('#msg_count')
-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);}});}
+var update_messages=function(reset){if(inList(['Guest'],user)){return;}
+if(!reset){$c_page('home','event_updates','get_unread_messages',null,function(r,rt){if(!r.exc){page_body.wntoolbar.set_new_comments(r.message);var circle=$('#msg_count')
+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);}});}else{page_body.wntoolbar.set_new_comments(0);$('#msg_count').toggle(false);}}
 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;}',{src:src}))}
 $(document).bind('startup',function(){erpnext.startup.start();});
 /*
  *	erpnext/website/js/topbar.js
diff --git a/unsupported.html b/unsupported.html
new file mode 100644
index 0000000..b770bad
--- /dev/null
+++ b/unsupported.html
@@ -0,0 +1,19 @@
+<html>
+<head>
+	<title>ERPNext - Uprade your browser</title>
+</head>
+<body style="background-color: #eee">
+	<div style="width: 900px; margin: 20px auto; padding: 20px;
+	background-color: #fff; border: 2px solid #aaa; font-family: Arial">
+	<h3>Upgrade Your Browser</h3>
+	<p><i>ERPNext requires a modern web browser to function correctly</i></p>
+	<p>Supported browsers are:
+		<ul>
+		<li><a href="http://mozilla.com/firefox">Mozilla Firfox 4+</a>,
+		<li><a href="http://google.com/chrome">Google Chorme 14+</a>,
+		<li><a href="http://apple.com/safari">Apple Safari 5+</a>,
+		<li><a href="http://ie.microsoft.com">Microsoft Internet Explorer 9+</a>,
+		<li><a href="http://www.opera.com/">Opera</a>
+		</ul>
+	</p>
+</body>
\ No newline at end of file
diff --git a/version.num b/version.num
index 5cd7ca2..b3fa96d 100644
--- a/version.num
+++ b/version.num
@@ -1 +1 @@
-748
\ No newline at end of file
+819