function mycarousel_initCallback(carousel)
{

    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 5,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
	jQuery('#mycarousel02').jcarousel({
        auto: 2,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
	
});
function thebackground() {
$('div.background div').css({opacity: 0.0});
$('div.background div:first').css({opacity: 1.0});
setInterval('change()',12000);
}
function txtthebackground() {
$('#slideshow div').css({opacity: 0.0});
$('#slideshow div:first').css({opacity: 1.0});
setInterval('change2()',12000);
}

function change() {
//slideSwitch();
var current = ($('div.background div.show')? $('div.background div.show') : $('div.background div:first'));
if ( current.length == 0 ) current = $('div.background div:first');
var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.background div:first') :current.next()) : $('div.background div:first'));
next.css({opacity: 0.0})
.addClass('show')
.animate({opacity: 1.0}, 12000);
current.animate({opacity: 0.0}, 12000)
.removeClass('show');
};


function change2() {
//slideSwitch();
var current = ($('#slideshow div.show')? $('#slideshow div.show') : $('#slideshow div:first'));
if ( current.length == 0 ) current = $('#slideshow div:first');
var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#slideshow div:first') :current.next()) : $('#slideshow div:first'));
next.css({opacity: 0.0})
.addClass('show')
.animate({opacity: 1.0}, 12000);
current.animate({opacity: 0.0}, 12000)
.removeClass('show');
};



$(document).ready(function() {
thebackground();	
txtthebackground();
$('div.background').fadeIn(12000); // works for all the browsers other than IE
$('div.background div').fadeIn(12000); // IE tweak


$('#slideshow div').fadeIn(12000); // works for all the browsers other than IE
});

function slideSwitch() {
    var $active = $('#slideshow001 DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow001 DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow001 DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

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


function slideSwitch2() {
    var $active = $('#slideshow-client DIV.active');

    if ( $active.length == 0 ) $active = $('#slideshow-client DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow-client DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $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 );
	setInterval( "slideSwitch2()", 5000 );	
});
