jQuery(document).ready(function()
{
    if (jQuery('.simpleTree').size() > 0)
    {
	simpleTreeCollection = jQuery('.simpleTree').simpleTree({
		autoclose: false,
		afterClick:function(node){
			//alert("text-"+$('span:first',node).text());
		},
		afterDblClick:function(node){
			//alert("text-"+$('span:first',node).text());
			//alert('ok');
		},
		afterMove:function(destination, source, pos)
		{
			var dstId =  parseInt(destination.attr('id').replace('node_', ''));
			var srcId =  parseInt(source.attr('id').replace('node_', ''));
			var pNo =  parseInt(pos);

                            
			jQuery.ajax({
				async: false,
				url: '/pl/menu/index/changeposition',
				data: {destination: dstId, source: srcId, position: pNo},
				success: function(data)
						{
							if (data != 1) alert(data);
							document.location.reload();
						}
			});

			//alert(destination.attr('id') + ' | ' +  source.attr('id') + ' | ' + pos);
			//alert("destination-"+$('span:first',destination).text()+" source-"+$('span:first',source).text()+" pos-"+pos);
		},
		afterAjax:function()
		{
			//alert('Loaded');
		},
		animate:false
		//,docToFolderConvert:true
		});
    }    
});

function showContextMenuEdit(sender) {
	jQuery('#select_menu_add b.context_menu').hide();
	jQuery(sender).parent().find('>b.context_menu').show();
}

