jQuery.fn.scrollingList = function(options) {
	var tid = $(this).attr("id");
    var pid = $(this).parent();
	var $this = $(this);
	var defaults = {
		SLheight:"90px",SLwidth:"200px",showMe:"0",buttonWidth:"24px",tWid:158,tWidPad:150,auto:false
		};
	options = $.extend(defaults, options);
    if(options.showMe==0){
        options.SLwidth = options.SLwidth;
    }else{
        var tWid = options.tWid ;
        var tWidPad = options.tWidPad;
        //alert(tWid);
        options.SLwidth = tWid*options.showMe + (parseInt(options.buttonWidth)*2);
    }
    //$this.children("li:first").addClass("firstOne");
    reindexMe(tid);
    
	$(this).parent().prepend("<div class='slideLeft' id='sl-"+tid+"'></div>");
    	$(this).parent().append("<div class='slideRight' id='sr-"+tid+"'></div>");
	$(this).children("li").css({"display":"inline","list-style-type":"none","margin-left":"0px","padding":"0px","float":"left","height":options.SLheight,"cursor":"pointer"});
	
	$(this).wrap("<div class='SLouterWrapper'><div class='SLinnerWrapper'></div></div>");
	
	
	$(this).parents(".SLouterWrapper").css({"height":options.SLheight,"width":options.SLwidth,"overflow":"hidden"});		
	
	$(this).children("li").children(".slide-link-outer").width(tWid).height(tWidPad)
	var newWidth = 0;
	$(this).children("li").each(function(){
			//alert($(this).children("img").width());
		newWidth = newWidth+parseInt($(this).children(".slide-link-outer").width());
	});
	//newWidth+= 200;
    //alert(newWidth);
	//$("#"+tid).parents(".SLinnerWrapper").css({"width":newWidth});
$(this).parents(".SLinnerWrapper").css({"paddingLeft":options.buttonWidth,"width":newWidth});
	$("#sr-"+tid+"").click(function(){
        var maxMinus = parseInt(newWidth-(options.showMe*tWid));
        //alert(maxMinus);
        var negMax = 0-maxMinus;
        //alert(negMax)
        var nML = parseInt($("#"+tid).parents(".SLinnerWrapper").css("marginLeft"));
        if(nML>negMax){
        nML-=(tWid*options.showMe);
        
       $("#"+tid).parents(".SLinnerWrapper").animate({"margin-left":nML},500);
       
        }else{
           $("#"+tid).parents(".SLinnerWrapper").animate({"margin-left":0},1000); 
        }
       	});
        
	$("#sl-"+tid+"").click(function(){
	   var minMinus = 0;
               var maxMinus = parseInt(newWidth-(options.showMe*tWid));
        //alert(maxMinus);
        var negMax = 0-maxMinus;
	  var nML = parseInt($("#"+tid).parents(".SLinnerWrapper").css("marginLeft"));
      if(nML<minMinus){
        nML+=(tWid*options.showMe);
       $("#"+tid).parents(".SLinnerWrapper").animate({"margin-left":nML},500);
       }else{
         $("#"+tid).parents(".SLinnerWrapper").animate({"margin-left":negMax},1000);
      
       }
       	});
	
	function reindexMe(idVal){
	   $("#"+idVal).children("li").removeClass("firstOne");
        $("#"+idVal).children("li").removeClass("lastOne");
	   $("#"+idVal).children("li:first").addClass("firstOne");
        $("#"+idVal).children("li:last").addClass("lastOne");
	}
	
//  return this.each(function(){


  //  alert(this);



  //});
};


