$('.col1 dl dt').each(function()
{
	$(this).click(function(){
		if(!this.parentNode.getElementsByTagName('DD').length>0)return ;
		var alink=this.getElementsByTagName('A')[0];
		var state=alink.className!='on'?true:false;
		alink.className=state?'on':'';
		this.parentNode.getElementsByTagName('DD')[0].style.display=state?'block':'none';			
	});
});
$('.myShowBtn').click(function(){
	$('#col2L').attr('class','col2L');
});
$('.showBtn').click(function(){
	$('#col2L').attr('class','col2L col2L02');
});
$('.videoBtn').click(function(){
	$('#col2L').attr('class','col2L col2L03');
});
$('#goldLink_hook').bind('mouseover',function(){
	$('#goldLink_block').css('display','block');
});
$('#goldLink_hook').bind('mouseout',function(){
	$('#goldLink_block').css('display','none');
});
$('.col1 em').each(function(i){
								
});

GuideFlash(true);

function rlist(e)
{
	$("#pagenav").css("display","block");
	e=$(e);
	e.parent().find(".on").removeClass("on");
	e.addClass("on");
	var minn = e.attr("in");
	var maxn = e.attr("maxin");
	$("#hotLive").html("");
	$.get("/Handle/GetRoomList.asp",{ac:"GetRoomList",top:96,ps:16,inum:minn,maxin:maxn,t:GetSendTime},function(){
		var dataObj = eval("("+RoomListRe+")");
		$.each(dataObj.data,function(i,e){
			if(e.roompic==""){e.roompic="/images/defaultroompic.jpg";}
			if(parseInt(e.onlinenum)>parseInt(e.maxnum)){e.onlinenum=e.maxnum;}
			if(e.islive!=""&&parseInt(e.islive)>2){e.livetime='直播已结束';}else{e.livetime='<font color=red>'+e.livetime+'</font>';}
			$("#hotLive").append($.format(tRoomListStr,e.onlinenum,e.maxnum,e.roomid,e.roompic,e.incomeclass,e.usernick,e.livetime,e.IDCType,e.isHiFi=="1"?"":"hide"));
		});
		$("#hotLiveMore").css("display","none");
		SetPageNav(dataObj);
	},"script");
}

function getrecord(p)
{
	$("#pagenav").css("display","block");
	var e=$("#hotLiveMore");
	var minn = e.attr("in");
	var maxn = e.attr("maxin");
	$("#hotLive").html("");
	$.get("/Handle/GetRoomList.asp",{ac:"GetRoomList",top:96,ps:16,page:p,inum:minn,maxin:maxn,t:GetSendTime},function(){
		var dataObj = eval("("+RoomListRe+")");
		$.each(dataObj.data,function(i,e){
			if(e.roompic==""){e.roompic="/images/defaultroompic.jpg";}
			if(parseInt(e.onlinenum)>parseInt(e.maxnum)){e.onlinenum=e.maxnum;}
			if(e.islive!=""&&parseInt(e.islive)>2){e.livetime='直播已结束';}else{e.livetime='<font color=red>'+e.livetime+'</font>';}
			$("#hotLive").append($.format(tRoomListStr,e.onlinenum,e.maxnum,e.roomid,e.roompic,e.incomeclass,e.usernick,e.livetime,e.IDCType,e.isHiFi=="1"?"":"hide"));
		});
		$("#hotLiveMore").css("display","none");
		SetPageNav(dataObj);
	},"script");
}


function rClassList(e)
{
	e=$(e);
	$("#pagenav").css("display","none");
	$(".kuainan").find(".on").removeClass("on");
	//e.parent().find(".on").removeClass("on");
	e.addClass("on");
	var cid = e.attr("cid");
	$("#hotLive").html("");
	$.get("/Handle/GetRoomList.asp",{ac:"GetRoomListByClass",top:32,ps:60,classid:cid,t:GetSendTime},function(){
		var dataObj = eval("("+RoomListRe+")");
		$.each(dataObj.data,function(i,e){
			if(e.roompic==""){e.roompic="/images/defaultroompic.jpg";}
			if(parseInt(e.onlinenum)>parseInt(e.maxnum)){e.onlinenum=e.maxnum;}
			if(e.islive!=""&&parseInt(e.islive)>2){e.livetime='直播已结束';}else{e.livetime='<font color=red>'+e.livetime+'</font>';}
			$("#hotLive").append($.format(tRoomListStr,e.onlinenum,e.maxnum,e.roomid,e.roompic,e.incomeclass,e.usernick,e.livetime,e.IDCType,e.isHiFi=="1"?"":"hide"));
		});
		$("#hotLiveMore").css("display","none");
	},"script");
}


