Ext.onReady(function(){
//公共检索
	var win_search;
	var button1 = Ext.get('search_c');
	if (button1 != null){
		button1.on('click', function(){
			if(!win_search){
				var tabs = new Ext.TabPanel({
					region: 'center',
					margins:'3 3 3 0', 
					activeTab: 0,
					defaults:{autoScroll:true},

					items:[{
						title: '服务信息检索',
						id: 'service',
						autoLoad: '/services/services_search.jsp'
					},{
						title: '共性服务规范检索',
						id: 'interface',
						autoLoad: '/services/services_search_by_interface.jsp'
					},{
						title: '服务分类检索',
						id: 'sort',
						autoLoad: {url:'/services/services_search_by_tree.jsp', scripts: true}
						//listeners: {activate: initTree}
					}]
				});
				
				win_search = new Ext.Window({
					title:'服务检索',
					layout:'fit',
					width:505,
					height:480,
					closeAction:'hide',
					//plain: true,
					//autoLoad:'test.jsp',
					scroll:'yes',
					items: [tabs],
					
					buttons: [{
						text: '查询',
						handler: function(){
							//alert(tabs.getActiveTab().id);
							//var newtab = Ext.getCmp('newTab');
							
							var cmp = tabs.getActiveTab().id;
							if (cmp == 'service'){	
								/*
								var cate = document.all.service_cate.value;
								var orderby = document.all.service_orderby.value;
								var asc = document.all.service_asc.value;
								var type = document.all.service_type.value;
								var keyword = document.all.service_keyword.value;
								win_search.hide();
								window.location = "/services/services_list_index.jsp?cate=" + cate + "&orderby=" + orderby + "&asc=" + asc +"&type=" + type +"&keyword=" + encodeURI(keyword);
								*/
								document.service_search.submit();
								/*
								cmp.load({
										url: "/services/services_list_index.jsp",
										params: {cate: common_cate, orderby: orderby, asc: asc, keyword: keyword}, // or a URL encoded string
										nocache: false,
										text: "Loading..."
								})	
								*/
								
							}	
							if (cmp == 'interface'){
								/*
								var cate = document.all.interface_cate.value;
								var orderby = document.all.interface_orderby.value;
								var asc = document.all.interface_asc.value;
								var keyword = document.all.interface_keyword.value;
								win_search.hide();
								window.location = "/services/services_interface_list.jsp?cate=" + cate + "&orderby=" + orderby + "&asc=" + asc +"&keyword=" + encodeURI(keyword);
								*/
								document.interface_search.submit();
							}	
							
							
						}
					}]				
				});	
			}
			win_search.show(this);
		});
	}
/*   
//分类树形结构
      var Tree = Ext.tree;
      var tree = new Tree.TreePanel( {
            el : 'tree-div',//目标div容器
            autoScroll : true,
            animate : true,
            enableDD : false,
            containerScroll : true,
            loader : new Tree.TreeLoader( {
                  dataUrl : '/common/tree.jsp'// OrgTreeJsonData.action就是要动态载入数据的请求地址，这里请求时会提交一个参数为node的值，值为root即new Tree.AsyncTreeNode()对象的id值
            })
      });

      var root = new Tree.AsyncTreeNode( {//alert("2");

            text : '服务分类',

            draggable : false,

            id : '0'//默认的node值：?node=-100

      });
		
      tree.on('beforeload', function(node){      
		       
			tree.loader.dataUrl = '/common/tree.jsp?id='+node.id; // 这里加入你的事件（如click）侦听器（addListener()）    

	  });

	  tree.on('click', function(node){  
		  
		    if (node.leaf == false){
				window.location = '/services/services_list_index.jsp?cate=' + node.id;
		    }else{
				window.location = '/services/services_list_index.jsp?cate=' + node.id + "&rootORleaf=ChildID";
			}
			// 这里加入你的事件（如click）侦听器（addListener()）    

	  });

      tree.setRootNode(root);
      tree.render();
      root.expand(false,false);
    

      var Tree_common = Ext.tree;
      var tree_common = new Tree_common.TreePanel( {
            el : 'common-tree-div',//目标div容器
            autoScroll : true,
            animate : true,
            enableDD : true,
            containerScroll : true,
            loader : new Tree_common.TreeLoader( {
                  dataUrl : '/common/tree.jsp'// OrgTreeJsonData.action就是要动态载入数据的请求地址，这里请求时会提交一个参数为node的值，值为root即new Tree.AsyncTreeNode()对象的id值
            })
      });

      var root_common = new Tree_common.AsyncTreeNode( {

            text : '服务分类',

            draggable : false,

            id : '0'//默认的node值：?node=-100

      });
		
      tree_common.on('beforeload', function(node){      
		       
			tree.loader.dataUrl = '/common/tree.jsp?id='+node.id; // 这里加入你的事件（如click）侦听器（addListener()）    

	  });

      tree_common.setRootNode(root_common);

      tree_common.render();

      root_common.expand(false,false);
      */
});


