(function(){
  $(function(){
  	/* gallery starter and prettyPhoto starter */
    jGallery('pitch', true, 5000);
    $(document).pngFix();
//    $("a[rel^='prettyPhoto']").prettyPhoto();

//    $("#pikame").PikaChoose();
    $("#screenshots a").fancybox();

    $("#contact_form input, #contact_form textarea").focus(function(){
      var idAttr = $(this).attr("id").replace("contact_", "");
    	$("#l" + idAttr).addClass('lcurrent');
    }).blur(function(){
      var idAttr = $(this).attr("id").replace("contact_", "");
      $("#l" + idAttr).removeClass('lcurrent');
    });

    // flash movies
    var movies = $(".flowmovies");
    if (movies.size()) {
      var url = window.location + "";

      // check anchor
      if (url.indexOf("#") > 0)
      {
        var anchor = url.substring(url.indexOf("#") + 1);
      }
      else
      {
        movies.eq(0).addClass("autobuffering");
      }

      movies.each(function(){
        flowplayer($(this).attr("id"), "/movies/flowplayer-3.1.5.swf", {
          clip: {
            autoPlay: false,
            autoBuffering: $(this).hasClass("autobuffering") || (anchor == $(this).attr("id")),
            onStart: function() {
//              this.getPlugin("play").css({opacity: 1});
//
//              this.getScreen().fadeIn(1000);
            },
            onFinish: function() {
//              this.getScreen().animate({width: 100, height: 80, left: 0});
//              this.getPlugin("play").css({opacity: 0});

//              this.unload();
//              $(this.getParent()).fadeOut(3000, 0.1);
            }
          }
//          play: {
//            opacity: 0
//          }
        });
      });
    }
  });
})();
