﻿var rotateTime = 4000;

$(function(){
	inputTitle('input.inputTitle'); // input 点击切换提示问题
	
	setTimeout(function(){
		rotateBox( '#ad-rotate ul li' ,'#ad-rotate .views');
	},300);
	
	/*index*/
	$('#ad-focusing div.recommend li').hover(function(){
		$(this).addClass('action');
	},function(){
		$(this).removeClass('action');
	});
	tabs('.sort-product-list','h2 li','.show .item','click');
	
 
	
});



function rotateBox( clild ,views){
	var $clild = $(clild);
	var $slideBox = $clild.parent();
	
	var $views =  $(views);
	var $width = $clild.eq(0).width();
	var len  = $clild.length;
	var index = 0;

	$views.find('a').hover(function(){
		if(boxTime) clearInterval(boxTime);
		index  = $views.find('a').index(this);
		showImg(index);
	},function(){
		boxTime = setInterval(function(){
			showImgSet()
		} , rotateTime);
	});
	var boxTime = setInterval(function(){
		showImgSet()
	},rotateTime);
	$views.find('a').eq(0).addClass("action");
	
	function showImgSet(){
		showImg(index);
		index++;
		if(index==len){index=0;}
	}
	
	function showImg(i){
		$slideBox.stop(true,false).animate({left : -($width*i) },'nomal'); 
		$views.find('a').eq(i).addClass("action").siblings().removeClass("action");
		
	}
	
};


