/*
 * CONFIDENTIAL AND PROPRIETARY
 * © COPYRIGHT 2006 (UNPUBLISHED WORK) VoiceQuilt.
 * ALL RIGHTS RESERVED.
*/

browserIsIE = (navigator.appVersion.indexOf("MSIE") != -1);

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (obj.offsetParent) {
            curtop += obj.offsetTop
        //    if (browserIsIE)
        //        curtop += obj.style.borderTop;
            obj = obj.offsetParent;
        }
	    //if (browserIsIE)
	    //    curtop += obj.style.borderTop;
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

function getElementWithId(id) {
    if (document.getElementById) {
        this.obj = document.getElementById(id);
        this.style = document.getElementById(id).style;
    }
    else if (document.all) {
        this.obj = document.all[id];
        this.style = document.all[id].style;
    }
    else if (document.layers) {
        if (document.layers[id]) {
            this.obj = document.layers[id];
            this.style = document.layers[id];
        }
        else {
            this.obj = document.layers.testP.layers[id];
            this.style = document.layers.testP.layers[id];
        }
    }
}

function setPosition(objId, refObj, offsetX, offsetY, show) {
    var newX = offsetX;
    var newY = offsetY;
    if (refObj) {
        newX += findPosX(refObj);
        newY += findPosY(refObj);
    }
    var x = new getElementWithId(objId);
    x.style.top = newY + 'px';
    x.style.left = newX + 'px';
    x.style.visibility = show ? 'visible' : 'hidden';
}

function play(playButton, theAudioUrl) {
    setPosition('wimpyTarget', playButton, 18, 0, true);
    wimpy_clearPlaylist();
    wimpy_addTrack(true, theAudioUrl, '', '', '', '');
}

function playUrl(theAudioUrl) {
    wimpy_clearPlaylist();
    wimpy_addTrack(true, theAudioUrl, '', '', '', '');
}
