
(function(){
//图片切换 v1.0
//template 
//html
/*
<div id="slider">
    <div id="sliderPre"><a href="javascript:power('-');"></a></div>
    <div id="sliderNext"><a href="javascript:power('+');"></a></div>
    <div id="sliderList" class="center">
      <ul>
        <li><a href="#" target="_parent"><img src="images/tester_1.jpg" width="870" height="280"  /></a></li>
        <li><a href="#" target="_parent"><img src="images/tester_2.jpg" width="870" height="280"  /></a></li>
        <li><a href="#" target="_parent"><img src="images/tester_3.jpg" width="870" height="280"  /></a></li>
        <li><a href="#" target="_parent"><img src="images/tester_4.jpg" width="870" height="280"  /></a></li>
      </ul>
    </div>
  </div>

*/
//css
/*
#root #slider {
	width:870px;
	height:280px;
	position:absolute;
	left:55px;
	top:219px;
}
#root #slider #sliderPre, #root #slider #sliderNext {
	top: 127px;
	width:58px;
	height:53px;
	z-index:9;
	background:url(../images/icon_1.png) left top no-repeat;
}
#root #slider #sliderPre a, #root #slider #sliderNext a {
	display:block;
	height:100%;
}
#root #slider #sliderPre {
	position:absolute;
	left:-30px;
}
#root #slider #sliderNext {
	position:absolute;
	left:843px;
	background-position:0px -55px;
}
#root #slider #sliderList {
}
#sliderList ul li {
	position:absolute;
	left:0px;
	top:0px;
}
*/	  
window.changeImage=changeImage;
function PowerPoint(fn){
	
	/*
	*参数配置 
	container: 容器id
	listTag: 列表标签
	*/
	var config=
	{
			container:"sliderList",
			listTag:"li",
			sliderPre:"sliderPre",
			sliderNext:"sliderNext"
	};
	if(fn){
		config=fn;
	} 
	
	var stack=[],images=$("#"+config.container+" "+config.listTag+""),v=stack["v"],goby=stack["goby"],timer=stack["timer"],v=0,goby=null;
	
	//初始化透明度
	images.each(
			   function(i){
					   $(this).css("opacity", "0.0");
			  });
	
	
	//切换动作
	function act(action){
		if(goby!=null){
			$(images[goby]).animate({opacity:0.0},1000,function(){
																$(this).css("z-index", 0);
																});
		}
		if(action=="+"){
			v++;
			if(v>=images.length){
				v=0;
			}
			goby=v;
			$(images[v]).animate({opacity:1.0},1000,function(){
															$(this).css("z-index", 1);
															});
			
		}else{
			v--;
			if(v<0){
				v=images.length-1;
			}
			$(images[v]).animate({opacity:1.0},1000);
			goby=v;
		}
	}
	
	//初始化组件
	function init(){
		$(images[v]).animate({opacity:1.0},1000);
		goby=v;
		timer=setInterval(function(){
					act("+");
					},3000);
	}
	
	
	init();

	
	//抛出外部控制器
	//action动作为 "+" 或 "-"
	return function onmouse(action){
		 
		clearInterval(timer);
		if(action=="over"){
			timer=setInterval(function(){
						act("+");
						},3000);		
		}else{
			act(action);
		}
	}
}
function changeImage(){
	 this.PowerPoint=PowerPoint;
}

})();
 
/*
var image=new changeImage();

var power=image.PowerPoint(null);
*/
