<%
function getSourceOption(currentid,tablename)
dim ifselect,rs,sql
sql="select id,Title from "&tablename&" order by id asc"
Set rs = conn.Execute(sql)
if rs.eof or rs.bof then
	getSourceOption="<option value=""0"">暂时没有</option>"&Chr(13)
else
	getSourceOption="<option value=""0"">=请选择=</option>"&Chr(13)
end if
while not rs.eof
	if(Clng(rs(0))=Clng(currentid)) then
		ifselect=" selected"
	else
		ifselect=""
	end if
	getSourceOption=getSourceOption&"<option value="""&rs(0)&""" "&ifselect&">"&rs(1)&"</option>"&Chr(13)
	rs.movenext
wend
rs.close
set rs=nothing
end function

function GetRoutes(catalogid,n,max,showprice)
	dim sql
	sql="select top "&n&" id,Title,Price,Color from t_route where 1=1"
	if(catalogid>0) then
		sql=sql&" and ClassId="&catalogid
	end if
	sql=sql&" order by id asc"
	set rs=conn.execute(sql)
	do while not rs.eof
		response.Write("<li>")
		if(showprice=true) then
			response.Write("<span class=""route_price"">￥"&rs(2)&"</span>")
		end if
		response.Write("<a href=""/routes_show.asp?id="&rs(0)&""" style=""color:"&rs(3)&""">"&left(rs(1),max)&"</a></li>")
		rs.movenext
	loop 
	rs.close
	set rs=nothing
end function

function GetRemRoutes(catalogid,n,max,showprice)
	dim sql
	sql="select top "&n&" id,Title,Price,Color from t_route where IsRem=1"
	if(catalogid>0) then
		sql=sql&" and ClassId="&catalogid
	end if
	sql=sql&" order by id asc"
	set rs=conn.execute(sql)
	do while not rs.eof
		response.Write("<li>")
		if(showprice=true) then
			response.Write("<span class=""route_price"">￥"&rs(2)&"</span>")
		end if
		response.Write("<a href=""/routes_show.asp?id="&rs(0)&""" style=""color:"&rs(3)&""">"&left(rs(1),max)&"</a></li>")
		rs.movenext
	loop 
	rs.close
	set rs=nothing
end function

function GetNews(catalogid,n,max,showdate)
	dim sql
	sql="select top "&n&" title,pagepath,isoutlink,title_color from news where 1=1"
	if(catalogid>0) then
		sql=sql&" and ClassId="&catalogid
	end if
	sql=sql&" order by id desc"
	set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,3,1
	while not rs.eof
		if(rs(2)=1) then
			urls=rs(1)
		else
			urls="/"&rs(1)
		end if
		response.Write("<li><a href="""&urls&""" style=""color:"&rs(3)&""">"&left(rs(0),max)&"</a></li>")
		rs.movenext
	wend
	rs.close
	set rs=nothing
end function			
function GetRemNews(catalogid,n,max,showdate)
	dim sql
	sql="select top "&n&" title,pagepath,isoutlink,title_color from news where recommend=1"
	if(catalogid>0) then
		sql=sql&" and ClassId="&catalogid
	end if
	sql=sql&" order by id desc"
	set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,3,1
	while not rs.eof
		if(rs(2)=1) then
			urls=rs(1)
		else
			urls="/"&rs(1)
		end if
		response.Write("<li><a href="""&urls&""" style=""color:"&rs(3)&""">"&left(rs(0),max)&"</a></li>")
		rs.movenext
	wend
	rs.close
	set rs=nothing
end function		

function GetHotels(catalogid,n,max,isrem)
	dim sql
	sql="select top "&n&" id,Title,Photo,MinPrice,MaxPrice,Stars,JianJie,Zbjd,Address from t_hotel where 1=1"
	if(catalogid>0) then
		sql=sql&" and ClassId="&catalogid
	end if
	if(isrem=true) then
		sql=sql&" and IsRem=1"
	end if
	sql=sql&" order by id asc"
	set rs=conn.execute(sql)
	do while not rs.eof
		response.Write("<li><div class=""title""><a href=""hotel_show.asp?id="&rs(0)&""">"&rs(1)&" </a></div><div class=""level"">")
		if(rs(5)=1) then
			response.Write("暂无星级")
		else
			response.Write(rs(5)&"星级")
		end if
		response.Write("</div><div class=""price"">￥"&rs(3)&"</div></li>")		
		rs.movenext
	loop 
	rs.close
	set rs=nothing
end function		

function GetFriendLink(rows,cols,linktype,ItColor1,ItColor2)
dim rs,sql,TempArr
	set rs=server.CreateObject("adodb.recordset")
	if(Cint(linktype)=0) then
		sql="select Title,LinkUrl from friendlink where Flag="&linktype
	elseif(Cint(linktype=1)) then
		sql="select Title,LinkUrl,Pic from friendlink where Flag="&linktype
	end if
  	set rs=conn.execute(sql)
	if not rs.eof then
  		TempArr=rs.GetRows()  
  		rs.close
		set rs=nothing   
		GetFriendLink=GetFriendLink&"<table class=""line22"" cellspacing=""0"" cellpadding=""0"" width=""100%"" border=""0"">"&Chr(10)
		for i=0 to rows-1' ubound(TempArr,2)按行循环

				if i mod 2=0 then
					GetFriendLink=GetFriendLink&"<tr bgcolor="""&ItColor1&""">"&Chr(10)
				else
					GetFriendLink=GetFriendLink&"<tr bgcolor="""&ItColor2&""">"&Chr(10)
				end if

			for j=0 to cols-1'按列循环
				GetFriendLink=GetFriendLink&"<td><div align=""center"">"&Chr(10)
				if(linktype=0) then
					if(i*cols+j<=ubound(TempArr,2)) then
						GetFriendLink=GetFriendLink&"<a href="""&TempArr(1,i*cols+j)&""" title="""&TempArr(0,i*cols+j)&""" target=""_blank"">"&TempArr(0,i*cols+j)&"</a>"&Chr(10)
					else
						GetFriendLink=GetFriendLink&"<a href="""&SiteUrl&""" target=""_blank"">友情链接</a>"&Chr(10)
					end if
				else
					if(i*cols+j<=ubound(TempArr,2)) then
						GetFriendLink=GetFriendLink&"<a href="""&TempArr(1,i*cols+j)&""" target=""_blank""><img src="""&TempArr(2,i*cols+j)&""" alt="""&TempArr(0,i*cols+j)&""" width=""88"" height=""31"" border=""0"" /></a>"&Chr(10)
					else
						GetFriendLink=GetFriendLink&"<a href="""&SiteUrl&""" target=""_blank"">友情链接</a>"&Chr(10)
					end if
				end if
				GetFriendLink=GetFriendLink&"</div></td>"&Chr(10)
			next
		GetFriendLink=GetFriendLink&"</tr>"&Chr(10)
		next
		GetFriendLink=GetFriendLink&"</table>"&Chr(10)	
	else
		rs.close
		set rs=nothing
	end if
end function		
%>