﻿// longsheng / 2011-6-14日 / 修改
// 英语站 JS 合并
// Jquery_Slide.js & HJpop.js & Nav.js & WebClick.js & Flash.js & Slide_Detail.js

//Nav
var IsLayerFocus = false; var IsMenuFocus = false; var LazyHideLayer = null; var LazyHideMenu = null; function bindHJMenu() { var displayType = +$(".hiNavDisplayType:first").val(); addRecord(); downNav(); $("#menu_parent dl").each(function (index, dom) { $(dom).bind('mouseover', function () { focusHJMenu(dom, index + 1) }); $(dom).bind('mouseout', function () { blurHJMenu(dom, index + 1) }) }); if (displayType == 2) { $("#hj_bar_top").bind('mouseover', function () { showHJMenu() }); $("#hj_bar_top").bind('mouseout', function () { hideHJMenu() }) } $("#hj_bar_menu").bind('mouseout', function () { if (+displayType == 1) hideHJLayer(); else { hideHJMenu() } }); $('.hj_layer').bind('mouseover', function () { IsLayerFocus = true; window.clearTimeout(LazyHideLayer); window.clearTimeout(LazyHideMenu) }); $('.hj_layer').bind('mouseout', function () { IsLayerFocus = false; hideHJLayer() }); suitBrowser(displayType) } function focusHJMenu(dom, num) { window.clearTimeout(LazyHideLayer); window.clearTimeout(LazyHideMenu); IsMenuFocus = true; $('#menu_parent dl').removeClass('bar_hover'); $(dom).addClass('bar_hover'); $(dom).children('dd').addClass('clear_border'); $(dom).prev('dl').children('dd').addClass('clear_border'); $('.hj_layer').hide(); $('#menu_layer' + num).css({ display: 'block' }) } function blurHJMenu(dom, num) { IsMenuFocus = false; $(dom).children('dd').removeClass('clear_border'); $(dom).prev('dl').children('dd').removeClass('clear_border') } function hideHJMenu() { LazyHideMenu = window.setTimeout(function () { if (!IsLayerFocus && !IsMenuFocus) { closeHJLayer(); $("#hj_bar_menu").hide(); $("#hj_bar_top").removeClass("bar_top_type3"); $("#hj_bar_top").addClass("bar_top_type2") } }, 200) } function hideHJLayer() { LazyHideLayer = window.setTimeout(function () { if (!IsLayerFocus) { closeHJLayer() } }, 200) } function closeHJLayer() { $('#menu_parent dl').removeClass('bar_hover'); $('.hj_layer').hide() } function showHJMenu() { $("#hj_bar_menu").show(); $('#menu_parent dl').removeClass('bar_hover'); $('.hj_layer').hide(); $("#hj_bar_top").removeClass("bar_top_type2"); $("#hj_bar_top").addClass("bar_top_type3") } function suitBrowser(displayType) { if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) { return } if ($.browser.msie && displayType == 2) { return } $('#menu_layer5').removeClass('menu_layer5_ie6'); if ($.browser.msie && ($.browser.version == "7.0")) { $('#menu_layer5').addClass('menu_layer5_ie7') } else if ($.browser.msie && ($.browser.version == "8.0")) { $('#menu_layer5').addClass('menu_layer5_ie8') } else if ($.browser.mozilla) { $('#menu_layer5').addClass('menu_layer5_mozilla') } else if ($.browser.safari) { $('#menu_layer5').addClass('menu_layer5_chrome') } } function addRecord() { var linkname = "新导航_"; $("#menu_layer a").each(function () { $(this).bind('click', function () { DoRecord(this, linkname + $(this).html()) }) }) } function downNav() { var isDown = $(".hiIsDown:first").val(); if (isDown != "True") return; var layers = ["menu_layer1", "menu_layer2", "menu_layer3", "menu_layer4"]; for (var i in layers) { var cmsContent = $("#" + layers[i] + " .hj_layer_menu li:first").html(); var downContent = $("#" + layers[i] + " .hj_layer_menu li:last").html(); $("#" + layers[i] + " .hj_layer_menu li:first").html(downContent); $("#" + layers[i] + " .hj_layer_menu li:last").html(cmsContent) } }
//End Nav

