$(function() {
    
    $('#npChooser li a').each(function() {
        var veh = $(this).attr("id").replace(/_splash$/,"");

        branch_new.preload.push('/layout/images/new/portal/'+ veh + '_splash.jpg');
        branch_new.preload.push('/layout/images/new/portal/'+ veh + '_price.gif');
    });


    $('#npChooser li a').hover(function(){

        branch_new.vehicle = $(this).attr("id").replace(/_splash$/,"");
        branch_new.flip();

        $('#npBtnLearn').attr("href", $(this).attr("href"));

        $(this).css({ color: '#cccccc' }).animate({ fontSize: '16px' }, 75);

    }, function() {
        $(this).css({ color: '#ffffff' }).animate({ fontSize: '11px' }, 75);
    }); 

    $('#npChooser').animate({
        left: '-150px'
    },300,'swing', function() {

        cht.tooltip({
            id: 'npChooserTT',
            parent: '#newPortal',
            tip: 'Mouseover to pick your vehicle',
            left: '50px',
            top: '100px',
            direction: 'left',
            duration: 8000
        });

    }).hover(function() {
        clearTimeout(branch_new.timeouts.chooserOut);

        $('#npChooserTT').fadeOut(500);

        $(this).animate({
            left: '0px'
        },300,'swing');
    }, function() {
        branch_new.timeouts.chooserOut = setTimeout(function(){
            $('#npChooser').animate({
                left: '-150px'
            },300,'swing');
        }, 1500);
    });

    var randA = function() {
        return (Math.round(Math.random())-0.5); 
    };
   
    $.preload(branch_new.preload);

    branch_new.flip();

});

var branch_new = {
    preload: new Array,


    vehicle: 'camry',
    timeouts: {
        chooserOver: null,
        chooserOut: null
    },

    flip: function() {
        $('#npSplash').css({
            backgroundImage: "url('/layout/images/new/portal/" + branch_new.vehicle + "_splash.jpg')"
        });
        $('#npPrice').css({
            backgroundImage: "url('/layout/images/new/portal/" + branch_new.vehicle + "_price.gif')"
        });

    }
};
