Merge branch 'latest' of github.com:webnotes/erpnext into latest

Conflicts:
	index.html
	version.num
diff --git a/erpnext/patches/jan_mar_2012/customer_address_contact_patch.py b/erpnext/patches/jan_mar_2012/customer_address_contact_patch.py
new file mode 100644
index 0000000..6a7d405
--- /dev/null
+++ b/erpnext/patches/jan_mar_2012/customer_address_contact_patch.py
@@ -0,0 +1,58 @@
+import webnotes
+
+def execute():
+	"""
+		* Reload Search Criteria "Customer Address Contact"
+		* SET is_primary_contact=1, is_primary_address=1 WHERE not specified
+	"""
+	reload_sc()
+	patch_primary_contact()
+	patch_primary_address()
+
+def reload_sc():
+	from webnotes.modules.module_manager import reload_doc
+	reload_doc('selling', 'search_criteria', 'customer_address_contact')
+	reload_doc('selling', 'Module Def', 'Selling')
+
+def patch_primary_contact():
+	res = webnotes.conn.sql("""
+		SELECT name FROM `tabContact`
+		WHERE customer IN (
+			SELECT customer FROM `tabContact`
+			WHERE IFNULL(customer, '')!=''
+			GROUP BY customer HAVING SUM(IFNULL(is_primary_contact, 0))=0
+		) OR supplier IN (
+			SELECT supplier FROM `tabContact`
+			WHERE IFNULL(supplier, '')!=''
+			GROUP BY supplier HAVING SUM(IFNULL(is_primary_contact, 0))=0
+		) OR sales_partner IN (
+			SELECT sales_partner FROM `tabContact`
+			WHERE IFNULL(sales_partner, '')!=''
+			GROUP BY sales_partner HAVING SUM(IFNULL(is_primary_contact, 0))=0
+		)
+	""", as_list=1)
+	names = ", ".join(["'" + str(r[0]) + "'" for r in res if r])
+	if names: webnotes.conn.sql("UPDATE `tabContact` SET is_primary_contact=1 WHERE name IN (%s)" % names)
+
+def patch_primary_address():
+	res = webnotes.conn.sql("""
+		SELECT name FROM `tabAddress`
+		WHERE customer IN (
+			SELECT customer FROM `tabAddress`
+			WHERE IFNULL(customer, '')!=''
+			GROUP BY customer HAVING SUM(IFNULL(is_primary_address, 0))=0
+			AND SUM(IFNULL(is_shipping_address, 0))=0
+		) OR supplier IN (
+			SELECT supplier FROM `tabAddress`
+			WHERE IFNULL(supplier, '')!=''
+			GROUP BY supplier HAVING SUM(IFNULL(is_primary_address, 0))=0
+			AND SUM(IFNULL(is_shipping_address, 0))=0
+		) OR sales_partner IN (
+			SELECT sales_partner FROM `tabAddress`
+			WHERE IFNULL(sales_partner, '')!=''
+			GROUP BY sales_partner HAVING SUM(IFNULL(is_primary_address, 0))=0
+			AND SUM(IFNULL(is_shipping_address, 0))=0
+		)
+	""", as_list=1)
+	names = ", ".join(["'" + str(r[0]) + "'" for r in res if r])
+	if names: webnotes.conn.sql("UPDATE `tabAddress` SET is_primary_address=1 WHERE name IN (%s)" % names)
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index fe4f09c..c0c7d1e 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -35,4 +35,9 @@
 		'patch_file': 'remove_get_tds_button',
 		'description': "Remove One Get TDS button, which is appearing twice in JV"
 	},
+	{
+		'patch_module': 'patches.jan_mar_2012',
+		'patch_file': 'customer_address_contact',
+		'description': "Install Customer Address Contact report and run patches regarding primary address and contact"
+	},
 ]
diff --git a/erpnext/production/doctype/bill_of_materials/bill_of_materials.py b/erpnext/production/doctype/bill_of_materials/bill_of_materials.py
index 2a17817..6e99af9 100644
--- a/erpnext/production/doctype/bill_of_materials/bill_of_materials.py
+++ b/erpnext/production/doctype/bill_of_materials/bill_of_materials.py
@@ -135,7 +135,7 @@
 		""" Uncheck others if current one is selected as default, update default bom in item master"""
 
 		if self.doc.is_default and self.doc.is_active == 'Yes':
