ITVM=window.ITVM||{};ITVM.Draggable={};ITVM.Draggable.Content=(function($)
{function init()
{if($('.sortable').length)
{$('.homepage .highlight .content h2').addClass('drag-handle');$('.homepage .highlight.promotion img').addClass('drag-handle');$('.sortable').sortable({cancel:'.highlight .content h2 span span,.highlight .content h2 span a.sub',connectWith:'.sortable',cursor:'move',handle:'.drag-handle',items:'> .highlight',placeholder:'itv-drag-placeholder',revert:true,tolerance:'intersect',update:saveLayout});$('.homepage .highlight .content h2 span span').toggle(function()
{$(this).parents('.content').addClass('closed');},function()
{$(this).parents('.content').removeClass('closed');});$('.page-config .reset-layout').click(resetLayout);}}
function saveLayout(event,ui)
{if(typeof preventIE6DragLoss=='function')
{preventIE6DragLoss(ui);}
if(ui.sender===null)
{var cookie='';$('.sortable').each(function(i)
{$(this).children('.highlight').each(function(i)
{var parts=this.id.split('_');if(i>0)
{cookie+=',';}
cookie+=parts[parts.length-1];});cookie+=';';});if(typeof console!='undefined')
{console.log(cookie);}
$.cookie('itvm_homepage',cookie);$.ajax({data:{action:'setlayout',layout:cookie},dataType:'json',type:'GET',url:'/common/template/usercontrols/handlers/LoginHandler.ashx'});}}
function resetLayout(e)
{e.preventDefault();$.cookie('itvm_homepage',null);window.location.reload();}
return{init:init,resetLayout:resetLayout};})(jQuery);$(ITVM.Draggable.Content.init);