(function topLogin(){
    var control = $(".top .logreg .r").eq(0);
    control.click(function(){
        if($(".top .logtype").eq(0).css("display") == "none")
            $(".top .logtype").eq(0).css("display", "block");
        else
            $(".top .logtype").eq(0).css("display", "none");
    });
    $(".top .logtype a").each(function(){
        $(this).click(function(){
            $(".top .logtype").eq(0).css("display", "none");
        });
    });
})();
var menuSetUp = function(){
    var controls = $("#amenu li a.one");
    var index = $("#ondata").attr("onindex");
    var page = $("#ondata").attr("tnindex");
    if(page == "index"){
        var img = controls.eq(index).find("img");
        var imgname = img.attr("image");
        controls.eq(index).find("img").attr("src", "../images/global/" + imgname + ".c.png");
    }
    else{
        var img = controls.eq(parseInt(index) + 1).find("img");
        var imgname = img.attr("image");
        controls.eq(parseInt(index) + 1).find("img").attr("src", "../images/global/" + imgname + ".c.png");
        controls.eq(parseInt(index) + 1).parent("li").find(".smenu").css("display", "block");
        var scontrols = controls.eq(parseInt(index) + 1).parent("li").find(".smenu p a");
        scontrols.eq(page).addClass("current");
    }
    controls.each(function(){
        $(this).mouseover(function(){
            for(var i = 0; i < controls.length; i++){
                controls.eq(i).parent("li").find(".smenu").css("display", "none");
                var img = controls.eq(i).find("img");
                var imgname = img.attr("image");
                controls.eq(i).find("img").attr("src", "../images/global/" + imgname + ".png");
            }
            $(this).parent("li").find(".smenu").css("display", "block");
            $(this).find("img").attr("src", "../images/global/" + $(this).find("img").attr("image") + ".c.png");
            if(page == "index"){
                controls.eq(index).find("img").attr("src", "../images/global/" + controls.eq(index).find("img").attr("image") + ".c.png");
            }
            else{
                controls.eq(parseInt(index) + 1).find("img").attr("src", "../images/global/" + controls.eq(parseInt(index) + 1).find("img").attr("image") + ".c.png");
            }
        });
        $(this).mouseout(function(){
            for(var i = 0; i < controls.length; i++){
                var img = controls.eq(i).find("img");
                var imgname = img.attr("image");
                controls.eq(i).find("img").attr("src", "../images/global/" + imgname + ".png");
            }
            if(page == "index"){
                controls.eq(index).find("img").attr("src", "../images/global/" + controls.eq(index).find("img").attr("image") + ".c.png");
            }
            else{
                controls.eq(parseInt(index) + 1).find("img").attr("src", "../images/global/" + controls.eq(parseInt(index) + 1).find("img").attr("image") + ".c.png");
            }
        });
    });
};
$(document).ready(menuSetUp);

