﻿//使用在按推荐数量排序
var index_recomm_btn={
    init:function(recomm_btn)
    {
	    if(Cookie.getCookie('index_recomm'))
	    {
//		    alert(Cookie.getCookie('index_recomm')+'有值index_recomm--'+'asc');
            document.getElementById(recomm_btn).innerHTML='推荐人数由低到高';
	    }
    }
}
var item_recomm_btn={
    init:function(recomm_btn)
    {
	    if(Cookie.getCookie('item_recomm'))
	    {
//	        alert(Cookie.getCookie('item_recomm')+'有值item_recomm--'+'asc');
            document.getElementById(recomm_btn).innerHTML='推荐人数由低到高';
	    }
    }
}
var shop_recomm_btn={   
    init:function(recomm_btn)
    {
	    if(Cookie.getCookie('shop_recomm'))
	    {
//	        alert(Cookie.getCookie('shop_recomm')+'有值shop_recomm--'+'asc');
            document.getElementById(recomm_btn).innerHTML='推荐人数由低到高';
	    }
    }
}
var column_recomm_btn={
    init:function(recomm_btn,columnid)
    {
	    if(Cookie.getCookie('column_recomm'+columnid))
	    {
//	        alert(Cookie.getCookie('column_recomm'+columnid)+'有值column_recomm'+ columnid +'asc');
            document.getElementById(recomm_btn).innerHTML='推荐人数由低到高';
	    }
    }
}

var searchi_recomm_btn={
    init:function(recomm_btn)
    {
	    if(Cookie.getCookie('searchi_recomm'))
	    {
//	        alert(Cookie.getCookie('item_recomm')+'有值item_recomm--'+'asc');
            document.getElementById(recomm_btn).innerHTML='推荐人数由低到高';
	    }
    }
}

var searchs_recomm_btn={
    init:function(recomm_btn)
    {
	    if(Cookie.getCookie('searchs_recomm'))
	    {
//	        alert(Cookie.getCookie('item_recomm')+'有值item_recomm--'+'asc');
            document.getElementById(recomm_btn).innerHTML='推荐人数由低到高';
	    }
    }
}

var Cookie=new Object();
Cookie.setCookie=function(name,value,option)
{
	var str=name+"="+escape(value);
	if(option)
	{
		if(option.expireDays)
		{
			var date=new Date();
			var ms=option.expireDays*24*3600*1000;
			date.setTime(date.getTime()+ms);
			str+="; expires="+date.toGMTString();
		}	
		if(option.path)str+="; path="+path;
		if(option.domain)str+="; domain"+domain;
		if(option.secure)str+="; true";	
	}
	document.cookie=str;
}

Cookie.getCookie=function(name)
{
	var cookieArray=document.cookie.split("; ");
	var cookie=new Object();
	for(var i=0;i<cookieArray.length;i++)
	{
		var arr=cookieArray[i].split("=");
		if(arr[0]==name)return unescape(arr[1]);
	}
	return "";
}

Cookie.deleteCookie=function(name)
{
	this.setCookie(name,"",{expireDays:-1});
}

var s_GridView_CurrenPage = "1";
//首页按推荐人数排序开始
function index_recomm_mode(elm)
{
	if(Cookie.getCookie('index_recomm'))
	{
//		alert(Cookie.getCookie('sr')+'有值index_recomm--'+'asc');
        GuestIndexRecomm("asc")
        Cookie.deleteCookie('index_recomm');
        elm.innerHTML='推荐人数由高到低';
	}
	else
	{
//		alert(Cookie.getCookie('sr')+'空值index_recomm--'+'desc');
        GuestIndexRecomm("desc")
		Cookie.setCookie('index_recomm',1);
        elm.innerHTML='推荐人数由低到高';
	}
}
function GuestIndexRecomm(orderby)
{
    xmlHttpGet = GetXmlHttpObject();
    if (xmlHttpGet == null)
    {
        alert("浏览器不支持 ajax!");
        return;
    }
    var url = 'ajax/indexrecomm_get.aspx';
    url = url + "?sid=" + Math.random();
    url = url + "&orderby=" + orderby;
    xmlHttpGet.onreadystatechange = IndexRecommGetOK;
    xmlHttpGet.open("get", url, true);
    xmlHttpGet.send(null);
}

