// javascript document //图片左右切换 function dy_scroll(wraper,prev,next,img,speed,or) { var wraper = $(wraper); var prev = $(prev); var next = $(next); var img = $(img).find('ul'); var w = img.find('li').outerwidth(true); var s = speed; next.click(function() { img.animate({'margin-left':-w},function() { img.find('li').eq(0).appendto(img); img.css({'margin-left':0}); }); }); prev.click(function() { img.find('li:last').prependto(img); img.css({'margin-left':-w}); img.animate({'margin-left':0}); }); if (or == true) { ad = setinterval(function() { next.click();},s*1000); wraper.hover(function(){clearinterval(ad);},function(){ad = setinterval(function() { next.click();},s*1000);}); } } // dy_scroll('.img-scroll','.prev','.next','.img-list',3,true);// true为自动播放,不加此参数或false就默认不自动 //滚动 (function($){ $.fn.kxbdmarquee = function(options){ var opts = $.extend({},$.fn.kxbdmarquee.defaults, options); return this.each(function(){ var $marquee = $(this);//滚动元素容器 var _scrollobj = $marquee.get(0);//滚动元素容器dom var scrollw = $marquee.width();//滚动元素容器的宽度 var scrollh = $marquee.height();//滚动元素容器的高度 var $element = $marquee.children(); //滚动元素 var $kids = $element.children();//滚动子元素 var scrollsize=0;//滚动元素尺寸 var _type = (opts.direction == 'left' || opts.direction == 'right') ? 1:0;//滚动类型,1左右,0上下 //防止滚动子元素比滚动元素宽而取不到实际滚动子元素宽度 $element.css(_type?'width':'height',10000); //获取滚动元素的尺寸 if (opts.isequal) { scrollsize = $kids[_type?'outerwidth':'outerheight']() * $kids.length; }else{ $kids.each(function(){ scrollsize += $(this)[_type?'outerwidth':'outerheight'](); }); } //滚动元素总尺寸小于容器尺寸,不滚动 if (scrollsize<(_type?scrollw:scrollh)) return; //克隆滚动子元素将其插入到滚动元素后,并设定滚动元素宽度 $element.append($kids.clone()).css(_type?'width':'height',scrollsize*2); var nummoved = 0; function scrollfunc(){ var _dir = (opts.direction == 'left' || opts.direction == 'right') ? 'scrollleft':'scrolltop'; if (opts.loop > 0) { nummoved+=opts.scrollamount; if(nummoved>scrollsize*opts.loop){ _scrollobj[_dir] = 0; return clearinterval(moveid); } } if(opts.direction == 'left' || opts.direction == 'up'){ var newpos = _scrollobj[_dir] + opts.scrollamount; if(newpos>=scrollsize){ newpos -= scrollsize; } _scrollobj[_dir] = newpos; }else{ var newpos = _scrollobj[_dir] - opts.scrollamount; if(newpos<=0){ newpos += scrollsize; } _scrollobj[_dir] = newpos; } }; //滚动开始 var moveid = setinterval(scrollfunc, opts.scrolldelay); //鼠标划过停止滚动 $marquee.hover( function(){ clearinterval(moveid); }, function(){ clearinterval(moveid); moveid = setinterval(scrollfunc, opts.scrolldelay); } ); //控制加速运动 if(opts.controlbtn){ $.each(opts.controlbtn, function(i,val){ $(val).bind(opts.eventa,function(){ opts.direction = i; opts.oldamount = opts.scrollamount; opts.scrollamount = opts.newamount; }).bind(opts.eventb,function(){ opts.scrollamount = opts.oldamount; }); }); } }); }; $.fn.kxbdmarquee.defaults = { isequal:true,//所有滚动的元素长宽是否相等,true,false loop: 0,//循环滚动次数,0时无限 direction: 'up',//滚动方向,'left','right','up','down' scrollamount:1,//步长 scrolldelay:60,//时长 newamount:3,//加速滚动的步长 eventa:'mousedown',//鼠标事件,加速 eventb:'mouseup'//鼠标事件,原速 }; $.fn.kxbdmarquee.setdefaults = function(settings) { $.extend( $.fn.kxbdmarquee.defaults, settings ); }; })(jquery); /*$(document).ready(function(){ $('.marquee').kxbdmarquee({ direction:'left', eventa:'mouseenter', eventb:'mouseleave' }); }); */ var i=0; function picchange(obj){ if(i<$(""+obj+" li").length-1){ i++; $(""+obj+" li").eq(i).fadein().siblings("li").fadeout(); }else{ i=0; $(""+obj+" li").eq(i).fadein().siblings("li").fadeout(); } } /*设为首页加入收藏*/ function addfavorite(surl, stitle) { try { window.external.addfavorite(surl, stitle); } catch (e) { try { window.sidebar.addpanel(stitle, surl, ""); } catch (e) { alert("加入收藏失败,请使用ctrl+d进行添加"); } } } function sethome(obj,url){ try{ obj.style.behavior='url(#default#homepage)'; obj.sethomepage(url); } catch(e){ if(window.netscape) { try { netscape.security.privilegemanager.enableprivilege("universalxpconnect"); } catch (e) { alert("此操作被浏览器拒绝!n请在浏览器地址栏输入‘about:config’并回车n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。"); } var prefs = components.classes['@mozilla.org/preferences-service;1'].getservice(components.interfaces.nsiprefbranch); prefs.setcharpref('browser.startup.homepage',url); } } } //文字上下滚动 function autoscroll(obj){ $(obj).find("ul:first").animate({ margintop:"-28px" },500,function(){ $(this).css({margintop:"0px"}).find("li:first").appendto(this); }); } //专题 function zhuantimove(obj) { $(obj).addclass('current'); $(obj).siblings().removeclass('current'); var current = $("#zhuanti .icons li.current").index(); var zhuantiheight = 189; $('#zhuanti .pics').animate({margintop:-current * zhuantiheight+'px'}); clearinterval(zhuantiinterval); window.zhuantiinterval = setinterval('zhuantiinit()',3000); } function zhuantiinit() { var current = $("#zhuanti .icons li.current").index(); var next = current + 1; if (next == $("#zhuanti .icons li").length) { next = 0; } var obj = $("#zhuanti .icons li").eq(next); zhuantimove(obj); } //tab切换 function settab(titleid,contentid,index) { var titleid="#"+titleid; var contentid="#"+contentid; if($(titleid).children("li").eq(index).attr("class")!="current"&&$(titleid).children("a").eq(index).attr("class")!="current"){ $(titleid).find(".morehref").attr("href",$(titleid).find(".current").attr("mylink")); $(titleid).children("a").each(function() { if ($(this).index()!=index) { //$(this)[0].classname=""; $(this).removeclass("current"); } else { //$(this)[0].classname="current"; $(this).addclass("current"); } }); $(""+titleid+" a").each(function() { if ($(this).index()!=index) { //$(this)[0].classname=""; $(this).removeclass("current"); } else { //$(this)[0].classname="current"; $(this).addclass("current"); } }); $(titleid).children("ul").children("li").each(function() { if ($(this).index()!=index) { //$(this)[0].classname=""; $(this).removeclass("current"); } else { //$(this)[0].classname="current"; $(this).addclass("current"); } }); $(contentid).children("ul").each(function() { if ($(this).index()!=index) { $(this)[0].style.display="none"; } else { $(this)[0].style.display="block"; } }); }; } //图片滚动 调用方法 imgscroll({speed: 30,amount: 1,dir: "up"}); $.fn.imgscroll = function(o){ var defaults = { speed: 40, amount: 0, width: 1, dir: "left" }; o = $.extend(defaults, o); return this.each(function(){ var _li = $("li", this); _li.parent().parent().css({overflow: "hidden", position: "relative"}); //div _li.parent().css({margin: "0", padding: "0", overflow: "hidden", position: "relative", "list-style": "none"}); //ul _li.css({position: "relative", overflow: "hidden"}); //li if(o.dir == "left") _li.css({float: "left"}); //初始大小 var _li_size = 0; for(var i=0; i<_li.size(); i++) _li_size += o.dir == "left" ? _li.eq(i).outerwidth(true) : _li.eq(i).outerheight(true); //循环所需要的元素 if(o.dir == "left") _li.parent().css({width: (_li_size*3)+"px"}); _li.parent().empty().append(_li.clone()).append(_li.clone()).append(_li.clone()); _li = $("li", this); //滚动 var _li_scroll = 0; function goto(){ _li_scroll += o.width; if(_li_scroll > _li_size) { _li_scroll = 0; _li.parent().css(o.dir == "left" ? { left : -_li_scroll } : { top : -_li_scroll }); _li_scroll += o.width; } _li.parent().animate(o.dir == "left" ? { left : -_li_scroll } : { top : -_li_scroll }, o.amount); } //开始 var move = setinterval(function(){ goto(); }, o.speed); _li.parent().hover(function(){ clearinterval(move); },function(){ clearinterval(move); move = setinterval(function(){ goto(); }, o.speed); }); }); }; //$(document).ready(function(){ // $(".scrollleft").imgscroll({ // speed: 40, //图片滚动速度 // amount: 0, //图片滚动过渡时间 // width: 1, //图片滚动步数 /// dir: "left" // "left" 或 "up" 向左或向上滚动 // }); // $(".scrolltop").imgscroll({ // speed: 40, //图片滚动速度 // amount: 0, //图片滚动过渡时间 // width: 1, //图片滚动步数 // dir: "up" // "left" 或 "up" 向左或向上滚动 // }); //}); //select 模拟框 function selectbox(){ $(".options").hover(function(){ $(this).children("dd").show(); $(this).children("b").show(); }, function() { $(this).children("dd").hide(); }); $(".options ,.options div").hover(function(){ $(this).addclass("hover"); },function(){ $(this).removeclass("hover"); }); $(".options dd div").click(function(){ $("#text").val($(this).html());//当前 var s=$(this).attr("s"); window.open(s); $(this).children("dd").hide(); }); } //返回顶部 //滚动 $(window).scroll(function() { if($(this).scrolltop()>0){ $("#back-top").fadein(); }else{ $("#back-top").fadeout(); } }) $(function(){ $("#back-top").click(function(){ $('body,html').animate({scrolltop:0},200); }) }) //导航当前 $(function(){ var bclassid = "[!--bclass.id--]"; var classid = "[!--self.classid--]"; $(".nav li,.menu li,.time li").each(function() { if ($(this).attr('classid')==classid || $(this).attr('classid')==bclassid) { $(this).addclass('current'); } }) $(".inside_banner img,.fz_banner1,.fz_banner2,.fz_banner3,.inside_banner1,.inside_banner2,.inside_banner4,.inside_banner5,.inside_banner6").width($(window).width()); }) //图片放大 function showbigpic(obj) { window.w = $(obj).width(); window.h = $(obj).height(); window.orix = $(obj).offset().left; window.oriy = $(obj).offset().top; var screenimage = $(obj); // create new offscreen image to test var theimage = new image(); theimage.src = screenimage.attr("src"); // get accurate measurements from that. var imagewidth = theimage.width; var imageheight = theimage.height; var targeth =imageheight; var targetw =imagewidth; var targetx = ($(window).width() - targetw*400/targeth) / 2; var targety = ($(window).height() - 400) / 2 + $(document).scrolltop(); var closew=targetw*400/targeth+targetx-5; var closeh=targety-20; var btntop = targety + 400/2 - 16; var btnleft1 = targetx - 24; var btnleft2 = targetx + targetw*400/targeth; var html = '
<>
'; $("#alphabg").css({width:$(document).width()+"px",height:$(document).height()+"px"}); $("#alphabg").fadein(); var html2='×'; $("body").append(html); $("#bigpic").animate({width:targetw*400/targeth+'px',height:400+'px',left:targetx+'px',top:targety+'px'},1000,'swing',function() {$("#alphabg").css({width:$(document).width()+"px",height:$(document).height()+"px"});$("body").append(html2);} ); var url = $(obj).attr("titleurl"); $("#hiddenmorepic").remove(); $("body").append(""); $("#hiddenmorepic").load(url+" #morepic",function() { $("#hiddenmorepic li").length > 1 ? $("#alphabg span").show() : ""; }); } function show_next(para) { if (!($("#hiddenmorepic li").length > 0)) return; para == undefined ? para = 1 : ""; var current = -1; $("#hiddenmorepic li").each(function() { if ($(this).attr("pic") == $("#alphabg img").attr("src")) { current = $(this).index(); } }); var next = current + para; if (next < -1) { var next_img = $("#hiddenmorepic li:last").attr("pic"); } else if (next == $("#hiddenmorepic li").length) { var next_img = $("#alphabg img").attr("titlepic"); } else { var next_img = $("#hiddenmorepic li").eq(next).attr("pic"); } $("#alphabg img").attr("src",next_img); } function remove_big() { $("#alphabg span").remove(); $("#close").remove(); $("#bigpic").animate({width:w+'px',height:h+'px',left:orix+'px',top:oriy+'px'},1000,'swing',function() {$("#bigpic").remove();$("#alphabg").fadeout();}); }