//Flash.js
function GetFlash(id, playerfile, flashvers, width, height, NotTransparent) { if (NotTransparent == true) { NotTransparent = "window" } else { NotTransparent = "transparent" } var str = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0'"; str += "width='" + width + "' height='" + height + "' id='" + id + "' align='middle' >"; str += "<param name='allowScriptAccess' value='always' />"; str += "<param name='movie' value='" + playerfile + "' />"; str += "<param name='quality' value='high' />"; str += "<param name='scale' value='noScale' />"; str += "<param name='align' value='tl' />"; str += "<param name='wmode' value='" + NotTransparent + "' />"; str += "<param name='flashvars' value='" + flashvers + "' />"; str += "<embed src='" + playerfile + "' quality='high' scale='noScale' bgcolor='#ffffff' width='" + width + "' height='" + height + "' flashvars='" + flashvers + "' id='" + id + "' name='" + id + "' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'/>"; str += "</object>"; document.write(str) } function GetFlashCode(id, playerfile, flashvers, width, height, transparent) { if (transparent != true) { transparent = "window" } else { transparent = "transparent" } var str = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0'"; str += "width='" + width + "' height='" + height + "' id='" + id + "' align='middle' >"; str += "<param name='allowScriptAccess' value='always' />"; str += "<param name='movie' value='" + playerfile + "' />"; str += "<param name='quality' value='high' />"; str += "<param name='scale' value='noScale' />"; str += "<param name='wmode' value='" + transparent + "' />"; str += "<param name='flashvars' value='" + flashvers + "' />"; str += "<embed src='" + playerfile + "' quality='high' scale='noScale' bgcolor='#ffffff' width='" + width + "' height='" + height + "' flashvars='" + flashvers + "' id='" + id + "' name='" + id + "' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'/>"; str += "</object>"; if (arguments.length == 7) $("#" + arguments[6]).html(str); else return str } function GetWord(aWord) { var ID = 9999999 * Math.random(); GetFlash("hjw_" + ID, "http://dict.hjenglish.com/speaker_wv.swf", "w=" + aWord.split(" ").join("#"), 16, 16, false) } function ShowSound(aLinkObj, alan, aword) { if (alan == "en") { var sound = "http://dict.hjenglish.com/s/" + aword; aLinkObj.parentNode.innerHTML = GetFlashCode("dict_sound_" + aword, "http://dict.hjenglish.com/common/speaker_mini.swf", "autoplay=true&son=" + sound, 16, 16, true) } return false } var audioPlayer = "/2009/images/FlvPlayer.swf"; function HJ$(aControlID) { return document.getElementById(aControlID) } var soundPlayer = "http://class.yeshj.com/media/FlvPlayer.swf"; function ShowRecPlayer(aDiv, audioFile) { aDiv.innerHTML = GetFlashCode("flv_" + Math.random(), soundPlayer, "autoplay=true&file=" + audioFile, 149, 27, false) }
//End Flash.js

//Slide_Detail.js
function jump() { var u = pagejump.options[pagejump.options.selectedIndex].value - 1; var Url = "javascript:changeUrl(" + u + ")"; window.location.href = Url } var Urls = document.location.href; var Urls_qian; if (Urls.indexOf("page") > 0) { Urls_qian = Urls.substring(0, Urls.indexOf("page")) } else { Urls_qian = Urls.replace(/#/g, "") } function changeUrl(obj) { var newUrl; if (obj == 1) { newUrl = Urls_qian } else { newUrl = Urls_qian + "page" + obj + "/#slidetool" } document.location.href = newUrl } function changeImg(mypic) { var xw = 550; var xl = 550; var width = mypic.width; var height = mypic.height; var bili = width / height; var A = width / xw; var B = height / xl; if (A > 1 || B > 1) { if (A > B) { mypic.width = xw; mypic.height = xw / bili } if (A < B) { mypic.width = xl * bili; mypic.height = xl } } }
//End Slide_Detail.js



//jquery_slide
var getObj = function (id) { return "string" == typeof id ? document.getElementById(id) : id; }; var Class = { create: function () { return function () { this.initialize.apply(this, arguments); } } }

Object.extend = function (destination, source) {
    for (var property in source) { destination[property] = source[property]; }
    return destination;
}
var TransformView = Class.create(); TransformView.prototype = { initialize: function (container, slider, parameter, count, options) { if (parameter <= 0 || count <= 0) return; var oContainer = getObj(container), oSlider = getObj(slider), oThis = this; this.Index = 0; this._timer = null; this._slider = oSlider; this._parameter = parameter; this._count = count || 0; this._target = 0; this.SetOptions(options); this.Up = !!this.options.Up; this.Step = Math.abs(this.options.Step); this.Time = Math.abs(this.options.Time); this.Auto = !!this.options.Auto; this.Pause = Math.abs(this.options.Pause); this.onStart = this.options.onStart; this.onFinish = this.options.onFinish; oSlider.style.position = "absolute"; }, SetOptions: function (options) { this.options = { Up: true, Step: 5, Time: 70, Auto: true, Pause: 3500, onStart: function () { }, onFinish: function () { } }; Object.extend(this.options, options || {}); }, Start: function () {
    if (this.Index < 0) { this.Index = this._count - 1; } else if (this.Index >= this._count) { this.Index = 0; }
    this._target = -1 * this._parameter * this.Index; this.onStart(); this.Move();
}, Move: function () { clearTimeout(this._timer); var oThis = this, style = this.Up ? "top" : "left", iNow = parseInt(this._slider.style[style]) || 0, iStep = this.GetStep(this._target, iNow); if (iStep != 0) { this._slider.style[style] = (iNow + iStep) + "px"; this._timer = setTimeout(function () { oThis.Move(); }, this.Time); } else { this._slider.style[style] = this._target + "px"; this.onFinish(); if (this.Auto) { this._timer = setTimeout(function () { oThis.Index++; oThis.Start(); }, this.Pause); } } }, GetStep: function (iTarget, iNow) { var iStep = (iTarget - iNow) / this.Step; if (iStep == 0) return 0; if (Math.abs(iStep) < 1) return (iStep > 0 ? 1 : -1); return iStep; }, Stop: function (iTarget, iNow) { clearTimeout(this._timer); this._slider.style[this.Up ? "top" : "left"] = this._target + "px"; }
}; $(window).load(function () {
    var slideNum = $("#idNum li").length;
    function Each(list, fun) { for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); } }; var objs2 = getObj("idNum").getElementsByTagName("li"); var _width_ = $(".slider a img").width(); var tv2 = new TransformView("idTransformView", "idSlider", _width_, slideNum, { onStart: function () { Each(objs2, function (o, i) { o.className = tv2.Index == i ? "on" : ""; }) }, Up: false }); tv2.Start(); Each(objs2, function (o, i) {
        o.onmouseover = function () { o.className = "on"; tv2.Auto = false; tv2.Index = i; tv2.Start(); }
        o.onmouseout = function () { o.className = ""; tv2.Auto = true; tv2.Start(); }
    })
});
//end_jquery_slide

//default.jsvar 
lazySwitch = null; function switchCommend(obj, langs) { if (lazySwitch != null) clearTimeout(lazySwitch); lazySwitch = setTimeout(function () { $("#focus_switch ul li").removeClass("current"); $(obj).addClass("current"); $("#focus_main .langs_commend").hide(); var documentID = "focus_" + langs; document.getElementById(documentID).style.display = "block"; $("#focus_list").css("left", "0px") }, 300) } function cancelSwitch() { if (lazySwitch != null) clearTimeout(lazySwitch) } function animateSlide() { var speed = 500; $("#slide1").animate({ left: "-400px" }, speed); $("#slide2").animate({ left: "0px" }, speed); var moreLink = "<a id='aSlidePrev' href='javascript:void(0)' onclick='animatePrev()'>&lt;&lt;返回前页</a>&nbsp;&nbsp;"; moreLink += "<a id='aSlide' href='/new/' target='_blank'>查看更多&gt;&gt;</a>"; $("#slide_bottom").html(moreLink) } function animatePrev() { var speed = 500; $("#slide1").animate({ left: "5px" }, speed); $("#slide2").animate({ left: "400px" }, speed); var moreLink = "<a id='aSlide' href='javascript:void(0)' onclick='animateSlide()'>查看更多&gt;&gt;</a>"; $("#slide_bottom").html(moreLink) } function getBestIng(xid) { var url = "http://bulo.hjenglish.com/service/getbestIng.aspx"; var moreHref = "http://bulo.hjenglish.com/app/redirect?source=eng2009&type=1&returnurl=http://bulo.hjenglish.com/app/search/ing/%E6%B2%AA%E6%B1%9F"; var format = "{0}<div id='best_ing_more'><a target='_blank' href='{1}'>600万沪友眼中的沪江>></a></div>"; $.getScript(url, function () { var text = format.replace(/\{0\}/g, __ing).replace(/\{1\}/g, moreHref); $(xid).append(text) }) }
//End default.js

//HJpopvar 
var HJpop = function ()
{ var options = arguments[0] || {}; this.title = options.title || "新窗口", this.width = options.width || 280, this.height = options.height || 200, this.id = options.id || "id" + Math.abs(new Date() * Math.random()).toFixed(0), this.ico = options.ico || false, this.isModal = options.isModal === undefined ? true : options.isModal == false ? false : true, this.isOkToClose = options.isOkToClose === undefined ? true : options.isOkToClose == false ? false : true, this.hasOperation = options.hasOperation === undefined ? true : options.hasOperation == false ? false : true, this.hasCancleBtn = options.hasCancleBtn || false, this.okCallback = options.okCallback || function () { }, this.cancleCallback = options.cancleCallback || function () { }, this.closeCallback = options.closeCallback || function () { }; this.container = document.createElement("div"), this.handle = document.createElement("div"), this.init(); }
HJpop.prototype = { constructor: HJpop, init: function () {
    var me = this, container = me.container, width = me.width, height = me.height, id = me.id, builder = [], t = "getElementsByTagName"; if (typeof HJpop.z === "undefined") { HJpop.zIndex = 999; }
    document.body.insertBefore(container, null); container.id = id; if (me.ico) { container.className = "popups hjpop_ico" + me.ico; }
    else { container.className = "popups"; }
    container.style.width = width + "px"; container.style.height = height + "px"; builder.push('<form><div class="replaceable"></div>'); if (me.hasOperation) {
        builder.push('<div class="submitable">'); builder.push('<a class="positive" href="javascript:void(0)">确认</a>'); if (me.hasCancleBtn) { builder.push('<a class="negative" href="javascript:void(0)">取消</a>'); }
        builder.push('</div>');
    }
    builder.push('</form>'); builder.push('<a class="closebtn" href="javascript:void(0)"></a>'); container.innerHTML = builder.join(''); var handle = document.createElement("div"); handle.id = "handle" + Math.abs(new Date() * Math.random()).toFixed(0); handle.className = "caption"; handle.innerHTML = me.title; container.insertBefore(handle, container.childNodes[0]); var size = me.getBrowserWindowSize(); me.left = ((size.width - width) / 2) >> 0; me.top = ((size.height - height) / 2) >> 0; me.ie6 = /msie|MSIE 6/.test(navigator.userAgent); var divs = container[t]("div"), k = divs.length; while (--k >= 0) {
        if (divs[k].className == "replaceable") {
            me.content = divs[k]
            break;
        }
    }
    me.css(".popups", "position:absolute;left:" + me.left + "px;top:" + me.top + "px;overflow:hidden;"); 1
    container.style.zIndex = HJpop.zIndex++; if (me.ie6) {
        me.iframe = document.createElement("<iframe style='position:absolute;left:" +
me.left + "px;top:" + me.top + "px;width:" + (me.width + 10) + "px;height:" +
(me.height + 10) + "px;z-index:" + (HJpop.zIndex - 2) + ";filter:mask();display:none;' ></iframe>"); container.insertAdjacentElement('beforeBegin', me.iframe);
    }
    container.onclick = function () {
        var ee = me.getEvent(), node = ee[1], tag = ee[2]; if (tag == "a") {
            switch (node.className) {
                case "closebtn": me.hide(); if (me.closeCallback) { me.closeCallback(); }
                    break; case "positive": if (me.okCallback) { me.okCallback(); }
                    if (me.isOkToClose) { me.hide(); }
                    break; case "negative": me.hide(); if (me.cancleCallback) { me.cancleCallback(); }
                    break;
            }
        }
    }
    handle.onmousedown = function (e) {
        e = e || window.event; container.offset_x = e.clientX - container.offsetLeft; container.offset_y = e.clientY - container.offsetTop; document.onmousemove = function (e) { me.drag(e, me) }
        document.onmouseup = function () { me.dragend(container) }
    }
}, drag: function (e, me) {
    e = e || window.event; var el = me.container; var l = e.clientX - el.offset_x + "px", t = e.clientY - el.offset_y + "px"; with (el.style) { left = l; top = t; cursor = "move" }
    if (me.ie6) { with (me.iframe.style) { left = l; top = t; } } ! +"\v1" ? document.selection.empty() : window.getSelection().removeAllRanges();
}, dragend: function (el) { el.style.cursor = ""; document.onmouseup = document.onmousemove = null; }, hide: function () {
    this.container.style.display = "none"; if (this.ie6) { this.iframe.style.display = "none"; }
    this.mode(0, 0); this.incss(document.body, { width: "auto", height: "auto", overflow: "auto" }); this.incss(document.documentElement, { width: "auto", height: "auto", overflow: "auto" });
}, show: function () {
    this.container.style.display = "block"; if (this.ie6) { this.iframe.style.display = "block"; }
    var size = this.getBrowserWindowSize(); this.mode(size.width, size.height);
}, getBrowserWindowSize: function () { var de = document.documentElement; return { 'width': (de.clientWidth || document.body.clientWidth), 'height': (de.clientHeight || document.body.clientHeight)} }, attr: function (node, bag) {
    for (var i in bag) {
        if (bag.hasOwnProperty(i))
            node.setAttribute(i, bag[i])
    }
}, getEvent: function (e) {
    var e = e || window.event; if (!e) {
        var c = this.getEvent.caller; while (c) {
            e = c.arguments[0]; if (e && (Event == e.constructor || MouseEvent == e.constructor)) { break; }
            c = c.caller;
        }
    }
    var target = e.srcElement ? e.srcElement : e.target, currentN = target.nodeName.toLowerCase(), parentN = target.parentNode.nodeName.toLowerCase(), grandN = target.parentNode.parentNode.nodeName.toLowerCase(); return [e, target, currentN, parentN, grandN];
}, mode: function (w, h) {
    var mask = HJpop.mask, me = this; if (this.isModal) {
        this.incss(document.body, { width: "100%", height: "100%", overflow: "hidden" }); this.incss(document.documentElement, { width: "100%", height: "100%", overflow: "hidden" }); this.incss(mask, { position: "absolute", background: "#fff", top: 0, left: 0, width: w + "px", height: h + "px", "-moz-user-select": "none" }); ! +"\v1" ? (mask.style.filter = "alpha(opacity=0)") : (mask.style.opacity = "0"); mask.onselectstart = function (e) { me.stopEvent(e); }
        mask.oncontextmenu = function (e) { me.stopEvent(e); }
    }
}, stopEvent: function (e) { e = e || window.event; if (e.preventDefault) { e.preventDefault(); e.stopPropagation(); } else { e.returnValue = false; e.cancelBubble = true; } }, incss: function (node, bag) {
    var str = ";"
    for (var i in bag) {
        if (bag.hasOwnProperty(i))
            str += i + ":" + bag[i] + ";"
    }
    node.style.cssText = str;
}, css: function (selector, declaration) {
    if (typeof document.createStyleSheet === 'undefined') {
        document.createStyleSheet = (function () {
            function createStyleSheet() {
                var element = document.createElement('style'); element.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(element); var sheet = document.styleSheets[document.styleSheets.length - 1]; if (typeof sheet.addRule === 'undefined')
                    sheet.addRule = function (selectorText, cssText, index) {
                        if (typeof index === 'undefined')
                            index = this.cssRules.length; this.insertRule(selectorText + ' {' + cssText + '}', index);
                    }; return sheet;
            }
            return createStyleSheet;
        })();
    }
    if (!!HJpop.sheet) { if (!HJpop.memory.exists(selector, declaration)) { HJpop.memory.set(selector, declaration); HJpop.sheet.addRule(selector, declaration); } } else {
        HJpop.sheet = document.createStyleSheet(); var memory = function () {
            var keys = [], values = [], size = 0; return { get: function (k) {
                var results = []; for (var i = 0, l = keys.length; i < l; i++) { if (keys[i] == k) { results.push(values[i]) } }
                return results;
            }, exists: function (k, v) {
                var vs = this.get(k); for (var i = 0, l = vs.length; i < l; i++) {
                    if (vs[i] == v)
                        return true;
                }
                return false;
            }, set: function (k, v) { keys.push(k); values.push(v); size++; }, length: function () { return size; }
            }
        }
        HJpop.memory = memory(); HJpop.memory.set(selector, declaration); HJpop.sheet.addRule(selector, declaration); HJpop.mask = document.createElement("div"); document.body.insertBefore(HJpop.mask, this.container);
    }
}
}; HJpop.closeAll = function () { var allHJpop = getElementsByClassName("popups"); for (var i = 0; i < allHJpop.length; i++) { allHJpop[i].style.display = "none"; } }
var getElementsByClassName = function (searchClass, node, tag) {
    if (document.getElementsByClassName) { return document.getElementsByClassName(searchClass) }
    else {
        node = node || document; tag = tag || "*"; var classes = searchClass.split(" "), elements = (tag === "*" && node.all) ? node.all : node.getElementsByTagName(tag), patterns = [], returnElements = [], current, match; var i = classes.length; while (--i >= 0) { patterns.push(new RegExp("(^|\\s)" + classes[i] + "(\\s|$)")); }
        var j = elements.length; while (--j >= 0) {
            current = elements[j]; match = false; for (var k = 0, kl = patterns.length; k < kl; k++) { match = patterns[k].test(current.className); if (!match) break; }
            if (match) returnElements.push(current);
        }
        return returnElements;
    }
}
//End HJpop


//热点区域
  $(function(){
          //passport 喇叭关闭按钮      
            $("#hot_message_icon").click(function(){ 
                 if($("#hot_message_icon").hasClass('thot_icon_open'))
                 {
                       $("#hotMessage").slideToggle(650,function(){
                        $("#hot_message_icon").toggleClass("thot_icon_close");
                        $("#hot_message_icon").toggleClass("thot_icon_open");
                     });
                 }
                 else
                 {
                     $("#hot_message_icon").removeClass("thot_icon_close");
                     $("#hot_message_icon").addClass("thot_icon_open");
                     $("#hotMessage").slideToggle(650);
                 }
            });
        
          //关闭按钮
            $("a.warning_close").click(function() {
                        $("#hotMessage").slideToggle(650,function(){
                        $("#hot_message_icon").toggleClass("thot_icon_close");
                        $("#hot_message_icon").toggleClass("thot_icon_open");
                    });
                    Cookie.remove("HJ_IsHotMessage_EN");
                    Cookie.set("HJ_IsHotMessage_EN", "1", 3 * 24 * 60 * 60);
            });          
        });
//end 热点区域
