// 防伪查询
var xmlHttp;
function createXMLHttpRequest(){
  if (window.ActiveXObject){
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  else if (window.XMLHttpRequest){
    xmlHttp=new XMLHttpRequest();
  }
}

function validate(){
  var vdate=$("key").value;
  var actNum="";
  if (vdate.length<16 || vdate.length>21){
	  $("ajxcload").style.display="none";
	  $("formdiv").style.display="none";
	  $("ajxdiv").style.display="";
	  $("ajxc").innerHTML = "错误的查询码！<br />请正确输入16位或20位防伪码！";
  };
  createXMLHttpRequest();
  xmlHttp.open("POST","/Templets/bogus.asp",true);
  xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
  xmlHttp.onreadystatechange = mychange
  if (vdate.length<20){
	  actNum="n16b";
  }
  else
  {
	  actNum="n20b";
  }
  //alert("action=" + actNum + "&key="+ escape(vdate));
  xmlHttp.send("action=" + actNum + "&key="+ escape(vdate));
}

function mychange() {
    if(xmlHttp.readyState == 1)
	{
	  $("ajxcload").style.display="";
	  $("formdiv").style.display="none";
	  $("ajxdiv").style.display="none";
	}
    // 请求已完成
    if(xmlHttp.readyState == 4) {
	  $("ajxcload").style.display="none";
	  $("formdiv").style.display="none";
	  $("ajxdiv").style.display="";
	  $("ajxc").innerHTML = xmlHttp.responseText;
    }
}

function onbk()
{
  $("formdiv").style.display="";
  $("ajxdiv").style.display="none";
  
}



function gubook(){
  var vTopic=$("Topic").value;
  var vContent=$("Content").value;

  createXMLHttpRequest();
  xmlHttp.open("POST","/GuestBook/ajaxAddnewNotes.asp",true);
  xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
  xmlHttp.onreadystatechange = gubookchange
  xmlHttp.send("Content=" + escape(vContent)  + "&Topic=" + escape(vTopic));
}

function gubookchange() {
	
    if(xmlHttp.readyState == 1)
	{
		$("gubook_Tips").style.display="none";
		$("sbbtn").style.display="none";
		$("ajaxload").style.display="";
	}
    // 请求已完成
    if(xmlHttp.readyState == 4) {
		$("gubook_Tips").style.display="none";
		$("sbbtn").style.display="none";
		$("ajaxload").style.display="";
		if (xmlHttp.responseText=="noTitle")
		{
			$("gubook_Tips").style.display="";
			$("gubook_Tips").innerHTML="标题没有填写！";
			$("sbbtn").style.display="";
			$("ajaxload").style.display="none";
		}
		else if (xmlHttp.responseText=="noContent")
		{
			$("gubook_Tips").style.display="";
			$("gubook_Tips").innerHTML="内容没有填写！";
			$("sbbtn").style.display="";
			$("ajaxload").style.display="none";
		}
		else
		{
			$("ajaxload").innerHTML = "反馈提交成功感谢您的支持！";
		}
		
    }
}
