// JavaScript plugin my webguru


(function( $ ){

  $.fn.buttonSlide = function(MovingDiv,DivContent,ButtonContainer) {
  
//coding starts here

var counter=0;
var	temp=null;

var totalCount = DivContent.length;
	genlist();
	var Button = ButtonContainer.children($('.button'));
	Button.css('cursor','pointer');
	Button.eq(0).css('background','url(images/slide-active.png');
	var totalButton = Button.length;

	var shiftAmt = $(this).width();
	var inter = setInterval(change,4000);
	
	
	
	
	
	Button.bind('click',function(){
								 				
											
										   		var	idd = $(this).attr("id").split("_")[1];
												counter = idd;
												clearInterval(inter);
										   		
										   		movePlate();
												
										   	});
		
		
		
							
	function genlist()
	{
			var i=0;
			var htmlc = "";
			while(i<totalCount)
			{
			htmlc=htmlc+("<div class='button' id='Button_"+i+"'></div>");	
			i++;
			}
			ButtonContainer.html(htmlc);
			
			
	}
	
	//generating id ends here
	
	
	
	
	function change()
	{
		if(counter<(totalCount-1)) {   		counter++;    }
		else { 			}
		movePlate();
	}
	
	
	function movePlate()
	{ 
	
	  tshift = counter*shiftAmt*(-1);	
	  MovingDiv.stop().animate({left:tshift},1500);
	  
	  
	  Button.eq(temp).css('background','url(images/slide-deactive.png');
	  Button.eq(counter).css('background','url(images/slide-active.png');
		temp=counter;
	  
	}






//coding ends here

  };
})( jQuery );
