﻿$(function() {

    //页面头部搜索切换
    var sal = $("#search_menu").find("a");
    sal.click(function() {
        sal.removeClass("active");
        $(this).blur().addClass("active");
        $("#search_type").val(sal.index(this) + 1);
        return false;
    });

    /*首页左侧导航栏，鼠标移动层菜单*/
    $("#ProductType .bar1_title").BalloonPanel({
        width: 280,
        height: 100,
        minHeight: 50,
        VerticalOffset: "center",
        //event:"click",
        CurImage: "skin/Images/cue.gif",
        DataConverter: function(d, o) {
            return $("#__temp_productclass_content").find("div:[bigtype='" + $.trim(o.text()) + "']").html();
        }
    });

    //首页搜索分类
    var search_type_items = $("#search_type_div .search_type_items");
    var search_type_height = search_type_items.height();
    var search_type_as = $("#search_type_div .search_type").find("a");
    search_type_as.hover(function() {
        search_type_items.animate({ "scrollTop": search_type_height * search_type_as.removeClass("active").index(this) }, 400);
        $(this).addClass("active");
    }, function() { });

    //首页(员工天地、关于我们、联系方式、企业建站、兽药通)切换
    $(".title_bar_menu").each(function() {
        var $this = $(this);
        var listitems = $this.find("a").not(".moreqg");
        var content = $this.parent().next();
        var height = content.height();
        listitems.click(function() {
            content.stop();
            var of = content[0].scrollTop / height - listitems.removeClass("active").index(this);
            if (of < 0)
                of = -of;
            content.animate({ "scrollTop": height * listitems.removeClass("active").index(this) }, 300 * of);
            $(this).blur().addClass("active");
            return false;
        }).eq(0).click();
    });


    ///头部搜索
    $("#search_keyword").keypress(function(e) {
        if (e.keyCode == 13) {
            $("#search_submit").click();
            return false;
        }
    });
    //登陆
    $("#CompanyLogin1_txt_CompanyLoginName,#CompanyLogin1_txt_CompanyLoginPwd").keypress(function(e) {
        if (e.keyCode == 13) {
            $("#CompanyLogin1_btn_Login").click();
            return false;
        }
    });
})

/*
在页面输出一个flash动画，需要参数：动画路径、宽度、高度
调用形式如下：
<SCRIPT language=JavaScript>
<!--
fnFlashObject('/ad1/flash/bjypt.swf',468,60)
//-->
</SCRIPT>
*/
function fnFlashObject(byPath, byWidth, byHeight)
{
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + byWidth + '" height="' + byHeight + '">');
    document.write(' <param name="movie" value="' + byPath + '">');
    document.write(' <param name="quality" value="high">');
    document.write(' <param name="menu" value="false">');
	document.write(' <param name="SCALE" value="exactfit">');
	document.write(' <param name="wmode" value="opaque">');
    document.write(' <embed src="' + byPath + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + byWidth + '" height="' + byHeight + '"></embed>');
    document.write('</object>');
}
