// site.js (c) 2010 Artful Media LLC

// Contact
function contact(qs) {
  url = "/contact.php";
  if (qs) { url = url + "?" + qs; }
  window.location = url;
}

// Center above-the-fold content vertically
function aspCenterContent() {
  y = ($(window).height()-$(".aspAboveFold").height())/2;
  if (y-42 > 18) { $(".aspContent").css({"padding-top":y-42}); }
  if (y > 60) { $(".aspContentCenter").css({"margin-top":y}); }
}

// Splash
function aspSplash() {
  $("#aspSplashBackground").css({"height":$(window).height()});
  var y = ($(window).height()-470)/2;
  if (y > 20) { $("#aspSplashContainer").css({"margin-top":y}); }
  $("#aspSplash img").css({"display":"none"});
  $("#aspSplashBackground").css({"display":"block"});
  setCookie("splashed", "1");
  $("#aspSplash img:first").fadeIn(2000, function() {
    $("#aspSplash").cycle({
      fx: "fade",
      timeoutFn: aspSplashTimeout, 
      speedIn: 2000, 
      speedOut: 50, 
      sync: 0, 
      autostop: 1,
      end: function() { $("#aspSplashBackground").fadeOut(1000); }
    });
  });
}
function aspSplashTimeout(currSlide, nextSlide, options, isForward) {
  var index = options.currSlide;
  if (index == 0) {
    return 2000;
  } else {
    return 4000;
  }
}

// Skip splash
function aspSkipSplash() {
  $('#aspSplash').cycle('stop');
  $('#aspSplashBackground').css({'display':'none'});
}

// Pause splash
function aspPauseSplash() {
  $('#aspSplash').cycle('pause');
  $('#aspSplashPause').replaceWith('<a href="#" onClick="javascript:aspResumeSplash();" id="aspSplashResume">Play</a>');
}

// Resume splash
function aspResumeSplash() {
  $('#aspSplash').cycle('resume');
  $('#aspSplashResume').replaceWith('<a href="#" onClick="javascript:aspPauseSplash();" id="aspSplashPause">Pause</a>');
}

// Mini slide show with pager
function aspMiniShow(showId) {
  $("#"+showId).after('<div id="'+showId+'Pager">');
  $("#"+showId).cycle({
    fx: "fade",
    speedIn: 1000,
    speedOut: 50,
    timeout: 0,
    pager: "#"+showId+"Pager"
  });
}

// Content slides
function aspContentSlide(slideClass, slideId) {
  $('.'+slideClass+':not(#'+slideClass+'-'+slideId+')').css({'display':'none'});
  $('#'+slideClass+'-'+slideId).css({'display':'block'});
}
