  function createXMLHttpRequest() {
		var xmlHttp;
		try
		   {
		 
		     // try to create XMLHttpRequest object
		     xmlHttp = new XMLHttpRequest();
		
		   }
		   catch(e)
		   {
		   var prefixes = ["MSXML2.XmlHttp","Microsoft.XmlHttp","MSXML3.XmlHttp", "MSXML.XmlHttp"];
		     // assume IE6 or older
		   	for (var i = 0; i < prefixes.length; i++) {
				try{xmlHttp = new ActiveXObject(prefixes[i]);}catch(ex){};
			}
		       
		   }
		   // return the created object or display an error message
		   if (!xmlHttp)
		     alert("Error creating the XMLHttpRequest object.");
		   else
		     return xmlHttp;
    }

//根据一个产品dom对象，返回浏览器显示。
function getProductAsStr(product,show){
	var chufang,pic='buyOrange.gif';;
	var shangyong=product.getAttribute('shanyong');
	var pid=product.getAttribute('pid');
		if(shangyong!=null&&shangyong!='null'){//商用名
			shangyong='('+shangyong+')'
		}else{
			shangyong='';
		}
		chufang=product.getAttribute('chufang')
		if(chufang=='41'){
			chufang='处方药'
		pic='buyGrey.gif'
		}else if(chufang=='42'||chufang=='43'){
			chufang='非处方药'
		}else{
			chufang='非药品'
		}
	
	//促销处理方案
	var jiage=product.getAttribute('cuxiao');//显示价格
	var zhenshijia=product.getAttribute("member");//会员价
	var cupic='';//促销是否显示图片
	var jiagezi1='市场价';
	var jiagezi2='会员价';
	
	if(jiage>0){//显示促销价
	jiagezi1='会员价';
	jiagezi2='促销价';
	jiage=zhenshijia;
	cupic='<img src=\"images2/cuxiao_icon.gif\" align=\"absbottom\" />'
	zhenshijia=product.getAttribute('cuxiao');
	}else{
	jiage=product.getAttribute('market');
	}
	//促销处理方案
	
	 var proStr=''
	 
	if(show=='1'){//列表显示
	$('show1').checked= 'checked';
	//alert('列表显示');
			proStr="<div id=\"productList\"><div id=\"productList_image\"><a target='_blank' href='/product.jsf?productId="+pid+
					"'><img border=0 src="+product.getAttribute('small')
					+" width=\"150\" height=\"110\"></a><br></div><div id=\"productList_right\"><div class=\"productList_infor\"><ul><li>名称：<a target='_blank'  href='/product.jsf?productId="+pid+
					"'>"+product.getAttribute('tongyong')+shangyong+"</a>"+cupic+"</li> <li>规格："+product.getAttribute('spec')+" <span class=\"productList_icon\">类型："+chufang+"</span> "
			//处方药，给帮助提示。
			if(chufang=='处方药'){
				proStr=proStr+"<a href=\"#\" onMouseOver=Show(div"+pid+") onMouseOut=Hide(div"+pid+")><img  src=\"images2/help.gif\" alt=\"帮助\" width=\"14\" height=\"14\" border=\"0\"></a>	  <div id=div"+pid+
					" class=\"alt_style\">   国家药监局规定处方药不可在网上销售，所以请您通过留言或者来电留下您的联系方式，以便我们为您提供专业的免费咨询服务，电话号码参见页面顶部，谢谢！</div>"
			}
			proStr=proStr+" </li><li class=\"sccs_text\">生产厂商："+product.getAttribute('company')+
				"</li><li>"+jiagezi1+"：<b>￥</b> <span class=\"productList_Mprice\">"+jiage+"</span>元 <span class=\"productList_icon\">"+jiagezi2+"：<span class=\"productList_Nprice\">￥ "+zhenshijia+
				"元</span></span></li></ul></div><div class=\"productList_button\"><ul><li class=\"productList_button_li\"><img src=\"images2/favourite.gif\" alt=\"加入收藏\" width=\"15\" height=\"13\" align=\"absmiddle\"> <a href=\"/favorite/userFavoriteAdd.jsf?productId="
				+pid+"\">收藏该药品</a></li><li class=\"productList_button_li\"><a href=\"/order/cart.jsf?productId="+pid
				+"\"><img src=\"images2/"+pic+"\" alt=\"放入购物车\" border=0 width=\"168\" height=\"39\"></a></li></ul></div></div></div>"
		}else if(show=='2'){//图片显示
		$('show2').checked= 'checked';
		//alert('图片显示阿。')
		
			proStr='<div id="productImage_block">  <ul>  <li id="productImage_image"><a target=_blank href="/product.jsf?productId='+pid+
					'"><img border=0 src='+product.getAttribute("small")
					+' width=\"150\" height=\"110\"></a><br></li>  <li style="height:30px;padding-right:20px"><a  target=_blank href="/product.jsf?productId='+pid+'">'+product.getAttribute("tongyong")+shangyong
					+'</a>'+cupic+'</li>  <li>'+jiagezi1+'：<b>￥</b> <span class="productList_Mprice">  '+jiage+'</span>元</li>  <li>'+jiagezi2+'：<span class="productList_Nprice">￥  '+zhenshijia
					+'元</span></li>  <li><a href="/order/cart.jsf?productId='+pid+'"><img src="images2/'+pic+'" alt="放入购物车" width="168" height="39" border=0></a></li>  </ul>  </div>'
		
		
		}else if(show=='3'){//文字显示
		//alert('文字显示阿。')
		$('show3').checked= 'checked';
		proStr='  <div id="productText">	<div class="productList_infor">	<ul>	<li>名称：<a  target=_blank href="/product.jsf?productId='+pid+'">'+product.getAttribute("tongyong")+shangyong
				+'</a>'+cupic+' <span class="productList_icon">规格：'+product.getAttribute("spec")+'</span> <span class="productList_icon">类型：'+chufang+'</span>'
		
		if(chufang=='处方药'){
				proStr=proStr+"<a href=\"#\" onMouseOver=Show(div"+pid+") onMouseOut=Hide(div"+pid+")><img  src=\"images2/help.gif\" alt=\"帮助\" width=\"14\" height=\"14\" border=\"0\"></a>	  <div id=div"+pid+
					" class=\"alt_style\">   国家药监局规定处方药不可在网上销售，所以请您通过留言或者来电留下您的联系方式，以便我们为您提供专业的免费咨询服务，电话号码参见页面顶部，谢谢！</div>"
			}
		
		proStr=proStr+'</li><li>生产厂商：'+product.getAttribute("company")+' <span class="productList_icon">'+jiagezi1+'：<b>￥</b> <span class="productList_Mprice">'+jiage+'</span>元</span> <span class="productList_icon">'+jiagezi2+'：<span class="productList_Nprice">￥ '+zhenshijia
			+'元</span></span></li>	</ul>	</div>	<div class="productList_button">	<ul>	<li class="productText_button_li"><img src="images2/favourite.gif" alt="加入收藏" width="15" height="13" align="absmiddle"> <a href="/favorite/userFavoriteAdd.jsf?productId='+pid
			+'">收藏该药品</a></li>	<li class="productText_button_li"><a href="/order/cart.jsf?productId='+pid+'"><img src="images2/'+pic+'" alt="放入购物车" width="168" height="39" border=0></a><br></li>	</ul>	</div>  </div>'
		
		
		}else{
//		alert('why')
		}
	
	return proStr;
}
//将服务器返回的产品列表，在浏览器上全部显示
function initAll(doc){
	var products=doc.getElementsByTagName("product");
	var total=doc.getElementsByTagName("total")[0].getAttribute("total");
	var page=doc.getElementsByTagName("page")[0].getAttribute("page");
	var totalPage=doc.getElementsByTagName("totalPage")[0].getAttribute("totalPage");
	var priceby=doc.getElementsByTagName("price")[0].getAttribute("price");
	var show=doc.getElementsByTagName("show")[0].getAttribute("show");
	
	//价格升降
	if(priceby=='1'){
		$('price2').checked= 'checked';	
	}else{
		$('price1').checked= 'checked';
	}
	initPage(page,totalPage);
	initDaohang(doc);

	var str='';	
	for(var i=0;i<products.length;i++){
		str=str+getProductAsStr(products[i],show);
	}
	$('resultNumber').innerHTML='一共搜索到符合条件的产品 <span>'+total+' </span>个';
//	$('resultNumber').innerHTML=
	return str;
}
//显示上面导航。
function initDaohang(doc){
	if(doc.getElementsByTagName("curType").length>0){//分类列表需要重新导航
		var daoh='尊敬的顾客，您现在所在的位置是：<a href="/">网上药店</a>';
		var temp;
		if(doc.getElementsByTagName("parentType").length>0){
			temp=doc.getElementsByTagName("parentType")[0];
			daoh=daoh+' > <a href="/list2.jsp?type='+temp.getAttribute("id")+'">'+temp.getAttribute("name")+'</a>'
		}
		if(doc.getElementsByTagName("curType").length>0){
			temp=doc.getElementsByTagName("curType")[0];
			daoh=daoh+' > <a href="/list2.jsp?type='+temp.getAttribute("id")+'">'+temp.getAttribute("name")+'</a>'
		}
		$('daohang').innerHTML=daoh;
	}
}
//初始化页面导航
function initPage(page,totalPage){
//上部分页
	if(totalPage<=1)	{
			$('page_top').innerHTML= '<span style="margin-bottom:5px;">1/1</span><br>'
		}else if(page==1){
			$('page_top').innerHTML= '<span style="margin-bottom:5px;">'+page+'/'+totalPage+'</span>   <a href="#"  onclick=loadingProductList("null","null",'+page+',"back")> <img  border="0" src="images2/list_show_button1.gif" alt="上一页" width="16" height="15" align="top"></a>  <a href="#"  onclick=loadingProductList("null","null",'+page+',"next")><img border="0"  src="images2/list_show_button2.gif" alt="下一页" width="46" height="15" align="top"></a><br> '
		}else if(page==totalPage){
			$('page_top').innerHTML= '<span style="margin-bottom:5px;">'+page+'/'+totalPage+'</span>    <a href="#"  onclick=loadingProductList("null","null",'+page+',"back")><img border="0" src="images2/list_show_button4.gif" alt="上一页" width="16" height="15" align="top">  </a>    <a href="#"  onclick=loadingProductList("null","null",'+page+',"cur")><img  border="0"src="images2/list_show_button3.gif" alt="下一页" width="46" height="15" align="top"></a><br> '
		}else{
			$('page_top').innerHTML= '<span style="margin-bottom:5px;">'+page+'/'+totalPage+'</span>    <a href="#"  onclick=loadingProductList("null","null",'+page+',"back")><img border="0"  src="images2/list_show_button4.gif" alt="上一页" width="16" height="15" align="top">   </a>   <a href="#"  onclick=loadingProductList("null","null",'+page+',"next")><img  border="0" src="images2/list_show_button2.gif" alt="下一页" width="46" height="15" align="top"></a><br> '
		}
		//下部分页
		var tempPage='<span  class="listPage_normal" ><a  onclick=loadingProductList("null","null",'+page+',"back")  href="#">上一页</a></span>';
		//导航最多显示9页
		var i=1,max=totalPage;
		if(totalPage>=10){
		
			if(parseInt(page)<5){
				max=9;
				}else if((totalPage-parseInt(page))<5){
					i=max-9;
				}else {
					i=parseInt(page)-4;
					max=parseInt(page)+4;
				}
		}
		for(;i<=max;i++){
		if(i==page){
			tempPage=tempPage+'<span  class="listPage_curpage"><a   onclick=loadingProductList("null","null",'+i+',"cur") href="#">'+i+'</a></span>'
			}else{
			tempPage=tempPage+'<span  class="listPage_normal"><a  onclick=loadingProductList("null","null",'+i+',"cur") href="#">'+i+'</a></span>'			
			}
		}
		if(page==totalPage){
		 	tempPage=tempPage+'<span  class="listPage_normal"><a  onclick=loadingProductList("null","null",'+page+',"cur")   href="#">下一页</a></span>'
		 }else{
			 tempPage=tempPage+'<span class="listPage_normal"><a  onclick=loadingProductList("null","null",'+page+',"next")   href="#">下一页</a></span>'
		 }
		 //下部选择页
		tempPage=tempPage+' 到 <select id="botPage" onchange="changePage();" name="select">' 
		for(i=1;i<=totalPage;i++){
			if(i==page){
				tempPage=tempPage+'<option selected>-'+i+'-</option>'
			}else{
				tempPage=tempPage+'<option >-'+i+'-</option>'		
			}
		}
		 tempPage=tempPage+'</select>页' ;
		$('listPage').innerHTML=tempPage;
}

//改变显示方式。
function initShow(sid,showtype){
loadingProductList('null','null','null','null',showtype)
}



//清空所有
function clearAll(){
		$('list').innerHTML = '';
		$('message').innerHTML = '加载中......';
		$('listPage').innerHTML=''
		$('page_top').innerHTML=''
		//$('daohang').innerHTML='尊敬的顾客，您现在所在的位置是：<a href="/">网上药店</a>';
}

function changePage(){
loadingProductList('null','null',parseInt($('botPage').selectedIndex)+1,'null','null')
}

function change(v1,v2){
	if(v1==1){
	//按价格升降。
		loadingProductList('null',v2)
	}else{
		loadingProductList(v2,'null')
	}
}

