/* FAQ */
function collapse(divID, variable) {
    //kept for backwards compatability
}

function replaceHomeSectionClass(color) {
    var element;
    if (navigator.appName == 'Microsoft Internet Explorer')
        element = document.getElementById('main').previousSibling;
    else
        element = document.getElementById('main').previousSibling.previousSibling;
    element.className = color + "-home";
}

/* News ticker Script */
function changecontent() {
    var container = document.getElementById("tickerdata");
    var heads1 = container.getElementsByTagName('li');
    var fcontent = new Array();

    for (var i = 0; i < heads1.length; i++) {
        fcontent[i] = heads1[i].innerHTML;
    }

    if (index >= fcontent.length)
        index = 0
    if (DOM2) {
        document.getElementById("ticker").innerHTML = fcontent[index]

        if (fadelinks)
            linkcolorchange(1);
        colorfade(1, 15);
    }
    else if (ie4)
        document.all.ticker.innerHTML = fcontent[index];
    index++
}

function linkcolorchange(step) {
    var obj = document.getElementById("ticker").getElementsByTagName("A");

    if (obj.length > 0) {
        for (i = 0; i < obj.length; i++) {
            obj[i].style.color = getstepcolor(step);
        }
    }
}

function colorfade(step) {
    var fadecounter;

    if (step <= maxsteps) {
        document.getElementById("ticker").style.color = getstepcolor(step);

        if (fadelinks)
            linkcolorchange(step);
        step++;
        fadecounter = setTimeout("colorfade(" + step + ")", stepdelay);
    }
    else {
        clearTimeout(fadecounter);
        document.getElementById("ticker").style.color = "rgb(" + endcolor[0] + ", " + endcolor[1] + ", " + endcolor[2] + ")";
        setTimeout("changecontent()", delay);
    }
}


function getstepcolor(step) {
    var diff
    var newcolor = new Array(3);

    for (var i = 0; i < 3; i++) {
        diff = (startcolor[i] - endcolor[i]);

        if (diff > 0) {
            newcolor[i] = startcolor[i] - (Math.round((diff / maxsteps)) * step);
        }
        else {
            newcolor[i] = startcolor[i] + (Math.round((Math.abs(diff) / maxsteps)) * step);
        }
    }
    return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}


function openWindow(pagina, naam, width, height, x, y, scrollbars) {
    var sOptions = "height=" + height;
    sOptions += ", width=" + width;
    sOptions += ", left=" + x;
    sOptions += ", top=" + y;
    sOptions += ", scrollbars=" + scrollbars;
    sOptions += ", menubar=no, resizable=no, status=no, titlebar=no, toolbar=no, location=no, directories=no";
    var objWindow = window.open(pagina, naam, sOptions);
    objWindow.focus();
    return true;
}

function openWindow(name, title) {
    var newWin = window.open('', '', 'location=no, menubar=no, status=no, width=410, height=500, top=200, left=200');
    newWin.document.write("<html><head><title>" + title + "</title><link rel=\"stylesheet\" href=\"../../css/styles.css\" type=\"text/css\"></head><body>");
    newWin.document.write(document.getElementById(name).innerHTML);
    newWin.document.write("</body></html>");
    return false;
}

//============================================
// CAROUSSEL BASED ON PICTURES in SDL TRIDION
//============================================
function createTridionCaroussel(sCollectionId, sThumbWidth, sThumbHeight, sEffect, sPreviousId, sNextId) {
    $('#' + sCollectionId + ' img').width(sThumbWidth + 'px');
    $('#' + sCollectionId + ' img').height(sThumbHeight + 'px');
    //$('#' + sCollectionId + ' img').each(function(index, image) {
        //var sHeight = $(image).height();
        //if (sHeight > sThumbWidth){
        //	$(image).height(sThumbWidth + 'px');
        //} 
    //});
    $('#' + sCollectionId).cycle({
        fx: sEffect,
        timeout: 8000,
        next: '#' + sNextId,
        prev: '#' + sPreviousId
    });
}

$(function() {
    $("#main table.features tr td:contains('True')").each(function() {
        if ($(this).parent().hasClass('alternate')) {
            $(this).html('<img src="/images/table-highlight-check-alternate.jpg" alt="check" />');
        } else {
            $(this).html('<img src="/images/table-highlight-check.jpg" alt="check" />');
        }
    });

    $("#main div.collapse-content dl dd").hide();

    $("#main div.collapse-content dl dt.statement").click(function() {
        var id = $(this).attr('id');
        var answerId = "#" + id.replace('dt', 'dd');
        if ($(answerId).is(':visible')) {
            $(this).removeClass('active');
            $(answerId).slideUp();
        }
        else {
            $(answerId).slideDown();
            $(this).addClass('active');
            WbtrsTrigger($(answerId)[0]);
        }
    });

    if ($("#main #innertabs ul.tablinks li[active]").size() == 0) {
        $("#main #innertabs ul.tablinks li a[href='#tab1']").parent().addClass('active');
        $("#main #innertabs ul.tablinks").css("margin", "0");
        $("#main #innertabs #innertabs-content div.article").hide();
        $("#main #innertabs #innertabs-content #tab1").show();
        $("#main #innertabs #innertabs-content-wrapper span.rc-top-left").css("background", "none");
    }

    $("#main #innertabs ul.tablinks li a").click(function() {
        $("#main #innertabs ul.tablinks li").removeClass('active');
        $("#main #innertabs #innertabs-content div.article").hide();
        $("#main #innertabs #innertabs-content " + $(this).attr('href')).show();
        $(this).parent().addClass('active');

        if ($(this).attr('href') == '#tab1') {
            $("#main #innertabs ul.tablinks").css("margin-left", "0px");
            $("#main #innertabs #innertabs-content-wrapper span.rc-top-left").css("background", "none");
        } else {
            $("#main #innertabs ul.tablinks").css("margin-left", "7px");
            $("#main #innertabs #innertabs-content-wrapper span.rc-top-left").css("background", "transparent url(/images/rc-top-left.jpg) no-repeat scroll left top");
        }
    });

    $("span.tooltip").each(function() {
        $(this).qtip({
            content: $("#" + $(this).attr('id').replace("tooltip", "tooltipcontent")).html(), // Use the tooltip attribute of the element for the content
            style: { 
                  border: { 
                  width: 2, 
                  radius: 10, 
                  color: '#5791C6' 
            },
            hide: {
                  when: { event: 'mousemove'},
                  delay: 1000
            },
                  background: '#ffffff', 
                  color: '#000000', 
                  padding: 10, 
                  textAlign: 'left', 
                  tip: true
            } 

        });
    });
});