(function($) {

	$.fn.easySlider = function(options){
	  
		// default configuration properties
		var defaults = {
			prevUrl:			'',
			nextUrl:			'',
			prevId: 		'prevBtn',
			prevText: 		'',
			nextId: 		'nextBtn',	
			nextText: 		'Next',
			orientation:	'', //  'vertical' is optional;
			speed: 			800		
		}; 
		
		var options = $.extend(defaults, options);  
		
		return this.each(function() {  
			obj = $(this); 				
			var s = $("li", obj).length;
			var w = obj.width(); 
						var h = obj.height(); 
			var ts = s-1;
			var t = 0;
			var vertical = (options.orientation == 'vertical');
			$("ul", obj).css('width',s*w);			
			if(!vertical) $("li", obj).css('float','left');			
			
			$("#"+options.nextId).click(function(){		
				animate("next");
				
				
			   //alert($("#slider ul li", obj).attr('title'));
			   
			//   alert($("li", obj).attr('title'));
			
			
					
				
				//alert($("ul li", obj).attr('title'));
				//alert($("ul li ", obj).attr('title'));
				
				//alert($("#slider ul li").change(function(){	attr('title') } ) );
				
				//if (t>=ts) $(this).fadeOut();
				//$("a","#"+options.prevId).fadeIn();
			});
			$("#"+options.prevId).click(function(){		
				animate("prev");
				
				/*var cid=1;
				
				//alert(cid);
					$(".tab_content").hide(); 				
					$(".tabs a:[href=#tabs-"+cid+"").addClass("active").show(); 
					$("#tabs-"+cid+"").show(); 					
					$("#tabsimg-"+cid+"").attr("src","images/port-imges/tab-"+cid+"-over.gif");
					
					for(i=0;i<=5;i++)
					{
						  if(cid!=i)
						  {
								$("#tabsimg-"+i+"").attr("src","images/port-imges/tab-"+i+"-main.gif");
						
						  }
					}
					
					$(".tab_content").hide();
				var activeTab = $(this).attr("href"); 
				$("#tabs-"+cid+"").show();
				*/
				//if (t<=0) $(this).fadeOut();
				//$("a","#"+options.nextId).fadeIn();
			});	
			function animate(dir){
				
				
				if (t<ts && t!=0){
					
					
								var incre_id=t;
								
							if(dir=='next')
							{
								
								incre_id=incre_id+1;
								
							}
							if(dir=='prev')
							{
								
								incre_id=incre_id-1;
								
								
							}
							
							
								
								
								   var cid=document.getElementById('cat_incre_id'+incre_id+'').value;
							
							//alert(cid);
								$(".tab_content").hide(); 				
								$(".tabs a:[href=#tabs-"+cid+"").addClass("active").show(); 
								$("#tabs-"+cid+"").show(); 					
								$("#tabsimg-"+cid+"").attr("src","images/port-imges/tab-"+cid+"-over.gif");
								
								for(i=0;i<=5;i++)
								{
									  if(cid!=i)
									  {
											$("#tabsimg-"+i+"").attr("src","images/port-imges/tab-"+i+"-main.gif");
									
									  }
								}
								
								$(".tab_content").hide();
							var activeTab = $(this).attr("href"); 
							$("#tabs-"+cid+"").show();
				
				
				}
				
				if(dir == "next"){
					if (t>=ts){
						
						
						location.href=options.nextUrl;
					}
					t = (t>=ts) ? ts : t+1;	
				} else {
					if (t<=0){
						location.href=options.prevUrl;
					}
					t = (t<=0) ? 0 : t-1;
				};								
				if(!vertical) {
					p = (t*w*-1);
					
					$("ul",obj).animate(
						{ marginLeft: p }, 
						options.speed
					);				
				} else {
					p = (t*h*-1);
					$("ul",obj).animate(
						{ marginTop: p }, 
						options.speed
					);					
				}
			};
			if(s>1) $("a","#"+options.nextId).fadeIn();	
		});
	  
	};

})(jQuery);
