var topSlideCounter = 1;
var topSlideCounterText = 1;
var intervalID = 0;


function slideSwitch() {
    var $active = $('#galleryTop IMG.active');

    if ( $active.length == 0 ) $active = $('#galleryTop IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#galleryTop IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}


function animateGallery(){
	clearInterval(intervalID);
	if(topSlideCounter == 3){
		topSlideCounterText = 2;
		topSlideCounter = 0;
	}
		
	$('#slideGalleryText').animate({top: '-'+(topSlideCounterText*445)+'px'}, 850, function(){});
	
	$('#slideGallery').animate({top: '-'+(topSlideCounter*445)+'px'}, 850, function() {
		intervalID = setInterval("animateGallery()", 4200);
	});
	
	topSlideCounter++;
	topSlideCounterText--;
	
}

$(function() {
    var $test = $('#galleryTop IMG.active');
    	if ( $test.length > 0 ){
    		setInterval( "slideSwitch()", 5000 );
    	}
    
    /*if($('#slideGallery').is('img')){
    	intervalID = setInterval( "animateGallery()", 4200 );
    	$('#galleryTopTecno').css('height','445px');
    }*/
    
});