function rClassListBySearch()
{
	$("#pagenav").css("display","none");
	var e=$('#SearchKey').attr("value");
	$("#hotLive").html("");
	$.get("/Handle/GetRoomList.asp",{ac:"GetRoomListBySearch",top:60,ps:60,key:e,t:GetSendTime},function(){
		var dataObj = eval("("+RoomListRe+")");
		$.each(dataObj.data,function(i,e){
			if(e.roompic==""){e.roompic="/images/defaultroompic.jpg";}
			if(parseInt(e.onlinenum)>parseInt(e.maxnum)){e.onlinenum=e.maxnum;}
			if(e.islive!=""&&parseInt(e.islive)>2){e.livetime='直播已结束';}else{e.livetime='<font color=red>'+e.livetime+'</font>';}
			$("#hotLive").append($.format(tRoomListStr,e.onlinenum,e.maxnum,e.roomid,e.roompic,e.incomeclass,e.usernick,e.livetime,e.IDCType,e.isHiFi=="1"?"":"hide"));
		});
		$("#hotLiveMore").css("display","none");
	},"script");
}
function rlist_top(e)
{
	$("#pagenav").css("display","none");
	e=$(e);
	e.parent().find(".on").removeClass("on");
	e.addClass("on");
	$("#hotLive").html("");
	$.get("/Handle/GetRoomList.asp",{ac:"GetRoomTopList",top:60,ps:60,t:GetSendTime},function(){
		var dataObj = eval("("+RoomListRe+")");
		$.each(dataObj.data,function(i,e){
			if(e.roompic==""){e.roompic="/images/defaultroompic.jpg";}
			if(parseInt(e.onlinenum)>parseInt(e.maxnum)){e.onlinenum=e.maxnum;}
			if(e.islive!=""&&parseInt(e.islive)>2){e.livetime='直播已结束';}else{e.livetime='<font color=red>'+e.livetime+'</font>';}
			$("#hotLive").append($.format(tRoomListStr,e.onlinenum,e.maxnum,e.roomid,e.roompic,e.incomeclass,e.usernick,e.livetime,e.IDCType,e.isHiFi=="1"?"":"hide"));
		});
		$("#hotLiveMore").css("display","none");
	},"script");
}


function rlist_Recommend()
{
	$("#pagenav").css("display","none");
	$("#Recommend").html("");
	$.get("/Handle/GetRoomList.asp",{ac:"GetRoomTopList",top:2,ps:2,t:GetSendTime},function(){
		var RdataObj = eval("("+RoomListRe+")");
		$.each(RdataObj.data,function(i,e){
			if(e.roompic==""){e.roompic="/images/defaultroompic.jpg";}
			if(parseInt(e.onlinenum)>parseInt(e.maxnum)){e.onlinenum=e.maxnum;}
			if(e.islive!=""&&parseInt(e.islive)>2){e.livetime='直播已结束';}else{e.livetime='<font color=red>'+e.livetime+'</font>';}
			$("#Recommend").append($.format(tRecommendListStr,e.onlinenum,e.maxnum,e.roomid,e.roompic,e.incomeclass,e.usernick,e.livetime,e.IDCType,e.isHiFi=="1"?"":"hide"));
		});
	},"script");
}


function pageto(i)
{
	$("#pagenav")[0].innerHTML="";
	getrecord(i);
}