function IndexRecommGetOK()
{
    if (xmlHttpGet.readyState == 4)
    {
        var gustIndexRecommDiv = document.getElementById("index_recomm_list");
        gustIndexRecommDiv.innerHTML = xmlHttpGet.responseText;
    }
}

//商品列表页按推荐人数排序开始
function item_recomm_mode(elm,page,columnid)
{
    if(page==0)
    {
        s_GridView_CurrenPage="1";
    }
    else
    {
        s_GridView_CurrenPage=page+1;
    }
    var s_GridView_ColumnId=columnid;
	if(Cookie.getCookie('item_recomm'))
	{
//      alert(Cookie.getCookie('item_recomm')+'有值item_recomm--asc'+columnid +'pagenum='+s_GridView_CurrenPage);
        GuestItemRecomm(s_GridView_ColumnId,"asc")
        Cookie.deleteCookie('item_recomm');
        elm.innerHTML='推荐人数由高到低';//说明现在排名方式是按由低到高排序，点击之后会由高到低排序
	}
	else
	{
//	    alert(Cookie.getCookie('item_recomm')+'空值item_recomm--desc'+columnid +'pagenum='+s_GridView_CurrenPage);
        GuestItemRecomm(s_GridView_ColumnId,"desc")
		Cookie.setCookie('item_recomm',1);
        elm.innerHTML='推荐人数由低到高';//说明现在排名方式是按由高到低排序，点击之后会由低到高排序
	}
}

function GuestItemRecomm(columnid,orderby)
{
    xmlHttpGet = GetXmlHttpObject();
    if (xmlHttpGet == null)
    {
        alert("浏览器不支持 ajax!");
        return;
    }
    var url = 'ajax/itemrecomm_get.aspx';
    url = url + "?sid=" + Math.random();
    url = url + "&columnid=" + columnid;
    url = url + "&page=" + s_GridView_CurrenPage;
    url = url + "&orderby=" + orderby;
    xmlHttpGet.onreadystatechange = ItemRecommGetOK;
    xmlHttpGet.open("get", url, true);
    xmlHttpGet.send(null);
}

function ItemRecommGetOK()
{
    if (xmlHttpGet.readyState == 4)
    {
        var gustItemRecommDiv = document.getElementById("item_recomm_list");
        gustItemRecommDiv.innerHTML = xmlHttpGet.responseText;
    }
}

function ItemRecommPaging(columnid,orderby,s_Param_PageNumber)
{
    s_GridView_CurrenPage = s_Param_PageNumber;
    GuestItemRecomm(columnid,orderby)
}

//店铺列表页按推荐人数排序开始
function shop_recomm_mode(elm,page)
{
    if(page==0)
    {
        s_GridView_CurrenPage="1";
    }
    else
    {
        s_GridView_CurrenPage=page+1;
    }
	if(Cookie.getCookie('shop_recomm'))
	{
//	    alert(Cookie.getCookie('shop_recomm')+'有值shop_recomm--asc--cpagenum='+s_GridView_CurrenPage);
        GuestShopRecomm("asc")
        Cookie.deleteCookie('shop_recomm');
        elm.innerHTML='推荐人数由高到低';//说明现在排名方式是按由低到高排序，点击之后会由高到低排序
	}
	else
	{
//	    alert(Cookie.getCookie('shop_recomm')+'空值shop_recomm--desc--pagenum='+s_GridView_CurrenPage);
        GuestShopRecomm("desc")
		Cookie.setCookie('shop_recomm',1);
        elm.innerHTML='推荐人数由低到高';//说明现在排名方式是按由高到低排序，点击之后会由低到高排序
	}
}