-			sql("update `tabBill Of Materials` set is_default = 0 where name != %s", self.doc.name)
+			sql("update `tabBill Of Materials` set is_default = 0 where name != %s and item=%s", (self.doc.name, self.doc.item))
 
 			# update default bom in Item Master
 			sql("update `tabItem` set default_bom = %s where name = %s", (self.doc.name, self.doc.item))
diff --git a/erpnext/selling/Module Def/Selling/Selling.txt b/erpnext/selling/Module Def/Selling/Selling.txt
index 5500cb3..42c8449 100644
--- a/erpnext/selling/Module Def/Selling/Selling.txt
+++ b/erpnext/selling/Module Def/Selling/Selling.txt
@@ -1,673 +1,335 @@
+# Module Def, Selling
 [
+
+	# These values are common in all dictionaries
 	{
-		'_last_update': None,
-		'creation': '2011-06-30 15:45:03',
-		'disabled': 'No',
+		'creation': '2011-07-01 17:39:08',
 		'docstatus': 0,
+		'modified': '2012-01-23 18:25:58',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all Module Def Role
+	{
+		'doctype': 'Module Def Role',
+		'name': '__common__',
+		'parent': 'Selling',
+		'parentfield': 'roles',
+		'parenttype': 'Module Def'
+	},
+
+	# These values are common for all Module Def Item
+	{
+		'doctype': 'Module Def Item',
+		'name': '__common__',
+		'parent': 'Selling',
+		'parentfield': 'items',
+		'parenttype': 'Module Def'
+	},
+
+	# These values are common for all Module Def
+	{
+		'disabled': 'No',
 		'doctype': u'Module Def',
 		'doctype_list': 'Print Format, Sales Order\nPrint Format, Quotation Format\nPrint Format, Delivery Note Format',
 		'file_list': 'crm.gif,FileData/00208',
-		'idx': None,
 		'is_hidden': 'No',
-		'last_updated_date': None,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
 		'module_desc': 'Manage you sales team, with your leads, customers, quotes, orders etc.',
 		'module_icon': 'Selling.gif',
 		'module_label': 'Selling',
 		'module_name': 'Selling',
-		'module_page': None,
 		'module_seq': 3,
-		'name': 'Selling',
-		'owner': 'Administrator',
-		'parent': None,
-		'parentfield': None,
-		'parenttype': None,
-		'trash_reason': None,
-		'widget_code': None
+		'name': '__common__'
 	},
+
+	# Module Def, Selling
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
+		'doctype': u'Module Def',
+		'name': 'Selling'
+	},
+
+	# Module Def Item
+	{
 		'description': 'Database of potential customers you need to keep in touch with',
 		'display_name': 'Lead',
 		'doc_name': 'Lead',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': 'status\nlead_owner\nlead_name\ncontact_no\ncontact_by\ncontact_date\nexpected_month',
-		'hide': None,
-		'icon': None,
-		'idx': 1,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01284',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'fields': 'status\nlead_owner\nlead_name\ncontact_no\ncontact_by\ncontact_date\nexpected_month'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
 		'description': 'Your Customer Database',
 		'display_name': 'Customer',
 		'doc_name': 'Customer',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': 'customer_group\ncountry',
-		'hide': None,
-		'icon': None,
-		'idx': 2,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01285',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'fields': 'customer_group\ncountry'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
 		'description': 'Specific requirements from a Lead / Customer',
 		'display_name': 'Enquiry',
 		'doc_name': 'Enquiry',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ncompany',
-		'hide': None,
-		'icon': None,
-		'idx': 3,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01286',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ncompany'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
 		'description': 'Offers you have made to your customers',
 		'display_name': 'Quotation',
 		'doc_name': 'Quotation',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ngrand_total\ncompany',
-		'hide': None,
-		'icon': None,
-		'idx': 4,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01287',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ngrand_total\ncompany'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
 		'description': 'Database of confirmed Sale Orders from your Customers',
 		'display_name': 'Sales Order',
 		'doc_name': 'Sales Order',
 		'doc_type': 'Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': 'status\ntransaction_date\ncustomer\ncost_center\ngrand_total\nper_delivered\nper_billed\ncompany',
-		'hide': None,
-		'icon': None,
-		'idx': 5,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01288',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'fields': 'status\ntransaction_date\ncustomer\ncost_center\ngrand_total\nper_delivered\nper_billed\ncompany'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Sales Dashboard',
 		'doc_name': 'Sales Dashboard',
 		'doc_type': 'Pages',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 6,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01289',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
-		'display_name': None,
 		'doc_name': 'Reports',
 		'doc_type': 'Separator',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 7,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01290',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
+		'doc_name': 'Reports',
+		'doc_type': 'Separator',
+		'doctype': 'Module Def Item'
+	},
+
+	# Module Def Item
+	{
 		'display_name': 'Gross Profit',
 		'doc_name': 'Delivery Note Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 8,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01291',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Territory, Item Group wise GP',
 		'doc_name': 'Delivery Note',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 9,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01292',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Itemwise Sales Details',
 		'doc_name': 'Sales Order Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 10,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01293',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Itemwise Delivery Details',
 		'doc_name': 'Delivery Note Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 11,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01294',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Sales Personwise Transaction Summary',
 		'doc_name': 'Sales Person',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 12,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01295',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Total Target Variance Report',
 		'doc_name': 'Target Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 13,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01296',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Sales Persons Target Variance (Item Group wise)',
 		'doc_name': 'Target Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 14,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01297',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Territories Target Variance (Item Group wise)',
 		'doc_name': 'Target Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 15,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01298',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Sales Order Pending Items',
 		'doc_name': 'Sales Order Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 16,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01299',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Sales Orderwise Booking & Delivery Summary',
 		'doc_name': 'Sales Order Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 17,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01300',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Sales Orderwise Pending Qty To Deliver',
 		'doc_name': 'Sales Order Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 18,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01301',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Sales Orderwise Pending Amount To Bill',
 		'doc_name': 'Sales Order Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 19,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01302',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Delivered Items to be Install',
 		'doc_name': 'Delivery Note Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 20,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01303',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Itemwise Price List',
 		'doc_name': 'Ref Rate Detail',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 21,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01304',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
-		'description': None,
 		'display_name': 'Follow-up Report',
 		'doc_name': 'Follow up',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 22,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01305',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
 		'description': 'Ledger details of your debtors',
 		'display_name': "Debtor's Ledger",
 		'doc_name': 'GL Entry',
 		'doc_type': 'Reports',
-		'docstatus': 0,
-		'doctype': 'Module Def Item',
-		'fields': None,
-		'hide': None,
-		'icon': None,
-		'idx': 23,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01306',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'doctype': 'Module Def Item'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
+		'description': 'Report displaying Customer, Primary Address Details & Primary Contact Details',
+		'display_name': 'Customer Address Contact',
+		'doc_name': 'Customer',
+		'doc_type': 'Reports',
+		'doctype': 'Module Def Item'
+	},
+
+	# Module Def Item
+	{
 		'description': 'Customer Category',
 		'display_name': 'Customer Group',
 		'doc_name': 'Customer Group',
 		'doc_type': 'Setup Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': 'id\ndescription',
-		'hide': None,
-		'icon': None,
-		'idx': 24,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01307',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'fields': 'id\ndescription'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
 		'description': 'Sales person details',
 		'display_name': 'Sales Person',
 		'doc_name': 'Sales Person',
 		'doc_type': 'Setup Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': 'id\nterritory\ndepartment\nmobile_no\nemail_id',
-		'hide': None,
-		'icon': None,
-		'idx': 25,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01308',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'fields': 'id\nterritory\ndepartment\nmobile_no\nemail_id'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
 		'description': 'Item master',
 		'display_name': 'Item',
 		'doc_name': 'Item',
 		'doc_type': 'Setup Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': 'name\nitem_group\ndescription',
-		'hide': None,
-		'icon': None,
-		'idx': 26,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01309',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'fields': 'name\nitem_group\ndescription'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
 		'description': 'Sales partner details',
 		'display_name': 'Sales Partner',
 		'doc_name': 'Sales Partner',
 		'doc_type': 'Setup Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': 'id\npartner_type\nmobile\nemail\nterritory',
-		'hide': None,
-		'icon': None,
-		'idx': 27,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01310',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'fields': 'id\npartner_type\nmobile\nemail\nterritory'
 	},
+
+	# Module Def Item
 	{
-		'click_function': None,
-		'creation': '2011-06-30 15:45:03',
 		'description': 'Business campaigns',
 		'display_name': 'Campaign',
 		'doc_name': 'Campaign',
 		'doc_type': 'Setup Forms',
-		'docstatus': 0,
 		'doctype': 'Module Def Item',
-		'fields': 'id\ncampaign_name\ndescription',
-		'hide': None,
-		'icon': None,
-		'idx': 28,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDI01311',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'items',
-		'parenttype': 'Module Def'
+		'fields': 'id\ncampaign_name\ndescription'
 	},
+
+	# Module Def Role
 	{
-		'creation': '2011-06-30 15:45:03',
-		'docstatus': 0,
 		'doctype': 'Module Def Role',
-		'idx': 1,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDR00328',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'roles',
-		'parenttype': 'Module Def',
 		'role': 'Administrator'
 	},
+
+	# Module Def Role
 	{
-		'creation': '2011-06-30 15:45:03',
-		'docstatus': 0,
 		'doctype': 'Module Def Role',
-		'idx': 2,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDR00329',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'roles',
-		'parenttype': 'Module Def',
 		'role': 'Sales Manager'
 	},
+
+	# Module Def Role
 	{
-		'creation': '2011-06-30 15:45:03',
-		'docstatus': 0,
 		'doctype': 'Module Def Role',
-		'idx': 3,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDR00330',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'roles',
-		'parenttype': 'Module Def',
 		'role': 'Sales User'
 	},
+
+	# Module Def Role
 	{
-		'creation': '2011-06-30 15:45:03',
-		'docstatus': 0,
 		'doctype': 'Module Def Role',
-		'idx': 4,
-		'modified': '2011-06-30 15:45:03',
-		'modified_by': 'Administrator',
-		'name': 'MDR00331',
-		'owner': 'Administrator',
-		'parent': 'Selling',
-		'parentfield': 'roles',
-		'parenttype': 'Module Def',
 		'role': 'Sales Master Manager'
 	}
 ]
