﻿// File JScript

// SEZIONE DRAG'N'DROP


// Define state variables for drag and drop operation.
// Sezione per lo scoll TechNet
var beginY;
var isMouseDown = false;

// Start drag and drop operation.
function ghed_onMouseDown(sender, mouseEventArgs)
{
    // Set the beginning position of the mouse.
    beginY = mouseEventArgs.getPosition(null).y;
    isMouseDown = true;

    // Ensure this object is the only one receiving mouse events.
    
    sender.captureMouse();
    
    
    //debug
    //var Testo_TechNet = sender.findName("Testo_TechNet");
    //var Testo_Scorrimento_Technet = sender.findName("Testo_Scorrimento_Technet");
    //alert("Altezza testo technet: " + Testo_TechNet.actualHeight);
    //alert("Altezza maschera: " + Testo_Scorrimento_Technet.Height);
}

// Reposition object during drag and drop operation.
function ghed_onMouseMove(sender, mouseEventArgs)
{
    // Determine whether the mouse button is down.
    // If so, move the object.
    
    var Testo_TechNet = sender.findName("Testo_TechNet");
    var Testo_TechNet1 = sender.findName("Testo_TechNet1");
    var Testo_TechNet2 = sender.findName("Testo_TechNet2");
    var Testo_TechNet3 = sender.findName("Testo_TechNet3");
    var Testo_Scorrimento_Technet = sender.findName("Testo_Scorrimento_Technet");
    
    var rapporto = (Testo_TechNet.actualHeight+Testo_TechNet1.actualHeight)/152;
    
    if (isMouseDown == true)
    {
        // Retrieve the current position of the mouse.
        //var currX = mouseEventArgs.getPosition(null).x;
//        var currY = mouseEventArgs.getPosition(null).y;
//        sender["Canvas.Top"] += currY - beginY;
//        Testo_TechNet["Canvas.Top"] -=  (currY - beginY)*rapporto;
//        Testo_TechNet1["Canvas.Top"] -=  (currY - beginY)*rapporto;
//        Testo_TechNet2["Canvas.Top"] -=  (currY - beginY)*rapporto;
//        Testo_TechNet3["Canvas.Top"] -=  (currY - beginY)*rapporto;
//        // Update the beginning position of the mouse.
//        //beginX = currX;
//        beginY = currY;
        
        // vincoliamo il movimento del cursore di spostamento 
        if ( sender["Canvas.Top"] < 86 ){          
             sender["Canvas.Top"] = 86;
             Testo_TechNet["Canvas.Top"] =  2;
             Testo_TechNet1["Canvas.Top"] =  10+Testo_TechNet.ActualHeight;
             Testo_TechNet2["Canvas.Top"] =  10+Testo_TechNet1.ActualHeight+Testo_TechNet.ActualHeight;
             Testo_TechNet3["Canvas.Top"] =  10+Testo_TechNet2.ActualHeight+Testo_TechNet1.ActualHeight+Testo_TechNet.ActualHeight;
             
             //ghed_onMouseUp();
            return;
        }
        
        if ( sender["Canvas.Top"] > 238 ){          
             sender["Canvas.Top"] = 238;
             
            // Testo_TechNet["Canvas.Top"] =  -Testo_TechNet.actualHeight+2 ;
             //ghed_onMouseUp();
            return;
        } else {
            var currY = mouseEventArgs.getPosition(null).y;
            sender["Canvas.Top"] += currY - beginY;
            Testo_TechNet["Canvas.Top"] -=  (currY - beginY)*rapporto;
            Testo_TechNet1["Canvas.Top"] -=  (currY - beginY)*rapporto;
            Testo_TechNet2["Canvas.Top"] -=  (currY - beginY)*rapporto;
            Testo_TechNet3["Canvas.Top"] -=  (currY - beginY)*rapporto;
            // Update the beginning position of the mouse.
            //beginX = currX;
            beginY = currY;
        }
    }
}

// Stop drag and drop operation.
function ghed_onMouseUp(sender, mouseEventArgs)
{
    isMouseDown = false;

    // Allow all objects to receive mouse events.
    sender.releaseMouseCapture();
}