function GuestShopRecomm(orderby)
{
    xmlHttpGet = GetXmlHttpObject();
    if (xmlHttpGet == null)
    {
        alert("浏览器不支持 ajax!");
        return;
    }
    var url = 'ajax/shoprecomm_get.aspx';
    url = url + "?sid=" + Math.random();
    url = url + "&page=" + s_GridView_CurrenPage;
    url = url + "&orderby=" + orderby;
    xmlHttpGet.onreadystatechange = ShopRecommGetOK;
    xmlHttpGet.open("get", url, true);
    xmlHttpGet.send(null);
}

function ShopRecommGetOK()
{
    if (xmlHttpGet.readyState == 4)
    {
        var gustShopRecommDiv = document.getElementById("shop_recomm_list");
        gustShopRecommDiv.innerHTML = xmlHttpGet.responseText;
    }
}

function ShopRecommPaging(orderby,s_Param_PageNumber)
{
    s_GridView_CurrenPage = s_Param_PageNumber;
    GuestShopRecomm(orderby)
}

//栏目页按推荐人数排序开始
function column_recomm_mode(elm,page,columnid)
{
    if(page==0)
    {
        s_GridView_CurrenPage="1";
    }
    else
    {
        s_GridView_CurrenPage=page+1;
    }
    var s_GridView_ColumnId=columnid;
	if(Cookie.getCookie('column_recomm'+columnid))
	{
//        alert(Cookie.getCookie('column_recomm'+columnid)+'column_recomm有值'+'asc'+columnid +'pagenum='+s_GridView_CurrenPage);
        GuestColumRecomm(s_GridView_ColumnId,"asc")
        Cookie.deleteCookie('column_recomm'+columnid);
        elm.innerHTML='推荐人数由高到低';//说明现在排名方式是按由低到高排序，点击之后会由高到低排序
	}
	else
	{
//	    alert(Cookie.getCookie('column_recomm'+columnid)+'column_recomm空值'+'desc'+columnid +'pagenum='+s_GridView_CurrenPage);
        GuestColumRecomm(s_GridView_ColumnId,"desc")
		Cookie.setCookie('column_recomm'+columnid,1);
        elm.innerHTML='推荐人数由低到高';//说明现在排名方式是按由高到低排序，点击之后会由低到高排序
	}
}

function GuestColumRecomm(columnid,orderby)
{
    xmlHttpGet = GetXmlHttpObject();
    if (xmlHttpGet == null)
    {
        alert("浏览器不支持 ajax!");
        return;
    }
    var url = 'ajax/columnrecomm_get.aspx';
    url = url + "?sid=" + Math.random();
    url = url + "&columnid=" + columnid;
    url = url + "&page=" + s_GridView_CurrenPage;
    url = url + "&orderby=" + orderby;
    xmlHttpGet.onreadystatechange = ColumnRecommGetOK;
    xmlHttpGet.open("get", url, true);
    xmlHttpGet.send(null);
}

function ColumnRecommGetOK()
{
    if (xmlHttpGet.readyState == 4)
    {
        var gustItemRecommDiv = document.getElementById("column_recomm_list");
        gustItemRecommDiv.innerHTML = xmlHttpGet.responseText;
    }
}

function columnRecommPaging(columnid,orderby,s_Param_PageNumber)
{
    s_GridView_CurrenPage = s_Param_PageNumber;
    GuestItemRecomm(columnid,orderby)
}

//商品搜索页按推荐人数排序开始
function searchi_recomm_mode(elm,page,keyword)
{
    if(page==0)
    {
        s_GridView_CurrenPage="1";
    }
    else
    {
        s_GridView_CurrenPage=page+1;
    }
    var s_GridView_KeyWord=keyword;
	if(Cookie.getCookie('searchi_recomm'))
	{
//        alert(Cookie.getCookie('searchi_recomm')+'有值searchi_recomm--asc'+'pagenum='+s_GridView_CurrenPage);
        GuestSearchiRecomm(s_GridView_KeyWord,"asc")
        Cookie.deleteCookie('searchi_recomm');
        elm.innerHTML='推荐人数由高到低';//说明现在排名方式是按由低到高排序，点击之后会由高到低排序
	}
	else
	{
//	    alert(Cookie.getCookie('searchi_recomm')+'空值searchi_recomm--desc'+'pagenum='+s_GridView_CurrenPage);
        GuestSearchiRecomm(s_GridView_KeyWord,"desc")
		Cookie.setCookie('searchi_recomm',1);
        elm.innerHTML='推荐人数由低到高';//说明现在排名方式是按由高到低排序，点击之后会由低到高排序
	}
}

