/*
var obj = null;
function checkHover() {
  if (obj) {
    obj.find('ul').hide();
  } //if
} //checkHover
$(document).ready(function() {
  $('#nav > li').hover(function() {
    if (obj) {
      obj.find('ul').hide();
      obj = null;
    } //if
    $(this).find('ul').show();
  }, function() {
    obj = $(this);
    setTimeout(
      "checkHover()",
      400);
  });
});
*/
$(document).ready(function() {
P7_ExpMenu();
});

function openDocument(url) {
	window.open(url, null, 'status=no,menubar=yes,toolbar=no,resizable=yes,height=600,width:800');

	return false;
}

function onClickDocument(obj) {
	return openDocument(obj.href);
}

function initSortable(parent) {
    $(parent).Sortable({
        accept : 'sortableitem',
        helperclass : 'sorthelper',
        handle: 'img.sortablehandle',
        axis: 'vertically',
        opacity:    0.5,
        fit :   false,
//      tolerance: 'fit', //    'pointer', 'intersect' or 'fit',
        onStop: function (data) {
            serialise(parent);
        }
    });
}

function serialise(parent) {
    var serial = $.SortSerialize();
    $.post('/admin/products/reorder', serial.hash, function() {
        // animate save complete
        var curBck = $(parent).css('background-color');
        $(parent).css('background-color', '#CED7D3');
        $(parent).animate({style: 'background-color: #DCE1DF;'}, 1000);
    });
}
