function setLanguage(language){
	document.getElementById("langcss").href="../style/style1.asp?language="+language;
}
/*首页显示产品_BEGIN*/
function ajax_getProducts(typeid)
{
	var date=new Date();
  	var stamp=date.getTime();
	var loader = new net.ContentLoader("productlist.asp?"+typeid+".html&timestamp="+stamp,
		statechange_getProducts,stateerror_getProducts);
}
function statechange_getProducts()
{
var respText = this.req.responseText;
document.getElementById("index_productlist_detail").innerHTML=respText;
}
function stateerror_getProducts(){
	document.getElementById("index_productlist_detail").innerHTML="连接服务器出错";
}
function showproducttype(){
	var producttype = document.getElementById("index_producttype");
	if(producttype.style.display=="none"){
		producttype.style.display="";
	}else{
		producttype.style.display="none";
	}
}
function hiddeproducttype(){
	var producttype = document.getElementById("index_producttype");
	producttype.style.display="none";
}
/*首页显示产品_END*/

/*弹出添加留言对话框_BEGIN*/
function ajax_AddComment()
{
	document.getElementById("dialog_comment").style.display='';
	var date=new Date();
  	var stamp=date.getTime();
	var loader = new net.ContentLoader("commentlist_addcomment.asp?timestamp="+stamp,
		statechange_AddComment,stateerror_AddComment);
}
function statechange_AddComment()
{
	var respText = this.req.responseText;
	document.getElementById("dialog_comment").innerHTML=respText;
}
function stateerror_AddComment(){
	alert("连接服务器出错");
	document.getElementById("dialog_comment").style.display="none";
}
/*弹出添加留言对话框_END*/
//检查添加留言对话框
//非空验证
function isNotEmpty(el_name,el_title)
{
	var e=document.getElementById(el_name);
	e.style.border="1px solid #9093BE";
	if (e.value==""){
		alert("请填写"+el_title);
		e.style.border="2px solid red";
		e.focus();
		return false;
	}else{
		return true;
	}
}
function checkform_AddComment()
{
	var flag=isNotEmpty("title","标题-Title")&&isNotEmpty("author","昵称-Nickname")&&isNotEmpty("email","Email")&&isNotEmpty("content","内容-Content")&&checkEmail("email","Email")&&checkLength("title","标题-Title",2,100)&&checkLength("author","昵称-Nickname",2,40)&&checkLength("content","内容-Content",10,1000);
	if (document.getElementById("tel").value!=""){
		flag=flag&&checkPhone("tel","电话/手机-Phone/Mobile");
	}
	return flag;
}
//检查Email地址
function checkEmail(el_name,el_title) {
	e=document.getElementById(el_name);
	el_value = e.value;
	if(!validateEmailByReg(el_value)) {
		alert(el_title+"不合法，请重新填写！");
		e.style.border="2px solid red";
		e.focus();
		return false;
	}
	return true;
}
//检查电话号码
function checkPhone(el_name,el_title){ 
	e=document.getElementById(el_name);
	el_value = e.value;
	var reg=/^([\d-+()]*)$/;
	if (reg.test(el_value)==false)
	{
		alert(el_title+"不合法，请重新填写！is not valid");
		e.style.border="2px solid red";
		e.focus();
		return false;
	}
	return true;
}

//检查长度
function checkLength(el_name,el_title,min_Len,max_Len){ 
	e=document.getElementById(el_name);
	el_value = e.value;
	if (el_value.length>max_Len)
	{
		alert(el_title+"字符过多，最多"+max_Len+"个字符！");
		e.style.border="2px solid red";
		e.focus();
		return false;
	}
	if (el_value.length<min_Len)
	{
		alert(el_title+"字符过少，最少"+min_Len+"个字符！");
		e.style.border="2px solid red";
		e.focus();
		return false;
	}
	return true;
}

function validateEmailByReg(str){
    return(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(str));
}
/*保存留言_BEGIN*/
function ajax_saveComment()
{
	if(checkform_AddComment()){
		var date=new Date();
		var stamp=date.getTime();
		var params="title="+document.getElementById("title").value;
		params+="&messagetype="+document.getElementById("messagetype").value;
		params+="&author="+document.getElementById("author").value;
		params+="&company="+document.getElementById("company").value;
		params+="&email="+document.getElementById("email").value;
		params+="&tel="+document.getElementById("tel").value;
		params+="&content="+document.getElementById("content").value;
		document.getElementById("dialog_comment").style.display='';
		var loader = new net.ContentLoader("commentlist_savecomment.asp?timestamp="+stamp,
			statechange_saveComment,stateerror_saveComment,"POST",params);
	}
}
function statechange_saveComment()
{
	var respText = this.req.responseText;
	alert(respText);
	document.getElementById("dialog_comment").style.display="none";
	location.reload();
}
function stateerror_saveComment(){
	alert("连接服务器出错");
	document.getElementById("dialog_comment").style.display="none";
}
/*保存留言_END*/
/*专题查看*/
function ajax_showspecial(specialid)
{
	var date=new Date();
  	var stamp=date.getTime();
	var loader = new net.ContentLoader("special.asp?"+specialid+"$0.html&timestamp="+stamp,
		statechange_showspecial,stateerror_showspecial);
}
function statechange_showspecial()
{
var respText = this.req.responseText;
document.getElementById("main_middle_layout").innerHTML=respText;
}
function stateerror_showspecial(){
	document.getElementById("main_middle_layout").innerHTML="连接服务器出错";
}
//关闭留言框
function closeAddComment(){
	var el=document.getElementById("dialog_comment");
	el.innerHTML="";
	el.style.display="none";
}
//显示搜索框
function showSearch(){
	var e=document.getElementById("searchbox");
	if(e.style.display=="none"){
		e.style.display="";
	}else{
		e.style.display="none";
	}
}
function checksearch(){
	var f=document.getElementById("searchform");
	if(isNotEmpty("keyword","关键字-Keyword")&&checkLength("keyword","关键字-Keyword",2,20))
		f.submit();
}
