 
//=============================================================
//产品搜索
//=============================================================

//显示当页面使用框架时的搜索框 
function showHide(id, on) 
{
	var Type=getCookie('Type');
	
	if(Type=='Product')
	{
		parent.document.forms[0].all.rbnProduct.checked = true;
	}
		else if(Type=='Enterprise')
	{
		parent.document.forms[0].all.rbnEnterprise.checked = true;
	
	}
		else if(Type=='Con1')
	{
		parent.document.forms[0].all.RadioButton_Con1.checked = true;
	}
		else if(Type=='Con2')
	{
		parent.document.forms[0].all.RadioButton_Con2.checked = true;
	}
				else if(Type=='Con3')
	{
		parent.document.forms[0].all.RadioButton_Con3.checked = true;
	}
		else if(Type=='Con4')
	{
		parent.document.forms[0].all.RadioButton_Con4.checked = true;
	}
		else
	{
		parent.document.forms[0].all.rbnProduct.checked = true;
	}
	if (document.forms[0].all.q.value!='')
	{
		parent.document.forms[0].all.s.value = document.forms[0].all.q.value;		
	}								
			
	var more=parent.document.getElementById(id);
	more.style.display=(on ? "inline" : "none");			
	
}
//精确搜索 		
function SearchEbzonExtra(key,evt)
{				
	if(evt.keyCode==13 || evt.keyCode==0)
	{             
		var keystr = escape(key.value); 
		if (keystr!="")
		{
			if(parent.document.forms[0].all.rbnProduct.checked)
			{
				url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Product";
			}			   
			else if(parent.document.forms[0].all.rbnEnterprise.checked)
			{
				url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Enterprise";
			}
			else if(parent.document.forms[0].all.RadioButton_Con1.checked)
			{
				url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Con1";
			}
			else if(parent.document.forms[0].all.RadioButton_Con2.checked)
			{
				url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Con2";
			}
			else if(parent.document.forms[0].all.RadioButton_Con3.checked)
			{
				url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Con3";
			}
			else if(parent.document.forms[0].all.RadioButton_Con4.checked)
			{
				url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Con4";
			}
			else
			{
				url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Product";
			}
			openwin(url);						
		} 
								
		return ;
	}
}
//关闭父页面使用偏好 
function closeParentSearchBox(divID,on) 
{
	var Type=getCookie('Type');
	
	if(Type=='Product')
	{
		document.forms[0].all.rbnProduct.checked = true;
	}
	else if(Type=='Enterprise')
	{
		document.forms[0].all.rbnEnterprise.checked = true;
		
	}
	else if(Type=='Con1')
	{
		document.forms[0].all.RadioButton_Con1.checked = true;
	}
	else if(Type=='Con2')
	{
		document.forms[0].all.RadioButton_Con2.checked = true;
	}
	else if(Type=='Con3')
	{
		document.forms[0].all.RadioButton_Con3.checked = true;
	}
	else if(Type=='Con4')
	{
		document.forms[0].all.RadioButton_Con4.checked = true;
	}
	else
	{
		document.forms[0].all.rbnProduct.checked = true;
	}

	if (document.forms[0].all.s.value!='输入关键字')
	{
		
		document.top.document.getElementById("q").value=document.forms[0].all.s.value;
	//	alert(document.frames("top").getElementById("j").value);// = document.forms[0].all.s.value;		
	}	
	var more=document.getElementById(divID);
	more.style.display=(on ? "inline" : "none");							
	
}
			
//对话框完成后的处理程序
function OnTextKeyDow(id)
			{
				if(event.keyCode==13)
				{
					document.getElementById(id).click();
					
				}
			}
		function openwin(url)
			{
				var obj = document.getElementById("tagOpenWin");			
				obj.href = url;
				obj.click();								
			}
	
			function SearchEbzon(key,evt)
			{	
					
				if(evt.keyCode==13 || evt.keyCode==0)
				{  
					var keystr = escape(key.value); 
					if (keystr!="")
					{
						var Type=getCookie('Type');
						if(Type=='Product')
						{
							url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Product";
						}
						else if(Type=='Enterprise')
						{
							url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Enterprise";
						}
						else if(Type=='Con1')
						{
							url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Con1";
						}
						else if(Type=='Con2')
						{
							url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Con2";
						}
						else if(Type=='Con3')
						{
							url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Con3";
						}
							else if(Type=='Con4')
						{
							url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Con4";
						}
						else
						{
							url="/SearchProduct/ExactSearchPro_One.aspx?KeyWord="+keystr+"&Type=Product";
						}			
						openwin(url);						
					}	
					return;			
				}
				
				
			}
			



    function getCookie(cookieName) 
	{
		var cookieString = document.cookie;	
		var start = cookieString.indexOf(cookieName + '=');
		if (start == -1) 
		return null;
		start += cookieName.length + 1;
		var end = cookieString.indexOf(';', start);
		if (end == -1) 
		return unescape(cookieString.substring(start));
		return unescape(cookieString.substring(start, end));
	}
	

