$(function(){
  $("#toggle_playlist").bind("click", function(){
    if ($("#artist_mp3player").css("height") == "80px"){
      $("#artist_mp3player").css("height", "19px");
    } else {
      $("#artist_mp3player").css("height", "80px");
    }
  });
  
  if ($('#home_gallery').length != 0) {
    $('#home_gallery').crossSlide({
      speed: 25,
      fade: 1
    }, [
      { 
        src: 'img/Photos/1.jpg',
        dir: 'left'
      }, {
        src: 'img/Photos/3.jpg',
        dir: 'right'
      }, {
        src: 'img/Photos/2.jpg',
        dir: 'left'
      }, {
        src: 'img/Photos/4.jpg',
        dir: 'right'
      }
    ]);  
  }
});

$(function() {
  $("#slide_left img").bind("click", function(e) {
    if ($("div#homepageslider ul:animated").length) return;
    if (typeof(e.originalEvent) !== "undefined") clearTimeout(timeout);
    $("div#homepageslider ul li:first").before($("div#homepageslider ul li:last").detach());
    $("div#homepageslider ul").css({"margin-left" : "-1145px" }).animate({ "margin-left" : "-590px" });
  });
  $("#slide_right img").bind("click", function(e) {
    if ($("div#homepageslider ul:animated").length) return;
    if (typeof(e.originalEvent) !== "undefined") clearTimeout(timeout);
    $("div#homepageslider ul").animate({ "margin-left" : "-1145px" }, function() {
      $("div#homepageslider ul li:last").after($("div#homepageslider ul li:first").detach());
      $("div#homepageslider ul").css({"margin-left" : "-590px" });
    })
  });
  var again = function() {
    $("#slide_right img").click();
    timeout = setTimeout(again, 4000);
  };
  var timeout = setTimeout(again, 4000);
});
