﻿var Demos = [];
var nDemos = 8;

var mouseOffset = null;
var iMouseDown = false;
var lMouseState = false;
var dragObject = null;

// Demo 0 variables
var DragDrops = [];
var curTarget = null;
var lastTarget = null;
var dragHelper = null;
var tempDiv = null;
var rootParent = null;
var rootSibling = null;
//var nImg = new Image();

//******** zhivko
var isHiddenFlag = true;

//nImg.src = 'images/drag_drop_poof.gif';

// Demo1 variables
var D1Target = null;

Number.prototype.NaN0 = function() { return isNaN(this) ? 0 : this; }

function CreateDragContainer() {
    /*
    Create a new "Container Instance" so that items from one "Set" can not
    be dragged into items from another "Set"
    */
    //debugger;
    var cDrag = DragDrops.length;
    DragDrops[cDrag] = [];

    /*
    Each item passed to this function should be a "container".  Store each
    of these items in our current container
    */
    for (var i = 0; i < arguments.length; i++) {
        var cObj = arguments[i];
        DragDrops[cDrag].push(cObj);
        if (cObj) {
            cObj.setAttribute('DropObj', cDrag);
        }
        /*
        Every top level item in these containers should be draggable.  Do this
        by setting the DragObj attribute on each item and then later checking
        this attribute in the mouseMove function
        */
    }

    //debugger;
    try {
        var items = document.getElementsByTagName("div");
        for (var i = 0; i < items.length; i++) {
            if (items[i].className == "DragBox") {
                items[i].setAttribute('DragObj', cDrag);
            }
        }
    } catch (e) { }

}

function getPosition(e) {
    
    var left = 0;
    var top = 0;
    try {
        while (e.offsetParent) {
            left += e.offsetLeft + (e.currentStyle ? (parseInt(e.currentStyle.borderLeftWidth)).NaN0() : 0);
            top += e.offsetTop + (e.currentStyle ? (parseInt(e.currentStyle.borderTopWidth)).NaN0() : 0);
            e = e.offsetParent;
        }
    } catch (e) { }


    left += e.offsetLeft + (e.currentStyle ? (parseInt(e.currentStyle.borderLeftWidth)).NaN0() : 0);
    top += e.offsetTop + (e.currentStyle ? (parseInt(e.currentStyle.borderTopWidth)).NaN0() : 0);
   
    return { x: left, y: top };

}


function mouseCoords(ev) {
    if (ev.pageX || ev.pageY) {
        return { x: ev.pageX, y: ev.pageY };
    }
    try {
        return {
            x: ev.clientX + document.body.scrollLeft - document.body.clientLeft,
            y: ev.clientY + document.body.scrollTop - document.body.clientTop
        };
    }
    catch (e) {
        return {
            x: 0,
            y: 0
        }
    }
}

function writeHistory(object, message) {
}

function getMouseOffset(target, ev) {
    ev = ev || window.event;

    var docPos = getPosition(target);
    var mousePos = mouseCoords(ev);
    return { x: mousePos.x - docPos.x, y: mousePos.y - docPos.y };
}


