﻿function switchTab(clientId, activateTab) {
    if (activateTab == 1) {
        document.getElementById("Tab_" + clientId + "_" + 1).className = "current";
        document.getElementById("Tab_" + clientId + "_" + 2).className = "";
        document.getElementById("Div_" + clientId + "_" + 1).style.display = "";
        document.getElementById("Div_" + clientId + "_" + 2).style.display = "none";
    }
    else {
        document.getElementById("Tab_" + clientId + "_" + 1).className = "";
        document.getElementById("Tab_" + clientId + "_" + 2).className = "current";
        document.getElementById("Div_" + clientId + "_" + 1).style.display = "none";
        document.getElementById("Div_" + clientId + "_" + 2).style.display = "";
    }
}

function articleRecommend(sUrl) {
    window.open(sUrl, 'Skicka', 'width=350,height=350,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no');
}

function articleLink(sUrl) {
    window.open(sUrl, 'Länk', 'width=450,height=220,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no');
}

function articlePrint(sUrl) {
    window.open(sUrl, 'Skriv', 'width=494,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no');
}

function ChartStockOpenWin(PagePath, SubMarket, InstID, WinName, TraderPeriod, statisticHref) {
    if (SubMarket == '') SubMarket = 'SSE';
    if (InstID == 'B-IDX-NIKK') SubMarket = 'TSE';

    if (statisticHref) {
        $.get(
            statisticHref
        );
    }
    
    window.open(PagePath + '?id=' + escape(InstID) + '&market=' + escape(SubMarket) + '&magic=(cc (detail (period ' + TraderPeriod + ')))', 'WinName', 'width=615,height=515,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=Yes,copyhistory=no');
}

function CalculateHeight(height, width, maxWidth) {
    return maxWidth > 0 && width > maxWidth ? Math.ceil(height * maxWidth / width) : height;
}

function CalculateWidth(width, maxWidth) {
    return maxWidth > 0 && width > maxWidth ? maxWidth : width;
}
