var cfrom = 0;
var cobj = 0;

var lfrom = 0;
var lobj = 0;

function Load()
{
    document.onselectstart = SelectStart;
}

function DoDrag( id )
{
    if ( document.getElementById )
    {
        obj = document.getElementById( id );

        if ( obj.tagName == "DIV" && obj.className == "category" )
        {
            cobj = obj;
            cobj.style.visibility = 'hidden';
            cfrom = String( obj.id ).substring( 1 );
        }

        if ( obj.tagName == "DIV" && obj.className == "link" )
        {
            lobj = obj;
            lobj.style.visibility = 'hidden';
            lfrom = String( obj.id ).substring( 1 );
        }
    }
}

function SelectStart()
{
    return ( ( cfrom || lfrom ) ? false : true );
}

function MouseUp()
{
    if ( cfrom )
    {
        cobj.style.visibility = 'visible';
        cfrom = 0;
        cobj = null;
    }

    if ( lfrom )
    {
        lobj.style.visibility = 'visible';
        lfrom = 0;
        lobj = null;
    }
}

function DragOver( obj )
{
    if ( cfrom )
    {
        if ( obj.className == 'cdrop' )
            obj.className = "cdrop over";

        if ( obj.className == 'ccoldrop' )
            obj.className = "ccoldrop over";
    }

    if ( lfrom )
    {
        if ( obj.className == 'link' )
            obj.className = 'link over';

        if ( obj.className == 'dropdownmenu' )
            obj.className = 'dropdownmenu over';
    }
}

function DragOut( obj )
{
    if ( cfrom )
    {
        if ( obj.className == 'cdrop over' )
            obj.className = "cdrop";

        if ( obj.className == 'ccoldrop over' )
            obj.className = "ccoldrop";
    }

    if ( lfrom )
    {
        if ( obj.className == 'link over' )
            obj.className = 'link';

        if ( obj.className == 'dropdownmenu over' )
            obj.className = 'dropdownmenu';
    }
}

function DoDrop( column, row )
{
    if ( cfrom )
    {
        location = "./?from=" + cfrom + "&column=" + column + ( row ? "&row=" + row : '' );

        cfrom = 0;
    }
}

function DoLinkDrop( categoryid, order )
{
    if ( lfrom )
    {
        //alert( categoryid + "|" + order );
        location = "./?lfrom=" + lfrom + "&category=" + categoryid + "&order=" + order;

        lfrom = 0;
    }
}

function InstallAccel()
{
    window.external.AddService( 'accelerators/add.xml.php' );
}


