﻿///////////////////////////////////////////////////////////////////////////////
// This code was written and is copyright by Andrew H. Cooper
// If you wish to reuse it then pleases credit me
// If you wish to contact me so I can write code for you then please do so
// Either by email at andrew.cooper@the-arena.co.uk
// Or by phone on 0044 7956 430145
///////////////////////////////////////////////////////////////////////////////

var isIE = document.all;
var tmr = null;
var current_panel;
var panel_active = false;

//this will fire the myFunction method every 1000 milliseconds (1 second)
//var tmr_1 = setInterval("myFunction()", 1000);

//and this will stop it
//clearInterval(tmr);

//function initMove(distance, speed)
//{
//    tmr = setInterval("moveBox(" + distance + ")", speed); 
//}

//function moveBox(distance)
//{
//    //var box = document.getElementById('myText');
//    var box = document.getElementById('AndysMovingDiv');
//    box.style.top = (box.offsetTop + distance) + "px";
//    box.style.left = ((box.offsetLeft + distance) - (box.Width / 2)) + "px";
//}


function stopstartbox(extendedID) {

    current_panel = document.getElementById('AndysMovingDiv' + extendedID);
    current_panel.style.position = "absolute";
    panel_active = !panel_active;

    var AndysPushPin = document.getElementById('AndysPushPin' + extendedID)
    if (panel_active) {
        AndysPushPin.src = "images/purple-pushpin_out.gif";
    } else {
        AndysPushPin.src = "images/purple-pushpin_in.gif";
    }
}

//function updatebox(evt) {
//    if (boxmove) {

//        if (evt.pageX) 
//            mouseX = evt.pageX;
//        else if (evt.clientX)
//            mouseX = evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
//        //mouseX = evt.pageX?evt.pageX:evt.clientX;

//        if (evt.pageY) 
//            mouseY = evt.pageY;
//        else if (evt.clientY)
//            mouseY = evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
//        //mouseY = evt.pageY?evt.pageY:evt.clientY;
//        
//        var box = document.getElementById('AndysMovingDiv');
//        //alert(box.offsetWidth);
//        
//        box.style.left = (mouseX  - (box.offsetWidth / 2)) - 3;
//        box.style.top = mouseY - 19;
//        
//    }
//}

function updatebox(e) {

    var mouseX = 0;
    var mouseY = 0;

    if (panel_active) {

        if (!e) var e = window.event;
        if (e.pageX || e.pageY) {
            mouseX = e.pageX;
            mouseY = e.pageY;
        }
        else if (e.clientX || e.clientY) {
            mouseX = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
            mouseY = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
        }

        //var box = document.getElementById('AndysMovingDiv' + extendedID);

        current_panel.style.left = ((mouseX - (current_panel.offsetWidth / 2)) - 0) + 'px';
        current_panel.style.top = (mouseY - 10) + 'px';

    }


    ////    // create a DIV element, using the variable eDIV as a reference to it
    ////    eDIV = document.createElement("div");
    ////    //use the setAttribute method to assign it an id
    ////    eDIV.setAttribute("id","myDiv");
    ////    // add the text "hello world" to the div with createTextNode
    ////    eDIV.appendChild(document.createTextNode("boxmove:[" + boxmove + "] - x:[" + mouseX + "] - x:[" + mouseY + "]"));
    ////    // append your newly created DIV element to an already existing element.
    ////    //document.getElementById("positionInformation").removeChild(0);
    ////    document.getElementById("positionInformation").appendChild(eDIV);
    ////    positionInformation.innerHTML
}

//document.onmousemove = updatebox(event);