function GuestSearchiRecomm(KeyWord,orderby)
{
    xmlHttpGet = GetXmlHttpObject();
    if (xmlHttpGet == null)
    {
        alert("浏览器不支持 ajax!");
        return;
    }
    var url = 'ajax/searchirecmm_get.aspx';
    url = url + "?sid=" + Math.random();
    url = url + "&keyword=" + KeyWord;
    url = url + "&page=" + s_GridView_CurrenPage;
    url = url + "&orderby=" + orderby;
    xmlHttpGet.onreadystatechange = SearchiRecommGetOK;
    xmlHttpGet.open("get", url, true);
    xmlHttpGet.send(null);
}

function SearchiRecommGetOK()
{
    if (xmlHttpGet.readyState == 4)
    {
        var gustItemRecommDiv = document.getElementById("searchi_recomm_list");
        gustItemRecommDiv.innerHTML = xmlHttpGet.responseText;
    }
}

function SearchiRecommPaging(keyword,orderby,s_Param_PageNumber)
{
    s_GridView_CurrenPage = s_Param_PageNumber;
    GuestSearchiRecomm(keyword,orderby)
}

//店铺搜索页按推荐人数排序开始
function searchs_recomm_mode(elm,page,keyword)
{
    if(page==0)
    {
        s_GridView_CurrenPage="1";
    }
    else
    {
        s_GridView_CurrenPage=page+1;
    }
    var s_GridView_KeyWord=keyword;
	if(Cookie.getCookie('searchs_recomm'))
	{
//        alert(Cookie.getCookie('searchs_recomm')+'有值searchs_recomm--asc'+'pagenum='+s_GridView_CurrenPage);
        GuestSearchsRecomm(s_GridView_KeyWord,"asc")
        Cookie.deleteCookie('searchs_recomm');
        elm.innerHTML='推荐人数由高到低';//说明现在排名方式是按由低到高排序，点击之后会由高到低排序
	}
	else
	{
//	    alert(Cookie.getCookie('searchs_recomm')+'空值searchs_recomm--desc'+'pagenum='+s_GridView_CurrenPage);
        GuestSearchsRecomm(s_GridView_KeyWord,"desc")
		Cookie.setCookie('searchs_recomm',1);
        elm.innerHTML='推荐人数由低到高';//说明现在排名方式是按由高到低排序，点击之后会由低到高排序
	}
}

function GuestSearchsRecomm(KeyWord,orderby)
{
    xmlHttpGet = GetXmlHttpObject();
    if (xmlHttpGet == null)
    {
        alert("浏览器不支持 ajax!");
        return;
    }
    var url = 'ajax/searchsrecmm_get.aspx';
    url = url + "?sid=" + Math.random();
    url = url + "&keyword=" + KeyWord;
    url = url + "&page=" + s_GridView_CurrenPage;
    url = url + "&orderby=" + orderby;
    xmlHttpGet.onreadystatechange = SearchsRecommGetOK;
    xmlHttpGet.open("get", url, true);
    xmlHttpGet.send(null);
}

function SearchsRecommGetOK()
{
    if (xmlHttpGet.readyState == 4)
    {
        var gustItemRecommDiv = document.getElementById("searchs_recomm_list");
        gustItemRecommDiv.innerHTML = xmlHttpGet.responseText;
    }
}

function SearchiRecommPaging(keyword,orderby,s_Param_PageNumber)
{
    s_GridView_CurrenPage = s_Param_PageNumber;
    GuestSearchsRecomm(keyword,orderby)
}
