//----------------创建 XMLHTTP------------------------------------------------------------------------------------------

function createAjax() {			//该函数将返回XMLHTTP对象实例
	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 addQ() {			//该函数将返回XMLHTTP对象实例
	var Q_title=document.getElementById("Q_title").value;
	var Q_content=document.getElementById("Q_content").value;
	var UR_name=document.getElementById("UR_name").value;
	var UR_ip=document.getElementById("UR_ip").value;
	var proid=document.getElementById("proid").value;
	var issuit=document.getElementById("suit").value;
	var parmeter="Q_title="+Q_title+"&Q_content="+Q_content+"&UR_name="+UR_name+"&UR_ip="+UR_ip+"&proid="+proid+"&issuit="+issuit;
	//alert(parmeter);
	var xmlhttp=createAjax();	
	if (xmlhttp) {		

		xmlhttp.onreadystatechange=function() {		
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	
						alert("提问成功");
		                document.getElementById("Q_title").value="";
		                document.getElementById("Q_content").value="";
		                getweblist2(1);
			}
			else {
				//alert("正在从服务器提取数据");	//如果服务器没有完成传送，则向用户提示正在传输。
			}
		}
		//xmlhttp.send(null);	//向服务器发送请求，因为是get请求，会直接附在URL后面，所以这里括号中的数据为null，IE中也可以不写，但FF就必须加上null，否则会发送失败。
	   
		xmlhttp.open("post", "/products/question.asp", true);
	    xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	    xmlhttp.send(parmeter);

	}
}

//----------------用户感言------------------------------------------------------------------------------------------
function getweblist(page,bool,issuit) {		//该函数用来获取分页数据
	id=document.getElementById("proid").value;
	//alert(issuit)
	var xmlhttp=createAjax();	//创建变量xmlhttp，并将createAjax()函数创建的对象实例赋于它
	if (xmlhttp) {		//如果xmlhttp对象创建成功，则执行条件语句中的程序

		var content=document.getElementById('content');		//获取页面中id为content的对象
		if(bool==0){
		xmlhttp.open('get','/products/customfeel2.asp?id='+id+'&page='+page+'&issuit='+issuit+'&n='+Math.random(),true);	
		}else if(bool==1){
		xmlhttp.open('get','/products/customfeel3.asp?id='+id+'&page='+page+'&issuit='+issuit+'&n='+Math.random(),true);	
		}
		xmlhttp.onreadystatechange=function() {		//为xmlhttp对象的readyState属性指定事件，改属性值改变时，则会执行其中的程序
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	
				content.innerHTML=unescape(xmlhttp.responseText);	//将服务器返回的数据解码并写入指定的ID中。
			}
			else {
				//content.innerHTML="<span style='color:red'>正在从服务器提取数据......</span>";	//如果服务器没有完成传送，则向用户提示正在传输。
			}
		}
		xmlhttp.send(null);	
	}
}
//----------------套装用户感言------------------------------------------------------------------------------------------
function getweblist_suit(page,bool,issuit,id){
	
var idTag="content";
if(bool==0){
	url = "/products/customfeel2_suit.asp";
}else if(bool==1){
	url = "/products/customfeel3_suit.asp";
}
var pars = "id="+id+"&page="+page+"&issuit="+issuit;


var myAjax = new Ajax.Updater(
		{success: idTag},
		url,
		{
		asynchronous:true,
		method: 'get',
		parameters: pars,
		//insertion: Insertion.Bottom,
		onFailure: reportError,
		encoding:'utf-8',
		//onCreate:createCF,
		//onComplete:completeCF,
		contentType:'application/x-www-form-urlencoded'
		}
	);
}

function reportError(request){
	alert('对不起，服务器内部错误，请稍后再试：）');
}

