// Workcast 

var d = document;
var iContainer;  				// container for images		
var newPos = 0;  				// scroll to position
var oldPos = 0;  				// previous postion
var scrollNum;  				// max scroll distance
var l = new Object();          // left hand controller
var r = new Object();          // right hand controller
var imageArray; 				// how many images we are dealing with
var w;          				// width of images
var m;          				// rollover position
var dir;
var num;
var descriptions = new Array();


descriptions = ["Chris Wilds from Communicator Corp talks about how WorkCast helped with his company's webcasting needs.",
                "Paul Callaghan, Chairman of Leighton Group, talks about how Web Conferencing and Webcasting are changing the way people do business.",
                "Gerard Callaghan, Managing Director of Workcast, talks about how Webcast Manager from WorkCast is bringing affordable Webcasting technology to normal business users.",
				"A product overview of WebCast Manager from The WorkCast Corporation.",
				"A presentation about the various benefits of using webcasting within your organisation."]

var urls = new Array();

urls = ["http://view.workcast.net/auditorium/?pak=3943319749203758",
                "http://view.workcast.net/auditorium/?pak=8195877510042859",
                "http://view.workcast.net/auditorium/?pak=5678368073638349",
				"http://view.workcast.net/auditorium/?pak=3326133813057886",
				"http://view.workcast.net/auditorium/?pak=2339923741604102"]

function addOnload(myfunc) {

    if (window.addEventListener)
        window.addEventListener('load', myfunc, false);
    else if (window.attachEvent)
        window.attachEvent('onload', myfunc);
}

addOnload(initialise);

function initialise() {

    iContainer = d.getElementById("imageContainer");
    imageArray = iContainer.getElementsByTagName('img');

    l = d.getElementById("scrollLeft");
    r = d.getElementById("scrollRight");

    l.num = 0;
    r.num = 0;

    l.onclick = function() {
        dir = 0;
        scrollObjects(dir);
    }

    r.onclick = function() {
        dir = 1;
        scrollObjects(dir);
    }

    w = getW(imageArray[0]); // get width of a single image

    if (w < 211) {

        w += 9;

        m = "-24";

    } else {

        w += 16; // add borders and padding

        m = "-45"; // the rollovers for the arrows
    }


    scrollNum = ((imageArray.length - 2) * w) * -1;

    r.onmouseover = function() {
        rollover(this, 1);
    }

    checkContainerPos();

}

function checkContainerPos() {

    var iCW = getW(iContainer);

    if (newPos == 0) {
        l.style.filter = "alpha(opacity=50)";
        l.style.opacity = ".5";
        l.style.cursor = "default";
        if (l.num > 0) l.onmouseover = null;
    } else {
        l.onmouseover = function() {
            l.num = 1;
            rollover(this, 1);
        }

        l.onmouseout = function() {
            rollover(this, 0);
        }
        l.style.filter = "alpha(opacity=100)";
        l.style.opacity = "1";
        l.style.cursor = "pointer";
    }

    if (newPos == ((imageArray.length - 1) * w) * -1) {
        r.style.filter = "alpha(opacity=50)";
        r.style.opacity = ".5";
        r.style.cursor = "default";
        if (r.num > 0) r.onmouseover = null;
    } else {
        r.onmouseover = function() {
            r.num = 1;
            rollover(this, 1);
        }
        r.onmouseout = function() {
            rollover(this, 0);
        }
        r.style.filter = "alpha(opacity=100)";
        r.style.opacity = "1";
        r.style.cursor = "pointer";
    }


}

function rollover(whatRoll, whatWay) {

    i = d.getElementById(whatRoll.id);
    switch (whatWay) {
        case 0: i.style.backgroundPosition = "left top"; break;
        case 1: i.style.backgroundPosition = "left " + m + "px"; break;
    }
}

function scrollObjects(dir) {

    oldPos = newPos;

    if (dir == 1) {
        if (oldPos >= scrollNum) {
            newPos -= w;
            new Effect.Move(iContainer.id, { x: newPos, y: 0, mode: 'absolute', afterFinish: checkContainerPos() });
        }

    } else {
        if (oldPos < 0) {
            newPos += w;
            new Effect.Move(iContainer.id, { x: newPos, y: 0, mode: 'absolute', afterFinish: checkContainerPos() });
        }
    }
}

function getW(obj) {

    return (obj.offsetWidth);
}

function getX(obj) {

    return (obj.offsetLeft);
}


function getY(obj) {

    return (obj.offsetTop);
}

function showOverlay(whatVid, whatImage, num) {

    bg = d.getElementById("overlay");
    vT = d.getElementById("videoText");
    vid = d.getElementById(whatVid);
    image = d.getElementById(whatImage);

    var xPos = getX(d.getElementById(image.id)) - 6;
    var yPos = getY(d.getElementById(image.id)) - 6;
    bg.style.left = (xPos + 6) + "px";
    bg.style.top = (yPos + 6) + "px";
    bg.style.display = "block";
    bg.style.cursor = "pointer";
    bg.innerHTML = descriptions[num];
    bg.onclick = function() {
        window.open(urls[num], 'auditorium', 'toolbar=0, menubar=0, location=0, status=0, resizable=1, scrollbars=yes');
    }
}

function hideOverlay() {
    bg = d.getElementById("overlay");
    bg.style.display = "none";

}

