
function createXMLHttpRequest(){
				  //开始初始化XMLHttpRequest对象
if(window.XMLHttpRequest) { //Mozilla 浏览器
				   xmlHttp = new XMLHttpRequest();
				   if (xmlHttp.overrideMimeType) {//设置MiME类别
					xmlHttp.overrideMimeType("text/html");
				   }
				  }
else if (window.ActiveXObject) { // IE浏览器
				   try {
					xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
				   } catch (e) {
					try {
					 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {}
				   }
				  }
if (!xmlHttp) { // 异常，创建对象实例失败
				   window.alert("Sorry,Error!(Don't Create XMLHttp)");
				   return false;
				  }
				  
			}
function checkk()
{
   if(checkspace(document.form2.searchkey.value)&&((document.form2.action.value=="3")||(document.form2.action.value=="1")))  {
	document.form2.searchkey.focus();
	alert("请输入查讯关键字！");
	return false;
  }
   document.form2.submit();
}

function checkk2()
{
   if(checkspace(document.getElementById('searchkey').value))  {
	//document.getElementById('searchkey').focus();
	alert("请输入查讯关键字！");
	return false;
  }
   document.searchform.submit();
}

function valNum(ev)
{
    var e = ev.keyCode;
    //允许的有大、小键盘的数字，左右键，backspace, delete, Control + C, Control + V
    if(e != 48 && e != 49 && e != 50 && e != 51 && e != 52 && e != 53 && e != 54 && e != 55 && e != 56 && e != 57 && e != 96 && e != 97 && e != 98 && e != 99 && e != 100 && e != 101 && e != 102 && e != 103 && e != 104 && e != 105 && e != 37 && e != 39 && e != 13 && e != 8 && e != 46)
    {
        if(ev.ctrlKey == false)
        {
            //不允许的就清空!
			alert("商品数量必须为数字!")
             ev.returnValue = "";
         }
        else
        {
            //验证剪贴板里的内容是否为数字!
             valClip(ev);
         }
     }
}
//验证剪贴板里的内容是否为数字!
function valClip(ev)
{
    //查看剪贴板的内容!
    var content = clipboardData.getData("Text");
    if(content != null)
    {
        try
        {
            var test = parseInt(content);
            var str = "" + test;
            if(isNaN(test) == true)
            {
                //如果不是数字将内容清空!
				alert("商品数量必须为数字!")
                 clipboardData.setData("Text","");
             }
            else
            {
                if(str != content)
                     clipboardData.setData("Text", str);
             }
         }
        catch(e)
        {
            //清空出现错误的提示!
             alert("粘贴出现错误!");
         }
     }
} 

function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}
//取得cookie   
function GetCookie(name) {   
    var arg = name + "=";   
    var alen = arg.length;   
    var clen = window.document.cookie.length;   
    var i = 0;   
    while (i < clen) {   
        var j = i + alen;   
        if (window.document.cookie.substring(i, j) == arg)    
           return getCookieVal (j);   
        i = window.document.cookie.indexOf(" ", i) + 1;   
        if (i == 0)    
          break;   
   }   
   return null;   
}   
//取出cookie的值   
function getCookieVal (offset) {   
    var endstr = window.document.cookie.indexOf (";", offset);   
    if (endstr == -1)    
         endstr = window.document.cookie.length;   
    return unescape(window.document.cookie.substring(offset, endstr));   
}   
  
//设置cookie   
function SetCookie (name, value,time) {   
       
    var exp = new Date();   
    exp.setTime(exp.getTime() + time);   //(30*24*60*60*1000)一个月
    window.document.cookie = name + "=" + escape (value)+ ";          expires=" + exp.toGMTString()+";path=/";   
}   
//删除cookie
function DeleteCookie (name) {   
    var exp = new Date();   
    exp.setTime (exp.getTime() - 1);   
    var cval = GetCookie (name);   
    window.document.cookie = name + "=" + cval + "; expires=" +    exp.toGMTString()+";path=/";   
}

