var VoiceTV={base_url:"",init:function(){VoiceTV.Debug.init();VoiceTV.MessageBox.init()},alert:function(a,b){VoiceTV.MessageBox.alert(a)}};VoiceTV.MessageBox={init:function(){$("body").append("<div style='display: none;'><div id='fancy_box_message' ></div></div><a id='fancy_box_link'  href='#fancy_box_message' >as</a>");$("#fancy_box_link").fancybox({titlePosition:"inside",transitionIn:"none",transitionOut:"none",hideOnOverlayClick:false,centerOnScroll:true})},alert:function(a){$("#fancy_box_link").attr("href","#fancy_box_message");$("#fancy_box_message").html(a);$("#fancy_box_link").trigger("click")},openUrl:function(a){$("#fancy_box_link").attr("href",a);$("#fancy_box_link").trigger("click")}};VoiceTV.Debug={enable:1,init:function(){$(document).bind("keydown","shift+d",function(){VoiceTV.Debug.toggleDebug()})},toggleDebug:function(){$(".debug").toggle($(".debug").eq(0).css("display")=="none");$(".yiiLog").toggle($(".yiiLog").eq(0).css("display")=="none")},put:function(a){$(".debug").html(a)}};VoiceTV.Profile={};VoiceTV.Profile.Tooltip={cache:null,init:function(){this.cache=new Array();$(".profile_tooltip").tooltip({onBeforeShow:function(){var a=this.getTrigger().attr("rel");if(jQuery.inArray(a,VoiceTV.Profile.Tooltip.cache)==-1){VoiceTV.Profile.Tooltip.cache.push(a);this.getTip().text("loading...");VoiceTV.Profile.Tooltip.loadProfileTooltip(a,this.getTip())}},effect:"slide",position:"top right",delay:100}).dynamic({bottom:{direction:"down",bounce:true}})},loadProfileTooltip:function(a,b){$.ajax({url:VoiceTV.base_url+"/user/ajaxProfileTooltip/?user="+a,success:function(c){b.html(c);$(".profile_tooltip[rel*='"+a+"'] ").each(function(d,e){$(e).parent().parent().find(".tooltip").html(c)})}})}};VoiceTV.Home={};VoiceTV.Home.ShowsBox={move:-15,zoom:1.2,init:function(a){this.assignElement(a)},assignElement:function(b){var a=VoiceTV.Home.ShowsBox.move;var c=VoiceTV.Home.ShowsBox.zoom;$(b).find("div.content_detail").hide();$(b).hover(function(){width=$(b).width()*c;height=$(b).height()*c;$(this).find("img").stop(false,true).animate({width:width,height:height,top:a,left:a},{duration:200});$(this).find("div.content_detail").stop(false,true).fadeIn(200)},function(){$(this).find("img").stop(false,true).animate({width:$(b).width(),height:$(b).height(),top:"0",left:"0"},{duration:100});$(this).find("div.content_detail").stop(false,true).fadeOut(200)})}};VoiceTV.Home.Highlight={init:function(){this.initSlideShow()},initSlideShow:function(){var a={next:$("#lofslidecontent45 .lof-previous"),previous:$("#lofslidecontent45 .lof-next")};var b=500;$obj=$("#lofslidecontent45").lofJSidernews({interval:4000,direction:"opacity",easing:"easeInOutExpo",duration:1200,auto:true,pauseWhenHover:true,maxItemDisplay:6,navPosition:"horizontal",navigatorHeight:65,navigatorWidth:95,mainWidth:960,buttons:a});$("#lofslidecontent45").hover(function(){if(!$.browser.msie){$(this).find(".lof-main-item-desc").fadeIn(b)}else{$(this).find(".lof-main-item-desc").show()}},function(){if(!$.browser.msie){$(this).find(".lof-main-item-desc").fadeOut(b)}else{$(this).find(".lof-main-item-desc").hide()}})}};VoiceTV.Life={animationSpeed:500,init:function(){VoiceTV.Life.Highlight.init();this.initShowBox()},initShowBox:function(){$(".show_box .content .caption").fadeOut(VoiceTV.Life.animationSpeed);$(".show_box .content").hover(function(){if(!$.browser.msie){$(this).find(".caption").fadeIn(VoiceTV.Life.animationSpeed)}else{$(this).find(".caption").show()}},function(){if(!$.browser.msie){$(this).find(".caption").fadeOut(VoiceTV.Life.animationSpeed)}else{$(this).find(".caption").hide()}})}};VoiceTV.Life.Highlight={init:function(){this.initSlideShow()},initSlideShow:function(){var a={next:$("#highlight .lof-previous"),previous:$("#highlight .lof-next")};var b=500;$obj=$("#highlight").lofJSidernews({interval:4000,direction:"opacity",easing:"easeInOutExpo",duration:1200,auto:true,maxItemDisplay:5,navPosition:"vertical",navigatorHeight:44,navigatorWidth:73,mainWidth:390,buttons:a});$("#highlight").hover(function(){if(!$.browser.msie){$(this).find(".lof-main-item-desc").fadeIn(b)}else{$(this).find(".lof-main-item-desc").show()}},function(){if(!$.browser.msie){$(this).find(".lof-main-item-desc").fadeOut(b)}else{$(this).find(".lof-main-item-desc").hide()}})}};VoiceTV.News={init:function(){VoiceTV.News.Highlight.init();this.initGallery();VoiceTV.News.Breaking.init();VoiceTV.News.Onair.init();VoiceTV.Wheather.init()},initGallery:function(){$("#mycarousel").jcarousel({scroll:3});$().piroBox({my_speed:400,bg_alpha:0.1,slideShow:true,slideSpeed:4,close_all:".piro_close,.piro_overlay"})}};VoiceTV.Wheather={init:function(){$.get(VoiceTV.base_url+"/news/wheather",function(a){$("#wheather").html(a)})}};VoiceTV.News.Onair={init:function(){this.refresh()},refresh:function(){$.get(VoiceTV.base_url+"/schedule/now",function(a){$(".incoming_news .onair .details").html(a)});setTimeout("VoiceTV.News.Onair.refresh()",60000)}};VoiceTV.News.Breaking={animationSpeed:500,currentIndex:0,refreshDataInterval:5000,init:function(){VoiceTV.News.Breaking.loadBreakingNews(function(){$("div.scrollingtext").carousel({autoSlide:true,direction:"vertical",slideEasing:"easeOutBounce",autoSlideInterval:5000,loop:true})})},loadBreakingNews:function(a){$.get(VoiceTV.base_url+"/breakingNews/index",function(b){$("#breaking_news_list").html(b);if(a){a()}})},refresh:function(){this.loadBreakingNews();setTimeout("VoiceTV.News.Breaking.refresh()",VoiceTV.News.Breaking.refreshDataInterval)}};VoiceTV.News.Highlight={init:function(){this.initSlideShow()},initSlideShow:function(){var a={next:$("#lofslidecontent45 .lof-previous"),previous:$("#lofslidecontent45 .lof-next")};var b=500;$obj=$("#lofslidecontent45").lofJSidernews({interval:4000,direction:"opacity",easing:"easeInOutExpo",duration:1200,auto:true,maxItemDisplay:6,navPosition:"horizontal",navigatorHeight:65,navigatorWidth:95,mainWidth:960,buttons:a});$("#lofslidecontent45").find(".lof-main-item-desc").show()}};VoiceTV.Util={initBlockQuoteStyle:function(){$("blockquote").each(function(a,b){$(b).html("<div class='inner' >"+$(b).html()+"</div>")})},initExampleText:function(a,b){$(a).val(b);$(a).css("color","#999");$(a).focus(function(){if($(a).val()==b){$(a).val("")}$(a).css("color","#000")});$(a).blur(function(){if($(a).val()==""){$(a).val(b);$(a).css("color","#999")}})},ajaxloading:function(a){$(a).css("position","relative");$(a).append($("<div></div").addClass("ajaxloading").css("width",$(a).width()).css("height",$(a).height()))},removeAjaxloading:function(a){$(a+" .ajaxloading").css("display","none")}};VoiceTV.Content={contentViewInit:function(){VoiceTV.Util.initBlockQuoteStyle();VoiceTV.Profile.Tooltip.init();$(".media_embed").each(function(a,b){if($(b).find("embed").html()!=null){$(b).find("embed").attr("wmode","transparent")}if($(b).find("object").html()!=null){$(b).find("object").append("<param name='wmode' value='transparent' /> ")}$(b).show()});$(".embed textarea").hover(function(){$(this).focus();$(this).select()});$("#content_view .text .description img").each(function(b,c){var a=$(c).attr("src");var d=document.title;$(c).wrap('<a title="'+d+'" class="pirobox_gall" href="'+a+'" />')});$().piroBox({my_speed:400,bg_alpha:0.1,slideShow:true,slideSpeed:4,close_all:".piro_close,.piro_overlay"});$("#more_gallery").toggle(function(){$("#piroBox").animate({height:$("#piroBoxList").height()},1000)},function(){$("#piroBox").animate({height:77},1000)});VoiceTV.Util.initExampleText("#comment_box","Add a comment");$("abbr.timeago").timeago();VoiceTV.Comment.init()}};VoiceTV.Thisismyfuture={contentViewInit:function(){$(".embed textarea").hover(function(){$(this).focus();$(this).select()});$(".image_tooltip").tooltip({position:"center right",predelay:100,effect:"fade",relative:true,offset:[-11,-20]}).dynamic({right:{direction:"right"}})}};VoiceTV.Comment={approve_status:0,init:function(){if(parseInt($("#total_comment").val())>10){$(".older_post").show()}this.initCommentTools();this.initClickEvent()},initClickEvent:function(){$("#older_comment").click(function(){var b=$(this).attr("rel");var d=$("#comment_list li");var a=d.length;var c=d.eq(a-1).attr("rel");$("#older_comment").hide();$("#comment_loading").show();VoiceTV.Comment.loadOlderPost(b,c)});$("#post_comment").click(function(){if($("#comment_box").val()!="Add a comment"){VoiceTV.Comment.postComment()}else{alert("กรุณาใส่ comment")}})},loadOlderPost:function(a,b){$.get(VoiceTV.base_url+"/comment/ajaxcomment/?content_id="+a+"&last_id="+b,function(c){$("#comment_list").append(c);$("#older_comment").show();$("#comment_loading").hide();if(c==""||$("#total_comment").val()<=$("#comment_list li").length){$(".older_post").hide()}VoiceTV.Comment.initCommentTools()})},postComment:function(){$.post(VoiceTV.base_url+"/comment/ajaxcomment/",$("#comment_form").serialize(),function(a){var b=jQuery.parseJSON(a);if(b.message=="success"){if(VoiceTV.Comment.approve_status){$("#comment_list").prepend(b.result);$("#comment_list li").eq(0).animate({backgroundColor:"#FFF"},3000)}else{alert("ได้รับความคิดเห็นของท่านเรียบร้อย ระบบจะแสดงความคิดเห็นของท่านเมื่อได้รับอนุญาตจากทีมงาน")}VoiceTV.Comment.initCommentTools();VoiceTV.Comment.increaseCountComment();$("#comment_box").val("")}else{}})},increaseCountComment:function(){if(VoiceTV.Comment.approve_status){var a=parseInt($("#total_comment").val());$("#total_comment").val(a+1);if(parseInt($("#total_comment").val())==1){$(".comment h2").eq(0).html($("#total_comment").val()+" Comment")}else{$(".comment h2").eq(0).html($("#total_comment").val()+" Comments")}}},decreaseCountComment:function(){var a=parseInt($("#total_comment").val());$("#total_comment").val(a-1);if(parseInt($("#total_comment").val())==1){$(".comment h2").eq(0).html($("#total_comment").val()+" Comment")}else{$(".comment h2").eq(0).html($("#total_comment").val()+" Comments")}},initCommentTools:function(){$("#comment_list .tools a").click(function(){var a=$(this);$.get($(this).attr("href"),function(b){var c=jQuery.parseJSON(b);if(c.message=="success"){a.parent().parent().parent().remove();VoiceTV.Comment.decreaseCountComment()}else{}});return false})}};VoiceTV.Facebook={logout:function(){$.get(VoiceTV.base_url+"/user/logout",function(a){window.location.reload()})},onLogin:function(){VoiceTV.MessageBox.openUrl(VoiceTV.base_url+"/facebook/authen/")},initialEventPopup:function(){$("#sign_up_with_facebook").submit(function(){VoiceTV.Facebook.register();return false});$("#link_account_facebook").submit(function(){VoiceTV.Facebook.link();return false})},register:function(){$("#sign_up_with_facebook .submit img").show();$.post(VoiceTV.base_url+"/facebook/register/",$("#sign_up_with_facebook").serialize(),function(b){var c=jQuery.parseJSON(b);if(c.message=="success"){window.location=c.result}else{var a="";$.each(c.result,function(d,e){a+="<li>"+e+"</li>"});a+="<li class='clear'></li>";$("#sign_up_with_facebook .error ul").html(a);$("#sign_up_with_facebook .error").show()}$("#sign_up_with_facebook .submit img").hide()})},link:function(){$("#link_account_facebook .submit img").show();$.post(VoiceTV.base_url+"/facebook/link/",$("#link_account_facebook").serialize(),function(b){var c=jQuery.parseJSON(b);if(c.message=="success"){window.location=c.result}else{var a="";$.each(c.result,function(d,e){a+="<li>"+e+"</li>"});a+="<li class='clear'></li>";$("#link_account_facebook .error ul").html(a);$("#link_account_facebook .error").show()}$("#link_account_facebook .submit img").hide()})}};VoiceTV.Twitter={init:function(){$(".twitter_signin").click(function(){VoiceTV.Twitter.login()})},login:function(){var a=VoiceTV.base_url+"/twitter/login";var b=window.open(a,"mywindow","width=960,height=500");if(b.opener==null){b.opener=self}return false},initialEventPopup:function(){$("#sign_up_with_twitter").submit(function(){VoiceTV.Twitter.register();return false});$("#link_account_twitter").submit(function(){VoiceTV.Twitter.link();return false})},register:function(){$("#sign_up_with_twitter .submit img").show();$.post(VoiceTV.base_url+"/twitter/register/",$("#sign_up_with_twitter").serialize(),function(b){var c=jQuery.parseJSON(b);if(c.message=="success"){window.location=c.result}else{var a="";$.each(c.result,function(d,e){a+="<li>"+e+"</li>"});a+="<li class='clear'></li>";$("#sign_up_with_twitter .error ul").html(a);$("#sign_up_with_twitter .error").show()}$("#sign_up_with_twitter .submit img").hide()})},link:function(){$("#link_account_twitter .submit img").show();$.post(VoiceTV.base_url+"/twitter/link/",$("#link_account_twitter").serialize(),function(b){var c=jQuery.parseJSON(b);if(c.message=="success"){window.location=c.result}else{var a="";$.each(c.result,function(d,e){a+="<li>"+e+"</li>"});a+="<li class='clear'></li>";$("#link_account_twitter .error ul").html(a);$("#link_account_twitter .error").show()}$("#link_account_twitter .submit img").hide()})}};VoiceTV.Show={init:function(){$("#nivoSlider .slider").nivoSlider({effect:"fold",directionNav:false});$(".scrollable").each(function(a,b){if($(b).find(".items .inner").length>1){$(b).scrollable({circular:true,mousewheel:true,speed:400}).navigator().autoscroll({autoplay:true,interval:10000})}else{$(b).parent().find(".browse").css("visibility","hidden")}})}};VoiceTV.User={};VoiceTV.User.Blog={initList:function(){$("#add_blog").click(function(){$.get(VoiceTV.base_url+"/blog/create",function(a){$("#blog").html(a)})})},initEditor:function(){var a={width:"392px"};a.toolbar="Basic";a.extraPlugins="MediaEmbed";a.toolbar_Basic=[["Source","-","Preview"],["Cut","Copy","Paste","PasteText","PasteFromWord"],["Undo","Redo","-","RemoveFormat"],"/",["Bold","Italic","Underline","Strike","-","Subscript","Superscript"],["NumberedList","BulletedList","-","Outdent","Indent","Blockquote"],["JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"],["Link","Unlink","Anchor"],["Image","Flash","MediaEmbed","Table","HorizontalRule","Smiley","SpecialChar"],"/",["Format","Font","FontSize"],["TextColor","BGColor"],];a.filebrowserBrowseUrl="/kcfinder/browse.php?type=files";a.filebrowserImageBrowseUrl="/kcfinder/browse.php?type=images";a.filebrowserFlashBrowseUrl="/kcfinder/browse.php?type=flash";a.filebrowserUploadUrl="/kcfinder/upload.php?type=files";a.filebrowserImageUploadUrl="/kcfinder/upload.php?type=images";a.filebrowserFlashUploadUrl="/kcfinder/upload.php?type=flash";$("textarea#content").ckeditor(a)},initCreate:function(){var a=$("#back").attr("rel");$("#create_blog").validationEngine();$("#back").click(function(){$.get(VoiceTV.base_url+"/user/blog?username="+a,function(b){$("#blog").html(b)})});$("#submit").click(function(){if($("#create_blog").validationEngine("validate")){var b=$("#create_blog");$.ajax({type:"POST",url:b.attr("action"),data:b.serialize(),success:function(){$.get(VoiceTV.base_url+"/user/blog?username="+a,function(c){$("#blog").html(c)})}})}else{alert("Please fill out the title")}})},initUpdate:function(b){$("#create_blog").validationEngine();var a=$("#back").attr("rel");$("#back").click(function(){$.get(VoiceTV.base_url+"/user/blog?username="+a,function(c){$("#blog").html(c)})});$("#submit").click(function(){if($("#update_blog").validationEngine("validate")){var c=$("#update_blog");$.ajax({type:"POST",url:c.attr("action"),data:c.serialize(),success:function(){$.get(VoiceTV.base_url+"/user/blog?username="+a,function(d){$("#blog").html(d)})}})}else{alert("Please fill out the title")}})},initView:function(a){$("#edit").click(function(){$.get(VoiceTV.base_url+"/blog/update/"+a,function(b){$("#blog").html(b)})});$("#delete").click(function(){$.ajax({type:"GET",url:VoiceTV.base_url+"/blog/delete/"+a,success:function(){$.get(VoiceTV.base_url+"/user/blog/",function(b){$("#blog").html(b)})}})});$("#back").click(function(){var b=$("#back").attr("rel");$.get(VoiceTV.base_url+"/user/blog?username="+b,function(c){$("#blog").html(c)})})}};