function mouseMove(ev) {
    try {
        ev = ev || window.event;

        /*
        We are setting target to whatever item the mouse is currently on

Firefox uses event.target here, MSIE uses event.srcElement
        */
        var target = ev.target || ev.srcElement;
        target = target.parentNode;
        var mousePos = mouseCoords(ev);
        //writeHistory(target, "x: " + mousePos.x + " y: " + mousePos.y);
        //if (Demos[0] || Demos[4]) {
        if (Demos[5] || Demos[4]) {
            //debugger;
            // mouseOut event - fires if the item the mouse is on has changed
            if (lastTarget && (target !== lastTarget)) {
                //writeHistory(lastTarget, 'Mouse Out Fired');

                // reset the classname for the target element
                try {
                    var origClass = lastTarget.getAttribute('origClass');
                    if (origClass) lastTarget.className = origClass;
                } catch (e) { }
            }

            /*
            dragObj is the grouping our item is in (set from the createDragContainer function).
            if the item is not in a grouping we ignore it since it can't be dragged with this
            script.
            */
            var dragObj = null;
            if (target) {
                try {
                    dragObj = target.getAttribute('DragObj');
                }
                catch (e) { }
            }

            // if the mouse was moved over an element that is draggable
            if (dragObj != null) {

                // mouseOver event - Change the item's class if necessary
                if (target != lastTarget) {
                    //writeHistory(target, 'Mouse Over Fired');

                    var oClass = target.getAttribute('overClass');
                    if (oClass) {
                        target.setAttribute('origClass', target.className);
                        target.className = oClass;
                    }
                }

                // if the user is just starting to drag the element
                if (iMouseDown && !lMouseState) {
                    //writeHistory(target, 'Start Dragging');

                    // mouseDown target
                    curTarget = target;

                    // Record the mouse x and y offset for the element
                    rootParent = curTarget.parentNode;
                    rootSibling = curTarget.nextSibling;

                    mouseOffset = getMouseOffset(target, ev);

                    // We remove anything that is in our dragHelper DIV so we can put a new item in it.
                    for (var i = 0; i < dragHelper.childNodes.length; i++) dragHelper.removeChild(dragHelper.childNodes[i]);

                    // Make a copy of the current item and put it in our drag helper.
                    dragHelper.appendChild(curTarget.cloneNode(true));
                    dragHelper.style.display = 'block';
                    
                    

                    // set the class on our helper DIV if necessary
                    var dragClass = curTarget.getAttribute('dragClass');
                    if (dragClass) {
                        dragHelper.firstChild.className = dragClass;
                    }

                    // disable dragging from our helper DIV (it's already being dragged)
                    dragHelper.firstChild.removeAttribute('DragObj');

                    /*
                    Record the current position of all drag/drop targets related
                    to the element.  We do this here so that we do not have to do
                    it on the general mouse move event which fires when the mouse
                    moves even 1 pixel.  If we don't do this here the script
                    would run much slower.
                    */
                    var dragConts = DragDrops[dragObj];

                    /*
                    first record the width/height of our drag item.  Then hide it since
                    it is going to (potentially) be moved out of its parent.
                    */
                    curTarget.setAttribute('startWidth', parseInt(curTarget.offsetWidth));
                    curTarget.setAttribute('startHeight', parseInt(curTarget.offsetHeight));
                    curTarget.style.display = 'none';

                    //new

                    // loop through each possible drop container
                    for (var i = 0; i < dragConts.length; i++) {
                        with (dragConts[i]) {
                            var pos = getPosition(dragConts[i]);

                            /*
                            save the width, height and position of each container.

				Even though we are saving the width and height of each
                            container back to the container this is much faster because
                            we are saving the number and do not have to run through
                            any calculations again.  Also, offsetHeight and offsetWidth
                            are both fairly slow.  You would never normally notice any
                            performance hit from these two functions but our code is
                            going to be running hundreds of times each second so every
                            little bit helps!

				Note that the biggest performance gain here, by far, comes
                            from not having to run through the getPosition function
                            hundreds of times.
                            */
                            setAttribute('startWidth', parseInt(offsetWidth));
                            setAttribute('startHeight', parseInt(offsetHeight));
                            setAttribute('startLeft', pos.x);
                            setAttribute('startTop', pos.y);
                        }

                        // loop through each child element of each container
                        for (var j = 0; j < dragConts[i].childNodes.length; j++) {
                            with (dragConts[i].childNodes[j]) {
                                if ((nodeName == '#text') || (dragConts[i].childNodes[j] == curTarget)) continue;

                                var pos = getPosition(dragConts[i].childNodes[j]);

                                // save the width, height and position of each element
                                setAttribute('startWidth', parseInt(offsetWidth));
                                setAttribute('startHeight', parseInt(offsetHeight));
                                setAttribute('startLeft', pos.x);
                                setAttribute('startTop', pos.y);
                            }
                        }
                    }
                }
            }

            // If we get in here we are dragging something
            if (curTarget) {
                //debugger;
                // move our helper div to wherever the mouse is (adjusted by mouseOffset)
                var helperTop = mousePos.y - mouseOffset.y;
                var helperLeft = mousePos.x - mouseOffset.x;

                dragHelper.style.top = helperTop.toString() + "px";
                dragHelper.style.left = helperLeft.toString() + "px";

                var dragConts = DragDrops[curTarget.getAttribute('DragObj')];
                var activeCont = null;

                var xPos = mousePos.x - mouseOffset.x + (parseInt(curTarget.getAttribute('startWidth')) / 2);
                var yPos = mousePos.y - mouseOffset.y + (parseInt(curTarget.getAttribute('startHeight')) / 2);

                // check each drop container to see if our target object is "inside" the container
                for (var i = 0; i < dragConts.length; i++) {
                    with (dragConts[i]) {
                        if ((parseInt(getAttribute('startLeft')) < xPos) &&
				(parseInt(getAttribute('startTop')) < yPos) &&
				((parseInt(getAttribute('startLeft')) + parseInt(getAttribute('startWidth'))) > xPos) &&
				((parseInt(getAttribute('startTop')) + parseInt(getAttribute('startHeight'))) > yPos)) {

                            /*
                            our target is inside of our container so save the container into
                            the activeCont variable and then exit the loop since we no longer
                            need to check the rest of the containers
                            */
                            activeCont = dragConts[i];

                            // exit the for loop
                            break;
                        }
                    }
                }

                // Our target object is in one of our containers.  Check to see where our div belongs
                if (activeCont) {
                    if (activeCont != curTarget.parentNode) {
                        //debugger;
                        //writeHistory(curTarget, 'Moved into ' + activeCont.id);
                    }

                    // beforeNode will hold the first node AFTER where our div belongs
                    var beforeNode = null;

                    // loop through each child node (skipping text nodes).
                    for (var i = activeCont.childNodes.length - 1; i >= 0; i--) {
                        with (activeCont.childNodes[i]) {
                            if (nodeName == '#text') continue;

                            // if the current item is "After" the item being dragged
                            if (curTarget != activeCont.childNodes[i] &&
					((parseInt(getAttribute('startLeft')) + parseInt(getAttribute('startWidth'))) > xPos) &&
					((parseInt(getAttribute('startTop')) + parseInt(getAttribute('startHeight'))) > yPos)) {
                                beforeNode = activeCont.childNodes[i];
                            }
                        }
                    }

                    // the item being dragged belongs before another item
                    if (beforeNode) {

                        if (beforeNode != curTarget.nextSibling) {
                            //writeHistory(curTarget, 'Inserted Before ' + beforeNode.id);

                            activeCont.insertBefore(curTarget, beforeNode);
                        }

                        // the item being dragged belongs at the end of the current container
                    } else {

                        if ((curTarget.nextSibling) || (curTarget.parentNode != activeCont)) {
                            //writeHistory(curTarget, 'Inserted at end of ' + activeCont.id);

                            activeCont.appendChild(curTarget);
                        }
                    }

                    // the timeout is here because the container doesn't "immediately" resize
                    setTimeout(function() {
                        var contPos = getPosition(activeCont);
                        activeCont.setAttribute('startWidth', parseInt(activeCont.offsetWidth));
                        activeCont.setAttribute('startHeight', parseInt(activeCont.offsetHeight));
                        activeCont.setAttribute('startLeft', contPos.x);
                        activeCont.setAttribute('startTop', contPos.y);
                    }, 5);

                    // make our drag item visible

                    if (curTarget.style.display != '') {
                        //writeHistory(curTarget, 'Made Visible');
                        curTarget.style.display = '';
                        curTarget.style.visibility = 'hidden';
                        //new
                    }
                    isHiddenFlag = true;

                } else {
                    //debugger;
                    // our drag item is not in a container, so hide it.
                    if (curTarget.style.display != 'none') {
                        if (isHiddenFlag) {
                            isHiddenFlag = false;
                            //debugger;
                            var xPos = mousePos.x - mouseOffset.x + (parseInt(curTarget.getAttribute('startWidth')) / 2);
                            var yPos = mousePos.y - mouseOffset.y + (parseInt(curTarget.getAttribute('startHeight')) / 2);

                            //writeHistory(curTarget, 'Hidden');

                            var goPrev = yPos <= rootParent.offsetTop || xPos <= rootParent.offsetLeft;

                            setTimeout("curTargetClick('" + curTarget.id + "','" + rootParent.id + "','" + goPrev + "')", 10);

                            if (goPrev) {
                                changePreviousPage(curTarget);
                            }
                            else {
                                changeNextPage(curTarget);
                            }
                            rootSibling = null;
                        }
                    }
                }
            }

            // track the current mouse state so we can compare against it next time
            //lMouseState = iMouseDown;

            // mouseMove target
            lastTarget = target;
        }

        if (dragObject) {
            dragObject.style.position = 'absolute';
            dragObject.style.top = mousePos.y - mouseOffset.y;
            dragObject.style.left = mousePos.x - mouseOffset.x;
        }

        // track the current mouse state so we can compare against it next time
        lMouseState = iMouseDown;

        // this prevents items on the page from being highlighted while dragging
        if (curTarget || dragObject) return false;
    }
    catch (e) { }
}

