var showSlot1 = false;
var showSlot2 = false;

function createHeader(c, a) {
    var b = new MainMenu(c, a);
    b.getDropDown()
}
function createFooter(c, b) {
    var a = Math.floor(Math.random() * 4);
    b += "?" + a;
    createContentFeed(c, b)
}
function createContentFeed(b, a) {
    $.get(a, function (c) {
        $("#" + b).html(c)
    })
}
function createMouseEvent(f, h, j) {
    $(document.body).mousedown(function (k) {
        var l = $(k.target).parents(f);
        if (l.length == 0) {
            $(f).each(function () {
                if (!inDiv(this.id, j)) {
                    if (!$("#" + this.id + " > .dd_panel").is(":hidden")) {
                        $("#" + this.id + " > .dd_panel").hide()
                    }
                }
            })
        }
    });
    var g = "";
    var a = "";
    var c = "";
    $(h).each(function () {
        if ((this.id == "linkSlotOne") || (this.id == "linkSlotTwo")) {
            if (a != "") {
                a += ","
            }
            a += "#" + this.id;
            if (c != "") {
                c += ","
            }
            c += "#" + this.parentNode.id
        } else {
            if (g != "") {
                g += ","
            }
            g += "#" + this.id
        }
    });
    $(g).bind("click", function (k) {
        var l = this.parentNode;
        $("div.dd_panel").each(function () {
            if (this.parentNode == l) {
                if ($(this).is(":hidden")) {
                    $(this).animate({
                        height: "show",
                        opacity: "show"
                    }, 400)
                } else {
                    $(this).hide()
                }
            } else {
                $(this).hide()
            }
        })
    });
    $(a).bind("mouseover", function () {
        var k = this.parentNode;
        $("div.dd_panel").each(function () {
            if (this.parentNode == k) {
                if ($(this).is(":hidden")) {
                    $(this).show()
                }
            } else {
                if (!inDiv(this.parentNode.id, j)) {
                    if (!$(this).is(":hidden")) {
                        $(this).hide()
                    }
                }
            }
        })
    });
    var e = 0;
    var d = null;
    var b = null;
    $(c).mouseout(function () {
        switch (this.id) {
        case "divSlotOne":
            showSlot1 = false;
            d = setTimeout("hideDropDown('" + this.id + "')", 100);
            break;
        case "divSlotTwo":
            showSlot2 = false;
            b = setTimeout("hideDropDown('" + this.id + "')", 100);
            break
        }
    }).mouseover(function () {
        switch (this.id) {
        case "divSlotOne":
            showSlot1 = true;
            if (d) {
                clearTimeout(d)
            }
            break;
        case "divSlotTwo":
            showSlot2 = true;
            if (b) {
                clearTimeout(b)
            }
            break
        }
    })
}
function hideDropDown(a) {
    switch (a) {
    case "divSlotOne":
        if (showSlot1) {
            return
        }
        break;
    case "divSlotTwo":
        if (showSlot2) {
            return
        }
        break
    }
    if (!$("#" + this.id + ">.dd_panel").is(":hidden")) {
        $("#" + a + ">.dd_panel").hide()
    }
}
function inDiv(c, a) {
    var b = a.split(",");
    for (i = 0; i < b.length; i++) {
        if (c == b[i].substring(1, b[i].length)) {
            return true
        }
    }
    return false
}
function hideDiv(a) {
    $("#" + a + " > .dd_panel").hide()
}
function createPageContent(a, f, c, d, e, b) {
    myPage = new PageContent();
    myPage.createPageContent(a, f, c, d, e, b)
}
function createHistory(c, b, a) {
    myHistory = new History();
    myHistory.add_history(document.title, window.location.href);
    myHistory.display_history(c)
}
function createFaq(a, b, c) {
    myFaq = new FAQ();
    myFaq.createFaq(a, b, c)
}
function createAbout(a, c, d, b) {
    myAbout = new About();
    myAbout.createAbout(a, c, d, b)
}
function popupWindow(b, a, c) {
    window.open(b, a, c)
}
function go(c, d, b, a) {
    var f = (screen.width / 2) - (d / 2);
    var e = (screen.height / 2) - (b / 2);
    window.open(c, "popup", "toolbar=0,scrollbars=" + a + ",location=0,statusbar=0,menubar=0,resizable=0,width=" + d + ",height=" + b + ",top=" + e + ",left=" + f)
}
function isPopup(a) {
    a = a.replace(" ", "");
    if ((a == "_blank") || (a == "_parent") || (a == "_self") || (a == "_top") || (a == "")) {
        return false
    } else {
        return true
    }
}
function OpenLink(b) {
    var d = b.split("|");
    var a = d[0];
    var c = d[1];
    if (a == "") {
        return
    }
    switch (d[1]) {
    case "":
        window.location.href = a;
        break;
    case "_blank":
        popupWindow(a, "01", "");
        break;
    case "_parent":
        window.location.href = a;
        break;
    case "_self":
        window.location.href = a;
        break;
    case "_top":
        window.location.href = a;
        break;
    default:
        popupWindow(a, "01", c);
        break
    }
}
function checkup(a, c) {
    if (!c) {
        c = "en"
    }
    var b = new Array();
    b.en = {
        user: "Please fill in Member ID",
        pin: "Please fill in pin code"
    };
    b.th = {
        user: "à¸?à¸£à¸¸à¸“à¸²à¸?à¸£à¸à¸?à¸«à¸¡à¸²à¸¢à¹€à¸¥à¸‚à¸ªà¸¡à¸²à¸Šà¸´à¸?",
        pin: "à¸?à¸£à¸¸à¸“à¸²à¸?à¸£à¸à¸?à¸£à¸«à¸±à¸ªà¸›à¸£à¸°à¸ˆà¸³à¸•à¸±à¸§"
    };
    if (a.userid.value == "") {
        alert(b[c].user);
        a.userid.focus();
        return false
    }
    if (a.pin.value == "") {
        alert(b[c].pin);
        a.pin.focus();
        return false
    }
    return true
}
function MainMenu(g, f) {
    this.getDropDown = b;
    var a = new Array(null, null, null, null, null);
    var c = new Array(false, false, false, false, false);

    function b() {
        var h = Math.floor(Math.random() * 4);
        for (i = 0; i < g.length; i++) {
            obj = g[i];
            url = f[i] + "?" + h;
            createContentFeed(obj, url)
        }
        e()
    }
    function e() {
        var h = [];
        for (var j = 0; j < g.length; j++) {
            h[j] = $("#" + g[j]).parents("li");
            $(h[j]).mouseout(function () {
                c[j] = false;
                if (!$(this).children("div.main_nav_dd").is(":hidden")) {
                    a[j] = setTimeout($(this).children("div.main_nav_dd").hide(), 200)
                }
            }).mouseover(function () {
                if (d($(this).children("div.main_nav_dd"))) {
                    return
                }
                c[j] = true;
                if (a[j]) {
                    clearTimeout(a[j])
                }
                if ($(this).children("div.main_nav_dd").is(":hidden")) {
                    $(this).children("div.main_nav_dd").show()
                }
            })
        }
    }
    function d(j) {
        var h = j.html();
        if (h.replace(" ", "") == "") {
            return true
        } else {
            return false
        }
    }
};
