// SHOW / HIDE CONTENT FUNCTION

jsMaxCount = 30;
var scrollTimer = 0;

function PlayMP3(url, title) {
    document.getElementById('flashPlayer').style.visibility = 'visible';
    setTimeout("go('" + url + "','" + title + "')", 100);
}

function go(url, title) {
    document.getElementById('myFlash').SetVariable('mp3url', url);
    document.getElementById('myFlash').SetVariable('mp3title', title);
    document.getElementById('myFlash').SetVariable('play', '');
}

function load() {
    if (window.location.href == 'http://www.greatmusic.dk/dansk.aspx' || window.location.href == 'http://greatmusic.dk/dansk.aspx' || window.location.href == 'http://www.greatmusic.dk/english.aspx' || window.location.href == 'http://greatmusic.dk/english.aspx') {
        PlayMP3('/media/257/wincrimes.mp3', 'winchimeslyden');
    }
}

function HideContent(d) { document.getElementById(d).style.display = "none"; }
function ShowContent(d) { document.getElementById(d).style.display = ""; }
function ReverseContentDisplay(d) {
    if (document.getElementById(d).style.display == "none") {
        document.getElementById(d).style.display = "block";
    } else { document.getElementById(d).style.display = "block"; } 
}




function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function openHoriz(url) {
    if (url.length > 0) {
        popupWin = open(url, "Popup", "resizable=no,scrollbars=no,width=525,height=460");
    }
}
function openVert(url) {
    if (url.length > 0) {
        popupWin = open(url, "Popup", "resizable=no,scrollbars=no,width=450,height=640");
    }
}
function closeWindow() {
    window.close()
}

function selectImage(smallImageName) {
    document.getElementById('selectedImage').src = smallImageName.replace(/^small_/, '');
}

var scrollTimer = 0;

function startScroll(direction) {
    if (!scrollTimer) {
        if (direction == 1) {
            scrollTimer = setInterval(scrollLeft, 15);
        }
        else {
            scrollTimer = setInterval(scrollRight, 15);
        }
    }
}

function scrollLeft() {
    var dl = document.getElementById('smallImageList');

    var n = parseInt(dl.style.marginLeft);

    if (isNaN(n))
        n = 0;

    if (n <= 0)
        dl.style.marginLeft = (n + 5) + 'px';
}

function scrollRight() {
    var dl = document.getElementById('smallImageList');

    var n = parseInt(dl.style.marginLeft);

    if (isNaN(n))
        n = 0;

    dl.style.marginLeft = (n - 5) + 'px';
}


function stopScroll() {
    clearInterval(scrollTimer);
    scrollTimer = 0;
}

var SL_scrollTimer = 0;
var SL_scrollInterval = 230 * 3;
var SL_scrollCount = 0;

function SL_startScroll(direction) {
    if (!SL_scrollTimer) {
        if (direction == 1) {
            SL_scrollCount++;
            if (SL_scrollCount > 0)
                SL_scrollCount = 0;
            SL_scrollTimer = setInterval(SL_scrollLeft, 1);
        }
        else {
            SL_scrollCount--;
            if (SL_scrollCount > 0)
                SL_scrollCount = 0;
            if (SL_scrollCount <= -jsMaxCount / 3)
                SL_scrollCount++;

            SL_scrollTimer = setInterval(SL_scrollRight, 1);
        }
    }
}

function SL_scrollLeft() {
    var dl = document.getElementById('smallImageList');

    var n = parseInt(dl.style.marginLeft);

    if (isNaN(n))
        n = 0;


    if (n > SL_scrollInterval * SL_scrollCount) {
        SL_stopScroll();
    } else {
        if (n < 0) {
            curdist = (SL_scrollInterval * SL_scrollCount) - n;
            movedist = curdist / 6 + 1;
            dl.style.marginLeft = (n + movedist) + 'px';
        } else {
            SL_stopScroll();
        }

    }

}

function SL_scrollRight() {
    var dl = document.getElementById('smallImageList');

    var n = parseInt(dl.style.marginLeft);

    if (isNaN(n))
        n = 0;



    if (n < SL_scrollInterval * SL_scrollCount) {
        SL_stopScroll();
    } else {
        curdist = (SL_scrollInterval * SL_scrollCount) - n;
        movedist = curdist / 6 - 1;
        dl.style.marginLeft = (n + movedist) + 'px';
    }
}


function SL_stopScroll() {
    clearInterval(SL_scrollTimer);
    SL_scrollTimer = 0;
}
