
var arrowimages={down:['downarrowclass','images/arrow-down.gif',25],right:['rightarrowclass','images/arrow-right.gif']}
var tvbHeader={changeSearchSelection:function(id,name){$("#hd-search-selected-search-type").html(name);$("#selSS").attr("value",id);$("#hd-search-selected-search-type-list").fadeOut(tvbHeaderMenu.fadesettings.outduration);}}
var tvbHeaderMenu={fadesettings:{overduration:350,outduration:100},buildmenu:function(menuid,arrowsvar){jQuery(document).ready(function($){var $mainmenu=$("#"+menuid+">ul")
var $headers=$mainmenu.find("ul").parent()
$headers.each(function(i){var $curobj=$(this)
var $subul=$(this).find('ul:eq(0)')
this._dimensions={w:this.offsetWidth,h:this.offsetHeight,subulw:$subul.outerWidth(),subulh:$subul.outerHeight()}
this.istopheader=$curobj.parents("ul").length==1?true:false
$subul.css({top:this.istopheader?this._dimensions.h+"px":0})
$curobj.children("a:eq(0)").css(this.istopheader?{paddingRight:arrowsvar.down[2]}:{}).append('<img src="'+(this.istopheader?arrowsvar.down[1]:arrowsvar.right[1])
+'" class="'+(this.istopheader?arrowsvar.down[0]:arrowsvar.right[0])
+'" style="border:0;" />')
$curobj.hover(function(e){var $targetul=$(this).children("ul:eq(0)")
this._offsets={left:$(this).offset().left,top:$(this).offset().top}
var menuleft=this.istopheader?0:this._dimensions.w
menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())?(this.istopheader?-this._dimensions.subulw+this._dimensions.w:-this._dimensions.w):menuleft
$targetul.css({left:(menuleft-1)+"px"}).fadeIn(tvbHeaderMenu.fadesettings.overduration)},function(e){$(this).children("ul:eq(0)").fadeOut(tvbHeaderMenu.fadesettings.outduration)})})
$mainmenu.find("ul").css({display:'none',visibility:'visible'})})}}
function check_set_homepage()
{if(document.all)
{return true;}
return false;}
function set_homepage()
{var url="http://www.tvb.com";if(document.all)
{document.body.style.behavior='url(#default#homepage)';document.body.setHomePage(url);}}
function clearBlank(what)
{if(what.value=="輸入搜尋字")
{what.value="";}}
function fillBlank(what)
{if(what.value=='')
{what.value="輸入搜尋字";}}
function validate(what)
{if(what.q.value=="輸入搜尋字")
{return false;}}
function prefillQ(what)
{if(what)document.getElementById("global_topnav_search_text").value=what;}
function preselectSS(what)
{if(what==1)document.getElementById("selSS").selectedIndex=0;else if(what==2)document.getElementById("selSS").selectedIndex=1;else if(what==3)document.getElementById("selSS").selectedIndex=2;else document.getElementById("selSS").selectedIndex=3;}
function selectChange(obj)
{var val=0;$("#selSS").attr("value",obj[obj.selectedIndex].value);}
function setTag(what)
{if(what)
{document.getElementById("tag_v").value=what;document.getElementById("frm-tag").submit();}}
$(document).ready(function(){$("#mpm").fpmpm();$("#whatsnew-module-container .whatsnew-module-content").liroller({auto_crop:true});$("#programme-highlight .pp-module-row-container").liroller({direction:"left"});try{tvbHeaderMenu.buildmenu("hd-search-dropdown",arrowimages);var select_value=$("#selSS").attr("value");var selected_index=parseInt(select_value)-1;if(selected_index<0)
select_value=3;switch($.url.attr("host"))
{case"forum.tvb.com":tvbHeader.changeSearchSelection(3,"討論區&nbsp;");break;case"blog.tvb.com":tvbHeader.changeSearchSelection(2,"藝人Blog");break;}}catch(e){}
$(".artiste-module-container .artiste-module-tab").hover(function(){$(this).removeClass("artiste-module-tab-off");$(this).addClass("artiste-module-tab-on");switch($(this).attr("id"))
{case"artiste-module-type1":$("#artiste-module-type2").removeClass("artiste-module-tab-on");$("#artiste-module-type2").addClass("artiste-module-tab-off");$("#artiste-module-type2-wrapper").css("display","none");$("#artiste-module-type1-wrapper").css("display","block");break;case"artiste-module-type2":$("#artiste-module-type1").removeClass("artiste-module-tab-on");$("#artiste-module-type1").addClass("artiste-module-tab-off");$("#artiste-module-type1-wrapper").css("display","none");$("#artiste-module-type2-wrapper").css("display","block");break;}},function(){});$(".mahjong[link]").click(function(){window.location=$(this).attr("link");})
if($(window).width()<1030)
{$(".weather_warning_icon").css("display","none");}});(function($){$.fn.fpmpm=function(opts){container=$(this);var default_opts={in_duration:200,out_duration:300};var option=$.extend(default_opts,opts);$(".mpm-item:not(.mpm-empty-item)",$(container)).hover(function(){$(this).stop();$(this).animate({opacity:"0.8"},option.in_duration);},function(){$(this).stop();$(this).animate({opacity:"1"},option.out_duration);})
return(this);}})(jQuery);(function($){$.fn.liroller=function(opts){var container=$(this);var rotation_interval=null;var default_opts={interval:3000,animate_duration:1000,auto_crop:false,max_trim_char:5,bounce_effect:"",direction:"up"};var option=$.extend(default_opts,opts);var h_padding=0;var v_padding=0;var cwidth=container.width();function trim(ele)
{var cnt=0;var val=$(ele).html();var twidth=$(ele).width();while(twidth>(cwidth-25))
{val=val.substring(0,(val.length-1));$(ele).html(val);twidth=$(ele).width();cnt++;if(cnt>option.max_trim_char)
break;}
if(cnt>0)
{$(ele).html(val+"...");}}
if(typeof(option.auto_crop)!="undefined"&&option.auto_crop)
{$("li > a",container).each(function(){trim(this);});}
function post_rotate()
{if(option.direction=="up")
{$("li:nth-child(1)",container).remove();$("ul",container).css("top","0px");}
else if(option.direction=="down")
{$("li:last-child",container).remove();$("ul",container).css("bottom",(v_padding*(-1))+"px");}
else if(option.direction=="left")
{$("li:nth-child(1)",container).remove();$("ul",container).css("left","0px");}
start();}
function rotate()
{var position=$("ul",container).position();if(option.direction=="up")
{$("li:nth-child(1)",container).clone().appendTo($("ul",container));$("ul",container).animate({top:(position.top-$("li:nth-child(1)",container).height())+"px"},option.animate_duration,option.bounce_effect,post_rotate);}
else if(option.direction=="down")
{var ele=$("li:last-child",container).clone();$("li:nth-child(1)",container).before(ele);$("ul",container).animate({bottom:(($("li:nth-child(1)",container).height()+(v_padding*2))*(-1))+"px"},option.animate_duration,option.bounce_effect,posy_rotate);}
else if(option.direction=="left")
{$("li:nth-child(1)",container).clone().appendTo($("ul",container));$("ul",container).animate({left:(position.left-$("li:nth-child(1)",container).width())+"px"},option.animate_duration,option.bounce_effect,post_rotate);}}
function start()
{stop();rotation_interval=setTimeout(rotate,option.interval);}
function stop()
{if(rotation_interval!=null)
clearTimeout(rotation_interval);}
container.css("position","relative");$("ul",container).css("position","absolute");v_padding+=(parseInt($("li:first-child",container).css("padding-top"))+parseInt($("li:first-child",container).css("padding-bottom")));h_padding+=(parseInt($("li:first-child",container).css("padding-top"))+parseInt($("li:first-child",container).css("padding-bottom")));var is_valid_for_scroll=false;if(option.direction=="up")
{$("ul",container).css("top","0px");if($("ul",container).height()>container.height())
is_valid_for_scroll=true;}
else if(option.direction=="down")
{$("ul",container).css("bottom",(v_padding*(-1))+"px");if($("ul",container).height()>container.height())
is_valid_for_scroll=true;}
else if(option.direction=="left")
{$("ul",container).css("left","0px");var kids=$("ul",container).children();var kid_width=0;if(kids.length>0)
{kid_width=$(kids[0]).width();}
$("ul",container).css("width",(kid_width*(kids.length)+0)+"px");if($("ul",container).width()>(container.width()+10))
is_valid_for_scroll=true;}
if(is_valid_for_scroll)
{$(container).hover(function(event){stop();},function(event){start();})
start();}
return(this);}})(jQuery);