\ No newline at end of file
diff --git a/erpnext/selling/search_criteria/customer_address_contact/__init__.py b/erpnext/selling/search_criteria/customer_address_contact/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/selling/search_criteria/customer_address_contact/__init__.py
diff --git a/erpnext/selling/search_criteria/customer_address_contact/customer_address_contact.txt b/erpnext/selling/search_criteria/customer_address_contact/customer_address_contact.txt
new file mode 100644
index 0000000..9e0a715
--- /dev/null
+++ b/erpnext/selling/search_criteria/customer_address_contact/customer_address_contact.txt
@@ -0,0 +1,36 @@
+# Search Criteria, customer_address_contact
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2012-01-23 18:28:40',
+		'docstatus': 0,
+		'modified': '2012-01-23 18:28:40',
+		'modified_by': 'Administrator',
+		'owner': 'Administrator'
+	},
+
+	# These values are common for all Search Criteria
+	{
+		'add_col': "`tabAddress`.address_line1 AS 'Address Line 1'\n`tabAddress`.address_line2 AS 'Address Line 2'\n`tabAddress`.city AS 'City'\n`tabAddress`.state AS 'State'\n`tabAddress`.pincode AS 'Pincode'\n`tabAddress`.country AS 'Country'\n`tabContact`.first_name AS 'Contact First Name'\n`tabContact`.last_name AS 'Contact Last Name'\n`tabContact`.phone AS 'Contact Phone'\n`tabContact`.mobile_no AS 'Contact Mobile'\n`tabContact`.email_id AS 'Contact Email'",
+		'add_cond': '`tabAddress`.customer=`tabCustomer`.name\nifnull(`tabAddress`.is_primary_address, 0)=1\n`tabContact`.customer=`tabCustomer`.name\nifnull(`tabContact`.is_primary_contact, 0)=1',
+		'add_tab': '`tabAddress`\n`tabContact`',
+		'columns': 'Customer\x01ID,Customer\x01Customer Name',
+		'criteria_name': 'Customer Address Contact',
+		'doc_type': 'Customer',
+		'doctype': 'Search Criteria',
+		'filters': "{'Customer\x01Saved':1,'Customer\x01Submitted':1}",
+		'module': 'Selling',
+		'name': '__common__',
+		'page_len': 50,
+		'sort_by': '`tabCustomer`.`customer_name`',
+		'sort_order': 'ASC',
+		'standard': 'Yes'
+	},
+
+	# Search Criteria, customer_address_contact
+	{
+		'doctype': 'Search Criteria',
+		'name': 'customer_address_contact'
+	}
+]
\ No newline at end of file
diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py
index eabf624..7602d1d 100644
--- a/erpnext/utilities/doctype/address/address.py
+++ b/erpnext/utilities/doctype/address/address.py
@@ -4,53 +4,64 @@
 from webnotes.model.doc import Document
 from webnotes import session, form, msgprint, errprint
 