function curTargetClick(id, parentId, goPrev) {
    //debugger;
    var curTarget = document.getElementById(id);
    var rootParent = document.getElementById(parentId);
    for (var i = 0; i < rootParent.childNodes.length; i++) {
        try {
            if (curTarget.getAttribute("psid")) {
                if (rootParent.childNodes[i].getAttribute("psid") == curTarget.getAttribute("psid")) {
                    setTimeout("curTargetClick('" + id + "','" + parentId + "','" + goPrev + "')", 10);
                    return;
                }
            }
            else {
                if (rootParent.childNodes[i].getAttribute("itemid") == curTarget.getAttribute("itemid")) {
                    setTimeout("curTargetClick('" + id + "','" + parentId + "','" + goPrev + "')", 10);
                    return;
                }
            }
        } catch (e) { }
    }

    var currentTarget = null;
    var prevTarget = null;
    
    if (curTarget && rootParent) {

        if (goPrev == "true") {
            addBeforeLast(curTarget, rootParent);
        }
        else {
            addAfterFirst(curTarget, rootParent);
        }

        curTarget.className = "DragBox";
        CreateDragContainer(rootParent);
        //debugger;
        if (goPrev == "true") {
            currentTarget = rootParent.childNodes[rootParent.childNodes.length - 2];
            prevTarget = rootParent.childNodes[rootParent.childNodes.length - 3];
        }
        else {
            currentTarget = rootParent.childNodes[1];
            prevTarget = rootParent.childNodes[0];
        }

        var prevSiblingId = 0;
        var currentId = currentTarget.getAttribute("itemid");
        var psidCurrent = currentTarget.getAttribute("psid");
        var psidPrev = 0;
        //debugger;
        if (prevTarget) {
            try {
                prevSiblingId = prevTarget.getAttribute("itemid");
            }
            catch (e) {
                prevTarget = prevTarget.previousSibling;
                try {
                    prevSiblingId = prevTarget.getAttribute("itemid");
                }
                catch (ex) { }
            }
        }
        if (prevTarget) {
            psidPrev = prevTarget.getAttribute("psid");
        }

        __doPostBack(currentTarget.getAttribute("updateevent"), currentId + "|" + prevSiblingId + "|" + false + "|" + psidCurrent + "|" + psidPrev);

    }
}

