123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- auto=null;
- timer=null;
- var focus=new Function();
- focus.prototype={
- init:function(){
- this.aTime=this.aTime || 10;
- this.sTime=this.sTime || 5000;
- this.oImg=document.getElementById('focus_m').getElementsByTagName("ul")[0];
- this.oImgLi=this.oImg.getElementsByTagName("li");
- this.oL=document.getElementById('focus_l');
- this.oR=document.getElementById('focus_r');
- this.createTextDom();
- this.target=0;
- this.autoMove();
- this.oAction();
- },
- createTextDom:function(){
- var that=this;
- this.oText=document.createElement("div");
- this.oText.className="focus_s";
- var ul=document.createElement('ul');
- var frag=document.createDocumentFragment();
- for (var i=0;i<this.oImgLi.length;i++) {
- var li=document.createElement("li");
- li.innerHTML='<b></b>';
- if (i==0) {
- li.className="active";
- };
- frag.appendChild(li);
- };
- ul.appendChild(frag);
- this.oText.appendChild(ul);
- this.o.insertBefore(this.oText,this.o.firstChild);
- this.oTextLi=this.oText.getElementsByTagName("li");
- },
- autoMove:function(){
- var that = this;
- auto=setInterval(function(){that.goNext()},that.sTime);
- },
- goNext:function() {
- this.target=this.nowIndex();
- this.target==this.oTextLi.length-1 ? this.target=0:this.target++;
- this.aStep=(this.target-this.nowIndex())*this.step;
- this.removeClassName();
- this.oTextLi[this.target].className="active";
- this.startMove();
- },
- goPrev:function() {
- this.target=this.nowIndex();
- this.target==0 ? this.target=this.oTextLi.length-1 : this.target--;
- this.aStep=(this.target-this.nowIndex())*this.step;
- this.removeClassName();
- this.oTextLi[this.target].className="active";
- this.startMove();
- },
- startMove:function (){
- var that=this;
- var t=0;
- this.timer='';
- function set(){
- if (t>100) {
- clearInterval(that.timer);
- }else {
- for (var i=0;i<that.oImgLi.length;i++) {
- that.oImgLi[i].style.display='none';
- };
- that.oImgLi[that.target].style.display='block';
- that.setOpacity(that.oImg,t);
- t+=5;
- };
- };
- timer=setInterval(set,that.aTime);
- },
- setOpacity:function(elem,level){
- if(elem.filters){
- elem.style.filter = 'alpha(opacity=' + level + ')';
- elem.style.zoom = 1;
- } else {
- elem.style.opacity = level / 100;
- };
- },
- nowIndex:function(){
- for (var i=0;i<this.oTextLi.length;i++) {
- if (this.oTextLi[i].className=='active') {
- return i;
- break;
- }
- };
- },
- oAction:function(){
- var that=this;
- for (var i=0;i<this.oTextLi.length;i++) {
- this.oTextLi[i].index=i;
- this.oTextLi[i].onclick=function(){
- clearInterval(auto);
- clearInterval(timer);
- that.setOpacity(that.oImg,100);
- that.target=this.index;
- that.removeClassName();
- this.className='active';
- that.startMove();
- }
- };
- mouseEnter (that.o,'mouseleave',function(e){
- clearInterval(auto);
- that.autoMove();
- }
- );
- //this.oL.onclick=function(){
- // that.goPrev();
- // };
- // this.oR.onclick=function(){
- // that.goNext();
- // };
- },
- removeClassName:function(){
- for (var i=0;i<this.oTextLi.length;i++) {
- this.oTextLi[i].className=""
- };
- }
- };
- var focusRun=new focus();
- focusRun.o=document.getElementById("focus");
- function mouseEnter(ele,type,func){
- if(window.document.all)
- ele.attachEvent('on'+type,func);
- else{//ff
- if(type==='mouseenter')
- ele.addEventListener('mouseover',this.withoutChildFunction(func),false);
- else if(type==='mouseleave')
- ele.addEventListener('mouseout',this.withoutChildFunction(func),false);
- else
- ele.addEventListener(type,func,false);
- };
- };
- function withoutChildFunction(func){
- return function(e){
- var parent=e.relatedTarget;
- while(parent!=this&&parent){
- try{
- parent=parent.parentNode;}
- catch(e){
- break;
- }
- }
- if(parent!=this)
- func(e);
- };
- };
- //重要通知
- //主函数
- var s=function(){
- var interv=2000; //切换间隔时间
- var interv2=10; //切换速度
- var opac1=80; //文字背景的透明度
- var source="show" //焦点轮换图片容器的id名称
- //获取对象
- function getTag(tag,obj){
- if(obj==null){
- return document.getElementsByTagName(tag);
- }else{
- return obj.getElementsByTagName(tag);
- }
- }
- function getid(id){
- return document.getElementById(id);
- };
- var opac=0,j=0,t=63,num,scton=0,timer,timer2,timer3;
- var id=getid(source);
- id.removeChild(getTag("div",id)[0]);
- var li=getTag("li",id);
- var div=document.createElement("div");
- var title=document.createElement("div");
- var span=document.createElement("span");
- var button=document.createElement("div");
- button.className="button";
- for(var i=0;i<li.length;i++){
- var a=document.createElement("a");
- a.innerHTML=i+1;
- a.onclick=function(){
- clearTimeout(timer);
- clearTimeout(timer2);
- clearTimeout(timer3);
- j=parseInt(this.innerHTML)-1;
- scton=0;
- t=63;
- opac=0;
- fadeon();
- };
- a.className="b1";
- a.onmouseover=function(){
- this.className="b2";
- };
- a.onmouseout=function(){
- this.className="b1";sc(j);
- };
- button.appendChild(a);
- }
- //控制图层透明度
- function alpha(obj,n){
- if(document.all){
- obj.style.filter="alpha(opacity="+n+")";
- }else{
- obj.style.opacity=(n/100);
- }
- }
- //控制焦点按钮
- function sc(n){
- for(var i=0;i<li.length;i++){
- button.childNodes[i].className="b1";
- };
- button.childNodes[n].className="b2";
- }
- title.className="num_list";
- title.appendChild(span);
- alpha(title,opac1);
- id.className="d1";
- div.className="d2";
- id.appendChild(div);
- id.appendChild(title);
- id.appendChild(button);
- //渐显
- var fadeon=function(){
- opac+=5;
- div.innerHTML=li[j].innerHTML;
- span.innerHTML=getTag("img",li[j])[0].alt;
- alpha(div,opac);
- if(scton==0){
- sc(j);
- num=-2;
- scrolltxt();
- scton=1;
- };
- if(opac<100){
- timer=setTimeout(fadeon,interv2);
- }else{
- timer2=setTimeout(fadeout,interv);
- }
- };
- //渐隐
- var fadeout=function(){
- opac-=5;
- div.innerHTML=li[j].innerHTML;
- alpha(div,opac);
- if(scton==0){
- num=2;
- scrolltxt();
- scton=1;
- }
- if(opac>0){
- timer=setTimeout(fadeout,interv2);
- }else{
- if(j<li.length-1){
- j++;
- }else{
- j=0;
- }
- fadeon();
- }
- };
- //滚动文字
- var scrolltxt=function(){
- t+=num;
- span.style.marginTop=t+"px";
- if(num<0 && t>3){
- timer3=setTimeout(scrolltxt,interv2);
- }else if(num>0 && t<62){
- timer3=setTimeout(scrolltxt,interv2);
- }else{
- scton=0
- }
- };
- fadeon();
- }
- window.onload=function(){
- s();
- focusRun.init();
-
- };
- //视频轮播
- // banner1切换
- var banner_a = 0; //当前显示的图片的索引
- var banner_img_number = $('#img_list a').size();
- $('#num span').mouseover(function(){
- clearInterval(banner_timer1);
- var span_a = $(this).index();
- banner_a = span_a;
- toggle_image1();
- }).mouseout(function(){
- banner_timer1 = setInterval(toggle_image1,5000);
-
- })
- function toggle_image1()
- {
- $('#img_list a').not(':eq('+banner_a+')').hide();
- $('#img_list a').eq(banner_a).show();
- $('#num span').removeClass('lh_hover').eq(banner_a).addClass('lh_hover');
- banner_a++;
- if(banner_a >= banner_img_number) banner_a = 0;
- }
- $('#num span').eq(0).mouseover();
- var banner_timer1 = setInterval(toggle_image1,5000);
- //图片轮播
- var banner_i = 0; //当前显示的图片的索引
- var banner_img_number = $('#img_list2 a').size();
- $('#num2 b').mouseover(function(){
- clearInterval(banner_timer);
- var span_i = $(this).index();
- banner_i = span_i;
- toggle_image();
- }).mouseout(function(){
- banner_timer = setInterval(toggle_image,5000);
-
- })
- function toggle_image()
- {
- $('#img_list2 a').not(':eq('+banner_i+')').hide();
- $('#img_list2 a').eq(banner_i).show();
- $('#num2 b').removeClass('lh_hover').eq(banner_i).addClass('lh_hover');
- banner_i++;
- if(banner_i >= banner_img_number) banner_i = 0;
- }
- $('#num2 span').eq(0).mouseover();
- var banner_timer = setInterval(toggle_image,5000);
- $(function(){
- //tab切换
- $(".tab_list").eq(0).show();
- $(".lie_tab a").hover(
- function(){
- $(".tab_list").eq($(this).index()).show().siblings(".tab_list").hide();
- $(this).addClass('xx').siblings().removeClass('xx');
- }
- );
-
- //重要活动轮播
- $('.my-slider').unslider({
- speed: 500,
- delay: 3000,
- autoplay:1
- });
-
-
-
- });
|