-sql = webnotes.conn.sql
-  
 # -----------------------------------------------------------------------------------------
 
 class DocType:
-  def __init__(self, doc, doclist=[]):
-    self.doc = doc
-    self.doclist = doclist
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
 
-  def autoname(self):
-    if self.doc.customer:
-      self.doc.name = self.doc.customer + '-' + self.doc.address_type
-    elif self.doc.supplier:
-      self.doc.name = self.doc.supplier + '-' + self.doc.address_type
-    elif self.doc.sales_partner:
-      self.doc.name = self.doc.sales_partner + '-' + self.doc.address_type
-      
-    # filter out bad characters in name
-    #self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','')
+	def autoname(self):
+		if self.doc.customer:
+			self.doc.name = self.doc.customer + '-' + self.doc.address_type
+		elif self.doc.supplier:
+			self.doc.name = self.doc.supplier + '-' + self.doc.address_type
+		elif self.doc.sales_partner:
+			self.doc.name = self.doc.sales_partner + '-' + self.doc.address_type
+			
+		# filter out bad characters in name
+		#self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','')
 
 #----------------------
 # Call to Validate
 #----------------------
-  def validate(self):
-    self.validate_primary_address()
-    self.validate_shipping_address()
+	def validate(self):
+		self.validate_primary_address()
+		self.validate_shipping_address()
 
 #----------------------
 # Validate that there can only be one primary address for particular customer, supplier
 #----------------------