function addToBeginning(target, parentEl) {
    //put in the beginning
    var childNodes = new Array();
    childNodes.push(target);
    var length = parentEl.childNodes.length;
    for (var i = length - 1; i >= 0; i--) {
        childNodes.push(parentEl.childNodes[i]);
        parentEl.removeChild(parentEl.childNodes[i]);
    }
    length = childNodes.length;
    for (var i = 0; i < length; i++) {
        parentEl.appendChild(childNodes.shift());
    }
}

function addToEnd(target, parentEl) {
    parentEl.appendChild(target);
}

function addAfterFirst(target, parentEl) {
    //debugger;
    var childNodes = new Array();
    var length = parentEl.childNodes.length;
    for (var i = length - 1; i >= 0; i--) {
        try {
            var itemId = parentEl.childNodes[i].getAttribute("itemid");
            childNodes.push(parentEl.childNodes[i]);
        }
        catch (e) { }
        parentEl.removeChild(parentEl.childNodes[i]);
    }
    length = childNodes.length;
    var pos = 1;
    for (var i = 0; i < length; i++) {
        if (i != 0) {
            parentEl.appendChild(childNodes.pop());
        }
        else {
            parentEl.appendChild(childNodes.pop());
            parentEl.appendChild(target);
            //length++;
        }
    }
}

