// JavaScript Document
// 导航
$(document).ready(function(){
	var btn_nav=$('.btn_s');
	 var num=Number(-38);
     var m=0;
	 var topdis;
	$('.btn_s').mouseover(function(){
		var n=Math.pow((-1),m);
		if(n>0){
			topdis=0;
			 }
			 else {
				 topdis=num;
				 }
			$('.top').animate({top:topdis},100);
			m++;
		});
	})


//医文会友切换tab
$(document).ready(function(){
	var tab_menue=$('.tab_menue li');
	var tab_contect=$('.tab_contect ul');
	tab_menue.each(function(){
		for(var i=0;i<tab_menue.length;i++){
			tab_menue.eq(i).addClass('tabbg_'+i)
			}
		$(this).click(function(){
			var indextab=tab_menue.index($(this));
				tab_contect.hide();
				tab_contect.eq(indextab).show();
				for(var i=0;i<tab_menue.length;i++){
			    tab_menue.eq(i).removeClass('tabbg_'+i+'_'+i)
			         }
				$(this).addClass('tabbg_'+indextab+'_'+indextab)
			})
		})
	})

//切换tab
$.extend({
	tab:function(config){
		var _tab_menue=config.tab_menue,
		    _tab_contect=config.tab_contect,
			_tab_currentstyle=config.tab_currentstyle,
			_tab_menuestyle=config.tab_menuestyle || "";
			_tab_menue.each(function(){
				$(this).click(function(){
					var indextabmenue=_tab_menue.index($(this));
					    _tab_menue.addClass(_tab_menuestyle).removeClass(_tab_currentstyle);
						$(this).addClass(_tab_currentstyle);
					    _tab_contect.hide();
						_tab_contect.eq(indextabmenue).show();
					})
				})
		}
	})
$(document).ready(function(){
	$.tab({tab_menue:$('.tabcollectmenu li'),tab_contect:$('.tabcontectword'),tab_currentstyle:"current"});   //收藏页切换
	})

	/*  首页切换
$(document).ready(function(){
	var tab_menue=$('.tab_menue li');
	var tab_contect=$('.tab_contect ul');
	tab_menue.each(function(){
		for(var i=0;i<tab_menue.length;i++){
			tab_menue.eq(i).addClass('tabbg_'+i)
			}
	})
	$.tab({tab_menue:$('.tab_menue li'),tab_contect:$('.tab_contect ul')});
	})

*/

//医文会友 滚动新闻
$(document).ready(function(){
	var listul=$('.list_p');
	var newlist=$('.list_p li');
	var liheight=52;
	var listheight=liheight*3;
	var timeoutsign;
	for(var i=0;i<newlist.length;i++){
	    $('.list_p').css('height',listheight);        //高度
		newlist.eq(i).css('top',liheight*i);          //li 位置
		if((i%2)==0){                                 //背景颜色
			newlist.eq(i).css('background','#FFF0F5')}
		}
		var slider=function(){   //首页新闻滚动
			var li_list=$('.list_p li');
		    timeoutsign=false;
			 if(!timeoutsign){
			li_list.eq(0).appendTo(listul).animate({'top':'-52'},'slow',function(){
				$(this).css({'top':156})
				});
			li_list.eq(1).animate({'top':0},'slow');
			li_list.eq(2).animate({'top':52},'slow');
			li_list.eq(3).animate({'top':104},'slow');
			timeoutsign=setTimeout(slider,2500);
			}
		   }
		timeoutsign=setTimeout(slider,2500);
		$('.list_p').hover(function(){clearTimeout(timeoutsign);timeoutsign=false;},function(){timeoutsign=setTimeout(slider,2500);})
	})

//医文会友文献活动弹出层
$(document).ready(function(){
	var offset=function(s){   //弹出框位置
		  var offsetleft=($(window).width()-s.width())/2,
		      offsetheight=$(document).scrollTop()+($(window).height()-s.height())/2;
		  s.css({left:offsetleft,top:offsetheight})
		}
	var pop_d=function(){   //弹出层
		$('<div/>').attr('class','bgc').css({'width':'100%','height':$(document).height(),'opacity':'0.5','overflow':'hidden','position':'absolute','left':0,'top':0,'background':'#999','z-index':100}).prependTo('body');   //背景
		 var popbox=$('.pop'),popcontect=$('.pop_box');
		     popbox.show().css({height:popcontect.height(),width:popcontect.width()});
		     offset(popbox,this);
		     $('.bgblack').css({'height':popcontect.height()});
			 return false;
		}
	var closepop=function(){  //关闭
		var popbox=$('.pop');
		var popbg=$('.bgc');
		    popbox.hide();
			popbg.hide();
		}
	
	$('.xz').bind('click',pop_d);
	$('.download').click(pop_d);
	$('.closeimg').bind('click',closepop);

	})
	
$(document).ready(function(){   //杏林之家首页我要投稿
       var posoffset=function(s,d){    //位置
		     var offset=s.offset(),   //按钮的位置
			     posleft=offset.left+s.width()+'px',  //靠近按钮弹出层的位置
				 postop=offset.top+s.height()+'px';
			 return d.css({left:posleft,top:postop})
		   }
	   var pop_tg=function(s){    //我要投稿弹出层
		   //liuying m (s)---------------------
		  // var btn_tg=$('.pop_tg');  //弹出层，弹按钮
		   var btn_tg=$('#a');
		 //liuying m (e)----------------------
	          btn_tg.fadeIn('slow');
		      posoffset(s,btn_tg);
		      return false;
		}
	   var pop_close_tg=function(){
		var btn_tg=$('.pop_tg');
		btn_tg.fadeOut('slow');
		}
	$('.pop_tg_btn').each(
	  function(){
		   $(this).bind('click',function(){pop_tg($(this));return false});
		  }
	)
	$('.close_tg').bind('click',pop_close_tg)
	
	//liuying add  点击查看大图--------------------------
	 var posoffset_center=function(s,d){    //位置
	     var offset=s.offset(),   //按钮的位置
		     posleft=offset.left+s.width()+50+'px',  //靠近按钮弹出层的位置
			 postop=$(document).scrollTop()+($(window).height()-d.height())/2+'px';
		 return d.css({left:posleft,top:postop})
	   }
	   var pop_center=function(s){    //点击查看大图
		   var btn_tg=$('#b');
	          btn_tg.fadeIn('slow');
	          posoffset_center(s,btn_tg);
		      return false;
		}
	$('#big').click(function(){		
		pop_center($(this));return false;
	})
	//liuying add  点击查看大图--------------------------
	
	})	

//文献品评活动隐藏显示

$(document).ready(function(){
	var btn_d=$('.btn_d');
	var p_height=$('.hh');
	var show=true;
	btn_d.bind('click',function(){
	    if(show){
		$(this).addClass('icon_down').removeClass('icon_top')
		p_height.removeClass('height_hidden');
		show=false;
		}
		else{
		$(this).addClass('icon_top').removeClass('icon_down')
		p_height.addClass('height_hidden');
		show=true;
			}
		})
	})


	
	
	
	
