// JavaScript Document
<!--
var xmlHttp,xmlHttp2;
var topcontent="";
var bottomcontent="";
var keyword2="";
var type2=0;
var icount=0;   //总记录条数
var pagecount; //总页数
var toppagecount;
var bottompagecount;
var topsearchpagecount; //搜索页数
var bottomsearchpagecount;
var toppagesize=48; //每页显示记录数 4x7
var bottompagesize=28; //每页显示记录数 4x10
var toppage=1;//当前页数
var bottompage=1;
var items;
var init_num=0;
var loadflag=0;
var template;
var topresults=new Array();
var bottomresults=new Array();
var t_item ;
var endtimearray=new Array();
var sortarray=new Array();
var timertop = new Array();

var timerbottom = new Array();
function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}
function startRequest(mykeyword,mytype){
	if(parseInt(loadflag)==0){
        alert('数据正在加载,请稍后两秒再操作!若30秒未完成请刷新页面!');
    }
    type2=mytype;
    keyword2=mykeyword;
	xmlHttp=xmlHttp2;
    init();	
	document.location='#currentcity';
}
function preload(){
    createXMLHttpRequest();
    xmlHttp.onreadystatechange=myhandleStateChange;
    citypinyin=getCookie("citypinyin");
	if(citypinyin==""||citypinyin==null) citypinyin="quanguo";
    loadflag=0;
    xmlHttp.open("GET","/group.php?citypinyin="+citypinyin,true);
    xmlHttp.send(null);	
}
function myhandleStateChange(){
    var result;
    if(xmlHttp.readyState==4){
        if(xmlHttp.status==200){
            init_num=1;
			xmlHttp2=xmlHttp;			
            init();
            init_num=0;
            loadflag=1;
        }
    }
}
function handleStateChange(){
    var result;
    if(xmlHttp.readyState==4){
		
        if(xmlHttp.status==200){
            init();
        }
    }
    else{
        document.getElementById("toppart").innerHTML="<div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div>";
    }
}
function clearkeyword(){
    document.getElementById("query")="";
}
function checksearch(s_type){
    keyword=document.getElementById("query").value;
    if(keyword=="小窍门:关键词+空格+精确 可实现精确搜索"||keyword=="")
    {	
        alert("输入关键词，按回车搜索团购");
        return false;
    }else {
		if(s_type==2)
			detail_search(keyword);
		else
        	searchload(keyword,2);
        return false;
    }
    return false;
}
function searchkey(keyword){
    if(keyword=="小窍门:关键词+空格+精确 可实现精确搜索"||keyword=="")
    {	
        alert("输入关键词，按回车搜索团购");
        return false;
    }else {
        searchload(keyword,2);
        return false;
    }
    return false;
}
function searchload(mykeyword,mytype){
    createXMLHttpRequest();
    xmlHttp.onreadystatechange=handleStateChange;
    mycityname=getCookie("city");
	if(mycityname=="" || mycityname == null) mycityname="全国";
    type2=mytype;
    keyword2=mykeyword;
    xmlHttp.open("GET","/coutxml.php?c="+escape(mycityname)+"&k="+escape(mykeyword),true);
    xmlHttp.send(null);
	document.location='#currentcity';	
}
function detail_search(keyword)
{
	var xmlHttpcity;
	var citypinyin="";
	citypinyin=getCookie("citypinyin");
	if(citypinyin==null||citypinyin=="")
	{
		if (window.ActiveXObject) {
			xmlHttpcity = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else if (window.XMLHttpRequest) {
			xmlHttpcity = new XMLHttpRequest();
		}
		xmlHttpcity.open("GET","/ip.php",false);
		xmlHttpcity.send(null);	
		citypinyin = xmlHttpcity.responseText;	
	}
	window.location="/search.php?citypinyin="+citypinyin+"&keyword="+keyword;
}
function handleStateChange(){
    var result;
    if(xmlHttp.readyState==4){
        if(xmlHttp.status==200){
            init();
        }
    }
    else{
        document.getElementById("toppart").innerHTML="<div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div>";
       // document.getElementById("bottompart").innerHTML="<div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div><div class='load' style='width:30px;height:30px;float:left;margin-left:10px;'><img src=\"/picture/07.gif\" style=\"width:30px;height:30px;\" /></div>";
    }
}

function init()
{
    var xmldoc=xmlHttp.responseXML;
    items=xmldoc.getElementsByTagName("i");
    data=xmldoc.getElementsByTagName("data");
    template=data[0].getAttribute("t");
	
    icount=items.length;	
    topsearchpagecount=0; //搜索结果数量
    bottomsearchpagecount=0;
    citykey=getCookie("city");
		
    if(citykey==null || citykey=="")
        citykey="全国";
    var j=0;
		
    for(var i=0;i<icount;i++)
    {
        try{
            t_item = items[i];
            groupname = t_item.getElementsByTagName("g")[0].childNodes[0].nodeValue;
            source = t_item.getElementsByTagName("s")[0].childNodes[0].nodeValue;
            city = t_item.getElementsByTagName("c")[0].childNodes[0].nodeValue;
            if(city!="全国"&&city!=citykey&&citykey!="全国"){
                continue;
            }
            t_class = t_item.getElementsByTagName("cl")[0].childNodes[0].nodeValue;
            newprice = t_item.getElementsByTagName("n")[0].childNodes[0].nodeValue;

            if(parseInt(type2)==1 && ifphpsearch == 0){ //城市过滤
                if(keyword2==1){
                    if(city=="全国")
                        continue;
                }else{
                    if(city!="全国")
                        continue;
                }
            }
           // else if(parseInt(type2)==2){ //关键词过滤
             //   if(groupname.indexOf(keyword2)<0&&source.indexOf(keyword2)<0&&city.indexOf(keyword2)<0)
               //     continue;
            //}
            else if(parseInt(type2)==3){ //来源过滤
                if(source.indexOf(keyword2)<0)
                    continue;
            }
            else if(parseInt(type2)==4){ //类别过滤
                if((t_class!=keyword2))
                    continue;
            }					
            //type2为其他值则不过滤
           // if(city != "全国")
           // {
                topresults[topsearchpagecount]=t_item;
                topsearchpagecount++;
           // }
           // else
            //{
           //     bottomresults[bottomsearchpagecount]=t_item;
           //     bottomsearchpagecount++;
           // }
            
        }catch(Exception){
        }
    }
		
    if(parseInt(type2)==6)//排序
    {
        if(parseInt(keyword2)==1){//价格排序 asc
            topresults.sort(function(y,x){
                return (parseInt(x.getElementsByTagName("n")[0].childNodes[0].nodeValue)-parseInt(y.getElementsByTagName("n")[0].childNodes[0].nodeValue));
            });
           // bottomresults.sort(function(y,x){
            //    return (parseInt(x.getElementsByTagName("n")[0].childNodes[0].nodeValue)-parseInt(y.getElementsByTagName("n")[0].childNodes[0].nodeValue));
          //  });
            document.getElementById("sort2").setAttribute("class", "desc");
            document.getElementById("sortlink1").setAttribute("class", "off");
            document.getElementById("sortlink2").setAttribute("class", "on");
            document.getElementById("sortlink3").setAttribute("class", "off");
            document.getElementById("sortlink2").setAttribute("href", "javascript:startRequest(2,6);");
        }
        if(parseInt(keyword2)==2){//价格排序 desc
            topresults.sort(function(x,y){
                return (parseInt(x.getElementsByTagName("n")[0].childNodes[0].nodeValue)-parseInt(y.getElementsByTagName("n")[0].childNodes[0].nodeValue));
            });
           // bottomresults.sort(function(x,y){
           //     return (parseInt(x.getElementsByTagName("n")[0].childNodes[0].nodeValue)-parseInt(y.getElementsByTagName("n")[0].childNodes[0].nodeValue));
           // });
            document.getElementById("sort2").setAttribute("class", "asc");
            document.getElementById("sortlink1").setAttribute("class", "off");
            document.getElementById("sortlink2").setAttribute("class", "on");
            document.getElementById("sortlink3").setAttribute("class", "off");
            document.getElementById("sortlink2").setAttribute("href", "javascript:startRequest(1,6);");
        }
        if(parseInt(keyword2)==3){//折扣排序 asc
            topresults.sort(function(y,x){
                return (parseInt(x.getElementsByTagName("d")[0].childNodes[0].nodeValue)-parseInt(y.getElementsByTagName("d")[0].childNodes[0].nodeValue));
            });
           // bottomresults.sort(function(y,x){
           //     return (parseInt(x.getElementsByTagName("d")[0].childNodes[0].nodeValue)-parseInt(y.getElementsByTagName("d")[0].childNodes[0].nodeValue));
          //  });
            document.getElementById("sort3").setAttribute("class", "desc");
            document.getElementById("sortlink1").setAttribute("class", "off");
            document.getElementById("sortlink2").setAttribute("class", "off");
            document.getElementById("sortlink3").setAttribute("class", "on");
            document.getElementById("sortlink3").setAttribute("href", "javascript:startRequest(4,6);");
        }
        if(parseInt(keyword2)==4){//折扣排序 desc
            topresults.sort(function(x,y){
                return (parseInt(x.getElementsByTagName("d")[0].childNodes[0].nodeValue)-parseInt(y.getElementsByTagName("d")[0].childNodes[0].nodeValue));
            });
          //  bottomresults.sort(function(x,y){
          //      return (parseInt(x.getElementsByTagName("d")[0].childNodes[0].nodeValue)-parseInt(y.getElementsByTagName("d")[0].childNodes[0].nodeValue));
          //  });
            document.getElementById("sort3").setAttribute("class", "asc");
            document.getElementById("sortlink1").setAttribute("class", "off");
            document.getElementById("sortlink2").setAttribute("class", "off");
            document.getElementById("sortlink3").setAttribute("class", "on");
            document.getElementById("sortlink3").setAttribute("href", "javascript:startRequest(3,6);");
        }
        if(parseInt(keyword2)==5){//人气排序 asc
            topresults.sort(function(y,x){
                return (y.getElementsByTagName("pe")[0].childNodes[0].nodeValue-x.getElementsByTagName("pe")[0].childNodes[0].nodeValue);
            });
          //  bottomresults.sort(function(y,x){
          //      return (y.getElementsByTagName("pe")[0].childNodes[0].nodeValue-x.getElementsByTagName("pe")[0].childNodes[0].nodeValue);
          //  });
            document.getElementById("sort1").setAttribute("class", "desc");
            document.getElementById("sortlink1").setAttribute("class", "on");
            document.getElementById("sortlink2").setAttribute("class", "off");
            document.getElementById("sortlink3").setAttribute("class", "off");
            document.getElementById("sortlink1").setAttribute("href", "javascript:startRequest(6,6);");
        }
        if(parseInt(keyword2)==6){//人气排序 desc
            topresults.sort(function(x,y){
                return (y.getElementsByTagName("pe")[0].childNodes[0].nodeValue-x.getElementsByTagName("pe")[0].childNodes[0].nodeValue);
            });
         //   bottomresults.sort(function(x,y){
         //       return (y.getElementsByTagName("pe")[0].childNodes[0].nodeValue-x.getElementsByTagName("pe")[0].childNodes[0].nodeValue);
         //   });
            document.getElementById("sort1").setAttribute("class", "asc");
            document.getElementById("sortlink1").setAttribute("class", "on");
            document.getElementById("sortlink2").setAttribute("class", "off");
            document.getElementById("sortlink3").setAttribute("class", "off");
            document.getElementById("sortlink1").setAttribute("href", "javascript:startRequest(5,6);");
        }       
    }
		
    if(topsearchpagecount%toppagesize>0)
    {
        toppagecount=parseInt(topsearchpagecount/toppagesize)+1;
    }
    else
    {
        toppagecount=parseInt(topsearchpagecount/toppagesize);
    }
    toppage=1;		
    if(toppagecount>20)
        toppagecount=20;
    
   /* if(bottomsearchpagecount%bottompagesize>0)
    {
        bottompagecount=parseInt(bottomsearchpagecount/bottompagesize)+1;
    }
    else
    {
        bottompagecount=parseInt(bottomsearchpagecount/bottompagesize);
    }
    bottompage=1;		
    if(bottompagecount>20)
        bottompagecount=20;
	*/
    mysearch_top();
   // mysearch_bottom();
}

function mysearch_top()
{
    topcontent="";
    if(init_num==1)
        return;
	var i=0;
    for(i=(toppage-1)*toppagesize;i<toppage*toppagesize&&i<topsearchpagecount;i++){//地方
        try{
            t_item = topresults[i];
            groupid=t_item.getAttribute("g");
				
            groupname = t_item.getElementsByTagName("g")[0].childNodes[0].nodeValue;
            source = t_item.getElementsByTagName("s")[0].childNodes[0].nodeValue;
            city = t_item.getElementsByTagName("c")[0].childNodes[0].nodeValue;
            url = t_item.getElementsByTagName("u")[0].childNodes[0].nodeValue;
            endtimearray[i] = t_item.getElementsByTagName("e")[0].childNodes[0].nodeValue;
            price = t_item.getElementsByTagName("pr")[0].childNodes[0].nodeValue;
            newprice = t_item.getElementsByTagName("n")[0].childNodes[0].nodeValue;
            picture = t_item.getElementsByTagName("pi")[0].childNodes[0].nodeValue;
            discount = t_item.getElementsByTagName("d")[0].childNodes[0].nodeValue;
            grade = t_item.getElementsByTagName("t")[0].childNodes[0].nodeValue;
			myaddress=t_item.getElementsByTagName("a")[0].childNodes[0].nodeValue;
            personnum = t_item.getElementsByTagName("pe")[0].childNodes[0].nodeValue;
			ads = t_item.getElementsByTagName("f")[0].childNodes[0].nodeValue;
			
            addlist_top(groupname,url,city,endtimearray[i],price,newprice,picture,grade,discount,personnum,source,i,groupid,myaddress,ads);
        }
        catch(Exception){ 
			addlist_top(groupname,url,city,endtimearray[i],price,newprice,picture,grade,discount,personnum,source,i,groupid,myaddress,ads);	
        }
    }
    if(topsearchpagecount==0)
    {
        topcontent="<span class='red'>对不起没有找到您所需要的团</span><br />";
    }
        
    //alert(topsearchpagecount);
    document.getElementById("toppart").innerHTML=topcontent;
    citykey=getCookie("city");
    if(citykey==null || citykey=="")
        citykey="全国";	
    var toppagecute;
    toppagecute="<a href='#currentcity' name='#country'>"+citykey+"团购</a>";
    toppagecute=toppagecute+"<a href='javascript:turntopage_top(1)'>首页</a>";
    toppagecute=toppagecute+"<a href='javascript:previousPage_top()'>上一页</a>";
    for(var j=1;j<=toppagecount;j++){
        if(j==toppage){
            toppagecute=toppagecute+"<a  style='background:url(/"+template+"/img/page_bg.jpg) no-repeat -87px 0px;' href='javascript:turntopage_top("+j+")'>"+j+"</a>";
        }
        else{
            toppagecute=toppagecute+"<a  href='javascript:turntopage_top("+j+")'>"+j+"</a>";
        }
    }
    toppagecute=toppagecute+"<a href='javascript:nextPage_top()'>下一页</a>";	
    toppagecute=toppagecute+"<a href='javascript:turntopage_top("+toppagecount+")'>尾页</a>";	
    document.getElementById("toppagecut").innerHTML=toppagecute;
}
function mysearch_bottom()
{
    bottomcontent="";
    if(init_num==1)
        return;
	var i=0;
    for(i=(bottompage-1)*bottompagesize;i<bottompage*bottompagesize&&i<bottomsearchpagecount;i++){//全国
        try{
            t_item = bottomresults[i];
            groupid=t_item.getAttribute("g");
				
            groupname = t_item.getElementsByTagName("g")[0].childNodes[0].nodeValue;
            source = t_item.getElementsByTagName("s")[0].childNodes[0].nodeValue;
            city = t_item.getElementsByTagName("c")[0].childNodes[0].nodeValue;
            url = t_item.getElementsByTagName("u")[0].childNodes[0].nodeValue;
            endtimearray[i] = t_item.getElementsByTagName("e")[0].childNodes[0].nodeValue;
            price = t_item.getElementsByTagName("pr")[0].childNodes[0].nodeValue;
            newprice = t_item.getElementsByTagName("n")[0].childNodes[0].nodeValue;
            picture = t_item.getElementsByTagName("pi")[0].childNodes[0].nodeValue;
            discount = t_item.getElementsByTagName("d")[0].childNodes[0].nodeValue;
            grade = t_item.getElementsByTagName("t")[0].childNodes[0].nodeValue;
            personnum = t_item.getElementsByTagName("pe")[0].childNodes[0].nodeValue;
            addlist_bottom(groupname,url,city,endtimearray[i],price,newprice,picture,grade,discount,personnum,source,i,groupid);
			k++;
        }
        catch(Exception){ 
			
        }
    }
    if(bottomsearchpagecount==0)
    {
        bottomcontent="<span class='red'>对不起没有找到您所需要的团</span><br />";
    }
        
    //alert(topsearchpagecount);
    document.getElementById("bottompart").innerHTML=bottomcontent;
    citykey=getCookie("city");
    if(citykey==null || citykey=="")
        citykey="全国";	
    var bottompagecute;
    bottompagecute="<a href='#country'>全国团购</a>";
    bottompagecute=bottompagecute+"<a href='javascript:turntopage_bottom(1)'>首页</a>";
    bottompagecute=bottompagecute+"<a href='javascript:previousPage_bottom()'>上一页</a>";
    for(var j=1;j<=bottompagecount;j++){
        if(j==bottompage){
            bottompagecute=bottompagecute+"<a  style='background:url(/"+template+"/img/page_bg.jpg) no-repeat -87px 0px;' href='javascript:turntopage_bottom("+j+")'>"+j+"</a>";
        }
        else{
            bottompagecute=bottompagecute+"<a  href='javascript:turntopage_bottom("+j+")'>"+j+"</a>";
        }
    }
    bottompagecute=bottompagecute+"<a href='javascript:nextPage_bottom()'>下一页</a>";	
    bottompagecute=bottompagecute+"<a href='javascript:turntopage_bottom("+bottompagecount+")'>尾页</a>";	
    document.getElementById("bottompagecut").innerHTML=bottompagecute;	
}
function startTimer(id,endtime)
{
	GetServerTime(id,endtime);
    document.getElementById(id+"_show").className="list_time2";
}
function stopTimer(id)
{
    document.getElementById(id+"_show").className="list_time";
}
function GetServerTime(ids,timer)
{
    var now = new Date();
    var urodz = new Date(timer);
    now.setTime(now.getTime()+250);
    days = (urodz - now) / 1000 / 60 / 60 / 24;
    daysRound = Math.floor(days);
    hours = (urodz - now) / 1000 / 60 / 60 - (24 * daysRound);
    hoursRound = Math.floor(hours);
    minutes = (urodz - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
    minutesRound = Math.floor(minutes);
    seconds = (urodz - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
    secondsRound = Math.round(seconds);
    try{ 
        document.getElementById(ids).innerHTML = daysRound + "天" + hoursRound + "时" + minutesRound + "分" + secondsRound + "秒";
    } 
    catch(Exception){ 
			
    }
    if(daysRound<0){
        try{ 
            document.getElementById(ids).innerHTML = "<span style=\"color:#FF0000\">本团购已结束</style>";
        } 
        catch(Exception){ 
			
        }
    }
		
}

function GetServerTime2_top(num)
{
    var ids;
    for(var i=0;i<num;i++){
        ids=i+"timetop";
        var now = new Date();
        var urodz = new Date(endtimearray[i]);
        now.setTime(now.getTime()+250);
        days = (urodz - now) / 1000 / 60 / 60 / 24;
        daysRound = Math.floor(days);
        hours = (urodz - now) / 1000 / 60 / 60 - (24 * daysRound);
        hoursRound = Math.floor(hours);
        minutes = (urodz - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
        minutesRound = Math.floor(minutes);
        seconds = (urodz - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
        secondsRound = Math.round(seconds);
        try{ 
            document.getElementById(ids).innerHTML = daysRound + "天" + hoursRound + "时" + minutesRound + "分" + secondsRound + "秒";
        } 
        catch(Exception){ 
			
        }
        if(daysRound<0){
            try{ 
                document.getElementById(ids).innerHTML = "<span style=\"color:#FF0000\">本团购已结束</style>";
            } 
            catch(Exception){ 
			
            }
        }
    }
}

function GetServerTime2_bottom(num)
{
    var ids;
    for(var i=0;i<num;i++){
        ids=i+"timebottom";
        var now = new Date();
        var urodz = new Date(endtimearray[i]);
        now.setTime(now.getTime()+250);
        days = (urodz - now) / 1000 / 60 / 60 / 24;
        daysRound = Math.floor(days);
        hours = (urodz - now) / 1000 / 60 / 60 - (24 * daysRound);
        hoursRound = Math.floor(hours);
        minutes = (urodz - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
        minutesRound = Math.floor(minutes);
        seconds = (urodz - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
        secondsRound = Math.round(seconds);
        try{ 
            document.getElementById(ids).innerHTML = daysRound + "天" + hoursRound + "时" + minutesRound + "分" + secondsRound + "秒";
        } 
        catch(Exception){ 
			
        }

        if(daysRound<0){
            try{ 
                document.getElementById(ids).innerHTML = "<span style=\"color:#FF0000\">本团购已结束</style>";
            } 
            catch(Exception){ 
			
            }
        }
    }
}
function htmlspecialchars(string){
	var data = [];
	for(var i = 0 ;i <string.length;i++) {
	data.push( "&#"+string.charCodeAt(i)+";");
	}
	return data.join("");
}

function addlist_top(groupname,url,city,endtime,price,newprice,picture,iftop,discount,personnum,source,i,groupid,address,ads)
{
	address2=address.replace(/【/g,"");
	address2=address2.replace(/】/g,"");	
	if(address==""||address=="未知"||address2=="") {
		address ="";
		address2="";
		if(city=="全国")
		{
			address ="全国通用";
			address2="全国通用";
		}
	}
	if(address!="")
		address="<a class=\"pl_a1\"  href='javascript:void(0)' title=\""+htmlspecialchars(address)+"\"></a>"+htmlspecialchars(address2);
	if(ads!=0)
		ads="<div class=\"tuanfanxian\">约返<br/><strong style=\"font-size:14px;\">"+ads+"</strong>元</div>";
	else
		ads="";
		
	topcontent=topcontent+"<div class=\"deal\" onmouseover=\"startTimer('"+i+"timetop','"+endtime+"')\" onmouseout=\"stopTimer('"+i+"timetop')\">\n\
<div class=\"list_img\"><a class=\"image_link\" href=\""+url+"\" target=\"_blank\">\n\
<img class=\"normal_image\" alt=\""+groupname+"\"src=\""+picture+"\" onerror=\"this.src='/upload/moren.jpg'\"/></a>"+ads+"</div>\n\
<div class=\"list_time\" id=\""+i+"timetop_show\">还剩：<label id=\""+i+"timetop\"class=\"time_div timeleft\">载入中...</label></div>\n\
<div class=\"list_bt\"><h4><a class=\"from\" title=\""+source+"网\" href=\"javascript:void(0)\" onclick=\"searchkey('"+source+"')\">"+source+"</a>|<a class=\"from\"  href=\"javascript:void(0)\" onclick=\"searchkey('"+city+"')\">"+city+"</a></h4>|<p>\n\
<a class=\"title\" title=\""+groupname+"\" href=\"/tuan/"+groupid+"\" target=\"_blank\">"+groupname+"</a></p></div>\n\
<div class=\"list_jg\">团购价：<b>"+newprice+"元</b><br />折扣：<font>"+discount+"折</font><br />原价："+price+"元</div>\n\
<div class=\"list_botton\"><a class=\"buy\" title=\"去看看\" href=\"/tuan/"+groupid+"\" target=\"_blank\"></a></div>\n\
<div class=\"list_pl\">"+address+"</div></div>";
}
function addlist_bottom(groupname,url,city,endtime,price,newprice,picture,iftop,discount,personnum,source,i,groupid)
{
    bottomcontent=bottomcontent+"<div class=\"deal\" onmouseover=\"startTimer('"+i+"timetop',"+endtime+")\" onmouseout=\"stopTimer('"+i+"timebottom')\">\n\
<div class=\"list_img\"><a class=\"image_link\" href=\""+url+"\" target=\"_blank\"><img class=\"normal_image\" alt=\""+groupname+"\"src=\""+picture+"\" onerror=\"this.src='/upload/moren.jpg'\"/></a></div>\n\
<div class=\"list_time\" id=\""+i+"timebottom_show\">还剩：<label id=\""+i+"timebottom\"class=\"time_div timeleft\">载入中...</label>\n\
</div><div class=\"list_bt\"><h4>\n\
<a class=\"from\" title=\""+source+"网\" href=\"javascript:void(0)\" onclick=\"searchkey('"+source+"')\">"+source+"</a>|"+city+"</h4>|<p>\n\
<a class=\"title\" title=\"[团购]"+city+source+"团购详细信息\" href=\"/tuan/"+groupid+"\" target=\"_blank\">"+groupname+"</a></p></div>\n\
<div class=\"list_jg\">团购价：<b>"+newprice+"元</b><br />折扣：<font>"+discount+"折</font><br />原价："+price+"元<br />已售："+personnum+"个</div>\n\
<div class=\"list_botton\"><a class=\"buy\" title=\"去看看\" href=\"/go.php?url="+url+"\" rel=\"nofollow\" target=\"_blank\"></a></div>\n\
<div class=\"list_pl\"><a class=\"pl_a2\" title=\"对此团购发表评论\" href=\"/tuan/"+groupid+"#deal_comment\" target=\"_blank\"></a></div></div>";
}
function turntopage_top(page)
{	
    var topage
    topage=page;
    if(parseInt(loadflag)==0){
        alert('数据正在加载,请稍后两秒再操作!若30秒未完成请刷新页面!');
    }
    if(topage<1)
    {
    //alert("该页面不存在！");
    //return false;
    }
    else if(topage>toppagecount)
    {
    //alert("该页面不存在！");
    //return false;
    }
    else
    {
        getList_top(topage);
    }
	document.location='#currentcity';
}
function turntopage_bottom(page)
{	
    var topage
    topage=page;
    if(parseInt(loadflag)==0){
        alert('数据正在加载,请稍后两秒再操作!若30秒未完成请刷新页面!');
    }
    if(topage<1)
    {
    //alert("该页面不存在！");
    //return false;
    }
    else if(topage>bottompagecount)
    {
    //alert("该页面不存在！");
    //return false;
    }
    else
    {
        getList_bottom(topage);
    }
	//document.location='#country';
}
function getList_top(curPage)
{
    if(curPage>0&&curPage<toppagecount)
    {
        toppage=curPage;
    }
    else if(curPage<1)
    {
        toppage=1;
    }
    else if(curPage>=toppagecount)
    {
        toppage=toppagecount;
    }
    mysearch_top();
}
function getList_bottom(curPage)
{
    if(curPage>0&&curPage<bottompagecount)
    {
        bottompage=curPage;
    }
    else if(curPage<1)
    {
        bottompage=1;
    }
    else if(curPage>=bottompagecount)
    {
        bottompage=bottompagecount;
    }
    mysearch_bottom();
}
function previousPage_top()
{
    if(parseInt(loadflag)==0){
        alert('数据正在加载,请稍后两秒再操作!若30秒未完成请刷新页面!');
        return ;
    }
    if (toppage>1)
    {
        getList_top(parseInt(toppage)-1);		//当前页数字符型转换成整型,以免溢出		2007年5月7日 Modify By HJF
    }
    else
    {
        alert("已经是第一页了");
    }
    document.location='#currentcity';
}
function previousPage_bottom()
{
    if(parseInt(loadflag)==0){
        alert('数据正在加载,请稍后两秒再操作!若30秒未完成请刷新页面!');
        return ;
    }
    if (bottompage>1)
    {
        getList_bottom(parseInt(bottompage)-1);		//当前页数字符型转换成整型,以免溢出		2007年5月7日 Modify By HJF
    }
    else
    {
        alert("已经是第一页了");
    }
   // document.location='#country';
}

function nextPage_top()
{
    if(parseInt(loadflag)==0){
        alert('数据正在加载,请稍后两秒再操作!若30秒未完成请刷新页面!');
        return ;
    }
    if(parseInt(toppage)<parseInt(toppagecount))
    {
        getList_top(parseInt(toppage)+1);		//当前页数字符型转换成整型,以免溢出		2007年5月7日 Modify By HJF
    }
    else
    {
        alert("已是最后一页,请点上一页!");
    }
	document.location='#currentcity';
}

function nextPage_bottom()
{
    if(parseInt(loadflag)==0){
        alert('数据正在加载,请稍后两秒再操作!若30秒未完成请刷新页面!');
        return ;
    }
    if(parseInt(bottompage)<parseInt(bottompagecount))
    {
        getList_bottom(parseInt(bottompage)+1);		//当前页数字符型转换成整型,以免溢出		2007年5月7日 Modify By HJF
    }
    else
    {
        alert("已是最后一页,请点上一页!");
    }
	//document.location='#country';
}

function turnPage_top(p)
{
    getList_top(p);
}

function turnPage_bottom(p)
{
    getList_bottom(p);
}
function jumpcount(fanli_id,username,source,groupid,siteid)
{
	if(fanli_id > 0&&username=="")
	{
		document.getElementById('jumpbox').style.display = 'block';
		return false;
	}
	else 
	{
		clickcount(source,groupid,siteid);
		return true;
	}
}

function taobao_search()
{
	document.getElementById('taobaosearchbox').style.display = 'block';
	return false;
}

function sendRequestPost(url,param){  
	createXMLHttpRequest();  
	xmlHttp.open("POST",url,true);  
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  
	xmlHttp.onreadystatechange = processResponse;  
	xmlHttp.send(param);  
} 
//处理返回信息函数  
function processResponse(){  
	if(xmlHttp.readyState == 4){  
		if(xmlHttp.status == 200){  
			var res = xmlHttp.responseText;  
			if(res >0)
				window.location.href=document.getElementById('jumpurl').value;
			else 
			alert("账号或密码错误");  
		}  
	}  
}  
//身份验证函数  
function userlogin(session){  
	var userName = document.getElementById('loginuser').value;  
	var psw = document.getElementById('loginpwd').value;  
	if(userName == ""||psw==""){  
		window.alert("用户名不能为空");  
		return false;  
	}  
	else{  
		var url = "/ajax.php?fun=checkLogin";  
		var param = "ddusername="+userName+"&dduserpwd="+psw+"&session="+session;  
		sendRequestPost(url,param);  
	}  
}  
function clickcount(source,groupid,siteid){
//	alert(filepath);
	createXMLHttpRequest();
	//xmlHttp.onreadystatechange=handleStateChange;
	xmlHttp.open("GET","/click.php?source="+source+"&groupid="+groupid+"&siteid="+siteid,true);
	//alert("aa");
	xmlHttp.send(null);
	
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null) return unescape(arr[2]);
    return null;

}
