SortableLists={lists:["channelsList"],updated:function(a){var b=a.getAttribute("id"),c=SortableLists[b];c.length=0;Sortable.sequence(a).each(function(d){c.push(parseInt(d))});jQuery.ajax({type:"POST",url:"/ajax/remote/save/",data:{remote:":"+c.join(":")+":"},dataType:"json"})},createSortables:function(){var a=SortableLists.lists;a.each(function(b){var c=SortableLists[b],d=$(b);d.innerHTML="";var e={id:"channel","class":"sortable"};c.each(function(f){var g=SortableLists.items[f];e.id="channel_"+f;
d.insert({bottom:Builder.node("li",e).update(g)})})});a.each(function(b){Sortable.create(b,{dropOnEmpty:true,containment:a,constraint:"vertical",only:"sortable",onUpdate:SortableLists.updated})})}};
function reloadRemote(){jQuery.ajax({type:"GET",url:"/ajax/remote/load",dataType:"json",success:function(a,b){eval(a.Message);SortableLists.createSortables()},error:function(a,b,c){jQuery("#response").html("<div class=err>Err "+c+"! "+b+"</div>").effect("pulsate",{times:3},300);SortableLists.createSortables()}})}function toggleRemote(){jQuery("#remotebox").is(":visible")?hideRemote():showRemote()}
function showRemote(){jQuery("#remotebutton").removeClass("remoteoff").addClass("remoteon");jQuery("#text").focus();jQuery("#remotebox").show("highlight")}function hideRemote(){jQuery("#remotebutton").removeClass("remoteon").addClass("remoteoff");jQuery("#remotebox").hide("highlight")}
function addToRemote(a){jQuery.ajax({type:"GET",url:"/ajax/remote/add",data:{id:a},dataType:"json",success:function(b,c){reloadRemote();showRemote();setTimeout("jQuery('#channel_"+b.ID+"').show('pulsate', {times:3}, 300);",1000)}});return false}function addToRemoteFrame(a,b){jQuery.ajax({type:"GET",url:"/ajax/remote/add",data:{id:a,login:b},dataType:"json",success:function(c,d){top.location="/user/"+c.Login+"/pult/"}});return false}
function removeFromRemote(a){jQuery.ajax({type:"GET",url:"/ajax/remote/remove",data:{id:a},dataType:"json",success:function(b,c){reloadRemote();showRemote()},error:function(b,c,d){reloadRemote();showRemote()}});return false};
