$(document).ready(function(){
	
		$(".hover").hover(
		  function () {
			 var o = $(this).attr('src').replace(".gif",'_over.gif');
			 $(this).attr('src', o);

		  }, 
		  function () {
		
			var o = $(this).attr('src');
			o = o.replace("_over.gif",'.gif');
		 	$(this).attr('src', o);

		  }
		);
		
		//NIcks slider pugin
		//
			$('#slidesThumbs li:last').children().addClass('last');
			$(".thbhomeslide a").click(function (event) { 
				if($(this).parent().hasClass("active"))return;
				event.preventDefault();
				stopinterval();
				$('.active').removeClass('active')
				var slidehref = $(this).attr('href');
				var slideimgsrc = $(this).attr('id');
				
				$('#mainSlider').append("<li class='waiting' style='display:none;'><a href='"+slidehref+"'><img src='"+slideimgsrc+"' /></a></li>");
				$("#mainSlider li:first").remove();
				$('#mainSlider .waiting').fadeIn('slow', function () {
																   
					$(this).removeClass('waiting');
					startinterval();
					
				});
				
			 	$(this).parent().addClass('active');
			});
			
			startinterval();
 });
function stopinterval(){
	if(timer!=""){
          window.clearInterval(timer)
          timer=""
         
      }
	
}
function changeslidetimer(){
	who = $('#slidesThumbs .active');
	if(!$('#slidesThumbs li.active').children().hasClass("last")){
		who.next().children().click();
		//console.debug('na');
	}else{
		
		$('#slidesThumbs li a:first').click();
	}
}

function startinterval(){
	timer = window.setInterval("changeslidetimer()",21000); 	
	
}
	