﻿// 商品添加到购物车
function addShopCart(productno,productnum)
{
    createXMLHttpRequest();
    xmlHttp.open("Get","shopcart.aspx?act=add&productid="+productno+"&productnum="+productnum,true);
    xmlHttp.onreadystatechange=function() {	
			if (xmlHttp.readyState==4 && xmlHttp.status==200) {	
				alert(unescape(xmlHttp.responseText));
			}
			else {
				content.innerHTML='<span style="color:red">正在从服务器提取数据......</span>';
			}
		}
    xmlHttp.send(null); 
} 
// 商品添加到收藏记录
function addRecord(productno)
{
    createXMLHttpRequest();
    xmlHttp.open("Get","shopcart.aspx?act=fav&productid="+productno,true);
    xmlHttp.onreadystatechange=function() {	
			if (xmlHttp.readyState==4 && xmlHttp.status==200) {	
				alert(unescape(xmlHttp.responseText));
			}
			else {
				content.innerHTML='<span style="color:red">正在从服务器提取数据......</span>';
			}
		}
    xmlHttp.send(null); 
} 

function delShopCart(shopcartid)
{
    createXMLHttpRequest();        
     
    xmlHttp.open("Get","shopcart.aspx?act=del&shopcartid="+shopcartid,true); 
    
    xmlHttp.onreadystatechange=function() {	
            //alert(shopcartid);
			if (xmlHttp.readyState==4 && xmlHttp.status==200) {	
				alert(unescape(xmlHttp.responseText));    
			}
			else {
				content.innerHTML='<span style="color:red">正在从服务器提取数据......</span>';
			}
		}
    xmlHttp.send(null); 
}

//获得水晶知识
function GetCrystalInfoList()
{
     document.getElementById("product_crystalinfo").innerHTML="<center><br /><br /><br /><img src='/images/ajax.gif' /></center>";
    Mnsj.control.Crystal_Info.Get_CrystalInfo(CallBack_CrystalInfoList);
}
//数据回传
function CallBack_CrystalInfoList(res)
{
    if(!res.error && res.value !="")
    {
       document.getElementById("product_crystalinfo").innerHTML = res.value;
    }
    else
    {
       document.getElementById("product_crystalinfo").innerHTML = "读取数据出错！";
    }
}


//显示新闻列表
function GetNewsPageList(nowtype) {		
	    createXMLHttpRequest();
		var content=document.getElementById('content');		
		xmlHttp.open('get','/newshtmllist.aspx?type='+nowtype+'&page='+CurrPage+'&n='+Math.random(),true);	
		xmlHttp.onreadystatechange=function() {	
			if (xmlHttp.readyState==4 && xmlHttp.status==200) {	
				content.innerHTML=unescape(xmlHttp.responseText);
			}
			else {
				content.innerHTML='<span style="color:red">正在从服务器提取数据......</span>';
			}
		}
		xmlHttp.send(null);
}
//显示产品列表
function GetProductList(nowtype) {		
	    createXMLHttpRequest();
		var content=document.getElementById('content');		
		xmlHttp.open('get','/producthtmllist.aspx?type='+nowtype+'&page='+CurrPage+'&n='+Math.random(),true);	
		xmlHttp.onreadystatechange=function() {	
			if (xmlHttp.readyState==4 && xmlHttp.status==200) {	
				content.innerHTML=unescape(xmlHttp.responseText);
			}
			else {
				content.innerHTML='<span style="color:red">正在从服务器提取数据......</span>';
			}
		}
		xmlHttp.send(null);
}
function GetProductPageList(nowtype) {		
	    createXMLHttpRequest();
		var content=document.getElementById('content');		
		xmlHttp.open('get','/producthtmllist.aspx?class='+nowtype+'&page='+CurrPage+'&n='+Math.random(),true);	
		xmlHttp.onreadystatechange=function() {	
			if (xmlHttp.readyState==4 && xmlHttp.status==200) {	
				content.innerHTML=unescape(xmlHttp.responseText);
			}
			else {
				content.innerHTML='<span style="color:red">正在从服务器提取数据......</span>';
			}
		}
		xmlHttp.send(null);
}

function GetSearchPageList(keyword,searchtype) {		
	    createXMLHttpRequest();	    
		var content=document.getElementById('content');		
		xmlHttp.open('get','/searchhtmllist.aspx?keyword='+ escape(keyword) + '&type='+ searchtype +'&page='+ CurrPage +'&n='+ Math.random(),true);		
	    xmlHttp.onreadystatechange=function() {	
			if (xmlHttp.readyState==4 && xmlHttp.status==200) {	
				content.innerHTML=unescape(xmlHttp.responseText);
			}
			else {
				content.innerHTML='<span style="color:red">正在从服务器提取数据......</span>';
			}
		}
		//alert(keyword+'========='+searchtype);	    
		xmlHttp.send(null);
}