function SetPageNav(dataObj)
{
	var PageNav = $("#pagenav")[0];
	if(dataObj.currentpage>1)
	{
		PageNav.innerHTML+=$.format(" <a href='javascript:void(0)' onclick='pageto({0})'> 上一页 </a> ",dataObj.currentpage-1);
	}
	for(i=1;i<dataObj.pagenum+1;i++)
	{
		PageNav.innerHTML+=dataObj.currentpage==i?" "+i+" ":$.format(PageNavFormatStr,i);
	}
	if(dataObj.pagenum>dataObj.currentpage)
	{
		PageNav.innerHTML+=$.format(" <a href='javascript:void(0)' onclick='pageto({0})'> 下一页 </a> ",dataObj.currentpage+1);
	}
}

var tRoomListStr='<li><div class="l"><p class="pic"><em class="state"><img class="hifi {8}" src="/images/pixel.gif" title="高保真"></em><em class="rc">{0}/{1}</em><a href="/{2}" target="_blank"><img src="{3}"></a></p><p class="point"><img class="{4} userLevelSmall" src="/images/pixel.gif"><a href="/{2}" target="_blank">{5}【{7}房】</a></p><p class="t"><span>开播:</span><em class="hit">{6}</em></p></div></li>';
var tNoticeList='<li><a target="_blank" href="{0}">{1}</a></li>';
var tTopStr='<li><div class="l"><a target="_blank" href="/{0}">{1}</a><strong class="hit">({0})</strong></div><div class="r"><img src="/images/pixel.gif" class="{2} userLevelSmall"></div></li>';
var tRecommendListStr='<li id="emcee_1" class=""><a target="_blank" href="/{2}"><img src="{3}"></a><div class="bigbg" style="display: none;"></div><div class="text"><p><span>{0}</span>人</p><a target="_blank" title="{5}" href="/{2}">{5}【{7}房】</a></div></li>';
var tRoomClassList='<a href="javascript:void(0)" onclick="rClassList(this)" cid="{0}">{1}<em></em></a>';
var PageNavFormatStr=" <a href='javascript:void(0)' onclick='pageto({0})'> {0} </a> ";

