var m_iInterval;
var arrMax=3;
var arrCursor=0;
var divId='';
var ListArr = new Array();
    
function Rotate(lnk)
{
   clearInterval(m_iInterval);
   arrCursor=0;
   divId = lnk.substring(lnk.indexOf('#')+1);
   ListArr = document.getElementById(divId).getElementsByTagName('div')[0].getElementsByTagName('li');
   m_iInterval = setInterval(SlideContent, 6000);
}


function SlideContent()
{ 
      

     for(var i=0;i<arrMax;i++)
     { 
        $(ListArr[i]).removeClass("active");
     }
     
     
     $(ListArr[arrCursor]).addClass("active");
     
     var img = document.getElementById(divId).getElementsByTagName('img')[0];
     
     if(img && ListArr[arrCursor]) {
		img.src = ListArr[arrCursor].getElementsByTagName('img')[0].src;
		img.alt = $(ListArr[arrCursor]).find("h4 a").html();
	 }
     
    // $(img).fadeIn();
     
    
     arrCursor++;
     if(arrCursor >= arrMax)     
         arrCursor=0;  
	

}


function SlideContentHover(listitem)
{ 
    clearInterval(m_iInterval);
	
	arrCursor = $(listitem).parent().children().index($(listitem));	
	
	$(listitem).parents('.tab-rotator').find('li').removeClass("active");

    $(listitem).addClass("active");
     
     var img = $(listitem).parents('.tab-rotator').find('img').eq(0);
     
	 var src = $(listitem).find('img').attr('src');
	 
     $(img).attr('src',src);
	 
	 $(img).attr('alt',$(listitem).find("h4 a").html());
	 
}



  
  $(document).ready(function(){
   
    $("ul.tabs").tabs("div.tabcontent");
    
    $("ul.tabs li").click(function () {Rotate($(this).find('a').attr('href'));});
	
	$(".tab-rotator li").hover(function () {SlideContentHover(this)} , function (){m_iInterval = setInterval(SlideContent, 6000); });
	
    $(".scrollable").scrollable();
    
    $('.scrollable .items a:first').addClass('active'); 
    
    $(".scrollable .items span a").click(function () {showPane($(this));});

    $(".scrollabe-news").scrollable({next: '.left', prev: '.right'});

	Rotate("#news");

});
  
    
    
 
