//1 产品，2 供应,3 求购,4 企业,5 新闻	错误的，请查看表				
function book_check(bookid,booktype){
		document.getElementById("book_id").value=bookid;
		document.getElementById("book_type").value=booktype;
		if(document.getElementById("se_cust_id")==null||document.getElementById("se_cust_id").value=="")
		{
			alert("请您先登录！");
			return ;
		}
		if(bookid!="")
		{
		document.getElementById("trade_type_code").value="5430";
		document.book_form.submit();
		}
	}

/**
  *百科导航栏搜索
**/
function baikeSearchCheckValue(){
	if(document.getElementById('keywrod').value==''){
		alert('请输入关键字！');
		return false;
	}
	if(document.getElementById('xype').value==''){
		alert('请选择搜索类型！');
		return false;
	}
	document.searchform.submit();
}
function setTyptValue(val){
	for(var i=1;i<=6;i++){
		if(i==val){
			document.getElementById("dt"+val).className="a1";
		}else{
			document.getElementById("dt"+i).className="";
		}
	}
	document.getElementById('xype').value=val;
}

String.prototype.Trim  =  function() 
{  
  return  this.replace(/(^\s*)|(\s*$)/g,  "");  
} 
/**adv：广告位(对应div那个id)，ad_id:广告id,type:广告类型,width:图片宽，height：图片高*/
function getAD(adv,ad_id,type,width,height){
  var adv_content = $.ajax({
		  url: "/templates/default/jsp/getAd.jsp?ad_id="+ad_id+"&ad_type="+type+"&width="+width+"&height="+height+"&"+Math.random(),
		  async: false
		 }).responseText;
  document.getElementById(adv).innerHTML=adv_content;
}
	function getAdOne(adv,width,height){
		  var ad=$.ajax({
			  url: "/templates/default/jsp/getAd.jsp?ad_id="+adv+"&ad_type=2&width="+width+"&height="+height+"&"+Math.random(),
			  async: false
		  }).responseText;
		  document.write(ad);  
	}
//删除字符串左端的空格
String.prototype.LTrim  =  function()  
{  
return  this.replace(/(^\s*)/g,  "");  
}  
  //删除字符串右端的空格
String.prototype.RTrim  =  function()  
  {  
  return  this.replace(/(\s*$)/g,  "");  
}

function loadUrl()
{
location.href='/member/leaveWordsMgr/addLeavewords.jsp';
}
//显示留言提示函数
function showErrorMessage()
{
alert("您好！请登录后留言！");
}

//显示登录提示函数
function showLogin(val)
{
//alert("您好！请您先登录！");
location.href="/templates/login.html?comeurl="+val;
}
function clearInput(obj)
{
	obj.value="";
}

//截取字符串
//str字符串　len字符串长度  tof　1追加点　0不追加
function strProc(str,len,tof)
{
	str=str.replace(/<[^<|^>]+>/g,"");
	if(str.length>len)
		if(tof=="1")
			document.write(str.substring(0,len)+"..");
		else
			document.write(str.substring(0,len));
	else
			document.write(str);
}

//是否登录
function isLogin()
{
	if(document.getElementById("se_cust_id")==null||document.getElementById("se_cust_id").value=="")
		return false;
	else
		return true;
}

//留言
function leaveWords(cust_id,user_id,word_type)
{
	if(isLogin())
	{
		if(cust_id==document.getElementById("se_cust_id").value)
		{alert("不可以给自己留言！");return ;}
		openUrlProc("/member/leaveWordsMgr/addLeavewords.jsp?cust_id="+cust_id+"&user_id="+user_id+"&word_type="+word_type);
		//var strurl="/member/leaveWordsMgr/addLeavewords.jsp?cust_id="+cust_id+"&user_id="+user_id+"&word_type="+word_type;
		//window.open(strurl);
	}
else
	alert("请您登录后留言！");
}

//管理员
function isAdmin()
{
	if(document.getElementById("se_cust_type")!=null && document.getElementById("se_cust_type").value=="0")
		return true;
	else
		return false;
}
//企业会员
function isMember()
{
	if(isLogin() && document.getElementById("se_cust_type").value=="1" )
		return true;
	else
		return false;
}
//个人会员
function isUser()
{
	if(isLogin() && document.getElementById("se_cust_type").value=="2" )
		return true;
	else
		return false;
}

