/*--------------------------------------------------------------------
 *
 *创建一个XMLHttp实例
 *return object 成功创建返回一个XMLHttp对象实例,否则返回false
 *
 *--------------------------------------------------------------------
 */
 function CreateAjax()
 {
    var XMLHttp;
    try
    {
        XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");   //IE的创建方式
    }
    catch(e)
    {
        try
        {
            XMLHttp = new XMLHttpRequest();     //FF等浏览器的创建方式
        }
        catch(e)
        {
            XMLHttp = false;        //创建失败，返回false
        }
    }
    return XMLHttp;     //返回XMLHttp实例
 }
 
 
  //点击函数
function saveAdclick(Adcode,posid)
{
	//alert(Adcode);
	var _xmlhttp = CreateAjax();
	var url = "/adpage/adNum_log.asp?cmd=click&code="+Adcode+"&posid="+posid+"&n="+Math.random()+"";
	if(_xmlhttp)    //判断XmlHttp是否创建成功
    {
        _xmlhttp.open('GET',url,true);
        _xmlhttp.onreadystatechange=function()
        {
            if(_xmlhttp.readyState == 4)        //客户端完成请求
            {
                if(_xmlhttp.status == 200)      //服务端完成处理并返回数据
                {
                    var ResponseText = _xmlhttp.responseText;
                    if(ResponseText == "" )   //service返回了错误信息
                    {
						//alert("yes");
                    }
                    else
                    {
							//alert("no");
                       //content.innerHTML = ResponseText;
                    }
                }
                else    //服务器出现异常
                {
                   // alert("服务器返回异常！");
                }
            }
            else    //请求未完成时的提示信息
            {
                //content.innerHTML='<span style="color:red"><img src="images/indicator.gif" border="0">正在从服务器提取数据......</span>';
            }
        }
        _xmlhttp.send(null);  //向服务器发送请求。
    }
    else    //创建未成功
    {
       // alert("您的浏览器不支持或未启用 XMLHttp!");
    }
}

  //显示函数
function saveAdshow(Adcode,posid)
{
	var _xmlhttp = CreateAjax();
	var url = "/adpage/adNum_log.asp?cmd=show&code="+Adcode+"&posid="+posid+"&n="+Math.random()+"";
	if(_xmlhttp)    //判断XmlHttp是否创建成功
    {
        _xmlhttp.open('GET',url,true);
        _xmlhttp.onreadystatechange=function()
        {
            if(_xmlhttp.readyState == 4)        //客户端完成请求
            {
                if(_xmlhttp.status == 200)      //服务端完成处理并返回数据
                {
                    var ResponseText = _xmlhttp.responseText;
                    if(ResponseText == "" )   //service返回了错误信息
                    {
							//alert(ResponseText);
                    }
                    else
                    {
							//alert(ResponseText);
                       //content.innerHTML = ResponseText;
                    }
                }
                else    //服务器出现异常
                {
					//alert(ResponseText);
                 //   alert("服务器返回异常！");
                }
            }
            else    //请求未完成时的提示信息
            {
                //content.innerHTML='<span style="color:red"><img src="images/indicator.gif" border="0">正在从服务器提取数据......</span>';
            }
        }
        _xmlhttp.send(null);  //向服务器发送请求。
    }
    else    //创建未成功
    {
     //   alert("您的浏览器不支持或未启用 XMLHttp!");
    }
}
 