//---------------访客咨询---------------------------------------------------------------------------------------------------------------------------------
function getweblist2(page) {		//该函数用来获取分页数据
    id=document.getElementById("proid").value;
	var xmlhttp=createAjax();	//创建变量xmlhttp，并将createAjax()函数创建的对象实例赋于它
	if (xmlhttp) {		//如果xmlhttp对象创建成功，则执行条件语句中的程序
		var content2=document.getElementById('content2');		//获取页面中id为content的对象
		xmlhttp.open('get','/products/customnote2.asp?id='+id+'&page='+page+'&n='+Math.random(),true);	//打开与服务器的连接，其中get为连接方式，server.asp为要连接的页面，有两个参数，其中第一个参数page为需要返回数据的页数,第二个参数n为一个随机数，这样每次发送的URL都会不一样，相当于都向服务器发出一个新的请求，避免浏览器缓存数据。
		xmlhttp.onreadystatechange=function() {		//为xmlhttp对象的readyState属性指定事件，改属性值改变时，则会执行其中的程序
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	//如果xmlhttp.readyState==4并且xmlhttp.status==200时，执行条件中的程序，其中readyState有五个值，4为请求完成，是客户端向服务器提交的数据成功到达，status有N多值-_-!!，其中200为OK，是指服务器向客户端完成发送数据。
				content2.innerHTML=unescape(xmlhttp.responseText);	//将服务器返回的数据解码并写入指定的ID中。
			}
			else {
				//content2.innerHTML='<span style="color:red">正在从服务器提取数据......</span>';	//如果服务器没有完成传送，则向用户提示正在传输。
			}
		}
		xmlhttp.send(null);	//向服务器发送请求，因为是get请求，会直接附在URL后面，所以这里括号中的数据为null，IE中也可以不写，但FF就必须加上null，否则会发送失败。
	}
}

//---------------有帮助的文章---------------------------------------------------------------------------------------------------------------------------------
function articlelist(tag,page) {		//该函数用来获取分页数据
    //tag=document.getElementById("tag").value;
	//tag="(1),(2),(3),(4),(5),";
	tag="("+tag+"),"
	var xmlhttp=createAjax();	//创建变量xmlhttp，并将createAjax()函数创建的对象实例赋于它
	if (xmlhttp) {		//如果xmlhttp对象创建成功，则执行条件语句中的程序
		var content=document.getElementById('content');		//获取页面中id为content的对象
		xmlhttp.open('get','/common/helparticle.asp?tag='+tag+'&page='+page+'&n='+Math.random(),true);	//打开与服务器的连接，其中get为连接方式，server.asp为要连接的页面，有两个参数，其中第一个参数page为需要返回数据的页数,第二个参数n为一个随机数，这样每次发送的URL都会不一样，相当于都向服务器发出一个新的请求，避免浏览器缓存数据。
		xmlhttp.onreadystatechange=function() {		//为xmlhttp对象的readyState属性指定事件，改属性值改变时，则会执行其中的程序
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	//如果xmlhttp.readyState==4并且xmlhttp.status==200时，执行条件中的程序，其中readyState有五个值，4为请求完成，是客户端向服务器提交的数据成功到达，status有N多值-_-!!，其中200为OK，是指服务器向客户端完成发送数据。
				content.innerHTML=unescape(xmlhttp.responseText);	//将服务器返回的数据解码并写入指定的ID中。
			}
			else {
				content.innerHTML='<span style="color:red">正在从服务器提取数据......</span>';	//如果服务器没有完成传送，则向用户提示正在传输。
			}
		}
		xmlhttp.send(null);	//向服务器发送请求，因为是get请求，会直接附在URL后面，所以这里括号中的数据为null，IE中也可以不写，但FF就必须加上null，否则会发送失败。
	}
}
//---------------用户体验文章---------------------------------------------------------------------------------------------------------------------------------
function feellist(tag,page) {		//该函数用来获取分页数据
    //tag=document.getElementById("tag").value;
	//tag="(1),(2),(3),(4),(5),";
	tag="("+tag+"),"
	var xmlhttp=createAjax();	//创建变量xmlhttp，并将createAjax()函数创建的对象实例赋于它
	if (xmlhttp) {		//如果xmlhttp对象创建成功，则执行条件语句中的程序
		var content2=document.getElementById('content2');		//获取页面中id为content的对象
		xmlhttp.open('get','/common/feelarticle.asp?tag='+tag+'&page='+page+'&n='+Math.random(),true);	//打开与服务器的连接，其中get为连接方式，server.asp为要连接的页面，有两个参数，其中第一个参数page为需要返回数据的页数,第二个参数n为一个随机数，这样每次发送的URL都会不一样，相当于都向服务器发出一个新的请求，避免浏览器缓存数据。
		xmlhttp.onreadystatechange=function() {		//为xmlhttp对象的readyState属性指定事件，改属性值改变时，则会执行其中的程序
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	//如果xmlhttp.readyState==4并且xmlhttp.status==200时，执行条件中的程序，其中readyState有五个值，4为请求完成，是客户端向服务器提交的数据成功到达，status有N多值-_-!!，其中200为OK，是指服务器向客户端完成发送数据。
				content2.innerHTML=unescape(xmlhttp.responseText);	//将服务器返回的数据解码并写入指定的ID中。
			}
			else {
				content2.innerHTML='<span style="color:red">正在从服务器提取数据......</span>';	//如果服务器没有完成传送，则向用户提示正在传输。
			}
		}
		xmlhttp.send(null);	//向服务器发送请求，因为是get请求，会直接附在URL后面，所以这里括号中的数据为null，IE中也可以不写，但FF就必须加上null，否则会发送失败。
	}
}
//----------------topnews------------------------------------------------------------------------------------------
function articledisplay(id) {		//该函数用来获取分页数据
    var xmlhttp=createAjax();	//创建变量xmlhttp，并将createAjax()函数创建的对象实例赋于它
	if (xmlhttp) {		//如果xmlhttp对象创建成功，则执行条件语句中的程序
		var topnew=document.getElementById('topnew');		//获取页面中id为content的对象
		xmlhttp.open('get','/common/getopNews.asp?id='+id+'&n='+Math.random(),true);	//打开与服务器的连接，其中get为连接方式，server.asp为要连接的页面，有两个参数，其中第一个参数page为需要返回数据的页数,第二个参数n为一个随机数，这样每次发送的URL都会不一样，相当于都向服务器发出一个新的请求，避免浏览器缓存数据。
		xmlhttp.onreadystatechange=function() {		//为xmlhttp对象的readyState属性指定事件，改属性值改变时，则会执行其中的程序
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	//如果xmlhttp.readyState==4并且xmlhttp.status==200时，执行条件中的程序，其中readyState有五个值，4为请求完成，是客户端向服务器提交的数据成功到达，status有N多值-_-!!，其中200为OK，是指服务器向客户端完成发送数据。
				topnew.innerHTML=unescape(xmlhttp.responseText);	//将服务器返回的数据解码并写入指定的ID中。
			}
			else {
				topnew.innerHTML='';	//如果服务器没有完成传送，则向用户提示正在传输。
			}
		}
		xmlhttp.send(null);	//向服务器发送请求，因为是get请求，会直接附在URL后面，所以这里括号中的数据为null，IE中也可以不写，但FF就必须加上null，否则会发送失败。
	}
}
//----------------顶一下------------------------------------------------------------------------------------------

