$(document).ready( function () {
			
			if ($.browser.opera) {
				$.support.opacity = true;
			}
			
			$('#promo img').each( function () {
				$(this).replaceWith('<div style="background-image:url('+$(this).attr('src')+')"></div>');
			});
				
			function loop(){
				$(window).stopTime('timer1');
				$(window).everyTime(10000, 'timer1', function () {
					go($('#next'),700);
				});
			}
			loop();
			
			var anime = false;
			
			$('#go-prev div,#go-next div').css('opacity',0);
			$('#current a').clone().appendTo('#relay');
			$('#go-next').click( function () { loop(); if(anime) return; go($('#next'),500); });
			$('#go-prev').click( function () { loop(); if(anime) return; go($('#prev'),500); });			
			
			$('#navigation').hover( function () {
				$('#relay a').stop().css({'display':'block','opacity':0}).animate({'opacity':0.7},300);
			}, function () {
				$('#relay a').stop().animate({'opacity':0},300, function () { $(this).css('display','none'); });
			});			
			
			$('#go-prev,#go-next').hover( function () {
				$(this).find('div').stop().animate({'opacity':0.8},400);				
			}, function () {
				$(this).find('div').stop().animate({'opacity':0},400);
			});
			
			/*scrolling function*/
			function go(whois,speed){
				if($('#prev').is(':first-child')){
					$('#promo li:last-child').insertBefore('#prev').attr('id','prevprev').css('left',0);
				}
				if($('#next').is(':last-child')){
					$('#promo li:first-child').insertAfter('#next').attr('id','nextnext').css('left',968);
				}
				if( $(whois).is('#next') ){					
					anime = true;
					$('#relay a').animate({'opacity':0},300, function () { 
						$(this).html($('#next a').html())
						.attr('href',$('#next a')
						.attr('href'))
						.animate({'opacity':0.7},300); 
					});				
					$('#next').animate({left:201,width:566},speed, function() {
						$(this).attr('id','current');
					});
					$('#current').animate({left:0,width:192},speed, function() { 
						$(this).attr('id','prev'); 
					});
					$('#prev').animate({left:0,width:0},speed, function() {
						$('#prevprev').removeAttr('id'); 
						$(this).attr('id','prevprev'); 
					});
					$('#nextnext').animate({left:776,width:192},speed, function() { 												
						$(this).attr('id','next');						
						$(this).next().attr('id','nextnext');
						anime = false;
					});					
				}
				if( $(whois).is('#prev') ){
					anime = true;
					$('#relay a').animate({'opacity':0},300, function () { 
						$(this).html($('#prev a').html())
						.attr('href',$('#prev a')
						.attr('href'))
						.animate({'opacity':0.7},300); 
					});
					$('#next').animate({left:968,width:0},speed, function() { 
						$('#nextnext').removeAttr('id'); 
						$(this).attr('id','nextnext'); 
					});
					$('#current').animate({left:776,width:192},speed, function() { 
						$(this).attr('id','next');
					});
					$('#prev').animate({left:201,width:566},speed, function() { 
						$(this).attr('id','current');
					});
					$('#prevprev').animate({left:0,width:192},speed, function() { 
						$(this).attr('id','prev');							
						$(this).prev().attr('id','prevprev');
						anime = false;
					});					
				}
			}			
		});