$(document).ready(function() {
	$('.goodsimg').hover(function() { //网站前台 当鼠标移到商品图片时产生 浮动窗口显示大图片
		var imgresize = function (width,height,twidth,theight) {
			if(width>twidth||height>theight) {
				var im = (twidth/theight)/(width/height);
				if(im>1) {
					return 'height='+theight;
				} else {
					return 'width='+twidth ;
				}
			} else if(width<=twidth&&height<=theight) {
				return 'width='+width;
			}
		}
		var position = $(this).offset();
		var htop = ((position.top-$(document).scrollTop()+10)<150)?(position.top+10):(position.top-150); //(position.top-$(document).scrollTop()) 元素离屏幕上边的距离
		var hleft = position.left-$(document).scrollLeft();//元素离屏幕左边的距离		
		var img=$(this).find('img').attr('src').replace(/tmb\//g,'');
		(hleft<450)?$('#fldiv').css('left',parseInt(hleft)+200+10) : $('#fldiv').css('left',parseInt(hleft)-360);
		$('#fldiv').html('<img src='+img+ ' border="0" />' ) .show() .css({'top':htop,'height':240,'width':300});
		var simg = "<table border=0 cellspacing=0 width=100% height=98%><tr valign=middle><td align=center><img src ='"+img+"' border='0'  "+ imgresize($('#fldiv').find('img').width(),$('#fldiv').find('img').height(),295,235)+"></td></tr></table>"
		$('#fldiv').html(simg)  .show() .hover(function(){ $(this).show();},function(){$(this).hide();});

	},function() {
		$('#fldiv').hide();
	 });
});

//显示具体某个成员信息是，用div加载页面信息
$(document).ready(function(){
	var fileIntroPath=$('#hidFileIntroPath').val();
	if(fileIntroPath!='')
		$('#loadFileIntroDiv').load(fileIntroPath);
});

//首页显示多张图片时，控制显示一张
$(document).ready(function(){
	$('#showOnePict2').hide();
	$('#showOnePict3').hide();
	$('#showOnePict4').hide();
	$('#showIdDiv1').css('fontWeight','600');//图片页面 1 加粗
	
	var showOneImg=function()
	{
		var divId=$(this).html();
		var i;
		for(i=1;i<5;i++)
		{
			if(i==divId)	
			{//显示选中的图片
				$('#showOnePict'+divId).show();
				$('#showIdDiv'+divId).css('fontWeight','600');
			}
			else
			{//隐藏图片其他
				$('#showOnePict'+i).hide();
				$('#showIdDiv'+i).css('fontWeight','100');
			}
		}
	}
	$('#allNums').find('div').bind('click',showOneImg);
	
});



//前台首页显示多张成员图片 jquery plugin
$(document).ready(function(){
	$('#slide').cycle({
		fx:'zoom', 
		delay:-4000
	});

});

//前台首页显示多个成员的图片和信息 ， 分页
$(document).ready(function() 
{ //table 分页
  $('#moreSocImgs').each(function() {
    var $div = $(this);
	var currentPage = 0;
    var numPerPage = 1;//每页显示的行数
    $div.bind('repaginate', function() {//分页
      $div.find('tr').show();
        $div.find('tr:lt('+(currentPage * numPerPage)+')')
          .hide()
        .end();
        $div.find('tr:gt('+((currentPage + 1) * numPerPage - 1)+')')
          .hide()
        .end();
    });
	
    var numRows = $div.find('tr').length;
    var numPages = Math.ceil(numRows / numPerPage);
	if(numPages>1) {//当页数大于1时显示分页
    	var $pager = $('<div class=\"pager\" align="center" ></div>');
   	 	for (var page = 0; page < numPages; page++) {//分页页码
      	$('<span class="page-number">' + (page + 1) + '</span>')
       	 	.bind('click', {'newPage': page}, function(event) {
         		 currentPage = event.data['newPage'];
         		 $div.trigger('repaginate');
          		$(this).addClass('active').siblings().removeClass('active');
        	})
        	.appendTo($pager).addClass('clickable');
   	 	}
    	$pager.find('span.page-number:first').addClass('active');
		$pager.insertAfter($div);
    	$div.trigger('repaginate');
	}
  });
  
  
});
