IConForm = function () {
	IConForm.search = function () {
		IConForm.search.form = Ext.getDom("IConFormId");
		IConForm.search.allName = Ext.getDom("allName");
	    IConForm.search.typeName = Ext.getDom("typeName");
	    IConForm.search.courseName = Ext.getDom("courseName");
	    IConForm.search.gradeName = Ext.getDom("gradeName");
	    IConForm.search.areaName = Ext.getDom("areaName");
	    IConForm.search.lableName = Ext.getDom("lableName");
	    IConForm.search.ordName = Ext.getDom("orderType");
	    IConForm.search.currentPage = Ext.get("currentPage");
		
		IConForm.common();
	};
	
	IConForm.index = function () {
		IConForm.search();
		IConForm.common.showMenuTo();
		
		var array = new Array();
         var panel = Ext.get("showTypePanel").select("li[class]");
         for(var i = 0; i < panel.elements.length; i++) {
           array.push(new ssh.util.CCMenu("typeList_" + (i + 1), "typeListPalel_" + (i + 1)));
         }
         ssh.util.CCMenu.Tip(array);
	};
	
	IConForm.findbefor = function () {
		IConForm.search();
		IConForm.common.showMenuTo();
		var array = new Array();
        array.push(new ssh.util.CCMenu("areaChecked", "areaCheckedPanel", -10, 0, 35));
        array.push(new ssh.util.CCMenu("courseChekced", "typeCheckedPanel", -10, 0, 35));
        ssh.util.CCMenu.Tip(array);
         
        IConForm.findbefor.set = function (value, id) {
        	Ext.getDom(id).value = value;
        };
	};
	
	IConForm.findResult = function () {
		IConForm.search();
		IConForm.common.showMenuTo();
		IConForm.findResult.searchAll = function () {
			IConForm.search.set.all(IConForm.search.allName.value, true, true)
		};
		IConForm.findResult.searchType = function (value) {
            IConForm.search.set.type(value, true);
        };
        IConForm.findResult.searchCourse = function (value) {
            IConForm.search.set.course(IConForm.search.typeName.value, value, true);
        };
        IConForm.findResult.searchGrade = function (value) {
            IConForm.search.set.grade(IConForm.search.typeName.value,
                IConForm.search.courseName.value, value, true);
        };
        IConForm.findResult.searchArea = function (value) {
            IConForm.search.set.area(value, true);
        };
        IConForm.findResult.searchLable = function (value) {
            IConForm.search.set.lable(IConForm.search.areaName.value, value, true);
        };
        IConForm.findResult.setOrder = function (value) {
            IConForm.search.ordName.value = value;
            IConForm.search.submit(true);
        };
        IConForm.findResult.order = function (type) {
        	var offsetLeft = 0;
        	if(Ext.isIE) {
        		offsetLeft = 2;
        	}
        	if(Ext.get("courseprise") != null) {
	        	if(type == 1) {
		            IConForm.common.showMenu("courseprise",
		                  [{text: '最佳匹配度排序', href:"javascript: IConForm.findResult.setOrder(0);" },
		                    {text: '最新更新排序', href:"javascript: IConForm.findResult.setOrder(5);" },
		                    {text: '价格从低到高', href:"javascript: IConForm.findResult.setOrder(1);"}, 
		                    {text: '价格从高到低', href:"javascript: IConForm.findResult.setOrder(2);"
		                    }], offsetLeft, 0
		            );
		        } else if(type == 2){
		             IConForm.common.showMenu("courseprise",
		                  [{text: '最佳匹配度排序', href:"javascript: IConForm.findResult.setOrder(0);"},
		                   {text: '最新更新排序', href:"javascript: IConForm.findResult.setOrder(5);"
		                  }], offsetLeft, 0
		            );
		        }
        	}
        };
         IConForm.findResult.shift = function (type, value) {
         	if(type == 1) {
         		IConForm.search.form.action = IConForm.common.courseURL;
         	} else if(type == 2) {
         		IConForm.search.form.action = IConForm.common.agenURL;
         	}
         	IConForm.search.set.all(value, true, false);
         }
         
         /*var array = new Array();
         var panel = Ext.get("showTypePanel").down("div").down("ul").select("li[class]");
         var menu = new ssh.util.CCMenu("showTypeClickButton", "showTypePanel");
         for(var i = 0; i < panel.elements.length; i++) {
         	menu.addItems("typeList_" + (i + 1), "typeListPalel_" + (i + 1));
         }
         array.push(menu);
         ssh.util.CCMenu.Tip(array);*/
	};
	
	IConForm.agen = function () {
		IConForm.findResult();
		//var imgList = Ext.get("imgShiftList").select("img[src^=fts_res/css/index/images/my-img-]");
		IConForm.agen.shiftimg = function (index) {
			var photograph = new ssh.Photograph({
		    renderTo: 'imgShiftList',
		    //delay:0.2,
		    width:'997px',
		    height:'325px',
		    cls: 'photograph-scroll-1', // 滚动
		    //cls: 'photograph-orange', 渐隐
		    isShowText: false,
		    items:[
		          {alt:'',  href:'agen/AgenEnterprise/sendEnter.do', src:'fts_res/css/index/images/my-img-1.jpg'}, 
		          {alt:'',  href:'agen/AgenEnterprise/sendEnter.do', src:'fts_res/css/index/images/my-img-2.jpg'}, 
		          {alt:'',  href:'agen/AgenEnterprise/sendEnter.do', src:'fts_res/css/index/images/my-img-3.jpg'}, 
		          {alt:'',  href:'agen/AgenEnterprise/sendEnter.do', src:'fts_res/css/index/images/my-img-4.jpg'}
		        ]   
		                      
		    });
		};
		
		IConForm.agen.shiftimg(0);
	}
	
	IConForm.common = function () {
		IConForm.common.allURL = Ext.get("submiturl_allId").dom.value;
		IConForm.common.courseURL = Ext.get("submiturl_courseId").dom.value;
		IConForm.common.agenURL = Ext.get("submiturl_agenId").dom.value;
		
        // 显示头部搜索下拉菜单
        IConForm.common.showMenu = function (id, items, offsetLeft, offsetTop) {
        	 new ssh.Menu({
	            mode:'click',
	            borderWidth:1,
	            adhereTo: id,
	            offsetLeft: offsetLeft,
                offsetTop: offsetTop,
	            cls: 'menu-gray',
	            items: items
	           
		    });
        };
        IConForm.common.showMenuTo = function () {
        	var offsetLeft = -2;
        	if(Ext.isIE6) {
        		offsetLeft = 0;
        	} 
            IConForm.common.showMenu("menuPanelId1", 
                    [{text: '全部', click: function(index){
                            Ext.get("menu3Span").dom.innerHTML ="全部";
                            IConForm.search.form.action= IConForm.common.allURL;
                        }
                    }, {text: '课程', click: function(index){
                            Ext.get("menu3Span").dom.innerHTML ="课程";
                            IConForm.search.form.action= IConForm.common.courseURL;
                        }
                    },{text: '学校', click: function(index){
                            Ext.get("menu3Span").dom.innerHTML ="学校";
                            IConForm.search.form.action= IConForm.common.agenURL;
                    }
                }], offsetLeft, 0);
         };
        // 面板切换
        IConForm.common.shift = function (num, obj, id, count, className) {
        	for(var i = 0; i < count; i = i+1) {
	            Ext.get(id + "_a_" + i).removeClass(className);
	            Ext.get(id + "_b_" + i).setStyle("display", "none");
	        }
	        Ext.get(id + "_a_" + num).addClass(className);
	        Ext.get(id + "_b_" + num).setStyle("display", "block");
	    };
    };
};
IConForm();
IConForm.search.submit = function(sisubmit){
    if(sisubmit) {
    	Ext.getDom("allName").value = IConForm.search.allName.value;
        Ext.getDom("typeName").value = IConForm.search.typeName.value;
        Ext.getDom("courseName").value = IConForm.search.courseName.value;
        Ext.getDom("gradeName").value = IConForm.search.gradeName.value;
        Ext.getDom("areaName").value = IConForm.search.areaName.value;
        Ext.getDom("lableName").value = IConForm.search.lableName.value;
        Ext.getDom("orderType").value = IConForm.search.ordName.value;
        Ext.getDom("currentPage").value = IConForm.search.currentPage.value;
        if("找学校或课程" == IConForm.search.allName.value) {
        	Ext.getDom("allName").value = "";
        }
        if(!IConForm.search.currentPage.value) {
        	 Ext.getDom("currentPage").value = 1;
        }
        IConForm.search.form.submit();
    }
};