function addBeforeLast(target, parentEl) {
    var childNodes = new Array();
    var length = parentEl.childNodes.length;
    for (var i = length - 1; i >= 0; i--) {
        try {
            var itemId = parentEl.childNodes[i].getAttribute("itemid");
            childNodes.push(parentEl.childNodes[i]);
        } catch (e) { }
        parentEl.removeChild(parentEl.childNodes[i]);
    }
    length = childNodes.length;
    var pos = length - 1;
    for (var i = 0; i < length; i++) {
        if (i != pos) {
            parentEl.appendChild(childNodes.pop());
        }
        else {
            parentEl.appendChild(target);
            length++;
        }
    }
}



function mouseUp(ev) {

    if (Demos[0] || Demos[5] || Demos[4]) {
        if (curTarget) {
            //writeHistory(curTarget, 'Mouse Up Fired');
            //debugger;
            dragHelper.style.display = 'none';
            var previousSibling = curTarget.previousSibling;
            var prevSiblingId = 0;
            var currentId = curTarget.getAttribute("itemid");
            var psidCurrent = curTarget.getAttribute("psid");
            var psidPrev = 0; //curTarget.getAttribute("psid");
            //debugger;
            if (previousSibling) {
                try {
                    prevSiblingId = previousSibling.getAttribute("itemid");
                }
                catch (e) {
                    previousSibling = previousSibling.previousSibling;
                    try {
                        prevSiblingId = previousSibling.getAttribute("itemid");
                    }
                    catch (ex) { }
                }
            }
            if (previousSibling) {
                psidPrev = previousSibling.getAttribute("psid");
            }
            var insertBefore = false;
            if (prevSiblingId == 0) {
                insertBefore = true;
            }
            if (insertBefore) {
                var nextSibling = curTarget.nextSibling;
                if (nextSibling) {
                    try {
                        prevSiblingId = nextSibling.getAttribute("itemid");
                        psidPrev = nextSibling.getAttribute("psid");
                    }
                    catch (e) {
                        nextSibling = nextSibling.nextSibling;
                        try {
                            prevSiblingId = nextSibling.getAttribute("itemid");
                            psidPrev = nextSibling.getAttribute("psid");
                        }
                        catch (ex) { }
                    }
                }
            }
            //debugger;
            __doPostBack(curTarget.getAttribute("updateevent"), currentId + "|" + prevSiblingId + "|" + insertBefore + "|" + psidCurrent + "|" + psidPrev);
            //__doPostBack("lbtnUpdate_Click", currentId + "|" + prevSiblingId + "|" + insertBefore);

            curTarget.style.display = '';
            curTarget.style.visibility = 'visible';

        }

        curTarget = null;

    }
    dragObject = null;

    iMouseDown = false;
}

function mouseDown(ev) {
    //try {
        ev = ev || window.event;
        var target = ev.target || ev.srcElement;
        target = target.parentNode;

        iMouseDown = true;
        if (Demos[0] || Demos[4] || Demos[5]) {
            //debugger;
            if (lastTarget) {
                //writeHistory(lastTarget, 'Mouse Down Fired');
            }
        }
        if (target) {
            if (target.onmousedown || target.getAttribute('DragObj')) {
                return false;
            }
        }
    //} catch (e) { }
}

function makeDraggable(item) {
    if (!item) return;
    item.onmousedown = function(ev) {
        dragObject = this;
        mouseOffset = getMouseOffset(this, ev);
        return false;
    }
}

function makeClickable(item) {
    if (!item) return;
    item.onmousedown = function(ev) {
        document.getElementById('ClickImage').value = this.name;
    }
}

function addDropTarget(item, target) {
    //debugger;
    item.setAttribute('droptarget', target);
}

document.onmousemove = mouseMove;
document.onmousedown = mouseDown;
document.onmouseup = mouseUp;

function LoadDraging() {
    
    for (var i = 0; i < nDemos; i++) {
        Demos[i] = document.getElementById('Demo' + i);
    }
    
    if (Demos[4]) {
        //debugger;
        CreateDragContainer(document.getElementById('DragContainer4'));
        // Create our helper object that will show the item while dragging
        dragHelper = document.getElementById("helperContainer");
    }
    //debugger;
    if (Demos[5]) {
        //debugger;
        if (Demos[0]) {
            //debugger;
            CreateDragContainer(document.getElementById('DragContainer'));
            // Create our helper object that will show the item while dragging
            //dragHelper = document.getElementById("helperContainer");
        }
        CreateDragContainer(document.getElementById('DragContainer5'));
        // Create our helper object that will show the item while dragging
        dragHelper = document.getElementById("helperContainer");

        
    }

}