$(function(){
	//onlinenum,maxnum,roomid,roompic,incomeclass,usernick,livetime
	$.get("/Handle/GetRoomList.asp",{ac:"GetRoomList",top:12,ps:20,inum:0,maxin:999900000,t:GetSendTime},function(){
		var dataObj = eval("("+RoomListRe+")");
		$.each(dataObj.data,function(i,e){
			if(e.roompic==""){e.roompic="/images/defaultroompic.jpg";}
			if(parseInt(e.onlinenum)>parseInt(e.maxnum)){e.onlinenum=e.maxnum;}
			if(e.islive!=""&&parseInt(e.islive)>2){e.livetime='直播已结束';}else{e.livetime='<font color=red>'+e.livetime+'</font>';}
			$("#hotLive").append($.format(tRoomListStr,e.onlinenum,e.maxnum,e.roomid,e.roompic,e.incomeclass,e.usernick,e.livetime,e.IDCType,e.isHiFi=="1"?"":"hide"));
		});
	},"script");
	$.get("/Handle/GetNotice.asp",{ac:"GetNotice",top:50,ps:50,t:GetSendTime},function(){
		var NdataObj = eval("("+NoticeRe+")");
		$.each(NdataObj.data,function(i,e){
			$("#NoticeList").append($.format(tNoticeList,e.noticehref,e.noticename));
		});
	},"script");
	$.get("/Handle/GetRoomClass.asp",{ac:"GetRoomClass",top:10,ps:10,t:GetSendTime},function(){
		var CdataObj = eval("("+RClassRe+")");
		$.each(CdataObj.data,function(i,e){
			
			var tRe='<dl class="kuainan">';
			tRe=tRe+$.format('<dt><a href="javascript:void(0)" class="on">{0}<em></em><img src="/images/pixel.gif"></a></dt>',e.cname)
				tRe=tRe+'<dd id="iRoomClass">';
				$.each(e.child,function(j,o){
					tRe=tRe+$.format(tRoomClassList,o.cid,o.cname);
				});
				tRe=tRe+'</dd>';
			tRe=tRe+'</dl>';
			$("#AfterRoomClassList").after(tRe);
		});
		$('.col1 dl dt').each(function()
		{
			$(this).click(function(){
				if(!this.parentNode.getElementsByTagName('DD').length>0)return ;
				var alink=this.getElementsByTagName('A')[0];
				var state=alink.className!='on'?true:false;
				alink.className=state?'on':'';
				this.parentNode.getElementsByTagName('DD')[0].style.display=state?'block':'none';			
			});
		});
	},"script");
	
	////
});
rlist_Recommend();
CD1();
function CD1()
{
	//toplist day
	if(typeof(TopListReDay)!="undefined")
	{
		var DayObj = eval("("+TopListReDay+")");
		var Ct = DayObj.CreatTime;
		if(countTimeLength('M',Ct,nowTime())>60*24)
		{
			GetAjaxTopList1("Day");
			return false;
		}
		$.each(DayObj.data,function(i,e){
			$("#TopListOne").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
		$.each(DayObj.datatwo,function(i,e){
			$("#TopListTwo").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
	}
	else
	{
		GetAjaxTopList1("Day");
	}
}
function CD(y,c)
{
	//toplist day
	if(typeof(TopListReDay)!="undefined")
	{
		var DayObj = eval("("+TopListReDay+")");
		var Ct = DayObj.CreatTime;
		if(countTimeLength('M',Ct,nowTime())>60*24)
		{
			GetAjaxTopList1("Day");
			return false;
		}
		if(y){
		$("#TopListOne").html("");
		$.each(DayObj.data,function(i,e){
			$("#TopListOne").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
		}
		else{
		$("#TopListTwo").html("");
		$.each(DayObj.datatwo,function(i,e){
			$("#TopListTwo").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});}
	}
	else
	{
		GetAjaxTopList1("Day");
	}
	$(c).parent().parent().find(".on").removeClass("on");
	$(c).addClass("on");
}

function CW(y,c)
{
	//toplist week
	if(typeof(TopListReWeek)!="undefined")
	{
		var WeekObj = eval("("+TopListReWeek+")");
		var Ct = WeekObj.CreatTime;
		if(countTimeLength('M',Ct,nowTime())>60*24*7)
		{
			GetAjaxTopList2("Week");
			return false;
		}
		if(y){
		$("#TopListOne").html("");
			$.each(WeekObj.data,function(i,e){
				$("#TopListOne").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
			});
		}
		else{
		$("#TopListTwo").html("");
			$.each(WeekObj.datatwo,function(i,e){
				$("#TopListTwo").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
			});
		}
	}
	else
	{
		GetAjaxTopList2("Week");
	}
	$(c).parent().parent().find(".on").removeClass("on");
	$(c).addClass("on");
}

function CM(y,c)
{
	//toplist month
	if(typeof(TopListReMonth)!="undefined")
	{
		var MonthObj = eval("("+TopListReMonth+")");
		var Ct = MonthObj.CreatTime;
		if(countTimeLength('M',Ct,nowTime())>60*24*30)
		{
			GetAjaxTopList3("Month");
			return false;
		}
		if(y){
		$("#TopListOne").html("");
			$.each(MonthObj.data,function(i,e){
				$("#TopListOne").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
			});
		}
		else{
		$("#TopListTwo").html("");
			$.each(MonthObj.datatwo,function(i,e){
				$("#TopListTwo").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
			});
		}
	}
	else
	{
		GetAjaxTopList3("Month");
	}
	$(c).parent().parent().find(".on").removeClass("on");
	$(c).addClass("on");
}

function CS(y,c)
{
	//toplist supper
	if(typeof(TopListReSupper)!="undefined")
	{
		var SupperObj = eval("("+TopListReSupper+")");
		var Ct = SupperObj.CreatTime;
		if(countTimeLength('M',Ct,nowTime())>60*24*7)
		{
			GetAjaxTopList4("Supper");
			return false;
		}
		if(y){
		$("#TopListOne").html("");
			$.each(SupperObj.data,function(i,e){
				$("#TopListOne").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
			});
		}
		else{
		$("#TopListTwo").html("");
			$.each(SupperObj.datatwo,function(i,e){
			$("#TopListTwo").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
			});
		}
	}
	else
	{
		GetAjaxTopList4("Supper");
	}
	$(c).parent().parent().find(".on").removeClass("on");
	$(c).addClass("on");
}

function GetAjaxTopList1(str)
{
	$.get("/f/CreatTopUser.asp",{ac:str,t:GetSendTime},function(){
		var DayObj = eval("("+TopListReDay+")");
		$("#TopListOne").html("");
		$.each(DayObj.data,function(i,e){
			$("#TopListOne").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
		$("#TopListTwo").html("");
		$.each(DayObj.datatwo,function(i,e){
			$("#TopListTwo").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
	},"script");
}

function GetAjaxTopList2(str)
{
	$.get("/f/CreatTopUser.asp",{ac:str,t:GetSendTime},function(){
		var WeekObj = eval("("+TopListReWeek+")");
		$("#TopListOne").html("");
		$.each(WeekObj.data,function(i,e){
			$("#TopListOne").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
		$("#TopListTwo").html("");
		$.each(WeekObj.datatwo,function(i,e){
			$("#TopListTwo").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
	},"script");
}

function GetAjaxTopList3(str)
{
	$.get("/f/CreatTopUser.asp",{ac:str,t:GetSendTime},function(){
		var MonthObj = eval("("+TopListReMonth+")");
		$("#TopListOne").html("");
		$.each(MonthObj.data,function(i,e){
			$("#TopListOne").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
		$("#TopListTwo").html("");
		$.each(MonthObj.datatwo,function(i,e){
			$("#TopListTwo").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
	},"script");
}

function GetAjaxTopList4(str)
{
	$.get("/f/CreatTopUser.asp",{ac:str,t:GetSendTime},function(){
		var SupperObj = eval("("+TopListReSupper+")");
		$("#TopListOne").html("");
		$.each(SupperObj.data,function(i,e){
			$("#TopListOne").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
		$("#TopListTwo").html("");
		$.each(SupperObj.datatwo,function(i,e){
			$("#TopListTwo").append($.format(tTopStr,e.roomid,e.nick,e.iclass));
		});
	},"script");
}

function LoadAcc()
{
	GuideFlash(false);
	$(".viewCount").css("display","");
}

function SetAllUserNum(e)
{
	$("#SumUserNum").text(formatNum(e));
}

function GuideFlash(e)
{
	if(e)
	{
		var strtime = getDataTimes();
		var swfVersionStr = "11.1.0";
		var xiSwfUrlStr = "/swf/playerProductInstall.swf";
		var flashvars = {};
		var params = {};
		params.quality = "high";
		params.wmode = "transparent";//transparent";
		var u = navigator.userAgent;
		if(u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) || (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1))
		{
			//params.wmode = "Window";
		}
		params.bgcolor = "#ffffff";
		params.allowscriptaccess = "sameDomain";
		params.allowfullscreen = "true";
		var attributes = {};
		attributes.id = "iFlashGuide";
		attributes.name = "iFlashGuide";
		attributes.align = "middle";
		swfobject.embedSWF("/swf/Guide.swf?"+strtime, "TFlashGuideDiv","100%", "100%", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
	}
	else
	{
		$("#FlashGuideDiv").css({width:"1px",height:"1px"});
	}
}

function LargeGuide()
{
	return ;
	var bc = $("#FlashGuideDiv").css("background");
	$("#FlashGuideDiv").css("background","none");
	$("#FlashGuideDiv").css({width:"100%",height:"100%"});
	$("#FlashGuideDiv").css("background",bc);
}

function formatNum(num) 
{
  if(!/^(\+|-)?\d+(\.\d+)?$/.test(num)){return num;}
  var re = new RegExp().compile("(\\d)(\\d{3})(,|\\.|$)");
  num += ""; 
  while(re.test(num))
    num = num.replace(re, "$1,$2$3")
  return num;
} 


$(function(){
	if(window.location.search.substr(1)=="rlist_top")
	{
		$("#rlist_top_bt").click();
	}
	$("#InTop a:last").click();
	$("#PayTop a:last").click();	
});