//-----------------------------------------------------------------------------------------------------------------

// Sezione per lo scoll Msdn
var beginYScroll2;
var isMouseDownOnScroll2 = false;

// Start drag and drop operation.
function ghed_onMouseDownScroll2(sender, mouseEventArgs)
{
    // Set the beginning position of the mouse.
    beginYScroll2 = mouseEventArgs.getPosition(null).y;
    isMouseDownOnScroll2 = true;

    // Ensure this object is the only one receiving mouse events.
    
    sender.captureMouse();
    
}

// Reposition object during drag and drop operation.
function ghed_onMouseMoveScroll2(sender, mouseEventArgs)
{
    // Determine whether the mouse button is down.
    // If so, move the object.
    
    var Testo_Msdn = sender.findName("Testo_Msdn");
    var Testo_Msdn1 = sender.findName("Testo_Msdn1");
    var Testo_Msdn2 = sender.findName("Testo_Msdn2");
    var Testo_Msdn3 = sender.findName("Testo_Msdn3");
    var Testo_Scorrimento_Msdn = sender.findName("Testo_Scorrimento_Msdn");
    
    var rapporto = (Testo_Msdn.actualHeight+Testo_Msdn1.actualHeight)/152;
    
    if (isMouseDownOnScroll2 == true)
    {
        // Retrieve the current position of the mouse.
        //var currX = mouseEventArgs.getPosition(null).x;
//        var currY = mouseEventArgs.getPosition(null).y;
//        sender["Canvas.Top"] += currY - beginYScroll2;
//        Testo_Msdn["Canvas.Top"] -=  (currY - beginYScroll2)*rapporto;
//        Testo_Msdn1["Canvas.Top"] -=  (currY - beginYScroll2)*rapporto;
//        Testo_Msdn2["Canvas.Top"] -=  (currY - beginYScroll2)*rapporto;
//        Testo_Msdn3["Canvas.Top"] -=  (currY - beginYScroll2)*rapporto;
//        // Update the beginning position of the mouse.
//        //beginX = currX;
//        beginYScroll2 = currY;
        
        // vincoliamo il movimento del cursore di spostamento 
        if ( sender["Canvas.Top"] < 86 ){          
             sender["Canvas.Top"] = 86;
             Testo_Msdn["Canvas.Top"] =  2;
             Testo_Msdn1["Canvas.Top"] =  10+Testo_Msdn.ActualHeight;
             Testo_Msdn2["Canvas.Top"] =  10+Testo_Msdn1.ActualHeight+Testo_Msdn.ActualHeight;
             Testo_Msdn3["Canvas.Top"] =  10+Testo_Msdn2.ActualHeight+Testo_Msdn1.ActualHeight+Testo_Msdn.ActualHeight;
             //ghed_onMouseUp();
            return;
        }
        
        if ( sender["Canvas.Top"] > 238 ){          
             sender["Canvas.Top"] = 238;
             
             //Testo_Msdn["Canvas.Top"] =  -Testo_Msdn.actualHeight+2 ;
             //Testo_Msdn1["Canvas.Top"] =  -Testo_Msdn1.actualHeight+10+Testo_Msdn.ActualHeight ;
             //ghed_onMouseUp();
             //window.status="end";
            return;
        } else
        {
            var currY = mouseEventArgs.getPosition(null).y;
            sender["Canvas.Top"] += currY - beginYScroll2;
            Testo_Msdn["Canvas.Top"] -=  (currY - beginYScroll2)*rapporto;
            Testo_Msdn1["Canvas.Top"] -=  (currY - beginYScroll2)*rapporto;
            Testo_Msdn2["Canvas.Top"] -=  (currY - beginYScroll2)*rapporto;
            Testo_Msdn3["Canvas.Top"] -=  (currY - beginYScroll2)*rapporto;
            // Update the beginning position of the mouse.
            //beginX = currX;
            beginYScroll2 = currY;
        }
    }
}

// Stop drag and drop operation.
function ghed_onMouseUpScroll2(sender, mouseEventArgs)
{
    isMouseDownOnScroll2 = false;

    // Allow all objects to receive mouse events.
    sender.releaseMouseCapture();
}