-  def validate_primary_address(self):
-    if self.doc.is_primary_address == 1:
-      if self.doc.customer: 
-        sql("update tabAddress set is_primary_address=0 where customer = '%s'" % (self.doc.customer))
-      elif self.doc.supplier:
-        sql("update tabAddress set is_primary_address=0 where supplier = '%s'" % (self.doc.supplier))
-      elif self.doc.sales_partner:
-        sql("update tabAddress set is_primary_address=0 where sales_partner = '%s'" % (self.doc.sales_partner))
-        
+	def validate_primary_address(self):
+		sql = webnotes.conn.sql
+		if self.doc.is_primary_address == 1:
+			if self.doc.customer: 
+				sql("update tabAddress set is_primary_address=0 where customer = '%s'" % (self.doc.customer))
+			elif self.doc.supplier:
+				sql("update tabAddress set is_primary_address=0 where supplier = '%s'" % (self.doc.supplier))
+			elif self.doc.sales_partner:
+				sql("update tabAddress set is_primary_address=0 where sales_partner = '%s'" % (self.doc.sales_partner))
+		elif not self.doc.is_shipping_address:
+			if self.doc.customer: 
+				if not sql("select name from tabAddress where is_primary_address=1 and customer = '%s'" % (self.doc.customer)):
+					self.doc.is_primary_address = 1
+			elif self.doc.supplier:
+				if not sql("select name from tabAddress where is_primary_address=1 and supplier = '%s'" % (self.doc.supplier)):
+					self.doc.is_primary_address = 1
+			elif self.doc.sales_partner:
+				if not sql("select name from tabAddress where is_primary_address=1 and sales_partner = '%s'" % (self.doc.sales_partner)):
+					self.doc.is_primary_address = 1
+
+				
 #----------------------
 # Validate that there can only be one shipping address for particular customer, supplier
 #----------------------
