var minFlashVersion = "9.0.0";
var movieFile = "http://download.expandrive.com/video/expandrive_screencast.mov";
var iPhoneMovieFile = "http://download.expandrive.com/video/iphone/expandrive_screencast.mov";
var screencastPreview = "/screencast/screencastPreview.jpg";
var playerFile = "/screencast/player.swf";
var skinFile = "/screencast/bekle.swf";

var previewImage = $('<img />').attr('src', screencastPreview).hide();

var flashvars = {
  author: "ExpanDrive Inc",
  description: "Introduction to ExpanDrive",
  duration: "89",
  image: screencastPreview,
  file: movieFile,
  icons: "false",
  screenalpha: "0",
  bufferlength: "12",
  skin: skinFile,
  frontcolor: "444444",
  backcolor: "F7F7F7",
  lightcolor: "F33E1B",
  controlbar: "over",
  stretching: "fill",
  autostart: "true",
  plugins: "googlytics-1"
};
var params = {
  allowfullscreen: "false",
  allowscriptaccess: "always",
  menu: "false",
  play: "true",
  wmode: "transparent"
};
var attributes = {
  id: "myDynamicContent",
  name: "myDynamicContent"
};

$(document).ready(function () {
  $("#screencast").click(function(){
    if (swfobject.hasFlashPlayerVersion(minFlashVersion)) {
      swfobject.embedSWF(playerFile, "screencast", "600", "480",
                         minFlashVersion, null,
                         flashvars, params, attributes);
    }
    else if (navigator.userAgent.toLowerCase().match(/iPhone/i)) {
        $.getScript("http://www.apple.com/library/quicktime/scripts/ac_quicktime.js", function(){
                $.getScript("http://www.apple.com/library/quicktime/scripts/qtp_library.js", function(){
                        QT_WritePoster_XHTML('Click to Play', screencastPreview,
                                             iPhoneMovieFile,
                                             '450', '360', '',
                                             'controller', 'true',
                                             'autoplay', 'true',
                                             'bgcolor', 'black',
                                             'scale', 'aspect');
                    });
            });
    }
    else {
      window.location = movieFile;
    }
  });
});
