$w = window.$w = window;

$w.front_1_count;
$w.front_2_count;
$w.front_3_count;
// used to keep track of the current image
$w.front_1_counter;
$w.front_2_counter; 
$w.front_3_counter;
$w.front_scroll_amt = 148;

$w.front_scroll = function(){
    $('front_1').effect('top',{
        duration: 500,
			fps: 35,
        transition: Fx.Transitions.Cubic.easeInOut,
        onComplete: $w.front_end_scroll.pass('front_1')
    }).start(-($w.front_1_counter*$w.front_scroll_amt), -(($w.front_1_counter-1)*$w.front_scroll_amt));
    $('front_2').effect('top',{
        duration: 500,
			fps: 35,
        transition: Fx.Transitions.Cubic.easeInOut,
        onComplete: $w.front_end_scroll.pass('front_2')
    }).start(-($w.front_2_counter*$w.front_scroll_amt), -(($w.front_2_counter-1)*$w.front_scroll_amt));
    $('front_3').effect('top',{
        duration: 500,
			fps: 35,
        transition: Fx.Transitions.Cubic.easeInOut,
        onComplete: $w.front_end_scroll.pass('front_3')
    }).start(-($w.front_3_counter*$w.front_scroll_amt), -(($w.front_3_counter-1)*$w.front_scroll_amt));
    $w.setTimeout(function() {$w.front_scroll();}, 12000); //12000
}

$w.front_end_scroll = function(type_id, count){
    $w[type_id+'_counter']--;
    if($w[type_id+'_counter']==0){
        new Fx.Style(type_id,'top').set(-($w[type_id+'_counter']*$w.front_scroll_amt));
        $w[type_id+'_counter']=$w[type_id+'_count'];
    }
}

$w.addEvent('domready', function() {
	$('front_1').setStyle('position','absolute');
	$('front_2').setStyle('position','absolute');
	$('front_3').setStyle('position','absolute');
    //set these to the number of images to scroll through
    $w.front_1_count = $('front_1').getElementsByTagName('a').length ;
    $w.front_2_count = $('front_2').getElementsByTagName('a').length ;
    $w.front_3_count = $('front_3').getElementsByTagName('a').length ;

    // used to keep track of the current image
    $w.front_1_counter=$w.front_1_count;
    $w.front_2_counter=$w.front_2_count;
    $w.front_3_counter=$w.front_3_count;

    new Fx.Style('front_1','top').set(-($w.front_1_counter*$w.front_scroll_amt));
    new Fx.Style('front_2','top').set(-($w.front_2_counter*$w.front_scroll_amt));
    new Fx.Style('front_3','top').set(-($w.front_3_counter*$w.front_scroll_amt));
    $w.front_scroll();

    //$w.setInterval($w.front_scroll, 12000);
});