function ShowPlans() {
    var plans = document.getElementById('plans');
    var rates = document.getElementById('rates');
    var plansTab = document.getElementById('plansTab');
    var ratesTab = document.getElementById('ratesTab');

    plans.style.display = 'block';
    rates.style.display = 'none';
    plansTab.className = 'current';
    ratesTab.className = '';

    SetMainContentSize();
}

function ShowRates() {
    var plans = document.getElementById('plans');
    var rates = document.getElementById('rates');
    var plansTab = document.getElementById('plansTab');
    var ratesTab = document.getElementById('ratesTab');

    plans.style.display = 'none';
    rates.style.display = 'block';
    ratesTab.className = 'current';
    plansTab.className = '';

    SetMainContentSize();
}

function ShowHideCountriesAutomatic(countryLetter) {
    var country = document.getElementById('country' + countryLetter);
    var contentItem = document.getElementById('content' + countryLetter);
    var actionImg = document.getElementById('action' + countryLetter);

    if (country.className == 'prg_active_item') {
        country.className = 'prg_item';
        contentItem.style.display = 'none';
        actionImg.src = './images/phonegridimg/plus.png';
    }
    else {
        country.className = 'prg_active_item';
        contentItem.style.display = 'block';
        actionImg.src = './images/phonegridimg/minus.png';
    }

    SetMainContentSize();
}

function ShowHideCountries(countryLetter, show) {
    var country = document.getElementById('country' + countryLetter);
    var contentItem = document.getElementById('content' + countryLetter);
    var actionImg = document.getElementById('action' + countryLetter);

    HideCountry('A');
    HideCountry('B');
    HideCountry('C');
    HideCountry('D');
    HideCountry('E');
    HideCountry('F');
    HideCountry('G');
    HideCountry('H');
    HideCountry('I');
    HideCountry('J');
    HideCountry('K');
    HideCountry('L');
    HideCountry('M');
    HideCountry('N');
    HideCountry('O');
    HideCountry('P');
    HideCountry('Q');
    HideCountry('R');
    HideCountry('S');
    HideCountry('T');
    HideCountry('U');
    HideCountry('V');
    HideCountry('W');
    HideCountry('X');
    HideCountry('Y');
    HideCountry('Z');

    if (country != null && contentItem != null && actionImg != null) {
        if (show) {
            country.className = 'prg_active_item';
            contentItem.style.display = 'block';
            actionImg.src = './images/phonegridimg/minus.png';
        }
        else {
            country.className = 'prg_item';
            contentItem.style.display = 'none';
            actionImg.src = './images/phonegridimg/plus.png';
        }
    }

    SetMainContentSize();
}

function HideCountry(countryLetter) {
    var country = document.getElementById('country' + countryLetter);
    var contentItem = document.getElementById('content' + countryLetter);
    var actionImg = document.getElementById('action' + countryLetter);
    var showAll = document.getElementById('showAll');
    var hideAll = document.getElementById('hideAll');

    showAll.style.display = 'block';
    hideAll.style.display = 'none';

    if (country != null && contentItem != null && actionImg != null) {
        country.className = 'prg_item';
        contentItem.style.display = 'none';
        actionImg.src = './images/phonegridimg/plus.png';
    }

    SetMainContentSize();
}

function ShowCountry(countryLetter) {
    var country = document.getElementById('country' + countryLetter);
    var contentItem = document.getElementById('content' + countryLetter);
    var actionImg = document.getElementById('action' + countryLetter);

    if (country != null && contentItem != null && actionImg != null) {
        country.className = 'prg_active_item';
        contentItem.style.display = 'block';
        actionImg.src = './images/phonegridimg/minus.png';
    }

    SetMainContentSize();
}

function ShowHideAllCountries() {
    var showAll = document.getElementById('showAll');
    var hideAll = document.getElementById('hideAll');

    SetMainContentSize();

    if (hideAll.style.display == 'none') {

        showAll.style.display = 'none';
        hideAll.style.display = 'block';
        ShowCountry('A');
        ShowCountry('B');
        ShowCountry('C');
        ShowCountry('D');
        ShowCountry('E');
        ShowCountry('F');
        ShowCountry('G');
        ShowCountry('H');
        ShowCountry('I');
        ShowCountry('J');
        ShowCountry('K');
        ShowCountry('L');
        ShowCountry('M');
        ShowCountry('N');
        ShowCountry('O');
        ShowCountry('P');
        ShowCountry('Q');
        ShowCountry('R');
        ShowCountry('S');
        ShowCountry('T');
        ShowCountry('U');
        ShowCountry('V');
        ShowCountry('W');
        ShowCountry('X');
        ShowCountry('Y');
        ShowCountry('Z');
    }
    else {

        showAll.style.display = 'block';
        hideAll.style.display = 'none';
        HideCountry('A');
        HideCountry('B');
        HideCountry('C');
        HideCountry('D');
        HideCountry('E');
        HideCountry('F');
        HideCountry('G');
        HideCountry('H');
        HideCountry('I');
        HideCountry('J');
        HideCountry('K');
        HideCountry('L');
        HideCountry('M');
        HideCountry('N');
        HideCountry('O');
        HideCountry('P');
        HideCountry('Q');
        HideCountry('R');
        HideCountry('S');
        HideCountry('T');
        HideCountry('U');
        HideCountry('V');
        HideCountry('W');
        HideCountry('X');
        HideCountry('Y');
        HideCountry('Z');
    }
}

function SetMainContentSize() {

    var conHeight = $("#divTabs").height();

    $("#container_credit").height((1050 + conHeight));

    switch (pageLanguage) {

        case "fr":
        
        case "ru":
        
        case "de":

            $("#container_credit").height((1080 + conHeight));
            break;

        default:
            break;
    }
}

function SetPageHeigh() {
   
    if ($("#tblPhoneRates").length) {
   
        var conHeight = $("#tblPhoneRates").height();
   
        switch (pageLanguage) {

            case 'fr':
                $("#container").height((1500 + conHeight));
                break;

            case 'pt':
                $("#container").height((1450 + conHeight));
                break;

            case 'de':
                $("#container").height((1450 + conHeight));
                break;

            case 'he':
                $("#container").height((1300 + conHeight));
                break;
            
            case 'it':
                $("#container").height((1420 + conHeight));
                break;

            case 'ru':
                $("#container").height((1450 + conHeight));
                break;
            
            case 'es':
                $("#container").height((1400 + conHeight));
                break;

            default:
                $("#container").height((1200 + conHeight));
                break;

        }
    }
}

function SetTabsForMac() {

    $("#tabAllRates").css("font-size", "14px");
    $("#tabAllRates").css("padding-top", "13px");

    $("#tabOurPlans").css("font-size", "14px");
    $("#tabOurPlans").css("padding-top", "13px");
   
}

$(document).ready(function () {
    
    SetPageHeigh();

    var mac = navigator.appVersion.toLowerCase().indexOf("mac") != -1 ? true : false;

    if (mac) {

        SetTabsForMac();
    }

});