function support(id) {			//该函数将返回XMLHTTP对象实例
	var xmlhttp=createAjax();	//创建变量xmlhttp，并将createAjax()函数创建的对象实例赋于它
	if (xmlhttp) {		//如果xmlhttp对象创建成功，则执行条件语句中的程序
		var support=document.getElementById("support");		//获取页面中id为content的对象
		xmlhttp.open('get','/ajaxHtml/ajaxSupport.asp?id='+id+'&n='+Math.random(),true);			
		xmlhttp.onreadystatechange=function() {		//为xmlhttp对象的readyState属性指定事件，改属性值改变时，则会执行其中的程序
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	
				support.innerHTML=unescape(xmlhttp.responseText);	//将服务器返回的数据解码并写入指定的ID中。
			}
			else {
				//support.innerHTML=unescape("正在从服务器提取数据");	//如果服务器没有完成传送，则向用户提示正在传输。
			}
		}
		xmlhttp.send(null);
	}
}
//----------------文章收藏------------------------------------------------------------------------------------------

function collectarticle(id) {			//该函数将返回XMLHTTP对象实例
	var xmlhttp=createAjax();	//创建变量xmlhttp，并将createAjax()函数创建的对象实例赋于它
	if (xmlhttp) {		//如果xmlhttp对象创建成功，则执行条件语句中的程序
		xmlhttp.open('get','/ajaxHtml/ajaxcollectarticle.asp?id='+id+'&n='+Math.random(),true);			
		xmlhttp.onreadystatechange=function() {		//为xmlhttp对象的readyState属性指定事件，改属性值改变时，则会执行其中的程序
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	
				alert(unescape(xmlhttp.responseText));
			}
			else {
				//alert(xmlhttp.status)
				//support.innerHTML=unescape("正在从服务器提取数据");	//如果服务器没有完成传送，则向用户提示正在传输。
			}
		}
		xmlhttp.send(null);
	}
}
//----------------放入购物车------------------------------------------------------------------------------------------   
function incart(id){
    location.href="/cart/cart01.asp?action=add&pid="+id;
}
//----------------邮件发送确认------------------------------------------------------------------------------------------   
function postmail(Userid){
  re=/#/g
  url=location.href
  url=url.replace(re,"@@@")
  url=url+".asp"

  window.open("/ajaxHtml/mail.asp?userid="+Userid+"&url="+url,"","height=400,width=550,top=135,left=495,titlebar=no ");

}
//-----------------------我要提问-------------------------------------------------------------------------------------------------------
function ask(){
   $("Q_title").focus();
}
//-----------------------我要发表-------------------------------------------------------------------------------------------------------
function goComment(){
   window.open("/member/notComment.asp");
}