new cms with public folder
diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js
index 0561bd7..580fd33 100644
--- a/erpnext/accounts/page/accounts_browser/accounts_browser.js
+++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js
@@ -21,7 +21,6 @@
 // see ledger
 
 pscript['onload_Accounts Browser'] = function(wrapper){
-	wn.require('lib/js/wn/ui/tree.js');
 	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
 	wrapper.appframe.add_button('New Company', function() { newdoc('Company'); }, 'icon-plus');
 	wrapper.appframe.add_button('Refresh', function() {  
@@ -340,7 +339,7 @@
           var imgsrc=null;
           var has_children = true;
           if(cl[i].group_or_ledger=='Ledger') {
-            var imgsrc = 'lib/images/icons/page.png';
+            var imgsrc = 'images/lib/icons/page.png';
             has_children = false;
           }
           var t = tree.addNode(n, cl[i].account_name, imgsrc,tree.std_onclick, has_children ? tree.std_onexp : null);
@@ -353,7 +352,7 @@
           var imgsrc=null;
           var has_children = true;
           if(cl[i].group_or_ledger=='Ledger') {
-            var imgsrc = 'lib/images/icons/page.png';
+            var imgsrc = 'images/lib/icons/page.png';
             has_children = false;
           }
           var t = tree.addNode(n, cl[i].cost_center_name, imgsrc,tree.std_onclick, has_children ? tree.std_onexp : null);
@@ -470,7 +469,7 @@
 
   // refresh
    ref_btn = $a(pscript.group_area, 'div', '', {fontSize: '14px',marginBottom: '8px', marginTop: '24px', fontWeight: 'bold'});
-  ref_btn.innerHTML = '<img src="lib/images/icons/page_refresh.gif" style="margin-right: 8px"><span class="link_type">Refresh Tree</span>';
+  ref_btn.innerHTML = '<img src="images/lib/icons/page_refresh.gif" style="margin-right: 8px"><span class="link_type">Refresh Tree</span>';
   ref_btn.onclick= function() {
     pscript.cur_node.clear_child_nodes();
     pscript.cur_node.expand();
@@ -528,7 +527,7 @@
 
   //General ledger report link
   pscript.gl_rep = $a(pscript.ledger_area, 'div','', {fontSize: '14px',marginBottom: '8px', fontWeight: 'bold'});
-  pscript.gl_rep.innerHTML = '<img src="lib/images/icons/report.png" style="margin-right: 8px"><span class="link_type">Open Ledger</span>';
+  pscript.gl_rep.innerHTML = '<img src="images/lib/icons/report.png" style="margin-right: 8px"><span class="link_type">Open Ledger</span>';
   pscript.gl_rep.onclick = function(){ pscript.make_report('gl'); }
 
 }
diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js
index 615ffc7..498dbb4 100644
--- a/erpnext/buying/doctype/supplier/supplier.js
+++ b/erpnext/buying/doctype/supplier/supplier.js
@@ -107,7 +107,7 @@
 
 // make purchase order list
 cur_frm.cscript.make_po_list = function(parent, doc){
-	wn.require('lib/js/legacy/widgets/listing.js');
+	wn.require('js/listing.js');
 	var lst = new Listing();
 	lst.colwidths = ['5%','25%','20%','25%','25%'];
 	lst.colnames = ['Sr.','Id','Status','PO Date','Grand Total'];
@@ -122,7 +122,7 @@
 
 // make purchase receipt list
 cur_frm.cscript.make_pr_list = function(parent,doc){
-	wn.require('lib/js/legacy/widgets/listing.js');
+	wn.require('js/listing.js');
 	var lst = new Listing();
 	lst.colwidths = ['5%','20%','20%','20%','15%','20%'];
 	lst.colnames = ['Sr.','Id','Status','Receipt Date','% Billed','Grand Total'];
@@ -137,7 +137,7 @@
 
 // make purchase invoice list
 cur_frm.cscript.make_pi_list = function(parent,doc){
-	wn.require('lib/js/legacy/widgets/listing.js');
+	wn.require('js/listing.js');
 	var lst = new Listing();
 	lst.colwidths = ['5%','20%','20%','20%','15%','20%'];
 	lst.colnames = ['Sr.','Id','Posting Date','Credit To','Bill Date','Grand Total'];
diff --git a/erpnext/home/page/dashboard/dashboard.js b/erpnext/home/page/dashboard/dashboard.js
index 072af25..496c738 100644
--- a/erpnext/home/page/dashboard/dashboard.js
+++ b/erpnext/home/page/dashboard/dashboard.js
@@ -17,11 +17,11 @@
 pscript.onload_dashboard = function() {
 	// load jqplot
 	wn.require('lib/css/lib/jqplot.css');
-	wn.require('lib/js/lib/jqplot/jquery.jqplot.min.js');
-	wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.barRenderer.js'); 
-	wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.canvasAxisTickRenderer.min.js');
-	wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.canvasTextRenderer.min.js');
-	wn.require('lib/js/lib/jqplot/jqplot-plugins/jqplot.categoryAxisRenderer.min.js');
+	wn.require('js/lib/jqplot/jquery.jqplot.min.js');
+	wn.require('js/lib/jqplot/jqplot-plugins/jqplot.barRenderer.js'); 
+	wn.require('js/lib/jqplot/jqplot-plugins/jqplot.canvasAxisTickRenderer.min.js');
+	wn.require('js/lib/jqplot/jqplot-plugins/jqplot.canvasTextRenderer.min.js');
+	wn.require('js/lib/jqplot/jqplot-plugins/jqplot.categoryAxisRenderer.min.js');
 
 
 	pscript.dashboard_settings = {
diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js
index 78743e7..791c444 100644
--- a/erpnext/selling/doctype/customer/customer.js
+++ b/erpnext/selling/doctype/customer/customer.js
@@ -154,7 +154,7 @@
 // make quotation list
 // --------------------
 cur_frm.cscript.make_qtn_list = function(parent,doc){
-	wn.require('lib/js/legacy/widgets/listing.js');
+	wn.require('js/listing.js');
 
 	var lst = new Listing();
 	lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
@@ -172,7 +172,7 @@
 // make so list
 // -------------
 cur_frm.cscript.make_so_list = function(parent,doc){
-	wn.require('lib/js/legacy/widgets/listing.js');
+	wn.require('js/listing.js');
 
 	var lst = new Listing();
 	lst.colwidths = ['5%','20%','20%','30%','25%'];
@@ -190,7 +190,7 @@
 // make dn list
 // -------------
 cur_frm.cscript.make_dn_list = function(parent,doc){
-	wn.require('lib/js/legacy/widgets/listing.js');
+	wn.require('js/listing.js');
 
 	var lst = new Listing();
 	lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
@@ -208,7 +208,7 @@
 // make si list
 // -------------
 cur_frm.cscript.make_si_list = function(parent,doc){
-	wn.require('lib/js/legacy/widgets/listing.js');
+	wn.require('js/listing.js');
 	
 	var lst = new Listing();
 	lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
diff --git a/erpnext/selling/page/sales_browser/sales_browser.js b/erpnext/selling/page/sales_browser/sales_browser.js
index 4d5a3dc..66e1d52 100644
--- a/erpnext/selling/page/sales_browser/sales_browser.js
+++ b/erpnext/selling/page/sales_browser/sales_browser.js
@@ -15,7 +15,6 @@
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 pscript['onload_Sales Browser'] = function(wrapper){
-	wn.require('lib/js/wn/ui/tree.js');
 	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
 	wrapper.appframe.add_button('Refresh', function() {  
 			wrapper.make_tree();
@@ -128,437 +127,4 @@
 	selected_node: function() {
 		return this.tree.$w.find('.tree-link.selected');
 	}
-});
-
-/*
-pscript['onshow_Sales Browser'] = function(){
-  wn.require('lib/js/legacy/widgets/tree.js');
-
-	var route = decodeURIComponent(location.hash);
-	if(route.indexOf('/')!=-1) {
-		var chart_type = route.split('/')[1];
-		new SalesBrowser().set_val(chart_type)
-		return;
-	}
-
-  var parent = $i('tr_body');
-  parent.innerHTML = 'Please select your chart: '
-  var sel = $a(parent,'select');
-  add_sel_options(sel, ['Territory', 'Customer Group', 'Item Group', 'Sales Person'], 'Territory');
-  var btn = $btn(parent, 'Go', function() { new SalesBrowser().set_val(sel_val(sel)) }, {marginTop:'8px'});
-}
-
-//================================= SalesBrowser Class ======================================
-SalesBrowser = function(){
-  
-  this.make_body = function(){
-  
-    $i('tr_header').innerHTML = '';
-    $i('tr_body').innerHTML = '';
-    //make header
-    var desc = this.sel;
-    var me = this;
-    var h = new PageHeader($i('tr_header'),desc);
-    h.add_button('New '+this.sel, function() { me.set_dialog(1); }, 0, 'ui-icon-plus', 1);
-    h.add_button('Refresh', function() { me.refresh_tree(); }, 0, 'ui-icon-refresh');
-
-    var div_body = $a($i('tr_body'),'div');
-    var tr_main_grid = make_table(div_body,1,2,'100%',['60%','40%'],{width: "100%", tableLayout: "fixed", borderCollapse: "collapse", border:"0px", padding:"4px 4px 4px 4px"});
-    
-    $y($td(tr_main_grid,0,0),{border: "1px solid #dddddd", padding: "8px", width: "60%"});   
-    this.tree_area = $a($td(tr_main_grid,0,0),'div','',{minHeight:'400px'});
-
-    $y($td(tr_main_grid,0,1),{border: "1px solid #DDD"});   
-    this.detail_area = $a($td(tr_main_grid,0,1),'div');
-    
-    this.make_tree_body(this.tree_area);  
-    this.refresh_tree();
-  }
-  
-  this.set_val = function(b){
-    var me = this;
-    me.sel = b;  
-    me.make_body();
-  }
-}
-
-//=================================================================================================================================
-SalesBrowser.prototype.make_tree_body = function(parent){
-
-  //this.tab2 =make_table(this.wrapper,1,2,'100%',['60%','40%']);
-  this.make_tree();
-  this.make_rgt_sect();
-  
-}
-
-//=================================================================================================================================
-SalesBrowser.prototype.make_rgt_sect=function(){
-  //var d = $a($td(this.tab2,0,1),'div','',{border:'1px solid #000'});
-
-  this.rgt_tab =make_table(this.detail_area,4,1,'','',{padding:"4px",spacing:"4px"});
-  this.dtl = $a($td(this.rgt_tab,0,0),'div');
-  this.btn = $a($td(this.rgt_tab,1,0),'div','span');
-  this.help = $a($td(this.rgt_tab,2,0),'div');
-  this.help.innerHTML = "Note: Explore and click on the tree node to see details."
-
-  this.set_btn();
-}
-//=================================================================================================================================
-SalesBrowser.prototype.set_btn = function(){
-  var me = this;
-  this.edit_btn = $btn(this.btn,'Edit',function(){ me.set_dialog(2); });
-
-  this.trash_btn = $btn(this.btn,'Trash',null);
-  this.trash_btn.onclick = function(){
-    var check = confirm("Are you sure you want to trash "+me.cur_node.rec.name+" node?");
-    
-    if(check){
-      var arg = [me.cur_node.rec.name, me.sel];
-      $c_obj('Sales Browser Control','trash_record',arg.join(','),function(r,rt){      me.refresh_tree();});
-
-    }
-  }
-}
-
-//=====================================================
-SalesBrowser.prototype.set_dialog = function(f){
-
- 
-  if(this.sel == 'Territory')
-    new MakeDialog('Territory','territory',f,this);            //Territory Dialog
-  if(this.sel == 'Customer Group')
-    new MakeDialog('Customer Group','customer_group',f,this);  //Customer Group Dialog  
-  if(this.sel == 'Item Group')
-    new MakeDialog('Item Group','item_group',f,this);   //Item Group Dialog
-  if(this.sel == 'Sales Person')
-    new MakeDialog('Sales Person','sales_person',f,this);//Sales Person Dialog 
-  
-}
-//=====================================================Make Tree============================================================================
-SalesBrowser.prototype.make_tree = function() {
-  var me = this;
-
-  this.tree = new Tree(this.tree_area, '100%');
-  
-  //---------------------------------------------------------------------------------------------------------------------------------
-  // on click
-  this.tree.std_onclick = function(node) {
-      
-      me.cur_node = node;
-      if(node.rec.name =='All Customer Groups' || node.rec.name =='All Sales Persons' || node.rec.name =='All Item Groups' || node.rec.name =='All Territories'){
-        //$di(me.add_btn);
-
-        $dh(me.edit_btn);
-        $dh(me.trash_btn);
-      }
-      else{
-        //$di(me.add_btn);
-        //if(node.has_children == false)
-          //$dh(me.add_btn);
-
-        $di(me.edit_btn);
-        $di(me.trash_btn);
-
-      }
-      me.make_details();
-	  
-  }
-  //---------------------------------------------------------------------------------------------------------------------------------
-  // on expand
-  this.tree.std_onexp = function(node) {
-
-    if(node.expanded_once)return;
-    $di(node.loading_div);
-
-    var callback = function(r,rt) {
-
-      $dh(node.loading_div);
-      var n = me.tree.allnodes[r.message.parent];
-      var cl = r.message.cl;
-
-      for(var i=0;i<cl.length;i++) {
-        var imgsrc=null;
-        var has_children = true;
-
-        if(cl[i].is_group=='No') {
-          var imgsrc = 'lib/images/icons/page.png';
-          has_children = false;
-        }
-        var t = me.tree.addNode(n, cl[i].name, imgsrc,me.tree.std_onclick, has_children ? me.tree.std_onexp : null);
-        t.rec = cl[i];
-        t.parent_account = r.message.parent;
-        t.has_children = has_children;
-      }
-
-    }
-    var arg = [node.rec.name, me.sel];
-    $c_obj('Sales Browser Control','get_record_list',arg.join(','),callback);
-  }
-  
- 
-}
-
-//=================================================================================================================================
-SalesBrowser.prototype.make_details = function(){
-  var me = this;
-  var callback = function(r,rt){
-
-    me.dtl.innerHTML = "";
-    //me.dtl_tab = make_table(me.dtl,3,2,'','',{tableLayout:'fixed',borderCollapse: 'collapse'})
-    
-    var h = $a(me.dtl,'h3','',{padding:'4px', margin:'0px',backgroundColor:'#EEEEEE',borderBottom:'1px solid #AAAAAA'});
-    $(h).html(r.message.name);
-    
-    var d = $a(me.dtl,'div');
-    me.dtl_tab = make_table(me.dtl,3,2,'','',{tableLayout:'fixed',borderCollapse: 'collapse',padding:'4px'})
-    $td(me.dtl_tab,0,0).innerHTML="Parent";
-    if(r.message.parent != '')
-      $td(me.dtl_tab,0,1).innerHTML=": "+r.message.parent;
-    else
-      $td(me.dtl_tab,0,1).innerHTML=": ----";    
-    $td(me.dtl_tab,1,0).innerHTML="Has Child Node";
-    $td(me.dtl_tab,1,1).innerHTML=": "+r.message.is_group;
-   
-
-    me.open_doc = $a(me.dtl,'div','link_type',{paddingTop:'14px'});
-    me.open_doc.innerHTML = "Click here to open "+r.message.name;
-    
-    me.open_doc.onclick = function(){
-      loaddoc(me.sel,r.message.name );
-    }
-  }
-
-  var arg = [this.cur_node.rec.name, this.sel];
-  
-  $c_obj('Sales Browser Control','get_record',arg.join(','),callback);
-
-}
-//=================================================================================================================================
-SalesBrowser.prototype.refresh_tree=function(){
-
-  this.tree_area.innerHTML = '';
-  this.dtl.innerHTML = '';  
-  this.first_level_node();    //set root
-  //hide add, edit, trash buttons
-  //$dh(this.add_btn);
-  $dh(this.edit_btn);
-  $dh(this.trash_btn);
-  
-
-
-}
-
-//=============================== make first level node ================================================
-SalesBrowser.prototype.first_level_node = function(){
-
-  var me = this;
-  var callback = function(r,rt) {
-
-    var cl = r.message.cl;
-
-    for(var i=0;i<cl.length;i++) {
-      var imgsrc=null;
-      var has_children = true;
-
-      if(cl[i].is_group=='No') {
-        var imgsrc = 'lib/images/icons/page.png';
-        has_children = false;
-      }
-     me.tree_area.innerHTML = ''; 
-     if(me.tree) {
-
-        me.tree.innerHTML = '';
-        me.tree.body.innerHTML = '';
-        
-        me.make_tree();
-      }
-
-      var t = me.tree.addNode(null, cl[i].name, imgsrc,me.tree.std_onclick, has_children ? me.tree.std_onexp : null);
-      t.rec ={};
-      t.rec.name = cl[i].name;
-      t.has_children = has_children;
-    }
-  }
-
-  $c_obj('Sales Browser Control','get_fl_node',this.sel,callback);
-
-}
-
-//========================================= Dialog Section ===================================================================
-//--------------------------------------------------------------------------------------------------------------------------------
-//========================================================================
-MakeDialog=function(label,field_name,n,cls_obj){
-
-  var new_head = 'Create A New '+label;
-
-  this.label = label;
-
-  this.lbl_rec = label+' Name';
-  this.field_name = field_name;
-  this.n = n;
-  this.cls_obj=cls_obj;
-  //-----------------------------------------------
- 
-  this.main_dialog = new Dialog(400,300,new_head);      
-  this.set_dg_fields();
-  this.set_dg_values();
-  //-----------------------------------------------
-  this.new_main_dialog = this.main_dialog;
-  
-  this.new_main_dialog.show();
-
-}
-//=================================================================================================================================
-MakeDialog.prototype.set_dg_fields = function(){
-
-  var bd_lst = [];
-  bd_lst.push(['HTML','Heading'],['Data',this.lbl_rec],['Select','Parent'],['Select','Has Child Node']);
-  if(this.cls_obj.sel == 'Sales Person')
-    bd_lst.push(['HTML','','All nodes are allowed in transaction.']);
-  else
-    bd_lst.push(['HTML','','Only leaf nodes are allowed in transaction.']);
-  if(this.n==1)
-    bd_lst.push(['Button','Create']);
-  
-  if(this.n==2){
-    bd_lst.push(['Button','Update']);
-    this.set_edit_fields();
-  }  
-
-  this.main_dialog.make_body(bd_lst);
-  
-  //-----------------------------------------------
-}
-
-
-//==================================================================================================================================== 
-MakeDialog.prototype.set_edit_fields=function(){
-  var me = this;
-  var callback = function(r,rt){
-    
-    me.main_dialog.widgets[me.lbl_rec].value = r.message.name;
-    
-    add_sel_options(me.main_dialog.widgets['Parent'], r.message.parent_lst,r.message.parent);    
-    me.main_dialog.widgets['Has Child Node'].value = r.message.is_group;
-  }
-
-  var arg = [this.cls_obj.cur_node.rec.name, this.cls_obj.sel];
-  
-  $c_obj('Sales Browser Control','get_record',arg.join(','),callback);
-}
-//======================================= Validation - fields entered or not =================================================
-MakeDialog.prototype.validate = function(){
-
-  if(!this.main_dialog.widgets[this.lbl_rec].value) {
-      err_msg1 ='Please enter '+this.label +' Name' 
-      alert(err_msg1); 
-      return 1;
-    }
-    if(!this.main_dialog.widgets['Parent'].value){
-      alert('Please enter Parent Name' );
-      return 1;
-    }
-}
-//==================================================================================================================================== 
-MakeDialog.prototype.set_dg_values = function(){
-  if(this.n==1){
-    var me = this;
-    var callback = function(r,rt){
-      me.main_dialog.widgets[me.lbl_rec].disabled = 0;
-      me.main_dialog.widgets['Parent'].disabled = 0;
-
-      add_sel_options(me.main_dialog.widgets['Parent'],r.message);
-      //add_sel_options(this.main_dialog.widgets['Parent'], [this.cls_obj.cur_node.rec.name]);
-      me.btn_onclick('Create',me.cls_obj);
-    }
-  
-    $c_obj('Sales Browser Control','get_parent_lst',this.cls_obj.sel,callback);
-
-  }  
-  if(this.n == 2){
-    this.main_dialog.widgets[this.lbl_rec].disabled = 1;
-    this.main_dialog.widgets['Parent'].disabled = 0;
-    this.btn_onclick('Update');
-    this.old_value = sel_val(this.main_dialog.widgets['Parent']);
-  }
-
-  add_sel_options(this.main_dialog.widgets['Has Child Node'], ['Yes','No'], 'No');
-
-}
-
-//================================================================================================================================= 
-//-----------------------------------------Dialog button onclick event----------------------------------------------
-MakeDialog.prototype.btn_onclick=function(btn_name){
-  var me = this;
-  this.btn_name = btn_name;
-  this.main_dialog.widgets[this.btn_name].onclick = function() {
-  
-    var callback=function(r,rt){
-      if(r.message == 'true'){
-        me.main_dialog.hide();
-      }
-      else{
-        flag = me.validate();
-        if(flag == 1) return;
-           
-        //---------------------------------------------------------  
-
-        var arg2 = me.make_args();
-        
-        //create Sales Person -- server to Sales Browser Control
-        if(me.btn_name == "Create")
-          method_name = "add_node";
-        else 
-          method_name = "edit_node";       
-           
-        $c_obj('Sales Browser Control',method_name, docstring(arg2), function(r,rt) { 
-          me.main_dialog.widgets[me.lbl_rec].value='';
-          me.main_dialog.hide();
-          //if(me.btn_name == "Create"){
-          //  me.cls_obj.cur_node.clear_child_nodes();
-          //  me.cls_obj.dtl.innerHTML = '';  
-          //  me.cls_obj.cur_node.expand();
-          //}
-          //else{
-          //  me.cls_obj.refresh_tree();   
-          //}
-          me.cls_obj.refresh_tree(); 
-        });
-      }
-    }
-    var arg1 = {'node_title':me.cls_obj.sel,'is_group':sel_val(me.main_dialog.widgets['Has Child Node']),'lft':0,'rgt':0,'nm':me.main_dialog.widgets[me.lbl_rec].value,'parent_nm':sel_val(me.main_dialog.widgets['Parent']),'action':me.btn_name};
-    $c_obj('Sales Browser Control','mvalidate',docstring(arg1),callback);
-  }
-}
-//=================================================================================================================================
-
-MakeDialog.prototype.make_args = function(){
-  var args ={};   //args making
-  var nt = this.cls_obj.sel;
-  var nm = this.main_dialog.widgets[this.lbl_rec].value;
-  var pnm = sel_val(this.main_dialog.widgets['Parent']);
-  var grp = sel_val(this.main_dialog.widgets['Has Child Node']);
-
-  if(this.n==1)
-    var old_prt ='';
-  else if(this.n==2){
-    if(this.old_value == sel_val(this.main_dialog.widgets['Parent']))
-      var old_prt = '';
-    else
-      var old_prt = this.old_value;
-  }
-  
-  if(this.cls_obj.sel == 'Territory')
-    return {'node_title':nt,'territory_name':nm,'parent_territory':pnm,'is_group':grp,'old_parent':old_prt}
-
-  else if(this.cls_obj.sel == 'Customer Group')
-    return {'node_title':nt,'customer_group_name':nm,'parent_customer_group':pnm,'is_group':grp,'old_parent':old_prt}
-
-  else if(this.cls_obj.sel == 'Item Group')
-    return {'node_title':nt,'item_group_name':nm,'parent_item_group':pnm,'is_group':grp,'old_parent':old_prt}
-
-  else if(this.cls_obj.sel == 'Sales Person')
-    return {'node_title':nt,'sales_person_name':nm,'parent_sales_person':pnm,'is_group':grp,'old_parent':old_prt}
-
-}
-*/
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/erpnext/selling/page/sales_dashboard/sales_dashboard.js b/erpnext/selling/page/sales_dashboard/sales_dashboard.js
index e89c7fb..e0260c7 100644
--- a/erpnext/selling/page/sales_dashboard/sales_dashboard.js
+++ b/erpnext/selling/page/sales_dashboard/sales_dashboard.js
@@ -23,7 +23,7 @@
   //pscript.dx_axis = [];
 
 	wn.require('lib/css/lib/jqplot.css');
-	wn.require('lib/js/lib/jqplot/jquery.jqplot.min.js');
+	wn.require('js/lib/jqplot/jquery.jqplot.min.js');
 	pscript.all_onchnge();
 }
 //=======================================================================
diff --git a/erpnext/setup/page/modules_setup/modules_setup.js b/erpnext/setup/page/modules_setup/modules_setup.js
index 71fed93..79f4ebc 100644
--- a/erpnext/setup/page/modules_setup/modules_setup.js
+++ b/erpnext/setup/page/modules_setup/modules_setup.js
@@ -1,4 +1,4 @@
-wn.require('lib/js/lib/jquery/jquery.ui.sortable.js');
+wn.require('js/lib/jquery/jquery.ui.sortable.js');
 
 $.extend(wn.pages.modules_setup, {
 	modules: ['Activity', 'Accounts', 'Selling', 'Buying', 'Stock', 'Production', 'Projects', 
diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py
index a67a214..7df9839 100644
--- a/erpnext/startup/event_handlers.py
+++ b/erpnext/startup/event_handlers.py
@@ -89,6 +89,7 @@
 		if hasattr(conf, 'expires_on'): bootinfo['expires_on'] = conf.expires_on
 
 
+
 def get_letter_heads():
 	"""load letter heads with startup"""
 	import webnotes
@@ -129,3 +130,23 @@
 	
 	webnotes.response['message'] = 'Account Expired'
 	raise webnotes.AuthenticationError
+
+#### website
+
+def get_web_script():
+	"""returns web startup script"""
+	return webnotes.conn.get_value('Website Settings', None, 'startup_code') or ''
+
+def get_web_style():
+	"""returns web css"""
+	return webnotes.conn.get_value('Style Settings', None, 'custom_css') or ''
+
+def get_web_header():
+	"""get website header"""
+	from website.utils import get_header
+	return get_header()
+
+def get_web_footer():
+	"""get website footer"""
+	from website.utils import get_footer
+	return get_footer()
diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js
index b86116a..c687d95 100644
--- a/erpnext/startup/startup.js
+++ b/erpnext/startup/startup.js
@@ -53,22 +53,12 @@
 	
 	
 	erpnext.startup.set_globals();
-
-	if(wn.boot.user_background) {
-		erpnext.set_user_background(wn.boot.user_background);
-	}
 		
-	if(user == 'Guest'){
-		if(wn.boot.custom_css) {
-			set_style(wn.boot.custom_css);
+	if(user != 'Guest'){
+		if(wn.boot.user_background) {
+			erpnext.set_user_background(wn.boot.user_background);
 		}
-		if(wn.boot.website_settings.title_prefix) {
-			wn.title_prefix = wn.boot.website_settings.title_prefix;
-		}
-		if(wn.boot.startup_code) {
-			eval(wn.boot.startup_code);
-		}
-	} else {
+
 		// always allow apps
 		wn.boot.profile.allow_modules = wn.boot.profile.allow_modules.concat(
 			['To Do', 'Knowledge Base', 'Calendar', 'Activity', 'Messages'])
@@ -106,14 +96,14 @@
 				</div>', { expiry_string: expiry_string }));
 			}
 		}
-		
+		erpnext.set_about();
+		if(wn.control_panel.custom_startup_code)
+			eval(wn.control_panel.custom_startup_code);		
 	}
 
-	erpnext.set_about();
-	if(wn.control_panel.custom_startup_code)
-		eval(wn.control_panel.custom_startup_code);
 		
-	$('body').append('<a class="erpnext-logo" title="Powered by ERPNext" href="http://erpnext.com" target="_blank"></a>')
+	$('body').append('<a class="erpnext-logo" title="Powered by ERPNext" \
+		href="http://erpnext.com" target="_blank"></a>')
 }
 
 
diff --git a/erpnext/utilities/page/users/users.js b/erpnext/utilities/page/users/users.js
index 757b1a3..517c3cf 100644
--- a/erpnext/utilities/page/users/users.js
+++ b/erpnext/utilities/page/users/users.js
@@ -84,7 +84,7 @@
 		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.imgsrc = 'images/lib/ui/no_img_' + (data.gender=='Female' ? 'f' : 'm') + '.gif';
 		}
 		data.fullname = wn.user_info(data.name).fullname;
 		data.delete_html = '';
diff --git a/erpnext/website/doctype/style_settings/style_settings.js b/erpnext/website/doctype/style_settings/style_settings.js
index 0d0bf9e..64fa496 100644
--- a/erpnext/website/doctype/style_settings/style_settings.js
+++ b/erpnext/website/doctype/style_settings/style_settings.js
@@ -14,7 +14,7 @@
 // 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.require('lib/js/lib/jscolor/jscolor.js');
+wn.require('js/lib/jscolor/jscolor.js');
 
 cur_frm.cscript.onload_post_render = function() {
 	cur_frm.fields_dict.background_color.input.className = 'color';
diff --git a/erpnext/website/doctype/top_bar_item/top_bar_item.txt b/erpnext/website/doctype/top_bar_item/top_bar_item.txt
index 632425e..bd74d84 100644
--- a/erpnext/website/doctype/top_bar_item/top_bar_item.txt
+++ b/erpnext/website/doctype/top_bar_item/top_bar_item.txt
@@ -3,9 +3,9 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2012-03-27 14:36:48',
+		'creation': '2012-04-02 16:02:43',
 		'docstatus': 0,
-		'modified': '2012-03-27 14:36:48',
+		'modified': '2012-05-07 15:21:00',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -19,7 +19,7 @@
 		'name': '__common__',
 		'section_style': u'Simple',
 		'show_in_menu': 0,
-		'version': 4
+		'version': 1
 	},
 
 	# These values are common for all DocField
@@ -43,16 +43,8 @@
 		'doctype': u'DocField',
 		'fieldname': u'label',
 		'fieldtype': u'Data',
-		'label': u'Label'
-	},
-
-	# DocField
-	{
-		'doctype': u'DocField',
-		'fieldname': u'custom_page',
-		'fieldtype': u'Link',
-		'label': u'Page',
-		'options': u'Page'
+		'label': u'Label',
+		'width': u'120px'
 	},
 
 	# DocField
@@ -60,7 +52,17 @@
 		'doctype': u'DocField',
 		'fieldname': u'url',
 		'fieldtype': u'Data',
-		'label': u'URL'
+		'label': u'URL',
+		'width': u'200px'
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'target',
+		'fieldtype': u'Select',
+		'label': u'Target',
+		'options': u'\ntarget = "_blank"'
 	},
 
 	# DocField
diff --git a/erpnext/website/doctype/web_page/web_page.py b/erpnext/website/doctype/web_page/web_page.py
index 7f50d53..66941e4 100644
--- a/erpnext/website/doctype/web_page/web_page.py
+++ b/erpnext/website/doctype/web_page/web_page.py
@@ -27,6 +27,10 @@
 
 	def validate(self):
 		"""make page for this product"""
+		from jinja2 import Template
+		from webnotes.utils import global_date_format
+		from webnotes.model.code import get_obj
+		import os
 
 		# we need the name for the templates
 		if not self.doc.name:
@@ -36,11 +40,7 @@
 			webnotes.conn.sql("""delete from tabPage where name=%s""", self.doc.page_name)
 
 		p = website.utils.add_page(self.doc.name)
-		
-		from jinja2 import Template
-		from webnotes.utils import global_date_format
-		import os
-	
+			
 		self.doc.updated = global_date_format(self.doc.modified)
 		website.utils.markdown(self.doc, ['head_section','main_section', 'side_section'])
 				
@@ -48,6 +48,7 @@
 			p.content = Template(f.read()).render(doc=self.doc)
 
 		p.title = self.doc.title
+		p.web_page = 'Yes'
 		
 		if self.doc.insert_code:
 			p.script = self.doc.javascript
@@ -56,6 +57,7 @@
 			p.style = self.doc.css
 
 		p.save()
+		get_obj(doc=p).write_cms_page()
 		
 		website.utils.add_guest_access_to_page(p.name)
 		self.cleanup_temp()
diff --git a/erpnext/website/js/topbar.js b/erpnext/website/js/topbar.js
index 24af3e9..88cbe8b 100644
--- a/erpnext/website/js/topbar.js
+++ b/erpnext/website/js/topbar.js
@@ -38,7 +38,7 @@
 				<a class="brand">[brand]</a>\
 				<ul class="nav">\
 				</ul>\
-				<img src="lib/images/ui/spinner.gif" id="spinner"/>\
+				<img src="images/lib/ui/spinner.gif" id="spinner"/>\
 				<ul class="nav pull-right">\
 					<li id="login-topbar-item"><a href="#!Login Page">Login</a></li>\
 				</ul>\
@@ -75,7 +75,7 @@
 						.click(function() {
 							return false;
 						});
-					$parent_li.append('<ul class="dropdown-menu"></ul>');
+					$parent_li.append('');
 				}
 				erpnext.header_link_settings(item);
 				$parent_li.find('.dropdown-menu').append(repl('<li data-label="%(label)s">\
@@ -126,5 +126,5 @@
 
 $(document).bind('startup', function() {
 	erpnext.footer = new erpnext.Footer();
-	erpnext.navbar.navbar = new erpnext.navbar.Navbar();	
+	//erpnext.navbar.navbar = new erpnext.navbar.Navbar();	
 })
diff --git a/erpnext/website/utils.py b/erpnext/website/utils.py
index 971b0bc..04127bc 100644
--- a/erpnext/website/utils.py
+++ b/erpnext/website/utils.py
@@ -40,10 +40,8 @@
 
 def page_name(title):
 	"""make page name from title, and check that there is no duplicate"""
-	import re
-	name = title.lower()
-	name = re.sub('[~!@#$%^&*()<>,."\']', '', name)
-	return '-'.join(name.split()[:4])
+	import webnotes.cms
+	return webnotes.cms.page_name(title)
 	
 def add_page(title):
 	"""add a custom page with title"""
@@ -59,7 +57,7 @@
 	p.standard = 'No'
 
 	return p
-	
+
 def add_guest_access_to_page(page):
 	"""add Guest in Page Role"""
 	if not webnotes.conn.sql("""select parent from `tabPage Role`
@@ -68,3 +66,81 @@
 		d.parent = page
 		d.role = 'Guest'
 		d.save()
+
+def get_header():
+	"""get page header"""
+
+	from webnotes.model.doc import Document
+	from jinja2 import Template
+
+	def get_item(l, label):
+		for i in l:
+			if i['label']==label:
+				return i
+
+	top_bar_items = webnotes.conn.sql("""select * from `tabTop Bar Item`
+		where parent='Website Settings' and parentfield='top_bar_items'
+		order by idx asc""", as_dict=1)
+		
+	# build child items
+	for t in top_bar_items:
+		if t.get('parent_label'):
+			pi = get_item(t['parent_label'])
+			if not pi['child_items']:
+				pi['child_items'] = []
+			pi['child_items'].append(t)
+
+	website_settings = Document('Website Settings', 'Website Settings')
+	
+	return Template("""<div class="navbar navbar-fixed-top">
+		<div class="navbar-inner">
+		<div class="container">
+			<a class="brand">{{ brand }}</a>
+			<ul class="nav">
+				{% for page in top_bar_items %}
+					{% if not page.parent_label %}
+					<li data-label="{{ page.label }}">
+						<a href="{{ page.url }}" {{ page.target }}>
+						{{ page.label }}
+						{% if page.child_items %}
+							<ul class="dropdown-menu">
+							{% for child in page.child_items %}
+								<li data-label="{{ child.label }}">
+									<a href="{{ child.url }}" {{ child.target }}>
+							{% endfor %}
+							</ul>
+						{% endif %}
+						</a></li>
+					{% endif %}
+				{% endfor %}
+			</ul>
+			<img src="images/lib/ui/spinner.gif" id="spinner"/>
+			<ul class="nav pull-right">
+				<li id="login-topbar-item"><a href="#!Login Page">Login</a></li>
+			</ul>
+		</div>
+		</div>
+		</div>""").render(top_bar_items = top_bar_items, 
+			brand=website_settings.brand_html or webnotes.get_default('company') or 'ERPNext')
+			
+def get_footer():
+	"""get page footer"""
+	
+	from webnotes.model.doc import Document
+	from jinja2 import Template
+
+	website_settings = Document('Website Settings', 'Website Settings')
+
+	website_settings.footer_items = webnotes.conn.sql("""select * from `tabTop Bar Item`
+		where parent='Website Settings' and parentfield='footer_items'
+		order by idx asc""", as_dict=1)
+
+	return Template("""<div class="web-footer">
+		<div class="web-footer-menu"><ul>
+		{% for item in footer_items %}
+			<li><a href="{{ item.url }}" {{ item.target }}
+				data-label="{{ item.label }}">{{ item.label }}</a></li>
+		{% endfor %}
+		</ul></div>
+		<div class="web-footer-copyright">&copy; {{ copyright }}
+		</div>""").render(website_settings.fields)
\ No newline at end of file