﻿var digupPage=1,digupChannel='ALL',digupTab=1,digupTime=1,digupOrder='';$.fn.showDigList=function(){this.each(function(){var t=this;$.ajax({url:'/util/ajax/wm_index.asp?page='+digupPage+'&channel='+digupChannel+'&tab='+digupTab+'&time='+digupTime+'&order='+digupOrder,success:function(msg){$(t).html(msg).removeClass('loading').fadeIn(600).find('.dig').tudouDig();$('.bury').remove();intBury();}});$(this).html('节目正从田里取出来中...').addClass('loading');});}
function show_tab(t,n){digupTab=n;$(t).parent().parent().find('li').removeClass('nav_tabs_active');$(t).parent().addClass('nav_tabs_active');$('#tudouDig .clipList').hide();$($(t).rel()).fadeIn();if(!$($(t).rel()).html())
digup_page();}
function digup_page(n){if(typeof n!='undefined')
digupPage=n;try{$('.digup_sort a').removeClass('current');$('.digup_sort a:nth-child('+(digupTime-1)+')').addClass('current');$(this).addClass('current');}catch(e){}
$(digupTab==2?'#tab_waitingList':'#tab_dugList').showDigList();}

function intDigQuick(){
try{
	m=digupTab==2?'#tab_waitingList':'#tab_dugList';
	var q = $.cookie("quickListClips");
	if (q==null) {
		var n=0;
		q="";
	}
	$(m+" .pack_clipImg").parent().wrap("<div></div>").parent().prepend("<div class='quickBtn'><a href='javascript://' title='添加到便利点播单'></a></div>").addClass("quickList");
	$(m+" .pack_clipImg").hover(
		function(){ $(this).parent().prev().addClass("quickBtnAhover") },
		function(){ $(this).parent().prev().removeClass("quickBtnAhover") }
	)
	$(m+" .quickBtn a").each(function(){
		var code=$(this).parent().next("a").href().replace(/.*\/([^\/]+)\//g,"$1");
		var index = q.indexOf(code);
		if (index >=0)
			$(this).title("播放便利点播单").parent().toggleClass("quickAdded");
		$(this).click(function(){
			if (toggleQuick(code,null)) {
				$(this).title("播放便利点播单").parent().toggleClass("quickAdded");
			}
		})
	})
}catch(e){}
}
function intBury(){
	var i=100;
	$("#digs .pack_clip").each(function(){
		$(this).css("z-index",i);i=i-1;
	})
	$(".buryingBtn > a").click(function(){
		var a = $(this);
		if((typeof isGuest!='undefined' && isGuest) || (typeof uid!='undefined' && uid<=0)){
			return confirm('你还没登录呢，是否现在登录？')
		}else{
			 $(this).next().show();
		}
		return false;
	})
	$(".burying").click(function(){
		var b=$(this);
		$.get("/util/ajax/wm_ops.asp?action=m&itemID="+b.rel() , function(){
			b.parent().parent().html("埋掉了");
		})
	});
	$(".dropBurying").click(function(){
		$(this).parent().hide().prev().show();
	});
	$(".burying div a").click(function(){
		var b=$(this);
		$.get("/util/ajax/wm_ops.asp?action=m&itemID="+b.rel() , function(){
			b.parent().parent().html("埋掉了");
		})
	});
	$(".dropBurying").click(function(){
		$(this).parent().hide().prev().show();
	});

	intDigQuick();
	//$("#tudouDig .pack_clip").hoverClass("pack_clipHover");
}

$(function(){
	//setTimeout(intDigList,250);
	$('#tab_dugList').showDigList();
	//$('#recoClip a').each(function(){
		//if(this.href.match(/programs\/view/i)){
			//this.href+='?is_rec';
		//}
	//});
})