function slideSwitch() {
      var $lastactive = $('#stdBoxesLeft div.lastactive');
      var $active = $('#stdBoxesLeft div.active');
  
      if ( $active.length == 0 ) $active = $('#stdBoxesLeft div:first');
  
      var $next =  $active.next().length ? $active.next()
          : $('#stdBoxesLeft div:first');
  
      $lastactive.removeClass('lastactive');
      $active.removeClass('active');
      $active.addClass('lastactive');
      $next.addClass('active');
}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
}


  
$(document).ready(function () {

  $.ajaxSetup({ scriptCharset: "utf-8" ,contentType: "application/x-www-form-urlencoded; charset=UTF-8" });
  
  $('#themepic').nivoSlider({
    effect: 'fade',
    animSpeed: 900,
    pauseTime: 3000,
    directionNav: false,
    controlNav: false,
    pauseOnHover: false
  });
  
  // Form placeholder
  function placeholder() {
    $("input[type=text], input[type=password], textarea").each(function () {
      var phvalue = $(this).attr("placeholder");
      $(this).val(phvalue);
    });
  }
  placeholder();
  $("input[type=text], input[type=password], textarea").focusin(function () {
    var phvalue = $(this).attr("placeholder");
    if (phvalue == $(this).val()) {
      $(this).val("");
    }
  });
  $("input[type=text], input[type=password], textarea").focusout(function () {
    var phvalue = $(this).attr("placeholder");
    if ($(this).val() == "") {
      $(this).val(phvalue);
    }
  });

  $('ul#stdNavi').superfish();
  
  $.backstretch(template_url+"/vis/bg/bg.jpg");
  
  jQuery('#carousel').jcarousel({
        auto: 5,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
  
});