IConForm.search.event = function(sisubmit){
    IConForm.search.event.click = function (obj) {
    	if(obj.value == "找学校或课程") {
            obj.value = "";
        }
    };
    
    IConForm.search.event.focus = function (obj) {
        obj.style.color='#555';
        if(obj.value == "找学校或课程") {
        	obj.value = "";
        }
    };
    
    IConForm.search.event.blue = function (obj) {
        obj.style.color='#999';
        if(obj.value==null || obj.value==''){
        	obj.value='找学校或课程';
        }
    };
    
    IConForm.search.event.keyDown = function (obj) {
         var m = new ssh.util.MEvent();
	     var key = m.GetEvent();
	     if(key.keyCode == 13) {
	          IConForm.search.set.all(obj.value, true, true);
	     }
    }
    IConForm.search.event.mouseover = function (obj) {
     	var panel = Ext.get("showTypePanel").select("li[class]");
     	for(var i = 0; i < panel.elements.length; i++) {
     		Ext.get(panel.elements[i]).down("span").down("a").removeClass("curr");
     	}
     	Ext.get(obj).down("span").down("a").addClass("curr");
    };
    IConForm.search.event.mouseout = function (obj) {
    	var panel = Ext.get("showTypePanel").select("li[class]");
        for(var i = 0; i < panel.elements.length; i++) {
            Ext.get(panel.elements[i]).down("span").down("a").removeClass("curr");
        }
    }
};

