﻿/// <reference path="jquery-1[1].3.2-vsdoc2.js" />
;(
    function()
    {
        ///搜索浮动层
        $("#searchBtn").mouseover(
                                    function(event)
                                    {
                                        $(document.body).append("<iframe class=\"searchCondition\" id=\"iframe_search\" frameBorder=\"0\"></iframe>");

                                        var div_search = $("#div_search");

                                        $("#div_search").show();

                                        $("#iframe_search").css({ height: div_search.height(), zIndex: 0 })

                                        $(this).css({ backgroundPosition: "0 -30px" });
                                    }
                                 )
                        .mouseout(
                                    function(event)
                                    {
                                        if (event.relatedTarget != $("#div_search")[0])
                                        {
                                            $("#div_search").hide();
                                            $("#iframe_search").remove();
                                            $(this).removeAttr("style");
                                        }
                                    }
                                 );

        $("#div_search").mouseleave(
                                    function()
                                    {
                                        $(this).hide();
                                        $("#iframe_search").remove();
                                        $("#searchBtn").removeAttr("style");
                                    }
                                 );

        $("#expressBtn").mouseover(
                                    function()
                                    {
                                        $("#div_express").show().css({left: jQuery(this).offset().left + jQuery(this).outerWidth() - $("#div_express").outerWidth()});

                                        $(document.body).append("<iframe id=\"iframe_express\" class=\"quickLists\" frameBorder=\"0\"></iframe>");

                                        $("#iframe_express").css({ left: jQuery(this).offset().left + jQuery(this).outerWidth() - $("#div_express").outerWidth(), height: $("#div_express").height(), zIndex: 3 });
                                    }
                                  )
                         .mouseout(
                                    function(event)
                                    {
                                        if (event.relatedTarget != $("#div_express")[0])
                                        {
                                            $("#div_express").hide();
                                            $("#iframe_express").remove();
                                        }
                                    }
                                  );

        $("#div_express").mouseleave(
                                     function()
                                     {
                                         $(this).hide();
                                         $("#iframe_express").remove();
                                     }
                                   );
        ///设置导航的hover
        $(".bar li").each(
                          function()
                          {
                              $(this).hover(
                                            function()
                                            {
                                                $(this).addClass("selected");
                                                if (this == $(".bar li:last")[0])
                                                {
                                                    $(".floatBlock:hidden", this).slideDown(500)
                                                                                  .mouseleave(
                                                                                                function(event)
                                                                                                {
                                                                                                    if (event.relatedTarget != $(".bar li:last")[0])
                                                                                                    {
                                                                                                        $(this).slideUp(500);
                                                                                                    }
                                                                                                }
                                                                                             );
                                                }
                                            },
                                            function(event)
                                            {
                                                if (this != $(".bar li:last")[0])
                                                {
                                                    $(this).removeClass("selected");
                                                }
                                                else
                                                {
                                                    if (event.relatedTarget != $(".floatBlock", this)[0])
                                                    {
                                                        $(".floatBlock", this).slideUp(500);
                                                        $(this).removeClass("selected");
                                                    }
                                                }
                                            }
                                           );
                          }
                        );

        ///设置
        $(".rightSide a:first").mouseenter(function() { $(".rightSide .setFloat:hidden").slideDown(500); })
                               .mouseleave(
                                            function(event)
                                            {
                                                if (event.relatedTarget != $(".rightSide .setFloat")[0])
                                                {
                                                    $(".rightSide .setFloat").slideUp(500);
                                                }
                                            }
                                          );

        $(".rightSide .setFloat").mouseleave(
                                            function(event)
                                            {
                                                if (event.relatedTarget != $(".rightSide a:first")[0])
                                                {
                                                    $(this).slideUp(500);
                                                }
                                            }
                                          );

    }
)();

function searchbook(type)
{
    var obj = $("#text_keywords")[0]

    var keywords = $.trim(obj.value);

    if (keywords.length == 0 || keywords == obj.defaultValue)
    {
        alert("请填写关键词");
        obj.value = obj.defaultValue;
        return;
    }

    $(document.body).append([
                                "<form name=\"form_search\" id=\"form_search\" action=\"http://sosu.qidian.com/searchresult.aspx\" target=\"_blank\">",
                                    "<input type=\"hidden\" name=\"searchkey\" value=\""+keywords+"\" />",
                                    "<input type=\"hidden\" name=\"searchtype\" value=\"" + type + "\" />",
                                    "<input type=\"hidden\" name=\"page\" value=\"1\" />",
                                "</form>"
                            ].join(""));
    document.forms["form_search"].submit();

    remove("#form_search").remove();
}

function openFeedBack()
{
    new $.dialog(
                    {
                        title: "反馈信息", 
                        isHTML:false,
                        htmlOrUrl:"/ajax/newsite/feedback.aspx",
                        yesCallBack: "submitFeedBack()"
				   }
				 ).open();
}

function submitFeedBack()
{
    var content = $("#txtContent").val().trim();
    if (content.length == 0)
    {
        alert("反馈内容不能为空！");
        return;
    }
    var type = parseInt($("#sltType").val(), 10);
    jQuery.closeAllDialog();
    jQuery.loading("处理中...");
    $.post(
            "/Ajax/Feedback.ashx",
            {
                type: type,
                anonymousStatus: 0,
                content: content,
                ajaxMethod: "createFeedback"
            },
            function()
            {
                var obj = arguments[0];
                if (obj.result)
                {
                    alert("反馈提交成功！");
                }
                else
                {
                    alert("反馈提交失败！");
                }
                jQuery.loadingClose();
            },
            "json"
          );
}