	var select_ckind = ["select_ckind_1","select_ckind_2","select_ckind_3","select_companyItem_1",
						"select_companyItem_2","select_companyItem_3","select_mode_1","select_productItem_1",
						"select_productItem_2","select_productItem_3","select_area_1","select_area_2",
						"select_area_3","select_subject_1","select_subject_2","select_subject_3",
						"select_lengthservice_1","select_salary_1","select_jkind_1","select_cardkind_1",
						"select_cet_1","select_prepareTime_1","select_degree_1","select_ads_1","select_fileItem_1",
						"select_specItem_1","select_employeeCount_1","select_book_1","select_book_2"
						];
	
	function getmoreinfo(){
		var company_more_info = document.getElementById("company_more_info").style.display;
		if(company_more_info == "none"){
			document.getElementById("company_more_info").style.display = "";
		}else{
			document.getElementById("company_more_info").style.display = "none";
		}
	}
	
	function getmysdinfo(state,item){
		document.location.href = "supplyDemand.do?method=mySupplyDemand4Action&state="+state+"&item="+item;
	}
	function getsdinfo(id,sd_param){
		document.location.href = "supplyDemand.do?method=findSupplyDemand4Action&sd_param="+sd_param+"&id="+id;
	}
	function getmysitemail(state){
		if(state == 9){
			document.location.href = "sitemail.do?method=addSiteMailInput4Action";
		}else{
			document.location.href = "sitemail.do?state="+state;
		}
	}
	function getMySorts(userId){
		supplyDemandDWR.getMySorts(userId,
			function(data){
				var html = new String();
				html += "";
				for(var i = 0;i < data.length ; i++){
					html += "<div  id=sorts"+data[i][0]+" style='background:#FAFFF9' onclick='getMyFriendsBySortsId("+userId+","+data[i][0]+",this.id)'>"+data[i][1]+"("+data[i][2]+")</div><div id="+data[i][0]+"_"+"sorts"+data[i][0]+" ></div>";
				}
				document.getElementById("ld_main").innerHTML = html;
				document.getElementById("loginDIV").style.display = "block";
			}
		);
	}
	
	//ajax发站内短信息时，获取收件人列表
	function getMyFriendsBySortsId(userId,sortsId,divId){
		var s_html = new String();
		var divobject = document.getElementById(divId);
		var bgcolor = divobject.style.backgroundColor;
		var nextdivobject = document.getElementById(sortsId+"_"+divId)
		s_html += nextdivobject.innerHTML;
		var divId_sortsId = document.getElementById(""+divId+"_"+sortsId);
		//判断该DIV是否存在，存在则说明已经打开了该分组，
		//那么就要将该DIV关闭，所以不需要再进行查询，直接将s_html赋初值即可
		if(divId_sortsId == 'undefind' || divId_sortsId == null){
			supplyDemandDWR.getMyFriendsBySortsId(userId,sortsId,
				function(data){
					nextdivobject.style.display = "";
					if(data.length > 0){
						s_html += "<div id='"+divId+"_"+sortsId+"'>"
						for(var i = 0;i < data.length ; i++){
							s_html += "<div id='"+divId+"_"+sortsId+"_"+i+"' style='background:#F1F1F1' onclick='setMailToByFriends("+data[i][0]+",this.id)'>"+data[i][1]+"</div>";
						}
						s_html += "</div>";
						nextdivobject.innerHTML = s_html;
					}else{
							s_html = nextdivobject.innerHTML;
							nextdivobject.innerHTML = s_html;
					}
				} 
			);
		}else{
			divId_sortsId.innerHTML = "";
			nextdivobject.innerHTML = "";
			nextdivobject.style.display = "none";
		}	
		if(bgcolor.toLocaleUpperCase() == "#E3FECC"){
			divobject.style.backgroundColor = "#FAFFF9";
		}else{
			divobject.style.backgroundColor = "#E3FECC";
		}
	}
	
	//添加收件人，并显示不同颜色样式
	function setMailToByFriends(friendsId,divId){
		var divobj = document.getElementById(divId);
		var bgcolor = divobj.style.backgroundColor;
		var name = divobj.innerHTML;
		var to_friends_value = document.getElementById("to_friends").value;
		var targetUsers = document.getElementById("targetUsers").value;
		if(bgcolor.toLocaleUpperCase() == "#F1F1F1"){
			divobj.style.backgroundColor = "#FFFFCC";
			if(to_friends_value == null || to_friends_value == ""){
			document.getElementById("to_friends").value = friendsId;
			document.getElementById("targetUsers").value = name;
			}else{
				document.getElementById("to_friends").value = to_friends_value+","+friendsId;
				document.getElementById("targetUsers").value = targetUsers +","+name;
			}
		}else{
			divobj.style.backgroundColor = "#F1F1F1";
			if(to_friends_value == null || to_friends_value == ""){
				document.getElementById("to_friends").value = "";
				document.getElementById("targetUsers").value = "";
			}else{
				document.getElementById("to_friends").value = to_friends_value.substring(0,to_friends_value.lastIndexOf(","));
				document.getElementById("targetUsers").value = targetUsers.substring(0,targetUsers.lastIndexOf(","));
			}
		}

		
	}
	
	//设置文本的颜色
	function settextcolor(divId){
		var divobject = document.getElementById(divId);
		var bgcolor = divobject.style.backgroundColor;
		if(bgcolor.toLocaleUpperCase() == "#E3FECC"){
			divobject.style.backgroundColor = "#FAFFF9";
		}else if(bgcolor.toLocaleUpperCase() == "#FAFFF9"){
			divobject.style.backgroundColor = "#E3FECC";
		}else if(bgcolor.toLocaleUpperCase() == "#F1F1F1"){
			divobject.style.backgroundColor = "#FFFFCC";
		}else{
			divobject.style.backgroundColor = "#F1F1F1"
		}
	}
	
	function sendSiteMail(state){
		document.getElementById("mailstate").value = state;
		document.forms[0].submit();
	}
	
	//实现ajax级联通用类别
	function getCompanyItem(ci_type,parentId,begin,end,updateBoolean,itemvalue,select_count){
		commonItemDWR.findCommonItemList(ci_type,parentId,
			function(data){
			if(document.getElementById(select_ckind[begin])==null){
			}else{
				dwr.util.removeAllOptions(select_ckind[begin]);
				var select_ckinds = document.getElementById(select_ckind[begin]);
				
				var objOption0 = document.createElement("option");
				objOption0.value = 0;
				if(begin == 10){
					objOption0.text = "省份";
					objOption0.value = 0;	
				}else if(begin == 11){
					objOption0.text = "地级市";	
					objOption0.value = 0;	
				}else if(begin == 12){
					objOption0.text = "市、县级市、县";	
					objOption0.value = 0;	
				}else{
					objOption0.text = "请选择";	
					objOption0.value = 0;	
				}
				try{
					  select_ckinds.add(objOption0,null); // standards compliant
				}catch(ex){
					  select_ckinds.add(objOption0); // IE only
				}				
				if(data == null || data.length == 0){
					
				}else{
					for(var i = 0;i < data.length ; i++){
						var objOption = document.createElement("option");
						objOption.value = data[i][0];
						objOption.text = data[i][1];
						try{
						  	select_ckinds.add(objOption,null); // standards compliant
						}catch(ex){
						    select_ckinds.add(objOption); // IE only
						}
					}
				}
           		if(begin < end){
           			if(updateBoolean){
           			
				 		getCompanyItem(ci_type,initCommonItemValue(ci_type,begin,end,itemvalue,select_count),++begin,end,updateBoolean,itemvalue,select_count);	 
				 		
				 	}else{
			 			begin++;
			 			getCompanyItem(ci_type,$(select_ckind[begin]).value,begin,end,updateBoolean,itemvalue,select_count);
			 		}
			 	}else if(begin == end){
			 		if(updateBoolean){
				 		initCommonItemValue(ci_type,begin,end,itemvalue,select_count);
				 	}
			 	}
			
			}
			}
		);
	}
	

	function initCommonItemValue(ci_type,begin,end,itemvalue,select_count){
		dwr.engine.setAsync(false); 
		var value_int = 0;
		//获取alias的值，对其进行分割，通过下划线"_"的个数确定其为几级目录
		commonItemDWR.findCommonItemAliasById(ci_type,itemvalue,
			function(data){
				var itemvalue_str = data;
				if(itemvalue_str == null){
					return 0;
				}
				var itemvalue_arr = itemvalue_str.split("_");
				var select_value = document.getElementById(select_ckind[begin]);
				
				
				for(var j=0 ; j < select_value.options.length ; j++){
					if(select_value.options[j].value == itemvalue_arr[select_count-(end - begin+1)]){
						select_value.options[j].selected=true;
						value_int = select_value.options[j].value;
						break;
					}
				}
			}
		);
		return value_int;
	}
	function initProductItem(selectid,itemId){
		document.getElementById(selectid).value = itemId;
	}
	function initItem(selectid,itemId){
		document.getElementById(selectid).value = itemId;
	}
	//初始化公司信息页面公司行业、公司性质、模式等信息
	function init_C_Info(init_value_1,init_value_2,init_value_3,init_value_4){
		getCompanyItem('ckind',-1,0,2,true,init_value_1,3);
		getCompanyItem('companyItem',-1,3,5,true,init_value_2,3);
		getCompanyItem('mode',-1,6,6,true,init_value_3,1);
		getCompanyItem('area',-1,10,12,true,init_value_4,3);
	}
	//初始化注册新公司页面
	function init_C_New(){
		getCompanyItem('ckind',-1,0,2,false,null,3);
		getCompanyItem('companyItem',-1,3,5,false,null,3);
		getCompanyItem('mode',-1,6,6,false,null,1);
		getCompanyItem('area',-1,10,12,false,null,3);
	}	
	function uploadimage(userId,type){
		window.open("upload.do?userId="+userId+"&type="+type,"_blank"); 
	}
	function showmyimage(userId,type){
		window.open("upload.do?method=findmyImages4Action&type="+type+"&userId="+userId,"_blank");
	}
	
	//上传成功后，刷新父框架，并关闭页面
	function init_refresh(d_id,up_state,type){
		if(up_state == 9){
			alert("上传文件成功");
			// window.opener.location.reload();
			var _parentWin = window.opener ;
			if(type == "product_image"){
				_parentWin.sd_form.product_image.src = "/upload/image_"+d_id+"/index.html";
				_parentWin.sd_form.referenceId.value = d_id;
				window.close(); 
			}else if(type == "article_image"){
				_parentWin.articleForm.article_image.src = "/upload/image_"+d_id+"/index.html";
				_parentWin.articleForm.referenceId.value = d_id;
				window.close(); 				
			}else if(type == "ads"){
				_parentWin.adsActionForm.ads_image.src = "/upload/image_"+d_id+"/index.html";
				_parentWin.adsActionForm.referenceId.value = d_id;
				window.close(); 				
			}else if(type == "bk_image"){
				_parentWin.bookForm.bk_image.src = "/upload/image_"+d_id+"/index.html";
				_parentWin.bookForm.referenceId.value = d_id;
				window.close(); 				
			}else if(type == "farticle_image"){
				_parentWin.farticleForm.farticle_image.src = "/upload/image_"+d_id+"/index.html";
				_parentWin.farticleForm.referenceId.value = d_id;
				window.close(); 				
			}else if(type == "ads_image"){
				_parentWin.adsActionForm.ads_image.src = "/upload/image_"+d_id+"/index.html";
				_parentWin.adsActionForm.referenceId.value = d_id;
				window.close(); 
			}else if(type == "metting_file"){
				_parentWin.mettingForm.adjunct.value = d_id;
				_parentWin.document.getElementById('filename').innerHTML = d_id;
				window.close(); 
			}else if(type == "c_logo"){
			
				_parentWin.companyactionform.c_logo.src = "/upload/image_"+d_id+"/index.html";
				_parentWin.companyactionform.logoId.value = d_id;
				window.close(); 
			}else if(type == "sd_product_image"){
			
				_parentWin.sdinfoactionform.sd_product_image.src = "/upload/image_"+d_id+"/index.html";
				_parentWin.sdinfoactionform.referenceId.value = d_id;
				window.close(); 
			}else if(type == "file"){
				window.location.href = "/u/myupload/index.html";
			}
		}else if(up_state == 1){
			alert("上传失败！文件不能为空");
		}else if(up_state == 2){
			alert("上传失败！文件大小超过限制");
		}else if(up_state == 3){
			alert("上传失败！文件类型必须是.jpg或者.jpeg或者.jif或者.txt或者.doc或者.rar");
		}
	}	
	function usethisimage(d_id,type){
			var _parentWin = window.opener ;
		if(type == "product_image"){
			_parentWin.sd_form.product_image.src = "/upload/image_"+d_id+"/index.html";
			_parentWin.sd_form.referenceId.value = d_id;
			window.close(); 
		}else if(type == "article_image"){
			_parentWin.articleForm.article_image.src = "/upload/image_"+d_id+"/index.html";
			_parentWin.articleForm.referenceId.value = d_id;
			window.close(); 
		}	else if(type == "ads_image"){
			_parentWin.adsActionForm.ads_image.src = "/upload/image_"+d_id+"/index.html";
			_parentWin.adsActionForm.referenceId.value = d_id;
			window.close(); 
		}else if(type == "sd_product_image"){
				_parentWin.sdinfoactionform.referenceId.value = d_id;
				_parentWin.document.getElementById('sd_product_image').innerHTML = d_id;
				window.close(); 
			}
	}	
	function commonItem_init_main(ci_type){
		if(ci_type == "ckind"){
			getCompanyItem("ckind",-1,0,2,false,null,3);
		}else if(ci_type == "companyItem"){
			getCompanyItem('companyItem',-1,3,5,false,null,3);
		}else if(ci_type == "subject"){
			getCompanyItem('subject',-1,13,15,false, null,3);
		}else if(ci_type == "book"){
			getCompanyItem('book',-1,27,28,false, null,2);
		}
	}
	function initfileupload(up_state){
		init_refresh('',up_state ,'file');
		getCompanyItem("fileItem",-1,24,24,false,null,1);
	}
	function setcompanyItem(s){
		document.getElementById("companyItem").value = s;
	}
