/* $Id: index.js,v 1.7 2011/04/08 15:23:22 sap Exp $ */

var portfolio_count = 1;
var b2_count = 1;
var b2_items = 1;
var interval_id = false;

$(document).ready(function () {

    // box 1
    var p_items = $('div.top_col div.p_box ').length;

    $('#portfolio_prev').click(function () {
        var $active = $('div.top_col div.active');
        var $next;

            if (portfolio_count > 1)
            {
            $next = $('div.top_col div.p_box ').eq(portfolio_count - 2);
            portfolio_count--;
            }
            else
            {
            $next = $('div.top_col div.p_box ').eq(p_items - 1);
            portfolio_count = p_items;
            }

        $next.addClass('active');
        $active.removeClass('active');
        return false;
    });

    $('#portfolio_next').click(function () {
        var $active = $('div.top_col div.active');
        var $next;

            if (portfolio_count < p_items)
            {
            $next = $('div.top_col div.p_box ').eq(portfolio_count);
            portfolio_count++;
            }
            else
            {
            $next = $('div.top_col div.p_box ').eq(0);
            portfolio_count = 1;
            }

        $next.addClass('active');
        $active.removeClass('active');
        return false;
    });

    // box 2
    b2_items = $('div#b2_wrapper .b2_item').length;
    
    
    
function next_b2_cycle() {
    $('div#b2_wrapper').cycle({ 
        fx: 'scrollLeft',
        speed: 800,
        timeout: 0,
        next: '#b2_next',
        prev: '#b2_prev'
        //pause: 1
    });
}
    
    /* loop client logos */
    function client_cycle() {
        $('div#clogos_scroll_i').cycle({ 
            fx: 'scrollHorz', // scrollLeft scrollHorz
            timeout: 6000,
            next: '#clogos_next a',
            prev: '#clogos_prev a',
            pause: 1
        });
    }



next_b2_cycle();
client_cycle();





    
});

//jQuery(function( $ ){ 
//});


/* next_b2: loop images */
function next_b2() {
    
    var $active = $('div#b2_wrapper .active');
    var $next;

        if (b2_count < b2_items)
        {
        $next = $('div#b2_wrapper .b2_item').eq(b2_count);
        b2_count++;
        }
        else
        {
        $next = $('div#b2_wrapper .b2_item').eq(0);
        b2_count = 1;
        }

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

/* init loop images */
//$(function(){ interval_id = setInterval( "next_b2()", 3500 ); });