-  def validate_shipping_address(self):
-    if self.doc.is_shipping_address == 1:
-      if self.doc.customer: 
-        sql("update tabAddress set is_shipping_address=0 where customer = '%s'" % (self.doc.customer))
-      elif self.doc.supplier:
-        sql("update tabAddress set is_shipping_address=0 where supplier = '%s'" % (self.doc.supplier))      
-      elif self.doc.sales_partner:
-        sql("update tabAddress set is_shipping_address=0 where sales_partner = '%s'" % (self.doc.sales_partner))      
+	def validate_shipping_address(self):
+		sql = webnotes.conn.sql
+		if self.doc.is_shipping_address == 1:
+			if self.doc.customer: 
+				sql("update tabAddress set is_shipping_address=0 where customer = '%s'" % (self.doc.customer))
+			elif self.doc.supplier:
+				sql("update tabAddress set is_shipping_address=0 where supplier = '%s'" % (self.doc.supplier))			
+			elif self.doc.sales_partner:
+				sql("update tabAddress set is_shipping_address=0 where sales_partner = '%s'" % (self.doc.sales_partner))			
diff --git a/erpnext/utilities/doctype/contact/contact.js b/erpnext/utilities/doctype/contact/contact.js
index bca1615..d33750d 100644
--- a/erpnext/utilities/doctype/contact/contact.js
+++ b/erpnext/utilities/doctype/contact/contact.js
@@ -3,6 +3,7 @@
 	if(doc.customer) cur_frm.add_fetch('customer', 'customer_name', 'customer_name');
 	if(doc.supplier) cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name');
 }
