﻿var lock_prev = 0;
var lock_next = 0;
var countBanner = 1;
var animNav;

function prev_banner() {
    clearBanner();
    if (countBanner > 1) {
        lock_next = 1;
        var marginLeft = $('slide-content').getStyle('marginLeft').toInt();
        $('slide-content').effect('marginLeft', { duration: 300, transition: Fx.Transitions.linear, onComplete: function() { lock_next = 0 } }).start(marginLeft, marginLeft + 427);
        countBanner--;
    }
    else {
        countBanner = 4;
        $('slide-content').setStyle('marginLeft', '-1281px');
    }

}

function moveNav() {
    clearBanner();
    if (countBanner < 4 && lock_next == 0) {
        lock_next = 1;
        var marginRight = $('slide-content').getStyle('marginLeft').toInt();
        $('slide-content').effect('marginLeft', { duration: 300, transition: Fx.Transitions.linear, onComplete: function() { lock_next = 0 } }).start(marginRight, marginRight - 427);
    }

    countBanner++;
    if (countBanner == 5) {
        countBanner = 1;
        $('slide-content').setStyle('marginLeft', '0');
    }
	
}

function next_banner() {
    clearBanner();
    if (countBanner < 4 && lock_next == 0) {
        lock_next = 1;
        var marginRight = $('slide-content').getStyle('marginLeft').toInt();
        $('slide-content').effect('marginLeft', { duration: 300, transition: Fx.Transitions.linear, onComplete: function() { lock_next = 0 } }).start(marginRight, marginRight - 427);
    }

    countBanner++;
    if (countBanner == 5) {
        countBanner = 1;
        $('slide-content').setStyle('marginLeft', '0');

    }
	
}

function clearBanner() {
    clearTimeout(animNav);
    animNav = setTimeout('moveNav()', 8000);
}