//进入管理员或会员后台
function openUrlProc(url){
	
	if(isAdmin() && url.indexOf('member')!=-1 && url.indexOf("add_exhibition.jsp")<0&& url.indexOf("addNews.jsp")<0 && url.indexOf("add_zhaopin.jsp")<0)
	{
		alert("您是管理员!");
		return ;
	}
	if( !isAdmin() && url.indexOf('admin')!=-1)
	{
		alert("您不是管理员!");
		return ;
	}
	var admin = "/admin/mainMenu/default.jsp?comeurl="
	var memeber ="/member/mainMenu/default.jsp?comeurl=";
	if(isAdmin())
	{
		if(url.indexOf("add_exhibition.jsp")!=-1){
		   url=url.replace("member","admin");
		}
		if(url.indexOf("addNews.jsp")!=-1){
		   url="/admin/newsMgr/addNews.jsp";
		}
		if(url.indexOf("add_zhaopin.jsp")!=-1){
		   url=url.replace("member","admin");
		}
		location.href=admin+url;
	}else if( isMember() || isUser() ){
		location.href=memeber+url;
	}else
	{	
		//var url=window.location.pathname;
		showLogin(url);
	}
	return ;
}
//打开窗口
function openUrl(url)
{
	window.open(url);
}

//添加到收藏夹
function AddFavorite(sURL, sTitle)
    {
        try
        {
            window.external.addFavorite(sURL, sTitle);
        }
        catch (e)
        {
            try
            {
                window.sidebar.addPanel(sTitle, sURL, "");
            }
            catch (e)
            {
                alert("加入收藏失败，请使用Ctrl+D进行添加");
            }
        }
    }

	//设置首页
    function SetHome(obj,vrl)
    {
        try
        {
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                        } 
                        catch (e) { 
                                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
    }
function doZoom(size){
		var artibody = document.getElementById('artibody');
		if(!artibody){
			return;
		}
		var artibodyChild = artibody.childNodes;
		artibody.style.fontSize = size + 'px';
		//ÔÙ¶Ôartibody divÄÚµÄÖ±½Óhtml½ÚµãÉèÖÃfontSizeÊôÐÔ
		for(var i = 0; i < artibodyChild.length; i++){
			if(artibodyChild[i].nodeType == 1){
				artibodyChild[i].style.fontSize = size + 'px';
			}
		}		
	}
	//获取压缩图存放路径 size:小图还是中图，picPath:原图存放路径
	function getSmallPic(size,picPath){
		var smallPic="";
		if(size == "small"){
			smallPic = picPath.substring(0,picPath.indexOf("."))+"_small"+picPath.substring(picPath.indexOf("."),picPath.indexOf(".")+4);
			return smallPic;
		}
		if(size == "middle"){
			var smallPic = picPath.substring(0,picPath.indexOf("."))+"_middle"+picPath.substring(picPath.indexOf("."),picPath.indexOf(".")+4);
			return smallPic;
		}
		return picPath;
	}
	/*var url=window.location.href;
				if(url.indexOf("/shop.jsp")>0){
					setClass(1);
				}else if(url.indexOf("/good_index.html")>0){
					setClass(2);
				}else if(url.indexOf("/product/")>0){
					setClass(3);
				}else if(url.indexOf("/sales/")>0){
					setClass(4);
				}else if(url.indexOf("/buying/")>0){
					setClass(5);
				}else if(url.indexOf("/service/")>0){
					setClass(6);
				}else if(url.indexOf("/news/")>0){
					setClass(7);
				}else if(url.indexOf("/enterprise/")>0 || url.indexOf("company_list")>0){
					setClass(8);
				}else if(url.indexOf("/jobs/")>0 || url.indexOf("/work/QiuZhi/")>0|| url.indexOf("/jobs_list")>0){
					setClass(9);
				}else if(url.indexOf("/ZhanHui/")>0){
					setClass(10);
				}else if(url.indexOf("/price.jsp")>0){
					setClass(11);
				}else {
					setClass(0);
				}
			function setClass(val){
				for(var i =0;i<12;i++){
					if(i==val){
						if(document.getElementById("class"+i)!=null){
							document.getElementById("class"+i).className="cur";
						}
					}else{
						if(document.getElementById("class"+i)!=null){
							document.getElementById("class"+i).className="";
						}
					}
				}
			}	
	*/
	//ajax获取信息
	function ajaxInfo(info){
		var viewId = info.viewId;
		if(document.getElementById(viewId)){
			$("#"+viewId).html("&nbsp;&nbsp;&nbsp;&nbsp;正在获取信息 <img src='/images/loading.gif' /> ");
		    $.ajax({
				type:"post",
				data:{state:info.state,limit:info.limit,orderby:info.orderby,subCount:info.subCount,class_id:info.class_id},
				url:"/templates/default/jsp/j_get"+info.jsp+"?date="+Math.random(),
				success:function(msg){
					$("#"+viewId).html("");
					$("#"+viewId).html($.trim(msg));
				}
			});
		}
	}
	