+
 /*
 //---------- on refresh ----------------------
 cur_frm.cscript.refresh = function(doc,cdt,cdn){
diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py
index 6d7c4c4..8cc9ba1 100644
--- a/erpnext/utilities/doctype/contact/contact.py
+++ b/erpnext/utilities/doctype/contact/contact.py
@@ -4,40 +4,49 @@
 from webnotes.model.doc import Document
 from webnotes import session, form, msgprint, errprint
 
-sql = webnotes.conn.sql
-  
 # -----------------------------------------------------------------------------------------
 
 class DocType:
-  def __init__(self, doc, doclist=[]):
-    self.doc = doc
-    self.doclist = doclist
+	def __init__(self, doc, doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
 
-  def autoname(self):
-    if self.doc.customer:
-      self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer
-    elif self.doc.supplier:
-      self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier
-    elif self.doc.sales_partner:
-      self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner  
-    
-    # filter out bad characters in name
-    #self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','')      
+	def autoname(self):
+		if self.doc.customer:
+			self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer
+		elif self.doc.supplier:
+			self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier
+		elif self.doc.sales_partner:
+			self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner	
+		
+		# filter out bad characters in name
+		#self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','')			
 
 #----------------------
 # Call to Validate
 #----------------------
-  def validate(self):
-    self.validate_primary_contact()
+	def validate(self):
+		self.validate_primary_contact()
 
 #----------------------
 # Validate that there can only be one primary contact for particular customer, supplier
 #----------------------
-  def validate_primary_contact(self):
-    if self.doc.is_primary_contact == 1:
-      if self.doc.customer:
-        sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer))
-      elif self.doc.supplier:
-        sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier))  
-      elif self.doc.sales_partner:
-        sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner))  
+	def validate_primary_contact(self):
+		sql = webnotes.conn.sql
+		if self.doc.is_primary_contact == 1:
+			if self.doc.customer:
+				sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer))
+			elif self.doc.supplier:
+				sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier))	
+			elif self.doc.sales_partner:
+				sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner))
+		else:
+			if self.doc.customer:
+				if not sql("select name from tabContact where is_primary_contact=1 and customer = '%s'" % (self.doc.customer)):
+					self.doc.is_primary_contact = 1
+			elif self.doc.supplier:
+				if not sql("select name from tabContact where is_primary_contact=1 and supplier = '%s'" % (self.doc.supplier)):
+					self.doc.is_primary_contact = 1
+			elif self.doc.sales_partner:
+				if not sql("select name from tabContact where is_primary_contact=1 and sales_partner = '%s'" % (self.doc.sales_partner)):
+					self.doc.is_primary_contact = 1
diff --git a/erpnext/utilities/doctype/contact/contact.txt b/erpnext/utilities/doctype/contact/contact.txt
index e5a6757..9167ed4 100644
--- a/erpnext/utilities/doctype/contact/contact.txt
+++ b/erpnext/utilities/doctype/contact/contact.txt
@@ -5,14 +5,14 @@
 	{
 		'creation': '2010-08-08 17:08:55',
 		'docstatus': 0,
-		'modified': '2011-12-19 14:11:08',
+		'modified': '2012-01-23 16:07:56',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1316075905',
+		'_last_update': '1327314958',
 		'allow_trash': 1,
 		'colour': 'White:FFF',
 		'default_print_format': 'Standard',
@@ -26,7 +26,7 @@
 		'server_code_error': ' ',
 		'show_in_menu': 0,
 		'subject': '%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s',
-		'version': 243
+		'version': 245
 	},
 
 	# These values are common for all DocField
@@ -225,7 +225,7 @@
 	{
 		'colour': 'White:FFF',
 		'default': '0',
-		'depends_on': 'eval:(cint(doc.is_customer) || cint(doc.is_supplier) || cint(doc.is_sales_partner))',
+		'depends_on': 'eval:(doc.customer || doc.supplier || doc.sales_partner)',
 		'doctype': 'DocField',
 		'fieldname': 'is_primary_contact',
 		'fieldtype': 'Check',
diff --git a/index.html b/index.html
index 371a712..970c9e3 100644
--- a/index.html
+++ b/index.html
@@ -93,40 +93,20 @@
 wn={}
 wn.provide=function(namespace){var nsl=namespace.split('.');var l=nsl.length;var parent=window;for(var i=0;i<l;i++){var n=nsl[i];if(!parent[n]){parent[n]={}}
 parent=parent[n];}}
-wn.provide('wn.settings');wn.provide('wn.ui');
-/*
-*	lib/js/wn/xmlhttp.js
-*/
-
-wn.xmlhttp={request:function(){if(window.XMLHttpRequest)
+wn.provide('wn.settings');wn.provide('wn.ui');wn.xmlhttp={request:function(){if(window.XMLHttpRequest)
 return new XMLHttpRequest();else if(window.ActiveXObject)
 return new ActiveXObject("MsXml2.XmlHttp");},complete:function(req,callback,url){if(req.status==200||req.status==304){callback(req.responseText);}else{alert(url+' request error: '+req.statusText+' ('+req.status+')');}},get:function(url,callback,args,async){if(async===null)async=true;var req=wn.xmlhttp.request();req.onreadystatechange=function(){if(req.readyState==4){wn.xmlhttp.complete(req,callback,url)}}
 var sep=((args&&args.indexOf('?'))==-1)?'?':'&';var u=args?(url+sep+args):url;req.open('GET',u,async);req.send(null);if(!async){wn.xmlhttp.complete(req,callback,url)}}}
-/*
-*	lib/js/wn/versions.js
-*/
-
 wn.versions={check:function(){if(localStorage){if(window._version_number==-1||parseInt(localStorage._version_number)!=parseInt(window._version_number)){localStorage.clear();}
 localStorage.setItem('_version_number',window._version_number);}}}
-/*
-*	lib/js/wn/assets.js
-*/
-
 wn.assets={executed_:{},exists:function(src){if('localStorage'in window&&localStorage.getItem(src))
 return true},add:function(src,txt){if('localStorage'in window){localStorage.setItem(src,txt);}},get:function(src){return localStorage.getItem(src);},extn:function(src){if(src.indexOf('?')!=-1){src=src.split('?').slice(-1)[0];}
-return src.split('.').slice(-1)[0];},load:function(src){var t=src;wn.xmlhttp.get(t,function(txt){wn.assets.add(src,txt);},'q='+Math.floor(Math.random()*1000),false)},execute:function(src){if(!wn.assets.exists(src)){wn.assets.load(src);}
+return src.split('.').slice(-1)[0];},html_src:function(src){if(src.indexOf('/')!=-1){var t=src.split('/').slice(0,-1);t.push('src');t=t.join('/')+'/'+a.split('/').slice(-1)[0];}else{var t='src/'+src;}
+return t;},load:function(src){var t=wn.assets.extn(src)=='html'?wn.assets.html_src(src):src;wn.xmlhttp.get(t,function(txt){wn.assets.add(src,txt);},'q='&Math.floor(Math.random()*1000),false)},execute:function(src){if(!wn.assets.exists(src)){wn.assets.load(src);}
 var type=wn.assets.extn(src);if(wn.assets.handler[type]){wn.assets.handler[type](wn.assets.get(src),src);wn.assets.executed_[src]=1;}},handler:{js:function(txt,src){wn.dom.eval(txt);},css:function(txt,src){var se=document.createElement('style');se.type="text/css";if(se.styleSheet){se.styleSheet.cssText=txt;}else{se.appendChild(document.createTextNode(txt));}
-document.getElementsByTagName('head')[0].appendChild(se);},cgi:function(txt,src){wn.dom.eval(txt)}}}
-/*
-*	lib/js/wn/require.js
-*/
-
+document.getElementsByTagName('head')[0].appendChild(se);},html:function(txt,src){var page=wn.dom.add($('.outer .inner').get(0),'div','content',null,txt);page.setAttribute("_src",src);},cgi:function(txt,src){wn.dom.eval(txt)}}}
 wn.require=function(items){if(typeof items==="string"){items=[items];}
 var l=items.length;for(var i=0;i<l;i++){var src=items[i];if(!(src in wn.assets.executed_)){wn.assets.execute(src);}}}