function getOuterHTML(obj) {
    //            var temp = document.getElementById(obj).cloneNode(true);
    var temp = obj.cloneNode(true);
    document.getElementById('tempDiv').appendChild(temp);
    var outer = document.getElementById('tempDiv').innerHTML;
    document.getElementById('tempDiv').innerHTML = "";
    return outer;
}


//////////////////////////////////////////////////////////////
//var dhtmlgoodies_slideSpeed = 10;	// Higher value = faster
//var dhtmlgoodies_timer = 10;	// Lower value = faster

var dhtmlgoodies_slideSpeed = 20;
var dhtmlgoodies_timer = 20;

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;

function showHideContent(e, inputId) {
    //debugger;


    if (dhtmlgoodies_slideInProgress) return;
    dhtmlgoodies_slideInProgress = true;
    if (!inputId) inputId = this.id;
    inputId = inputId + '';
    var numericId = inputId.replace(/[^0-9]/g, '');
    var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

    objectIdToSlideDown = false;

    if (!answerDiv.style.display || answerDiv.style.display == 'none') {
        if (dhtmlgoodies_activeId && dhtmlgoodies_activeId != numericId) {
            objectIdToSlideDown = numericId;
            slideContent(dhtmlgoodies_activeId, (dhtmlgoodies_slideSpeed * -1));

        } else {

            answerDiv.style.display = 'block';
            answerDiv.style.visibility = 'visible';

            slideContent(numericId, dhtmlgoodies_slideSpeed);
            //new
            var divPlaylists = document.getElementById("plhdivShowPlaylists");
            if (divPlaylists != null && divPlaylists != 'undefined') {
                divPlaylists.style.display = "none";
                divPlaylists.style.width = "1px";
            }
        }
    } else {
        slideContent(numericId, (dhtmlgoodies_slideSpeed * -1));
        dhtmlgoodies_activeId = false;
        //new
        var divPlaylists = document.getElementById("plhdivShowPlaylists");
        if (divPlaylists != null && divPlaylists != 'undefined') {
            divPlaylists.style.display = "block";
            divPlaylists.style.width = "";
            currentObjPlayList = "";
        }

    }
}

function slideContent(inputId, direction) {
    //debugger;

    var obj = document.getElementById('dhtmlgoodies_a' + inputId);
    var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);

    width = obj.clientWidth;
    if (width == 0) width = obj.offsetWidth;
    width = width + direction;

    rerunFunction = true;

    if (width > contentObj.offsetWidth) {
        width = contentObj.offsetWidth;
        rerunFunction = false;
    }
    if (width <= 1) {
        width = 1;
        rerunFunction = false;

    }

    obj.style.width = width + 'px';
    var topPos = width - contentObj.offsetWidth;
    if (topPos > 0) topPos = 0;
    contentObj.style.left = topPos + 'px';
    obj.style.left = topPos * -1 + 'px';
    ////////////////////////////////////////
    if (obj.id == "dhtmlgoodies_a1") {

        currentObjPlayList = "q1";
    }
    else if (obj.id == "dhtmlgoodies_a2") {
        currentObjPlayList = "q2";
    }
    currentPlayListCntLeft = contentObj.style.left;
    currentPlayListWidth = obj.style.width;
    currentPlayListLeft = obj.style.left;


    ////////////////////////////////////////////
    if (rerunFunction) {
        setTimeout('slideContent(' + inputId + ',' + direction + ')', dhtmlgoodies_timer);
    } else {

        if (width <= 1) {
            obj.style.display = 'none';
            if (objectIdToSlideDown && objectIdToSlideDown != inputId) {
                document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display = 'block';
                document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility = 'visible';
                slideContent(objectIdToSlideDown, dhtmlgoodies_slideSpeed);
            }
            else {

                dhtmlgoodies_slideInProgress = false;
                //new
                currentObjPlayList = "";
            }
        } else {
            dhtmlgoodies_activeId = inputId;
            dhtmlgoodies_slideInProgress = false;
        }
    }
}


currentObjPlayList = "";
currentPlayListCntLeft = "";
currentPlayListWidth = "";
currentPlayListLeft = "";

