
jQuery.fn.accessNews=function(settings)
{
      settings=jQuery.extend({newsHeadline:"Top Stories",newsSpeed:"normal"},settings);
      return this.each(function(i)
                        {aNewsSlider.itemWidth=parseInt(jQuery(".item:eq("+i+")",".news_slider").css("width"))+parseInt(jQuery(".item:eq("+i+")",".news_slider").css("margin-right"));
                         aNewsSlider.init(settings,this);
                        }
                      )
};
var aNewsSlider={
                  itemWidth:0,
                  init:function(s,p)
                  {
                     itemLength=jQuery(".item",p).length;
                     newsContainerWidth=itemLength*aNewsSlider.itemWidth;
                     jQuery(".container",p).css("width",newsContainerWidth+"px");
                     jQuery(".next",p).css("display","block");
                     animating=false;
                     
                     //**** DOTS click start ******
                     jQuery(".dot",p).click(function()
                                             {  
                                                var back =false;
                                                var from_page = jQuery(".dot_active",p).attr("id");
                                                var to_page = jQuery(this).attr("id");
                                                jQuery(".dot_active",p).attr({"class": "dot"})
                                                jQuery(this).attr({"class": "dot_active"})  
                                                var to_page = jQuery(this).attr("id");
                                                var diff = (to_page - from_page);
                                                var step =Math.abs(to_page-from_page); 
                                                
                                                if (diff > 0)
                                                {
                                                  back = false; 
                                                }
                                                if (diff < 0)
                                                {
                                                  back = true; 
                                                }
                                                if (diff == 0)
                                                {
                                                  return false;
                                                }
                                                if (back==false)
                                                {  
                                                      if(animating==false)
                                                       {
                                                       inactive_dots= jQuery(".dot",p); 
                                                       animating=true;
                                                       animateLeft=parseInt(jQuery(".container",p).css("left"))-(aNewsSlider.itemWidth*1*step);
                                                       if(animateLeft+parseInt(jQuery(".container",p).css("width"))>0)
                                                          {
                                                          jQuery(".prev",p).css("display","block");
                                                          jQuery(".container",p).animate({left:animateLeft},s.newsSpeed,function(){jQuery(this).css("left",animateLeft)
                                                          
                                                           /**/
                                                          jQuery(".prev img",p).attr("src", jQuery("input.image_hidden_prev_a").attr("value"));
                                                          jQuery(".next img",p).attr("src", jQuery("input.image_hidden_next_a").attr("value")); 
                                                          
                                                          if(parseInt(jQuery(".container",p).css("left"))+parseInt(jQuery(".container",p).css("width"))<=aNewsSlider.itemWidth*1)
                                                          {
                                                             jQuery(".prev img",p).attr("src", jQuery("input.image_hidden_prev_a").attr("value"));                                                           
                                                             jQuery(".next img",p).attr("src", jQuery("input.image_hidden_next").attr("value")); 
                                                          }
                                                          /***/                                                          
                                                          animating=false})
                                                          }
                                                     
                                                       else {animating=false}
                                                       }
                                                  }
                                                  else
                                                  { 
                                                        if(animating==false)
                                                         {
                                                         animating=true;
                                                         animateLeft=parseInt(jQuery(".container",p).css("left"))+(aNewsSlider.itemWidth*1*step);
                                                         if((animateLeft+parseInt(jQuery(".container",p).css("width")))<=parseInt(jQuery(".container",p).css("width")))
                                                            {
                                                            jQuery(".next",p).css("display","block");
                                                            jQuery(".container",p).animate({left:animateLeft},s.newsSpeed,function(){jQuery(this).css("left",animateLeft);
                                                            
                                                              /**/
                                                              jQuery(".prev img",p).attr("src", jQuery("input.image_hidden_prev_a").attr("value"));
                                                              jQuery(".next img",p).attr("src", jQuery("input.image_hidden_next_a").attr("value")); 
                                                              
                                                              if(parseInt(jQuery(".container",p).css("left"))==0)
                                                              {                                                     
                                                                 jQuery(".prev img",p).attr("src", jQuery("input.image_hidden_prev").attr("value"));                                                           
                                                                 jQuery(".next img",p).attr("src", jQuery("input.image_hidden_next_a").attr("value")); 
                                                              }
                                                              /***/    
                                                        
                                                            animating=false})
                                                            }
                                                       
                                                            
                                                         else {animating=false}
                                                         }
                                                  }
                                                  jQuery(".next",p).css("display","block")
                                                  StopAll(); 
                                                  return false
                                             });
                     //**** DOTS klick end *******
                     
                     jQuery(".next",p).click(function()
                                             {
                                                if(animating==false)
                                                   {
                                                   animating=true;
                                                   animateLeft=parseInt(jQuery(".container",p).css("left"))-(aNewsSlider.itemWidth*1);
                                                   if(animateLeft+parseInt(jQuery(".container",p).css("width"))>0)
                                                      {
                                                      jQuery(".prev",p).css("display","block");
                                                      jQuery(".container",p).animate({left:animateLeft},s.newsSpeed,function(){jQuery(this).css("left",animateLeft);
                                                       
                                                      var n_active = jQuery("a.dot_active",p).attr("id");
                                                      var n_next_active = parseInt(n_active)+1;
                                                                                           
                                                      jQuery("a#"+n_next_active,p).attr({"class": "dot_active"});
                                                      jQuery("a#"+n_active,p).attr({"class": "dot"});
                                                      
                                                      //*******
                                                      jQuery(".prev img",p).attr("src", jQuery("input.image_hidden_prev_a").attr("value"));
                                                      jQuery(".next img",p).attr("src", jQuery("input.image_hidden_next_a").attr("value")); 
                                                      
                                                      if(parseInt(jQuery(".container",p).css("left"))+parseInt(jQuery(".container",p).css("width"))<=aNewsSlider.itemWidth*1)
                                                      {
                                                         jQuery(".prev img",p).attr("src", jQuery("input.image_hidden_prev_a").attr("value"));                                                           
                                                         jQuery(".next img",p).attr("src", jQuery("input.image_hidden_next").attr("value")); 
                                                       
                                                      }
                                                      
                                                      //*******
                                                         animating=false;
                                                       })
                                                      }
                                                   else {animating=false}
                                                   }
                                                StopAll(); 
                                                return false
                                             });
                                             
                     jQuery(".prev",p).click(function()
                                             {
                                                if(animating==false)
                                                   {
                                                   animating=true;
                                                   animateLeft=parseInt(jQuery(".container",p).css("left"))+(aNewsSlider.itemWidth*1);
                                                   if((animateLeft+parseInt(jQuery(".container",p).css("width")))<=parseInt(jQuery(".container",p).css("width")))
                                                      {
                                                      jQuery(".next",p).css("display","block");
                                                      jQuery(".container",p).animate({left:animateLeft},s.newsSpeed,function(){jQuery(this).css("left",animateLeft);
                    
                                                      var p_active = jQuery("a.dot_active",p).attr("id");
                                                      var p_next_active = parseInt(p_active)-1;   
                                                  
                                                      jQuery("a#"+p_active,p).attr({"class": "dot"});
                                                      jQuery("a#"+p_next_active,p).attr({"class": "dot_active"});
                                                    
                                                      jQuery(".prev img",p).attr("src", jQuery("input.image_hidden_prev_a").attr("value"));
                                                      jQuery(".next img",p).attr("src", jQuery("input.image_hidden_next_a").attr("value")); 
    
                                                      if(parseInt(jQuery(".container",p).css("left"))==0)
                                                      {
                                                      jQuery(".prev img",p).attr("src", jQuery("input.image_hidden_prev").attr("value"));
                                                      jQuery(".next img",p).attr("src", jQuery("input.image_hidden_next_a").attr("value")); 
                                                      }
                                                   
                                                      animating=false})
                                                      }
                                                   else 
                                                      {
                                                        animating=false;              
                                                      }
                                                   }
                                                   StopAll(); 
                                                   return false
                                               })
                  },
                  vAll:function(s,p)
                  {
                     var o=p;
                     while(p)
                     {
                        p=p.parentNode;
                        if(jQuery(p).attr("class")!=undefined&&jQuery(p).attr("class").indexOf("news_slider")!=-1)
                          {break}
                     }
                  }
                 };
                 
                 


                