-/*
-*	lib/js/wn/dom.js
-*/
-
 wn.provide('wn.dom');wn.dom.by_id=function(id){return document.getElementById(id);}
 wn.dom.eval=function(txt){var el=document.createElement('script');el.appendChild(document.createTextNode(txt));document.getElementsByTagName('head')[0].appendChild(el);}
 wn.dom.add=function(parent,newtag,className,cs,innerHTML,onclick){if(parent&&parent.substr)parent=wn.dom.by_id(parent);var c=document.createElement(newtag);if(parent)
@@ -138,18 +118,10 @@
 wn.dom.css=function(ele,s){if(ele&&s){for(var i in s)ele.style[i]=s[i];};return ele;}
 wn.dom.hide=function(ele){ele.style.display='none';}
 wn.dom.show=function(ele,value){if(!value)value='block';ele.style.display=value;}
-/*
-*	lib/js/wn/page.js
-*/
-
 wn.page={set:function(src){var new_selection=$('.inner div.content[_src="'+src+'"]');if(!new_selection.length){wn.assets.execute(src);new_selection=$('.inner div.content[_src="'+src+'"]');}
 $('.inner .current_page').removeClass('current_page');new_selection.addClass('current_page');var title=$('nav ul li a[href*="'+src+'"]').attr('title')||'No Title'
 state=window.location.hash;if(state!=src){window.location.hash=state;}
 else{document.title=title;}}}
-/*
-*	lib/js/lib/json2.js
-*/
-
 var JSON;if(!JSON){JSON={};}
 (function(){"use strict";function f(n){return n<10?'0'+n:n;}
 if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
@@ -174,12 +146,7 @@
 text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
 ('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
 if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
-throw new SyntaxError('JSON.parse');};}}());
-/*
-*	lib/js/core.js
-*/
-
-wn.versions.check();wn.require("lib/js/lib/jquery.min.js");wn.require("lib/js/lib/history/history.min.js");$(document).bind('ready',function(){var base=window.location.href.split('#')[0];$.each($('a[softlink!="false"]'),function(i,v){if(v.href.substr(0,base.length)==base){var path=(v.href.substr(base.length));if(path.substr(0,1)!='#'){v.href=base+'#'+path;}}});if(!wn.settings.no_history&&window.location.hash){wn.page.set(window.location.hash.substr(1));}});</script>
+throw new SyntaxError('JSON.parse');};}}());wn.versions.check();wn.require("lib/js/lib/jquery.min.js");wn.require("lib/js/lib/history/history.min.js");$(document).bind('ready',function(){var base=window.location.href.split('#')[0];$.each($('a[softlink!="false"]'),function(i,v){if(v.href.substr(0,base.length)==base){var path=(v.href.substr(base.length));if(path.substr(0,1)!='#'){v.href=base+'#'+path;}}});if(!wn.settings.no_history&&window.location.hash){wn.page.set(window.location.hash.substr(1));}});</script>
 </head>
 <body>
 	<header></header>
diff --git a/version.num b/version.num
index d55f9f7..7296f25 100644
--- a/version.num
+++ b/version.num
@@ -1 +1 @@
-136
\ No newline at end of file
+136