﻿$.ajaxSetup({
  url: "Service.ashx",
  global: false,
  cache:true,
  type: "POST"
});
var ServicePath = "Handle.ashx";
var loadingImg = "loading<img src=/images/loading.gif />";
var messageControl = {
    create: function (container, title, text, level) {
        var message = $("<div />", { "class": "message message-" + level }).append(
			$("<div />", { "class": "text" }).append(
				$("<h6 />", { "class": "messageTitle", html: title })
			).append(
				$("<div />", { "class": "messageText", html: text })
			)
		).append(
			$("<a />", { "class": "messageClose", click: function () {
			    $(this).parents(".message:first").fadeOut(200, function () { $(this).remove(); })
			}
			})
		)
        $(container).append(message);
        message.hide();
        message.fadeIn(200);
        return message;
    }
}
$(function () {
    if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
        $(".searchCombobox").hover(function () {
            $(this).find(".searchCombobox_list:first").show()
        }, function () {
            $(this).find(".searchCombobox_list:first").hide()
        })
    }
    $(".searchCombobox_list a").click(function () {
        $(this).parents(".searchCombobox > input[name='selectType']:first").val(this.value);
        $(this).parents(".searchCombobox .searchCombobox_text:first").html(this.innerText);
    })
    $("#topsearchbar .submit").click(function () {
        alert("submit");
        location.href = "?list&keywords=" + $("#topsearchbar input[name='keywords']").val();
    });
    $("#menubar>#Zone,#menubar>#Cate").hover(function () {
        $(this).find(".classbox:first").show()
    }, function () {
        $(this).find(".classbox:first").hide(500)
    })
    $(".ezTab a").click(function () {
        var t = $(this);
        var ezTab_content = t.parent().siblings(".ezTab_content");
        ezTab_content.hide()
        ezTab_content.eq(t.parent().find("a").index(this)).show();
        t.siblings().css("font-weight", "100");
        t.css("font-weight", "bold")

    })
    if (typeof (getClassInit) == "function")
        getClassInit();
    $("form[AjaxType='Comments'] .submit").click(function () {
        var _this = this;
        var CompanyId = $("#CompanyId").val(), Content = $("#Content").val(), CheckCode = $("#CheckCode").val();

        if (!/^.{2,500}$/.test(Content)) {
            alert("评论内容必须在2-500个字符之间!");
            return false;
        }
        if (!/^.{4}$/.test(CheckCode)) {
            alert("请输入验证码!")
            return false;
        }
        $.post(ServicePath, { Handle: "Comment", Act: "Add", CheckCode: CheckCode, CompanyId: CompanyId, Content: Content }, function (data) {
            eval("var data=" + data);
            if (data.Success) {
                alert("感谢您的评论!")
                location.reload();
            } else {
                switch (data.Data) {
                    case "CompanyId":
                        location.href = "/";
                        break;
                    case "Content":
                        alert("评论内容必须在2-500个字符之间!");
                        break;
                    case "CheckCode":
                        alert("验证码错误!");
                        break;
                    case "RePost":
                        alert("对不起，您两次发表间隔少于 30 秒，请不要灌水！");
                        break;
                }
            }

        });

        return false;
    })
    $("form[AjaxType='Comments'] .vcode").click(function () {
        $(this).css("background-image", "url(/service.ashx?action=getVcode&time=" + new Date() + ")")
    })
})

document.write("<script language=javascript src='http://add.5etv.com/webshow/webshow_win_u.jsp?roomid=5200&s=www.5etv.com&xx=no&left=0&top=300'></script>");