function initShowHideDivs() {
    var q1 = document.getElementById("dhtmlgoodies_q1");
    q1.onclick = showHideContent;
    var a1 = document.getElementById("dhtmlgoodies_a1");
    var ac1 = document.getElementById("dhtmlgoodies_ac1");
    ac1.style.left = 0 - ac1.offsetWidth + 'px';
    a1.style.left = 0 - ac1.offsetWidth + 'px';
    ac1.className = 'dhtmlgoodies_answer_content';
    a1.style.display = 'none';
    a1.style.width = '1px';

    ///////////////////////

    var q2 = document.getElementById("dhtmlgoodies_q2");
    q2.onclick = showHideContent;
    var a2 = document.getElementById("dhtmlgoodies_a2");
    var ac2 = document.getElementById("dhtmlgoodies_ac2");
    ac2.style.left = 0 - ac2.offsetWidth + 'px';
    a2.style.left = 0 - ac2.offsetWidth + 'px';
    ac2.className = 'dhtmlgoodies_answer_content';
    a2.style.display = 'none';
    a2.style.width = '1px';

    //////////////////////
    //debugger;
    var divPlaylists = document.getElementById("plhdivShowPlaylists");
    if (divPlaylists != null && divPlaylists != 'undefined') {
        divPlaylists.style.display = "block";
        divPlaylists.style.width = "";
    }

    if (currentObjPlayList == "q1") {

        //       document.getElementById("dhtmlgoodies_q1").click();
        document.getElementById("dhtmlgoodies_a1").style.width = currentPlayListWidth;
        document.getElementById("dhtmlgoodies_a1").style.left = currentPlayListLeft;
        document.getElementById("dhtmlgoodies_ac1").style.left = currentPlayListCntLeft;
        document.getElementById("dhtmlgoodies_a1").style.display = 'block';
        document.getElementById("dhtmlgoodies_a1").style.visibility = 'visible';


        var divPlaylists = document.getElementById("plhdivShowPlaylists");
        if (divPlaylists != null && divPlaylists != 'undefined') {
            divPlaylists.style.display = "none";
            divPlaylists.style.width = "1px";
        }
    }
    if (currentObjPlayList == "q2") {

        //       document.getElementById("dhtmlgoodies_q2").click();
        document.getElementById("dhtmlgoodies_a2").style.width = currentPlayListWidth;
        document.getElementById("dhtmlgoodies_a2").style.left = currentPlayListLeft;
        document.getElementById("dhtmlgoodies_ac2").style.left = currentPlayListCntLeft;
        document.getElementById("dhtmlgoodies_a2").style.display = 'block';
        document.getElementById("dhtmlgoodies_a2").style.visibility = 'visible';

        var divPlaylists = document.getElementById("plhdivShowPlaylists");
        if (divPlaylists != null && divPlaylists != 'undefined') {
            divPlaylists.style.display = "none";
            divPlaylists.style.width = "1px";
        }
    }


}


//window.onload = initShowHideDivs;

var dragableObject = null;
var nextPageFlag = true;
var prevPageFlag = true;

function onMouseOver(sender) {
    //debugger;
    sender.enableDraging = true;
    dragableObject = sender;
    var table = sender.firstChild.firstChild;
    table.style.backgroundColor = "#0000FF";
}

function onMouseOut(sender) {
    sender.enableDraging = false;
    dragableObject = null;
    var table = sender.firstChild.firstChild;
    table.style.backgroundColor = "#E6E6E6";
}

function onClick(sender) {
    //debugger;
    //__doPostBack(sender.id, sender.itemId);
}

function startDrag(sender) {
    var table = sender.firstChild.firstChild;
    table.style.backgroundColor = "#CC0000";
}

function stopDrag(sender) {
    var table = sender.firstChild.firstChild;
    table.style.backgroundColor = "#00CC00";
}

function clearMoveFlags() {

    isHiddenFlag = true;
}
//pager
function changeNextPage(target) {
    var pager = document.getElementById(target.getAttribute("pager"));
    var nextButton = pager.childNodes[2];
    if (nextButton != undefined && nextButton != "undefined" && nextButton != null) {
        if (nextButton.href != "") {
            eval(nextButton.href);
        }
    }
}

function changePreviousPage(target) {
    var pager = document.getElementById(target.getAttribute("pager"));
    var prevButton = pager.childNodes[0];
    if (prevButton != undefined && prevButton != "undefined" && prevButton != null) {
        if (prevButton.href != "") {
            eval(prevButton.href);
        }
    }
}