IConForm.search.clear = function () {
	  // 清除所有 
	  IConForm.search.clear.all = function () {
	        IConForm.search.allName.value = "";
	        IConForm.search.typeName.value = "";
	        IConForm.search.courseName.value = "";
	        IConForm.search.gradeName.value = "";
	        IConForm.search.areaName.value = "";
	        IConForm.search.lableName.value = "";
	        IConForm.search.ordName.value = 0;
	        IConForm.search.currentPage.value = 1;
	  };
	  
	  // 清除一级分类 
	  IConForm.search.clear.type = function (){
	  	    IConForm.search.typeName.value = "";
            IConForm.search.courseName.value = "";
            IConForm.search.gradeName.value = "";
	  };
	  // 清除二级分类
	  IConForm.search.clear.course = function (){
            IConForm.search.courseName.value = "";
            IConForm.search.gradeName.value = "";
      };
      // 清除 三级分类
      IConForm.search.clear.grade = function (){
            IConForm.search.gradeName.value = "";
      };
      // 清除地区分类 
      IConForm.search.clear.area = function (){
            IConForm.search.areaName.value = "";
            IConForm.search.lableName.value = "";
      };
        // 清除商区分类
      IConForm.search.clear.lable = function (){
            IConForm.search.lableName.value = "";
      };
      // 清除分页
      IConForm.search.clear.current = function (){
            IConForm.search.currentPage.value = 1;
      };
};

IConForm.search.set = function () {
	// 设置 查询条件
	IConForm.search.set.all = function (value1, issubmit, isClear) {
		 if(isClear) {
		 	IConForm.search.clear.all();
		 }
		 IConForm.search.allName.value = value1;
		 IConForm.search.submit(issubmit);
	};
	 // 设置一级分类
      IConForm.search.set.type = function (value1, issubmit){
            IConForm.search.typeName.value = value1;
            IConForm.search.clear.course();
            IConForm.search.submit(issubmit);
      };
      // 设置二级分类
      IConForm.search.set.course = function (value1, value2, issubmit){
      	    IConForm.search.typeName.value = value1;
            IConForm.search.courseName.value = value2;
            IConForm.search.clear.grade();
            IConForm.search.submit(issubmit);
      };
      // 设置 三级分类
      IConForm.search.set.grade = function (value1, value2, value3, issubmit){
      	    IConForm.search.typeName.value = value1;
            IConForm.search.courseName.value = value2;
            IConForm.search.gradeName.value = value3;
            IConForm.search.submit(issubmit);
      };
      // 设置地区分类 
      IConForm.search.set.area = function (value1, issubmit){
            IConForm.search.areaName.value = value1;
            IConForm.search.clear.lable();
            IConForm.search.submit(issubmit);
      };
        // 设置商区分类
      IConForm.search.set.lable = function (value1, value2, issubmit){
            IConForm.search.areaName.value = value1;
            IConForm.search.lableName.value = value2;
            IConForm.search.submit(issubmit);
      };
      // 清除分页
      IConForm.search.set.current = function (value){
            IConForm.search.currentPage.value = value;
            IConForm.search.submit(true);
      };
};
IConForm.search.event();
IConForm.search.clear();
IConForm.search.set();

IConForm.common.showMap = function (title, content, x, y){
	var map = new ssh.Map({
                renderTo: 'mapDiv',                     // 控件展示位置
                hideId: 'mapHide',                      // 隐藏域
                //width: 720,                         // 控件宽度
                //height: 500,                        // 控件高度
                mapSize: 17,
                cls: 'map-default',                     // 控件样式
                ajaxUrl: 'servlet/MapServlet',          // 保存路径
                jsonIcon: {w:21,h:21,l:0,t:0,x:6,lb:5},
                def: [x, y],        // 初始坐标
                isWindow: true,                        // 窗口中打开地图
                isAjax: false,                      // 是否开启AJAX保存
                isOpenOve: true,                   // 是否开启缩放       
                isOpenSca: true,                   // 是否开启比例尺      
                isOpenNav: true,                   // 是否开启小地图  
                isAdmin: false,                      // 是否管理员（管理员可修改地图上的信息）
                jsonArr: [
                   
                ]
        });
        map.add({title: title, content: content, point: x + "|"+ y});
        map.show();
};







 
