﻿// JavaScript Document
function tab(name,c,n){
  for(i=1;i<=n;i++){
  var menu=document.getElementById(name+i);
  var con=document.getElementById("c-"+name+i);
  menu.className=i==c?"hover":"";
  con.style.display=i==c?"block":"none";
  };
};

function tabindex(name,c,n){
	if(c==2){
		for(j=0;j<4;j++){
			var img2=document.getElementById('picbox2'+j);
			img2.src = picbox[c-1][j];
		}
	}
	if(c==3){
		for(k=0;k<6;k++){
			var img3=document.getElementById('picbox3'+k);
			img3.src = picbox[c-1][k];
		}
	}
	for(i=1;i<=n;i++){
		var menu=document.getElementById(name+i);
		var con=document.getElementById("c-"+name+i);
		menu.className=i==c?"hover":"";
		con.style.display=i==c?"block":"none";
	};
};

$(document).ready(function(){
	/**
	 * 主页热图榜
	 */
	if ($('.hot_list')) {
		$('.hot_list').mouseover(function(){
			$('#img_hot_list > a').attr('href', this.href);
			$('#img_hot_list img').attr({
				src: $(this).attr('img'),
				alt: $(this).text()
			});
		});
	}
	
	/**
	 * 美图推荐
	 */
	if($('.mt_recommend')){
		$('.mt_recommend').mouseover(function(){
			$('#img_mt_recommend > a').attr('href', this.href);
			$('#img_mt_recommend img').attr({
				src: $(this).attr('img'),
				alt: $(this).text()
			});
		});
	}
	
	/**
	 * 小编推荐
	 */
	if($('.xb_recommend')){
		$('.xb_recommend').mouseover(function(){
			$('#img_xb_recommend > a').attr('href', this.href);
			$('#img_xb_recommend img').attr({
				src: $(this).attr('img'),
				alt: $(this).text()
			});
		});
	}
	
	$('body').append('<div id="loadimg" style="display:none;"></div>');
	
	$('#picroll').scrollable({
		circular:true,
		next:'.picroll_next',
		prev:'.picroll_prev'
	});
	
	var scrollable_api = $('#picroll').data('scrollable');
	scrollable_api.onSeek(function(){
		var yl = 1;
		var index = scrollable_api.getIndex();
		if(index>=yl){
			var t = $('#picroll');
			t.find('img').each(function(i){
				if($(this).attr('original')){
					$(this).attr('src',$(this).attr('original'));
					$(this).removeAttr('original');
				}
			});
			yl ++;
		}
	});
});


/**
 * 点击显示图片
 */


$(window).load(function(){
	
	/**
	 * 预加载图片
	

	if ($('.hot_list')) {
		$('.hot_list').each(function(i){
			$('#loadimg').append('<img src="'+this.img+'" />');
		});
	}
	if ($('.mt_recommend')) {
		$('.mt_recommend').each(function(i){
			$('#loadimg').append('<img src="'+this.img+'" />');
		});
	}
	if ($('.xb_recommend')) {
		$('.xb_recommend').each(function(i){
			$('#loadimg').append('<img src="'+this.img+'" />');
		});
	}
	 */
});

