
function slideSwitch(theslideshow) {
    var $active = $('#'+theslideshow+' img.active');

    if ( $active.length == 0 ) $active = $('#'+theslideshow+' img:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#'+theslideshow+' img:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // 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}, 1500, function() {
            $active.removeClass('active last-active');
        });
}

var curmain = '';

$(document).ready(function(){



$(".home").css("top","0px").addClass("activepage");


$("a").click(function(){
$(this).blur();
});


$(".jqan, .logo").click(function(event){
var thehref = $(this).attr("href").substr(1);
curmain = thehref;
$(".activepage").removeClass("activepage").addClass("inactivepage").animate({top:"0px"},1000).animate({top:"-410px"},1);
$("#"+thehref).addClass("activepage").removeClass("inactivepage").animate({top:"0px"},1000);

$("#menu a").removeClass("act");
$("#menu #href_"+thehref).addClass("act");
$(".langchange").each(function(){
$(this).attr("href",'?lang='+$(this).attr('title')+'&autochange='+thehref+'&c='+curmain+'&w=1');
});

event.preventDefault();
});

$(".jqan2").click(function(event){
var thehref = $(this).attr("href").substr(1);

$(".activepage").removeClass("activepage").addClass("inactivepage").animate({top:"0px"},1000).animate({top:"-410px"},1);
$("#"+thehref).addClass("activepage").removeClass("inactivepage").css({top:"0px", left:"1230px"}).animate({left:"0px"},1000);
$(".langchange").each(function(){
$(this).attr("href",'?lang='+$(this).attr('title')+'&autochange='+thehref+'&c='+curmain+'&w=2');
});

event.preventDefault();
});



$(".slideshow").each(function(){
setInterval( "slideSwitch('"+$(this).attr('id')+"')", 5000 );
});



});