function setCookie(cookieName,cookieValue)
{
	window.document.cookie	= cookieName + "=" + escape(cookieValue);
}


function setinnertext(contID)
{
    alert(contID);
	if(contID=='trpro')
	{
		document.getElementById('cont').innerText='配置默认搜索类别为产品,搜索结果包括产品系列,产品所属类别,产品样本,企业介绍,产品介绍等。';
	}
	else if(contID=='trEnt')
	{
		document.getElementById('cont').innerText='配置默认搜索类别为企业,搜索结果包括企业介绍,企业产品介绍等。';
	}
	else if(contID=='trCon1')
	{
		document.getElementById('cont').innerText='配置默认搜索类别为新闻荟萃,搜索结果包括标题,关键字等。';
	}
	else if(contID=='trCon2')
	{
		document.getElementById('cont').innerText='配置默认搜索类别为行业资讯,搜索结果包括标题,关键字等。';
	}
	else if(contID=='trCon3')
	{
		document.getElementById('cont').innerText='配置默认搜索类别为知识库,搜索结果包括标题,关键字等。';
	}
	else if(contID=='trCon4')
	{
		document.getElementById('cont').innerText='配置默认搜索类别为协作公告,搜索结果包括标题,关键字等。';
	}
	else 
	{
		document.getElementById('cont').innerText='配置默认搜索类别';
	}
	
	document.getElementById(contID).bgColor='#ffffff';
}

function settrbackcol(color,contID)
{
	if(contID=='trpro')
	{
		document.getElementById('trpro').bgColor=color;
	}
	else if(contID=='trEnt')
	{
		document.getElementById('trEnt').bgColor=color;
	}
	else if(contID=='trCon1')
	{
		document.getElementById('trCon1').bgColor=color;
	}
	else if(contID=='trCon2')
	{
		document.getElementById('trCon2').bgColor=color;
	}
	else if(contID=='trCon3')
	{
		document.getElementById('trCon3').bgColor=color;
	}
	else if(contID=='trCon4')
	{
		document.getElementById('trCon4').bgColor=color;
	}
	else 
	{
		
	}
}

//选择全选框，即选中所有的复选框
function SelectAll (chkVal, idVal) 
{ 
	var thisfrm = document.forms[0]; 
	// 如果选上全选框，则把其它选项框全选上。 
	if (idVal.indexOf ('CheckBoxAll') != -1) 
	{
		for (i=0;i<thisfrm.length;i++)
		{
			if(chkVal) 
			{ 
			    if(thisfrm.elements[i].name.indexOf ('CheckBoxButton1') != -1)
			    {
			     thisfrm.elements[i].checked=true;
				}
			} 
			else 
			{ 
                if(thisfrm.elements[i].name.indexOf ('CheckBoxButton1') != -1)
			    {
			     thisfrm.elements[i].checked=false;
				}
			} 
		}
	}
	else 
	{
		if(chkVal) 
		{ 
			for (i=0;i<thisfrm.length;i++) //如果其它所有项都被选择，则选中全选框
			{
			    if(thisfrm.elements[i].name.indexOf ('CheckBoxButton1') != -1)
			    {
			      if(thisfrm.elements[i].checked==false)
			        return false;
				}
			}
			thisfrm.CheckBoxAll.checked =true;
		}
		else //如果其它有一项没选择，则取消全选框的选择
		{
			thisfrm.CheckBoxAll.checked = false
		}
	}
}
function sqlencode(str)
{
//window.alert(str);
str=str.replace(/'/g,"\'\'");

str=str.replace(/\[/g,"[[]"); //此句一定要在最先
//window.alert(str);
str=str.replace(/_/g,"[_]");
str=str.replace(/%/g,"[%]");

//str=str.replace(str,"&","#*#");
return str;
};


function SearchForConDetailsClass(form,type,classID)
{
	var Form1=document.getElementById(form);
	var content=GetQueryString("KeyWord");//document.getElementById('tbx_content');
	if(trim(content)!='')
	{
		if(classID != "")
		{
			acti	=	"../SearchCont/ConList.aspx?KeyWord=" + escape(content)+"&Type="+type+"&ClassID="+classID;
		}
		else
		{
			acti	=	"../SearchCont/ConList.aspx?KeyWord=" + escape(content)+"&Type="+type;
		}
		Form1.action=acti;
		Form1.target='_parent';
		Form1.submit();
	}
	else
	{
	
	}	
} 
