function setcookie(a,b){document.cookie=a+"="+escape(b)}function getcookie(a){if(document.cookie.length>0){c_start=document.cookie.indexOf(a+"=");if(c_start!=-1){c_start=c_start+a.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end))}}}
var remote={_nIndicator:0,_indicatorTimer:null,_nSelected:0,_updateIndicator:function(){var a=remote._nIndicator;if(a>9){var b=Math.floor(a/10);$("#r1").text(b).removeClass("indicatord").addClass("indicatora");$("#r2").text(a-b*10).removeClass("indicatord").addClass("indicatora");$("#channelsList > li").each(function(d){d+1!=remote._nIndicator&&remote._hideChannel($(this).attr("id"))})}else if(a>0){$("#r1").text(a).removeClass("indicatord").addClass("indicatora");$("#r2").text("-").removeClass("indicatord").addClass("indicatora");
$("#channelsList > li").each(function(d){d+1!=remote._nIndicator&&Math.floor((d+1)/10)!=remote._nIndicator?remote._hideChannel($(this).attr("id")):remote._showChannel($(this).attr("id"))})}else{$("#r1").text("-").removeClass("indicatora").addClass("indicatord");$("#r2").text("-").removeClass("indicatora").addClass("indicatord");$("#channelsList > li").each(function(){remote._showChannel($(this).attr("id"))})}},_openIndicatedChannel:function(){window.clearInterval(remote._indicatorTimer);remote.openChannel(remote._nIndicator)},
_showChannel:function(a){$("#"+a).height(30).css("list-style-type","decimal").css("display","list-item");$("#"+a+" > div").show()},_hideChannel:function(a){$("#"+a).height(0).css("list-style","none");$.browser.msie&&$("#"+a).css("display","inline");$("#"+a+" > div").hide()},keydown:function(a){if(a==-1){remote._nIndicator=Math.floor(remote._nIndicator/10);remote._nSelected=0}else if(a==-2)if(!$.browser.opera&&($("#remotebox").is(":visible")||$("#rtopbox").is(":visible"))){remote._nSelected>0&&remote._nSelected--;
$("#channelsList>li>div:visible").each(function(b){if(b==remote._nSelected){$(this).addClass("chbox_h");$(this).offset().top>$(window).height()?$(document).scrollTop((remote._nSelected+1)*30):$(document).scrollTop(0)}else $(this).removeClass("chbox_h")});return false}else return true;else if(a==-3)if(!$.browser.opera&&($("#remotebox").is(":visible")||$("#rtopbox").is(":visible"))){remote._nSelected<$("#channelsList >li").size()-1&&remote._nSelected++;$("#channelsList>li>div:visible").each(function(b){if(b==
remote._nSelected){$(this).addClass("chbox_h");(remote._nSelected+1)*30+90>$(window).height()&&$(document).scrollTop((remote._nSelected+1)*30)}else $(this).removeClass("chbox_h")});return false}else return true;else if(a==-4)if(!$.browser.opera&&($("#remotebox").is(":visible")||$("#rtopbox").is(":visible"))){remote.hideRemote();document.location=$("#channelsList>li>div:visible>a")[remote._nSelected*2]}else return true;else if(a==-5)remote.toggleRemote();else if(a==-6)remote.toggleRemote();else if(a==
-7){if(a=typeof is_setevizor!="undefined")top.location="/channel/"+slug+"/";else{a=document;if(cur_interface>0)a=top;if(slug)a.location="/apps/widgets/player/?slug="+slug+"&width="+screen.width+"&height="+screen.height+"&autostart=true&fullscreen=true";else document.location="http://setevizor.vefire.ru"}return true}else if(a==-8){remote.openRandomChannel();return true}else if(remote._nIndicator<10){remote._nSelected=0;if(a>=0&&a<10)remote._nIndicator=remote._nIndicator==0?a:10*remote._nIndicator+
a}remote._updateIndicator();window.clearInterval(remote._indicatorTimer);remote._indicatorTimer=window.setInterval(remote._openIndicatedChannel,1500);return false},openChannel:function(a){if(a=$("#channelsList :nth-child("+a+") > div > a").attr("href"))document.location=a},reloadRemote:function(a){jQuery("#response").html('<div class=wcloud><img src="http://s2.vefire.ru/img/progress_big.gif">Working...</div>');jQuery.ajax({type:"GET",url:"/ajax/remote/load",dataType:"json",success:function(b){jQuery("#response").html("");
if(b.Status>0){for(var d=typeof is_setevizor!="undefined",c="",e=0;e<b.Message.length;e++)with(b.Message[e]){c+='<li id="ch_'+id+'"><div class="';var f=/^\/channel\/([-\w\d]*)/i,g=/^\/apps\/widgets\/player\/\?slug=([-\w\d]*)/i,h=/^\/apps\/([\w\d]*)\/\?action=view&type=(\d)&slug=([-\w\d]*)/i;f=document.location.pathname.match(f);g=(document.location.pathname+document.location.search).match(g);h=(document.location.pathname+document.location.search).match(h);if(f!=undefined&&slug==f[1]||g!=undefined&&
slug==g[1]||h!=undefined&&slug==h[3]){remote._nSelected=e;c+="chbox chbox_h"}else c+=(status&1)!=1?"dchbox":"chbox";c+='"><a href="';if(a===undefined||a==0){c+=cur_lang=="en"?"http://wefire.tv":type==2?"http://radio.vefire.ru":type==3?"http://games.vefire.ru":"http://vefire.ru";c+=d?"/apps/widgets/player/?slug="+slug+"&width="+screen.width+"&height="+screen.height+"&autostart=true&fullscreen=true":"/channel/"+slug+"/"}else c+="?action=view&type="+type+"&slug="+slug;c+='" style="cursor:pointer">';
c+=type==2?'<img align=absmiddle width=16 height=16 src="http://s2.vefire.ru/img/icons/music-beam-16.png"> ':type==3?'<img align=absmiddle width=16 height=16 src="http://s2.vefire.ru/img/icons/game.png"> ':'<img align=absmiddle width=16 height=16 src="http://s2.vefire.ru/img/icons/monitor-image.png"> ';c+='<img align=absmiddle width=25 height=18 src="http://vefire.ru/l/mini/'+slug+'.gif" /> '+name+"</a>";c+='<a style="position:absolute;top:0;right:5;width:10px;" href="#" onclick="return remote.removeFromRemote('+
id+');" title="Remove this channel from my Remote Control">x</a>';c+="</div>"}jQuery("#channelsList").html(c).sortable({opacity:0.6,axis:"y",containment:"parent",forcePlaceholderSize:true,tolerance:"pointer",update:function(){var i=[];jQuery("#channelsList > li").each(function(j){i[j]=jQuery(this).attr("id").substring(3);jQuery.browser.msie&&jQuery(this).attr("value",j+1)});jQuery.ajax({type:"POST",url:"/ajax/remote/save/",data:{remote:":"+i.join(":")+":"},dataType:"json"})}});if(d){jQuery(".chbox, .achbox, .dchbox").mouseover(function(){jQuery(this);
jQuery("#curchannel").remove();jQuery("#response").before('<div id=curchannel align=center class=acloud style="position:absolute;z-index:20000;height:140px;width:380px;top:'+(jQuery(this).offset().top+10)+';"><h1 style="padding:5px;font-size:x-large">'+jQuery(this).text().substr(0,jQuery(this).text().length-1)+'</h1><img src="/l/en/'+$("a",this).attr("href").split("?")[1].split("=")[1].split("&")[0]+'.gif" width=100 height=70></div>')});jQuery(".chbox, .achbox, .dchbox").mouseout(function(){jQuery("#curchannel").remove()})}}a>
0&&resizeFrame()},error:function(b,d,c){jQuery("#response").html("<div class=err>Err "+c+"! "+d+"</div>").effect("pulsate",{times:3},300)}})},toggleRemote:function(){var a=typeof is_setevizor!="undefined";if(a)jQuery("#rtopbox").is(":visible")?remote.hideRemote():remote.showRemote();else jQuery("#remotebox").is(":visible")?remote.hideRemote():remote.showRemote()},showRemote:function(){var a=typeof is_setevizor!="undefined";if(a){jQuery("#rtopbutton").removeClass("rtopoff").addClass("rtopon");jQuery("body").scrollTop(0);
if(jQuery.browser.mozilla){jQuery("#video").css("position","relative");jQuery("#video").css("left","-430")}else if(jQuery.browser.msie||jQuery.browser.webkit){jQuery("#video").attr("width",screen.width-430);jQuery("#video2").attr("width",screen.width-430);jQuery("#player").attr("width",screen.width-430)}else jQuery("#video").hide();jQuery("#rtopbox").show("highlight")}else{jQuery("#remotebutton").removeClass("remoteoff").addClass("remoteon");jQuery("body").scrollTop(0);jQuery("#remotebox").show("highlight")}!a&&
cur_interface!=0&&resizeFrame()},hideRemote:function(){var a=typeof is_setevizor!="undefined";if(a){jQuery("#rtopbutton").removeClass("rtopon").addClass("rtopoff");jQuery("#rtopbox").hide("highlight");if(jQuery.browser.mozilla){jQuery("#video").css("position","relative");jQuery("#video").css("left","0")}else if(jQuery.browser.msie||jQuery.browser.webkit){jQuery("#video").attr("width",screen.width-10);jQuery("#video2").attr("width",screen.width-10)}else jQuery("#video").show()}else{jQuery("#remotebutton").removeClass("remoteon").addClass("remoteoff");
jQuery("#remotebox").hide("highlight")}cur_interface!=0&&cur_interface!=20&&resizeFrame()},addToRemote:function(a){jQuery.ajax({type:"GET",url:"/ajax/remote/add",data:{id:a},dataType:"json",success:function(b){if(cur_interface!=0){var d="\u0423 \u043c\u0435\u043d\u044f \u043d\u0430 \u043f\u0443\u043b\u044c\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c ",c="\u0410 \u0443 \u0432\u0430\u0441 ";if(channel_type==1){d+="\u043d\u043e\u0432\u044b\u0439 \u0442\u0435\u043b\u0435\u043a\u0430\u043d\u0430\u043b";
c+="\u0442\u0430\u043a\u043e\u0439"}else if(channel_type==2){d+="\u0440\u0430\u0434\u0438\u043e\u0441\u0442\u0430\u043d\u0446\u0438\u044f";c+="\u0442\u0430\u043a\u0430\u044f"}c+=" \u0435\u0441\u0442\u044c?";if(cur_interface==2){mailru.events.listen(mailru.common.events.streamPublish,function(){remote.reloadRemote();remote.showRemote();setTimeout("jQuery('#channel_"+b.ID+"').show('pulsate', {times:3}, 300);",1000)});mailru.common.stream.publish({title:d,text:channel_name+"! "+c,img_url:"http://vefire.ru/l/ru/"+
channel_slug+".gif",action_links:[{text:"\u0421\u043e\u0432\u0435\u0442\u0443\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c!",href:"?type="+channel_type+"&action=view&slug="+channel_slug}]})}else cur_interface==3&&FB.ui({method:"stream.publish",attachment:{name:channel_name,href:"http://vefire.ru/apps/fb/?type="+channel_type+"&action=view&slug="+channel_slug,media:[{type:"image",href:"http://vefire.ru/apps/fb/?type="+channel_type+"&action=view&slug="+channel_slug,src:"http://vefire.ru/l/ru/"+
channel_slug+".gif"}]},message:d+" "+channel_name+"! "+c,action_links:[{text:channel_name,href:"http://vefire.ru/apps/fb/?type="+channel_type+"&action=view&slug="+channel_slug}],user_message_prompt:"\u0420\u0430\u0441\u0441\u043a\u0430\u0436\u0438\u0442\u0435 \u0441\u0432\u043e\u0438\u043c \u0434\u0440\u0443\u0437\u044c\u044f\u043c \u043e \u043d\u043e\u0432\u043e\u043c \u043a\u0430\u043d\u0430\u043b\u0435!"},function(){remote.reloadRemote();remote.showRemote();setTimeout("jQuery('#channel_"+b.ID+
"').show('pulsate', {times:3}, 300);",1000)})}remote.reloadRemote();remote.showRemote();setTimeout("jQuery('#channel_"+b.ID+"').show('pulsate', {times:3}, 300);",1000)}});return false},addToRemoteFrame:function(a,b){jQuery.ajax({type:"GET",url:"/ajax/remote/add",data:{id:a,login:b},dataType:"json",success:function(){top.location=s.site+"/user/"+b+"/pult/"}});return false},removeFromRemote:function(a){jQuery.ajax({type:"GET",url:"/ajax/remote/remove",data:{id:a},dataType:"json",success:function(){remote.reloadRemote();
remote.showRemote()},error:function(){remote.reloadRemote();remote.showRemote()}});return false},openRandomChannel:function(){var a=typeof is_setevizor!="undefined";document.location=a?"/misc/random/?fullscreen=1&width="+screen.width+"&height="+screen.height:"/random";return false},autoConfigure:function(){jQuery.ajax({type:"GET",url:"/ajax/remote/autoconfigure",dataType:"json",success:function(){remote.reloadRemote();remote.showRemote()},error:function(a,b,d){jQuery("#response").html("<div class=err>Err "+
d+"! "+b+"</div>").effect("pulsate",{times:3},300);remote.reloadRemote();remote.showRemote()}});return false}};
$(document).ready(function(){if(jQuery.hotkeys){$(document).bind("keydown","r",function(){remote.toggleRemote();return false});$(document).bind("keydown","esc",function(){remote.toggleRemote();return false});$(document).bind("keydown","f1",function(){remote.openRandomChannel();return false});$(document).bind("keydown","0",function(){remote.showRemote();return remote.keydown(0)});$(document).bind("keydown","1",function(){remote.showRemote();return remote.keydown(1)});$(document).bind("keydown","2",
function(){remote.showRemote();return remote.keydown(2)});$(document).bind("keydown","3",function(){remote.showRemote();return remote.keydown(3)});$(document).bind("keydown","4",function(){remote.showRemote();return remote.keydown(4)});$(document).bind("keydown","5",function(){remote.showRemote();return remote.keydown(5)});$(document).bind("keydown","6",function(){remote.showRemote();return remote.keydown(6)});$(document).bind("keydown","7",function(){remote.showRemote();return remote.keydown(7)});
$(document).bind("keydown","8",function(){remote.showRemote();return remote.keydown(8)});$(document).bind("keydown","9",function(){remote.showRemote();return remote.keydown(9)});$(document).bind("keydown","up",function(){return remote.keydown(-2)});$(document).bind("keydown","down",function(){return remote.keydown(-3)});$(document).bind("keydown","return",function(){return remote.keydown(-4)});$(document).bind("keydown","backspace",function(){return remote.keydown(-1)});$(document).bind("keydown",
"f11",function(){return remote.keydown(-7)});$(document).bind("keydown","alt+1",function(){return topMenu("tmenu_1")});$(document).bind("keydown","alt+2",function(){return topMenu("tmenu_2")});$(document).bind("keydown","alt+3",function(){return topMenu("tmenu_4")});$(document).bind("keydown","alt+4",function(){return topMenu("tmenu_3")});$(document).bind("keydown","h",function(){document.location="/";return false})}});