var concatUs = function () {
    var isactive = false;
    var points = $(".point");
    for(var i = 0; i < points.length; i++){
        points.eq(i).attr("index", i);
    }
    $("#topconcat").click(concat);
    $(document).ready(function(){
        $("#leftconcat").click(concat);
        $("#bottomconcat").click(concat);
    });
    function concat(){
        if(isactive) return;
        isactive = true;
        $(".lx_bg").css("display", "block");
        if(!$.support.leadingWhitespace){
            $("#lx_map").animate({marginTop: "0px", opacity: "1"}, "slow", function(){ $("#lx_map").css({opacity: ""}); });
        }
        else{
            $("#lx_map").animate({marginTop: "0px", opacity: "1"}, "slow");
        }
        $("#close").css("display", "block");
        if(!$.support.leadingWhitespace){
            $("#close").animate({opacity: "1"}, "slow", function(){ $("#close").css({opacity: ""}); });
        }
        else{
            $("#close").animate({opacity: "1"}, "slow");
        }
        setTimeout(function () {
            $(".point").each(function () {
                $(this).css("display", "block");
                if(!$.support.leadingWhitespace){
                    $(this).animate({opacity: "1"}, "slow", function(){ isactive = false; $(this).css({opacity: ""}); });
                }
                else{
                    $(this).animate({opacity: "1"}, "slow", function(){ isactive = false; });
                }
            });
        }, 600);
    }
    $("#close").click(function(){
        if(isactive) return;
        isactive = true;
        $("#info").animate({opacity: "0"}, 300, function(){ $("#info").css("display", "none"); });
        $("#select").animate({top: "188px", opacity: "0"}, 300, function(){ $("#select").css("display", "none"); });
        points.eq(8).animate({left: "733px"}, 50);
        points.eq(7).animate({left: "485px"}, 50);
        points.eq(6).animate({left: "714px"}, 50);
        points.eq(5).animate({left: "646px"}, 50);
        points.eq(4).animate({left: "723px"}, 50);
        points.eq(3).animate({left: "643px"}, 50);
        points.eq(2).animate({left: "620px"}, 50);
        points.eq(1).animate({left: "721px"}, 50);
        points.eq(0).animate({left: "233px"}, 50);
        $(".point").each(function () {
            $(this).animate({opacity: "0"}, "slow", function(){ $(this).css("display", "none"); });
        });
        setTimeout(function(){
            $("#lx_map").animate({marginTop: "-443px", opacity: "0"}, "slow", function(){ $(".lx_bg").css("display", "none"); });
            $("#close").animate({opacity: "0"}, "slow", function(){ $("#close").css("display", "none"); isactive = false; });
        }, 600);
    });
    var index = 0;
    points.each(function(){
        $(this).click(function(){
            index = $(this).attr("index");
            for(var i = 0; i < points.length; i++){
                if(index == i){
                    points.eq(i).addClass("pointc");
                }
                else{
                    points.eq(i).removeClass("pointc");
                }
            }
            points.eq(0).animate({left: "900px", opacity: "0"}, 50);
            setTimeout(function(){ points.eq(1).animate({left: "900px", opacity: "0"}, 50); }, 50);
            setTimeout(function(){ points.eq(2).animate({left: "-100px", opacity: "0"}, 50); }, 100);
            setTimeout(function(){ points.eq(3).animate({left: "-100px", opacity: "0"}, 50); }, 150);
            setTimeout(function(){ points.eq(4).animate({left: "900px", opacity: "0"}, 50); }, 200);
            setTimeout(function(){ points.eq(5).animate({left: "-100px", opacity: "0"}, 50); }, 250);
            setTimeout(function(){ points.eq(6).animate({left: "900px", opacity: "0"}, 50); }, 300);
            setTimeout(function(){ points.eq(7).animate({left: "-100px", opacity: "0"}, 50); }, 350);
            setTimeout(function(){ points.eq(8).animate({left: "900px", opacity: "0"}, 50); }, 400);
            if(!$.support.leadingWhitespace){
                setTimeout(function(){
                    $("#select").css("display", "block");
                    $("#select").animate({top: "208px", opacity: "1"}, 300, function(){ $("#select").css({opacity: ""}); });
                }, 350);
                setTimeout(function(){
                    $("#info").css("display", "block");
                    $("#info").animate({opacity: "1"}, 300, function(){ $("#info").css({opacity: ""}); });
                }, 350);
            }
            else{
                setTimeout(function(){
                    $("#select").css("display", "block");
                    $("#select").animate({top: "208px", opacity: "1"}, 300);
                }, 350);
                setTimeout(function(){
                    $("#info").css("display", "block");
                    $("#info").animate({opacity: "1"}, 300);
                }, 350);
            }
            //----------------------------------------------------------------------
            setTimeout(function(){
                for(var i = 0; i < $("#info").children("div").length; i++){
                    if(index == i){
                        $("#info").children("div").eq(i).addClass("current");
                    }
                    else{
                        $("#info").children("div").eq(i).removeClass("current");
                    }
                }
                var controlcontent = $(".control");
                for(var i = 0; i < controlcontent.length; i++){
                    var controls = controlcontent.eq(i).children("li").children("a");
                    for(var j = 0; j < controls.length; j++){
                        controls.eq(j).attr("index", j);
                    }
                }
                $(".control li a").each(function(){
                    $(this).click(function(){
                        if(isactive) return;
                        isactive = true;
                        var controls = $(this).parent("li").parent("ul").children("li").children("a");
                        var contents = $(this).parent("li").parent("ul").parent("div").children("div");
                        var controlindex = $(this).attr("index");
                        for(var i = 0; i < 3; i++){
                            if(controlindex != i){
                                controls.eq(i).removeClass("current");
                                contents.eq(i).animate({height: "0px"}, 400, function(){ contents.eq(i).removeClass(index == 1 ? "currentg" : "currenta"); });
                            }
                        }
                        setTimeout(function(){
                            controls.eq(controlindex).addClass("current");
                            contents.eq(controlindex).css("display", "block");
                            contents.eq(controlindex).animate({height: index == 1 ? "230px" : "260px"}, 400, function(){ contents.eq(i).addClass(index == 1 ? "currentg" : "currenta"); isactive = false; });
                        }, 400);
                    });
                });
                for(var i = 0; i < $(".singapore").length; i++){
                    $(".singapore").eq(i).attr("index", i);
                }
                $(".singapore").each(function(){
                    $(this).click(function(){
                        if($(this).attr("index") == 0){
                            $(".singapore").eq(1).removeClass("currents");
                            $(".singapore").eq(0).addClass("currents");
                            $(".singapore").parent("div").children("p").eq(1).animate({opacity: "0"}, 400, function(){
                                $(".singapore").parent("div").children("p").eq(1).css("display", "none");
                                $(".singapore").parent("div").children("p").eq(0).css("display", "block");
                                $(".singapore").parent("div").children("p").eq(0).animate({opacity: "1"}, 400);
                            });
                        }
                        else{
                            $(".singapore").eq(0).removeClass("currents");
                            $(".singapore").eq(1).addClass("currents");
                            $(".singapore").parent("div").children("p").eq(0).animate({opacity: "0"}, 400, function(){
                                $(".singapore").parent("div").children("p").eq(0).css("display", "none");
                                $(".singapore").parent("div").children("p").eq(1).css("display", "block");
                                $(".singapore").parent("div").children("p").eq(1).animate({opacity: "1"}, 400);
                            });
                        }
                    });
                });
                for(var i = 0; i < $(".china").length; i++){
                    $(".china").eq(i).attr("index", i);
                    if(i == 0){
                        if(!$.support.leadingWhitespace) $(".bs_china").eq(i).css("opacity", "");
                        else $(".bs_china").eq(i).css("opacity", "1")
                    }
                }
                $(".china").each(function(){
                    $(this).click(function(){
                        if($(this).attr("index") == 0){
                            $(".china").eq(0).addClass("currentc");
                            $(".china").eq(1).removeClass("currentc");
                            $(".china").parent("div").children(".bs_china").eq(1).animate({opacity: "0"}, 400, function(){
                                $(".china").parent("div").children(".bs_china").eq(0).css("display", "block");
                                $(".china").parent("div").children(".bs_china").eq(1).css("display", "none");
                                $(".china").parent("div").children(".bs_china").eq(0).animate({opacity: "1"}, 400, function(){
                                    if(!$.support.leadingWhitespace) $(".china").parent("div").children(".bs_china").eq(0).css("opacity", "");
                                });
                            });
                        }
                        else{
                            $(".china").eq(0).removeClass("currentc");
                            $(".china").eq(1).addClass("currentc");
                            $(".china").parent("div").children(".bs_china").eq(0).animate({opacity: "0"}, 400, function(){
                                $(".china").parent("div").children(".bs_china").eq(0).css("display", "none");
                                $(".china").parent("div").children(".bs_china").eq(1).css("display", "block");
                                $(".china").parent("div").children(".bs_china").eq(1).animate({opacity: "1"}, 400, function(){
                                    if(!$.support.leadingWhitespace) $(".china").parent("div").children(".bs_china").eq(1).css("opacity", "");
                                });
                            });
                        }
                    });
                });
            }, 350);
        });
    });
    $("#select").click(function(){
        $("#info").animate({opacity: "0"}, 300, function(){ $("#info").css("display", "none"); });
        $("#select").animate({top: "188px", opacity: "0"}, 300, function(){ $("#select").css("display", "none"); });
        if(!$.support.leadingWhitespace){
            setTimeout(function(){ points.eq(6).animate({left: "714px", opacity: "1"}, 50, function(){ points.eq(6).css({opacity: ""}); }); }, 300);
            setTimeout(function(){ points.eq(5).animate({left: "646px", opacity: "1"}, 50, function(){ points.eq(5).css({opacity: ""}); }); }, 350);
            setTimeout(function(){ points.eq(4).animate({left: "723px", opacity: "1"}, 50, function(){ points.eq(4).css({opacity: ""}); }); }, 400);
            setTimeout(function(){ points.eq(3).animate({left: "643px", opacity: "1"}, 50, function(){ points.eq(3).css({opacity: ""}); }); }, 450);
            setTimeout(function(){ points.eq(2).animate({left: "620px", opacity: "1"}, 50, function(){ points.eq(2).css({opacity: ""}); }); }, 500);
            setTimeout(function(){ points.eq(1).animate({left: "721px", opacity: "1"}, 50, function(){ points.eq(1).css({opacity: ""}); }); }, 550);
            setTimeout(function(){ points.eq(0).animate({left: "233px", opacity: "1"}, 50, function(){ points.eq(0).css({opacity: ""}); }); }, 600);
            setTimeout(function(){ points.eq(7).animate({left: "485px", opacity: "1"}, 50, function(){ points.eq(7).css({opacity: ""}); }); }, 650);
            setTimeout(function(){ points.eq(8).animate({left: "733px", opacity: "1"}, 50, function(){ points.eq(8).css({opacity: ""}); }); }, 700);
        }
        else{
            setTimeout(function(){ points.eq(6).animate({left: "714px", opacity: "1"}, 50); }, 300);
            setTimeout(function(){ points.eq(5).animate({left: "646px", opacity: "1"}, 50); }, 350);
            setTimeout(function(){ points.eq(4).animate({left: "723px", opacity: "1"}, 50); }, 400);
            setTimeout(function(){ points.eq(3).animate({left: "643px", opacity: "1"}, 50); }, 450);
            setTimeout(function(){ points.eq(2).animate({left: "620px", opacity: "1"}, 50); }, 500);
            setTimeout(function(){ points.eq(1).animate({left: "721px", opacity: "1"}, 50); }, 550);
            setTimeout(function(){ points.eq(0).animate({left: "233px", opacity: "1"}, 50); }, 600);
            setTimeout(function(){ points.eq(7).animate({left: "485px", opacity: "1"}, 50); }, 650);
            setTimeout(function(){ points.eq(8).animate({left: "733px", opacity: "1"}, 50); }, 700);
        }
    });
};
concatUs();
(function sendMail(){
    var buttons = $("#info :button");
    buttons.each(function(){
        $(this).click(function(){
            var regexp = /^[a-zA-Z]+$/;
            var isEn;
            if(regexp.test($(this).attr("value"))){
                isEn = true;
            }
            else{
                isEn = false;
            }
            var key = $(this).attr("id").substring(0, $(this).attr("id").indexOf("_"));
            var name = $("#" + key + "_name");
            var email = $("#" + key + "_email");
            var subject = $("#" + key + "_subject");
            var message = $("#" + key + "_message");
            var target = $("#" + key + "_target");
            if(name.val() == "") { alert(isEn ? "Name can not be empty" : "姓名不能为空"); return; }
            if(email.val() == "") { alert(isEn ? "Email can not be empty" : "邮箱不能为空"); return; }
            if(subject.find("option:selected").val() == "") { alert(isEn ? "Please select the problem category" : "请选择问题类别"); return; }
            if(message.val() == "") { alert(isEn ? "Message can not be empty" : "问题描述不能为空"); return; }
            $.ajax({
                type: "POST",
                dataType: "json",
                data: { dname: name.val(), demail: email.val(), dsubject: subject.find("option:selected").val(), dmessage: message.val(), dtarget: target.html() },
                url: "HttpHandler/SendMail.ashx",
                beforeSend: function(){
                    $("#" + key + "_submit").attr("value", isEn ? "Sendding..." : "正在发送...");
                    $("#" + key + "_submit").attr("disabled", "disabled");
                    $("#" + key + "_reset").attr("disabled", "disabled");
                },
                success: function(e){
                    $("#" + key + "_submit").attr("value", isEn ? "Success" : "发送成功");
                    setTimeout(function(){
                        $("#" + key + "_submit").attr("value", isEn ? "Submit" : "提交");
                        $("#" + key + "_submit").removeAttr("disabled");
                        $("#" + key + "_reset").removeAttr("disabled");
                         $("#" + key + "_reset").click();
                    }, 2000);
                },
                error: function(e){
                    alert(e.readyState + "|" + e.status + "|" + e.responseText);
                }
            });
        });
    });
})();
(function noRight(){
    document.oncontextmenu = function(){ return false; };
    document.onselectstart = function(){ return false; };
    document.oncopy = function(){ return false; };
})();

