$(document).ready(function() {

//Open links in new window
$("a[rel='external']").click(function(){window.open(this.href); return false;});

$('#carousel').jcarousel();

$('#col-content #about-us, #col-content #our-offer, #col-content #our-contact ').hide();

$("#fst").click(function(){
	$("#faq").hide();
	$("#about-us").fadeIn();
	$("#our-offer").hide();
	$("#our-contact").hide();
});

$("#snd").click(function(){
	$("#faq").hide();
	$("#about-us").hide();
	$("#our-offer").fadeIn();
	$("#our-contact").hide();
});

$("#thrd").click(function(){
	$("#faq").hide();
	$("#about-us").hide();
	$("#our-offer").hide();
	$("#our-contact").fadeIn();
});

 $('.bubbleInfo').each(function () {
        var distance = 50;
        var time = 150;
        var hideDelay = 150;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;
        var trigger = $('.trigger', this);
        var info = $('.popup', this).css('opacity', 1);


        $([trigger.get(0), info.get(0)]).mouseover(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown || shown) {
                // don't trigger the animation again
                return;
            } else {
                // reset position of info box
                beingShown = true;

                info.css({
                    top: 0,
                    right: -235,
                    display: 'block'
                }).animate({
                    top: 0,
                    opacity: 1
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = true;
                });
            }

            return false;
        }).mouseout(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate({
                    top: 0,
                    opacity: 0
                }, time, 'swing', function () {
                    shown = false;
                    info.css('display', 'none');
                });

            }, hideDelay);

            return false;
        });
    });

$("#open").click(function(){
	$("#slidebox").slideDown("slow");
});	
	
$("#close").click(function(){
	$("#slidebox").slideUp("slow");	
});		

$("#toggle a").click(function () {
	$("#toggle a").toggle();
});

if($('.selectbox').length){
    $('.selectbox').sSelect();
}

});//End document ready

// Slideshow
function slideSwitch() {
    var $active = $('#clients img.active');

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


    var $next =  $active.next().length ? $active.next()
        : $('#clients 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() {
    setInterval( "slideSwitch()", 5000 );
});
