﻿var Modules_Card_UC_SortPaging =
{
    Change_SortBy: function(ddl, sortDesc, hdf) {
        get(hdf).value = ddl.selectedIndex;
        if (ddl.selectedIndex == 0)
            $('#' + sortDesc).hide();
        else
            $('#' + sortDesc).show();
    }
}

var Modules_Box_ParentNewsBox =
{
    content: null,
    curTab: null,
    tab: null,

    E: function(id) {
        if (id == null || id == "")
            return null;
        if (id && id.tagName)
            return id;
        return document.getElementById(id);
    },

    init: function() {
        var active = 0;
        this.content = Modules_Box_ParentNewsBox.E(this.content);
        for (var i = 0; i < this.tab.length; i++) {
            var but = Modules_Box_ParentNewsBox.E(this.tab[i][0]);
            if (but != null) {
                but.content = Modules_Box_ParentNewsBox.E(this.tab[i][1]);
                var c = Modules_Box_ParentNewsBox.E(but.content);
                var txt = c != null ? c.innerText || c.textContent : "";
                if (txt == "") {
                    $(but).hide();
                    if (i == active) active++;
                }
                else
                    $(but).mousedown(function changeTab() {
                        if (this != Modules_Box_ParentNewsBox.curTab) {
                            if (Modules_Box_ParentNewsBox.curTab) {
                                Modules_Box_ParentNewsBox.curTab.className = "TabBox_Title";
                                $(Modules_Box_ParentNewsBox.curTab.content).hide();
                            }

                            $.cookie("_cdtabttnet789", this.id);
                            this.className = "TabBox_Title_Select";
                            
                            if (this.content.parentNode != Modules_Box_ParentNewsBox.content) {
                                this.content.parentNode.removeChild(this.content);
                                Modules_Box_ParentNewsBox.content.appendChild(this.content);
                            }
                            $(this.content).show();
                            Modules_Box_ParentNewsBox.curTab = this;
                        }
                    });
            }

            if (this.tab.length > 0)
                this.changeTab(this.E(this.tab[active][0]), this.tab[active][1]);
        }
    },

    changeTab: function(but, butContent) {
        if (but != this.curTab) {
            if (this.curTab) {
                this.curTab.className = "TabBox_Title";
                $(this.curTab.content).hide();
            }
            but.className = "TabBox_Title_Select";
            but.content = Modules_Box_ParentNewsBox.E(butContent);
            if (but.content.parentNode != this.content) {
                but.content.parentNode.removeChild(but.content);
                this.content.appendChild(but.content);
            }
            $(but.content).show();
            this.curTab = but;
        }
    },

    Reactive: function() {
        var curTab = $.cookie("_cdtabttnet789");
        if (curTab != null && curTab != "") {
            var active = 0;

            for (var i = 0, len = this.tab.length; i < len; i++) {
                if (this.tab[i][0] == curTab) {
                    active = i;
                    break;
                }
            }

            this.changeTab(this.E(this.tab[active][0]), this.tab[active][1]);
        }
    }
}

var Module_NewsModule_User_UC_UC_PaypalCreditCard =
{
    CountryChange: function(source, ddl_state) {
        var tb = WEB_Ajax.GetState(source.value).value;
        var state = get(ddl_state);
        state.innerHTML = "";
        if (tb != null) {
            for (var i = 0; i < tb.Rows.length; i++) {
                var opt = document.createElement("OPTION");
                state.appendChild(opt);
                opt.innerHTML = tb.Rows[i]["State_Name"];
            }
        }
    }
}

function ___paging_submit(name) {
    $('[name=' + name + ']').click();
}
