var vDMVersion = "0.73";
var vDMUpdated = "Saturday 12th March 2011";
var vDMAuthor = "Peter Mitchell";
var vDMErrorColor = "white";
var vDMErrorBackgroundColor = "teal";
var vDMGlobalStyle = "dm-white-on-black";

var vModernizrVersion = "1.6";
var vJQueryVersion = "1.5";
var vWUnits = "";
var vHUnits = "";
var vCurrentSlideshowID = "";
var vCurrentSlideshowPath = "";
var vCurrentSlideshow = {};
var vCurrentSlideshowNumber = 0;

var $jqdm = jQuery.noConflict();

$jqdm(window).resize(function() {
   var x = parseFloat($jqdm(".dm-player-player").css("width")) - 50;
   $jqdm(".dm-player-scroller").css("width", x);
   var y = parseFloat(parseFloat($jqdm(".dm-wrapper-iframe").css("width")) * .74);
   $jqdm(".dm-wrapper-iframe").css("height", y);
});
$jqdm(document).ready(function() {
   var x = parseFloat($jqdm(".dm-player-player").css("width")) - 50;
   $jqdm(".dm-player-scroller").css("width", x);
   var y = parseFloat(parseFloat($jqdm(".dm-wrapper-iframe").css("width")) * .74);
   $jqdm(".dm-wrapper-iframe").css("height", y);
});

var deliveryman = {
   example: function(h) {
      h = h.replaceAll("<","&lt;");
      h = h.replaceAll(">","&gt;");
      h = h.replaceAll("\n","<br/>");
      return '<div class="code-html">'+h+'</div>';
   },
   unsupported: function(thePlugin, theWidth, theHeight) {
      if(thePlugin=="quartz") {
         return "<div style='width:"+theWidth+";height:"+theHeight+"' class='unsupported'><p>The Quartz browser plugin is not available for this platform.</p><p><img src='sadface.png'/><img src='quartz.png'/></p></div>";
      } else if(thePlugin=="flash") {
         return "<div style='width:"+theWidth+";height:"+theHeight+"' class='unsupported'>The Flash browser plugin is not available for this platform.<p><img src='sadface.png'/><img src='flash.png'/></p></div>";
      } else if(thePlugin=="video") {
         return "<div style='width:"+theWidth+";height:"+theHeight+"' class='unsupported'>The HTML5 video tag is not supported on this platform.<p><img src='sadface.png'/><img src='video.png'/></p></div>";
      } else if(thePlugin=="audio") {
         return "<div style='width:"+theWidth+";height:"+theHeight+"' class='unsupported'>The HTML5 audio tag is not supported on this platform.<p><img src='sadface.png'/><img src='audio.png'/></p></div>";
      } else {
         return "<div style='width:"+theWidth+"';height:'"+theHeight+";' class='unsupported'>Unsupported "+thePlugin+" plugin</div>";
      }
   },
   notinstalled: function(thePlugin, theWidth, theHeight) {
      if(thePlugin=="flash") {
         return "<div style='width:"+theWidth+";height:"+theHeight+"' class='notinstalled'><p>The Flash browser plugin is not installed.</p><p><img src='css/happyface.png'/><img src='css/flash.png'/></p><p>Don't panic...<br/>you can get the Flash plugin from <a href='?here</a>.</p></div>";
      } else if(thePlugin=="director") {
         return "<div style='width:"+theWidth+";height:"+theHeight+"' class='notinstalled'><p>The Flash browser plugin is not installed.</p><p><img src='css/happyface.png'/><img src='css/flash.png'/></p><p>Don't panic...<br/>you can get the Director Shockwave plugin from <a href='?here</a>.</p></div>";
      } else if(thePlugin=="quicktime") {
         return "<div style='width:"+theWidth+";height:"+theHeight+"' class='notinstalled'><p>The QuickTime browser plugin is not installed.</p><p><img src='css/happyface.png'/><img src='css/quicktime.png'/></p><p>Don't panic...<br/>you can get the QuickTime plugin from <a href='?here</a>.</p></div>";
      } else if(thePlugin=="vlc") {
         return "<div style='width:"+theWidth+";height:"+theHeight+"' class='notinstalled'><p>The VLC browser plugin is not installed.</p><p><img src='css/happyface.png'/><img src='css/vlc.png'/></p><p>Don't panic...<br/>you can get the VLC plugin from <a href='?here</a>.</p></div>";
      } else if(thePlugin=="earth") {
         return "<div style='width:"+theWidth+";height:"+theHeight+"' class='notinstalled'><p>The Google Earth browser plugin is not installed.</p><p><img src='css/happyface.png'/><img src='css/googleearth.png'/></p><p>Don't panic...<br/>you can get the Google Earth plugin from <a href='?here</a>.</p></div>";
      } else if(thePlugin=="o3d") {
         return "<div style='width:"+theWidth+";height:"+theHeight+"' class='notinstalled'><p>The Google O3D browser plugin is not installed.</p><p><img src='css/happyface.png'/><img src='css/browserplugin.png'/></p><p>Don't panic...<br/>you can get the Google O3D plugin from <a href='?here</a>.</p></div>";
      }
   },
   version: function() {
      return vDMVersion;
   },
   updated: function() {
      return vDMUpdated;
   },
   title: function() {
      return "DeliveryMan-JS";
   },
   description: function() {
      return "JavaScript library for browser and plugin detection along with media embedding.";
   },
   license: function() {
               return "No license until completed. Still developing the business model.";
   },
   copyright: function() {
      return "&copy; 2008 - 2011 : Peter Mitchell : Big Animated Digital Amsterdam : All Rights Reserved";
   },
   author: function() {
      return vDMAuthor;
   },
   detect: function() {
      return "QuickTime Plugin, Flash Plugin, VLC plugin, Google Earth plugin, Flip4Mac plugin, Quartz Composer Plugin";
   },
   documentation: function(p) {
      var h = '<table class="dm-documentation">';
      if(p=="deliveryman") {
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">DeliveryMan</th></tr>';
         h = h + '<tr><td>deliveryman.title();</td><td>'+deliveryman.title()+'</td></tr>';
         h = h + '<tr><td>deliveryman.version();</td><td>'+deliveryman.version()+'</td></tr>';
         h = h + '<tr><td>deliveryman.updated();</td><td>'+deliveryman.updated()+'</td></tr>';
         h = h + '<tr><td>deliveryman.description();</td><td>'+ deliveryman.description()+'</td></tr>';
         h = h + '<tr><td>deliveryman.copyright();</td><td>'+ deliveryman.copyright()+'</td></tr>';
         h = h + '<tr><td>deliveryman.author();</td><td>'+ deliveryman.author()+'</td></tr>';
         h = h + '<tr><td>deliveryman.license();</td><td>'+ deliveryman.license()+'</td></tr>';
      } else if(p=="environment") {
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">Environment</th></tr>';
         h = h + '<tr><td>environment.browser();</td><td>'+ environment.browser()+'</td></tr>';
         h = h + '<tr><td>environment.version();</td><td>'+ environment.version()+'</td></tr>';
         h = h + '<tr><td>environment.platform();</td><td>'+ environment.platform()+'</td></tr>';
         h = h + '<tr><td>environment.os();</td><td>'+ environment.os()+'</td></tr>';
         h = h + '<tr><td>environment.osVersion();</td><td>'+ environment.osVersion()+'</td></tr>';
         h = h + '<tr><td>environment.string();</td><td>'+ environment.string()+'</td></tr>';
         h = h + '<tr><td>environment.vendor();</td><td>'+ environment.vendor()+'</td></tr>';
         h = h + '<tr><td>environment.ratio();</td><td>'+ environment.ratio()+' // 1 = Normal resolution, 2 = Retina Display</td></tr>';
         h = h + '<tr><td>environment.cookies();</td><td>'+ environment.cookies()+'</td></tr>';
         h = h + '<tr><td>environment.language();</td><td>'+ environment.language()+'</td></tr>';
         h = h + '<tr><td>environment.availableWidth();</td><td>'+ environment.availableWidth()+'</td></tr>';
         h = h + '<tr><td>environment.availableHeight();</td><td>'+ environment.availableHeight()+'</td></tr>';
         h = h + '<tr><td>environment.is("iPod");</td><td>'+ environment.is("iPod")+'</td></tr>';
         h = h + '<tr><td>environment.is("iPad");</td><td>'+ environment.is("iPad")+'</td></tr>';
         h = h + '<tr><td>environment.is("iPhone");</td><td>'+ environment.is("iPhone")+'</td></tr>';
         h = h + '<tr><td>environment.is("Android");</td><td>'+ environment.is("Android")+'</td></tr>';
         h = h + '<tr><td>environment.is("AppleTV");</td><td>'+ environment.is("AppleTV")+'</td></tr>';
         h = h + '<tr><td>environment.is("GoogleTV");</td><td>'+ environment.is("GoogleTV")+'</td></tr>';
         h = h + '<tr><td>environment.canPlay("video/x-m4v");</td><td>'+ environment.canPlay("video/x-m4v")+'</td></tr>';
         h = h + '<tr><td>environment.canPlay("video/quicktime");</td><td>'+ environment.canPlay("video/quicktime")+'</td></tr>';
         h = h + '<tr><td>environment.canPlay("video/mp4");</td><td>'+ environment.canPlay("video/mp4")+'</td></tr>';
         h = h + '<tr><td>environment.plugin("earth");</td><td>'+ environment.plugin("earth")+'</td></tr>';
         h = h + '<tr><td>environment.plugin("flash");</td><td>'+ environment.plugin("flash")+'</td></tr>';
         h = h + '<tr><td>environment.plugin("flip4mac");</td><td>'+ environment.plugin("flip4mac")+'</td></tr>';
         h = h + '<tr><td>environment.plugin("quartz");</td><td>'+ environment.plugin("quartz")+'</td></tr>';
         h = h + '<tr><td>environment.plugin("quicktime");</td><td>'+ environment.plugin("quicktime")+'</td></tr>';
         h = h + '<tr><td>environment.plugin("vlc");</td><td>'+ environment.plugin("vlc")+'</td></tr>';
         h = h + '</table>';
      } else if(p=="player") {
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">Player</th></tr>';
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">Single video mode.</th></tr>';
         h = h + '<tr><td colspan="2">player.video({title:\"The 10 Second Video Test\", poster:\"http://www.deliveryman.nl/content/video/playlisttest/10secondtest/10secondtest.png\", description:\"This is a 10 second video for testing.\", copyright:\"All video copyright 2010 by Peter Mitchell.\", mov:\"http://www.deliveryman.nl/content/video/playlisttest/10secondtest/10secondtest.mov\", ogg:\"http://www.deliveryman.nl/content/video/playlisttest/10secondtest/10secondtest.ogv\", webm:\"http://www.deliveryman.nl/content/video/playlisttest/10secondtest/10secondtest.webm\", style: \"dm-white-on-blue\"})</td></tr></table>';
         h = h + player.video({title:"The 10 Second Video Test", poster:"http://www.deliveryman.nl/content/video/playlisttest/10secondtest/10secondtest.png", description:"This is a 10 second video for testing.", copyright:"All video copyright 2010 by Peter Mitchell.", mov:"http://www.deliveryman.nl/content/video/playlisttest/10secondtest/10secondtest.mov", ogg:"http://www.deliveryman.nl/content/video/playlisttest/10secondtest/10secondtest.ogv", webm:"http://www.deliveryman.nl/content/video/playlisttest/10secondtest/10secondtest.webm", style: "dm-white-on-blue"}) + '';
         h = h + '<table class="dm-documentation">';
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">Playlist mode.</th></tr>';
         h = h + '<tr><td colspan="2">player.video({title:\"The Playlist Video Test\", header:\"http://www.deliveryman.nl/content/video/playlisttest/header.png\", description:\"This is a video collection for testing playlists.\", copyright:\"All video copyright 2010 by Peter Mitchell.\", playlist:\"http://www.deliveryman.nl/content/video/playlisttest/playlist.json\", cover:\"http://www.deliveryman.nl/content/video/playlisttest/cover.png\", style: \"dm-white-on-blue\"})</td></tr></table>';
         h = h + player.video({title:"The Playlist Video Test", header:"http://www.deliveryman.nl/content/video/playlisttest/header.png", description:"This is a video collection for testing playlists.", copyright:"All video copyright 2010 by Peter Mitchell.", playlist:"http://www.deliveryman.nl/content/video/playlisttest/playlist.json", cover:"http://www.deliveryman.nl/content/video/playlisttest/cover.png", style: "dm-white-on-blue"}) + '';
      } else if(p=="flash") {
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">Flash Plugin</th></tr>';
         h = h + '<tr><td colspan="2">flash.embed({});<br/>'+ flash.embed({url:''})+'</td></tr>';
         h = h + '</table>';
      } else if(p=="quicktime") {
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">QuickTime Plugin</th></tr>';
         h = h + '<tr><td colspan="2">quicktime.embed({title:\"This is a QuickTime Movie\", description:\"This is a QuickTime Movie description\", url:\"\", width:\"640\", height:\"480\"});</td></tr></table>';
         h = h + quicktime.embed({title:"This is a QuickTime Movie", url:"", description:"This is a QuickTime Movie description", style: "dm-white-on-blue"}) +'';
      } else if(p=="video") {
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">Video Tag</th></tr>';
         h = h + '<tr><td colspan="2">video.embed({});<br/>'+ video.embed({})+'</td></tr>';
         h = h + '</table>';
      } else if(p=="vlc") {
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">VLC Plugin</th></tr>';
         h = h + '<tr><td colspan="2">vlc.embed({});<br/>'+ vlc.embed({})+'</td></tr>';
         h = h + '</table>';
      } else if(p=="youtube") {
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">YouTube Embed</th></tr>';
         h = h + '<tr><td colspan="2"><p>youtube.embed({id:"W18Z3UnnS_0",title:"Construction with Quadrotor Teams",description:"Teams of quadrotors autonomously build tower-like cubic structures from modular parts.  Work done by Quentin Lindsey, Daniel Mellinger, and Vijay Kumar at the GRASP Lab, University of Pennsylvania.",style:"dm-white-on-blue"});</p>'+ youtube.embed({id:"W18Z3UnnS_0",title:"Construction with Quadrotor Teams",description:"Teams of quadrotors autonomously build tower-like cubic structures from modular parts.  Work done by Quentin Lindsey, Daniel Mellinger, and Vijay Kumar at the GRASP Lab, University of Pennsylvania.",style:"dm-white-on-blue"}) +'</td></tr>';
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">YouTube Playlist</th></tr>';
         h = h + '<tr><td colspan="2"><p>youtube.playlist({id:"BE1A5414724C5627", height:"396",title:"Bluescafe Maloe Melo",description:"If you like the blues or any other type of live music then make sure you visit Bluescafe Maloe Melo when in Amsterdam.", style:"dm-white-on-blue"});</p>'+ youtube.playlist({id:"BE1A5414724C5627", height:"396",title:"Bluescafe Maloe Melo",description:"If you like the blues or any other type of live music then make sure you visit Bluescafe Maloe Melo when in Amsterdam.", style:"dm-white-on-blue"}) +'</td></tr>';
         h = h + '</table>';
      } else if(p=="vemio") {
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">Vemio</th></tr>';
         h = h + '<tr><td colspan="2">vemio.embed({});<br/>'+ vemio.embed({})+'</td></tr>';
         h = h + '</table>';
      } else if(p=="image") {
         h = h + '<tr><th colspan="2" class="dm-documentation-heading">Image Embed</th></tr>';
         h = h + '<tr><td colspan="2"><p>image.embed({id:"W18Z3UnnS_0",title:"Construction with Quadrotor Teams",description:"Teams of quadrotors autonomously build tower-like cubic structures from modular parts.  Work done by Quentin Lindsey, Daniel Mellinger, and Vijay Kumar at the GRASP Lab, University of Pennsylvania.",style:"dm-white-on-blue"});</p>'+ image.embed({id:"W18Z3UnnS_0",title:"Construction with Quadrotor Teams",description:"Teams of quadrotors autonomously build tower-like cubic structures from modular parts.  Work done by Quentin Lindsey, Daniel Mellinger, and Vijay Kumar at the GRASP Lab, University of Pennsylvania.",style:"dm-white-on-blue"}) +'</td></tr>';
         h = h + '</table>';
      } else if(p=="quartz") {
               
      }
      return h;
   }
}
var environment = {
   browser: function() {
      return browserDetect.browser;
   },
   version: function() {
      return browserDetect.version;
   },
   osVersion: function() {
      return browserDetect.OSVersion;
   },
   platform: function() {
      return browserDetect.platform;
   },
   string: function() {
      return navigator.userAgent;
   },
   vendor: function() {
      if(environment.browser()=="Firefox") {
         return "Mozzila Foundation";
      } else if(environment.browser()=="Opera") {
         return "Opera Software ASA";
      } else {
         return navigator.vendor;
      }
   },
   ratio: function() {
   if(window.devicePixelRatio === undefined) return 1; // No pixel ratio available. Assume 1:1.
      return window.devicePixelRatio;
   },
   os: function() {
      return browserDetect.OS;
   },
   is: function(p) {
               var s = environment.string();
               var index = s.indexOf(p);
               if (index == -1) {
                  return false;
               } else {
                  return true;
               }
            },
            canPlay: function(p) {
               return (navigator.mimeTypes[p]!=undefined);
            },
            cookies: function() {
               return navigator.cookieEnabled;
            },
            availableWidth: function() {
               return screen.availWidth;
            },
            availableHeight: function() {
               return screen.availHeight;
            },
            language: function() {
               return navigator.language;
            },
            platform: function() {
               return navigator.platform;
            },
            video: function(p) {
                  return Modernizr.video;
            },
            h264: function() {
               if(environment.browser()=="Safari Mobile") {
                  return true;
               } else if (Modernizr.video.h264=="probably") {
                  return true;
               } else {
                  return false;
               }
            },
            webm: function() {
               if(environment.browser()=="Chrome") {
                  return true;
               } else {
                  return false;
               }
            },
            audio: function(p) {
                  return Modernizr.audio;
            },
            mp3: function() {
                if(environment.browser()=="Safari Mobile") {
                  return true;
               } else if (Modernizr.audio.mp3=="maybe") {
                  return true;
               } else {
                  return false;
               }
            },
            audioogg: function() {
               if (Modernizr.audio.ogg=="probably") {
                  return true;
               } else {
                  return false;
               }
            },
            ogg: function() {
               if (Modernizr.video.ogg=="probably") {
                  return true;
               } else {
                  return false;
               }
            },
            jqueryTarget: function() {
               return vJQueryVersion;
            },
            jquery: function() {
               return $jqdm().jquery;
            },
            modernizr: function() {
               return vModernizrVersion;
            },
            mimeType: function(p) {
               return navigator.mimeTypes[p]
            },
            plugin: function(plug) {
               return this.isPlug(plug);
            },
            isPlug: function(plug) {
               var plugs = navigator.plugins;
               var plugCount = plugs.length-1;
               for (i = 0; i <= plugCount; i++) {
                  if(plugs[i].name.toLowerCase().indexOf(plug)!=-1) {
                     return true;
         }
      }
      return false;
   }
}
<!-- System Check -->
var browserDetect = {
   init: function () {
      this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
      this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "An unknown version";
      this.OSVersion = this.searchOSVersion(navigator.userAgent) || "An unknown OS version";
      this.OS = this.searchString(this.dataOS) || "An unknown OS";
      this.platform = this.searchString(this.dataPlatform) || "An unknown platform";
   },
   searchString: function (data) {
      for (var i=0;i<data.length;i++) {
         var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            this.versionOSSearchString = data[i].versionOSSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function (dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        var x = (dataString.substring(index+this.versionSearchString.length));
        if(browserDetect.browser=="Opera") {
           return x;
        } else if(browserDetect.browser!="Firefox") {
           return x.substring(0,x.indexOf(" "));
        } else {
          return x.substring(0,3);
        }
    },
    searchOSVersion: function (dataString) {
        var index = dataString.indexOf(this.versionOSSearchString);
        if (index == -1) return;
        var x = (dataString.substring(index+this.versionOSSearchString.length));
        var endVersion = x.indexOf(" ");
        x = x.substring(0, endVersion);
//alert(x);
        //var y = x.replaceAll("_",".");
//alert(y);
        //var z = y.replaceAll(";","");
//alert(z);
        return x;
    },
    dataBrowser: [
        {   string: navigator.userAgent,
            subString: "OmniWeb",
            versionSearch: "OmniWeb/",
            identity: "OmniWeb"
        },
        {
            string: navigator.userAgent,
            subString: "Opera",
            versionSearch: "Version/",
            identity: "Opera"
        },
        {
            string: navigator.userAgent,
            subString: "GranParadiso",
            identity: "GranParadiso"
        },
        {
            string: navigator.userAgent,
            subString: "Aspen Simulator",
            versionSearch: "Version/",
            identity: "Aspen Simulator"
        },
        {
            string: navigator.userAgent,
            subString: "Firefox",
            versionSearch: "Firefox/",
            identity: "Firefox"
        },
        {
            string: navigator.userAgent,
            subString: "iPhone",
            versionSearch: "Version/",
            versionOSSearch: "OS ",
            identity: "Safari Mobile"
        },
        {
            string: navigator.userAgent,
            subString: "iPod",
            versionSearch: "Version/",
            versionOSSearch: "OS ",
            identity: "Safari Mobile"
        },
        {
            string: navigator.userAgent,
            subString: "iPad",
            versionSearch: "Version/",
            versionOSSearch: "OS ",
            identity: "Safari Mobile"
        },
        {
            string: navigator.userAgent,
            subString: "Chrome",
            versionSearch: "Chrome/",
            identity: "Chrome"
        },
        {
            string: navigator.userAgent,
            subString: "Safari",
            versionSearch: "Version/",
            versionOSSearch: "OS X ",
            identity: "Safari"
        },
        {
            string: navigator.userAgent,
            subString: "AppleWebKit",
            versionSearch: "AppleWebKit/",
            versionOSSearch: "OS ",
            identity: "AppleWebKit"
        },
        {
            string: navigator.vendor,
            subString: "iCab",
            identity: "iCab"
        },
        {
            string: navigator.vendor,
            subString: "KDE",
            identity: "Konqueror"
        },
        {
            string: navigator.vendor,
            subString: "Camino",
            identity: "Camino"
        },
        {       // for newer Netscapes (6+)
            string: navigator.userAgent,
            subString: "Netscape",
            identity: "Netscape"
        },
        {
            string: navigator.userAgent,
            subString: "MSIE",
            identity: "Explorer 9",
            versionSearch: "MSIE 9"
        },
        {
            string: navigator.userAgent,
            subString: "MSIE",
            identity: "Explorer 8",
            versionSearch: "MSIE 8"
        },
        {
            string: navigator.userAgent,
            subString: "MSIE",
            identity: "Explorer 7",
            versionSearch: "MSIE 7"
        },
        {
            string: navigator.userAgent,
            subString: "MSIE",
            identity: "Explorer 6",
            versionSearch: "MSIE 6"
        },
        {
            string: navigator.userAgent,
            subString: "Gecko",
            identity: "Mozilla",
            versionSearch: "rv"
        },
        {       // for older Netscapes (4-)
            string: navigator.userAgent,
            subString: "Mozilla",
            identity: "Netscape",
            versionSearch: "Mozilla"
        }
    ],
    dataOS : [
        {
            string: navigator.platform,
            subString: "Windows NT 6.0",
            identity: "Windows Vista"
        },
        {
            string: navigator.platform,
            subString: "Windows NT 5.1",
            identity: "Windows XP"
        },
        {
            string: navigator.platform,
            subString: "Win",
            identity: "Windows"
        },
        {
            string: navigator.platform,
            subString: "iPhone Simulator",
            identity: "iPhone Simulator"
        },
        {
            string: navigator.platform,
            subString: "iPhone",
            identity: "iOS"
        },
        {
            string: navigator.platform,
            subString: "iPod",
            identity: "iOS"
        },
        {
            string: navigator.platform,
            subString: "iPad",
            identity: "iOS"
        },
        {
            string: navigator.platform,
            subString: "AppleTV",
            identity: "iOS"
        },
        {
            string: navigator.platform,
            subString: "MacPPC",
            identity: "MacPPC"
        },
        {
            string: navigator.platform,
            subString: "MacIntel",
            identity: "MacIntel"
        },
        {
            string: navigator.platform,
            subString: "Linux",
            identity: "Linux"
        },
        {
            string: navigator.platform,
            subString: "Opera",
            identity: "Opera"
        }
    ],
    dataPlatform : [
        {
            string: navigator.platform,
            subString: "Windows NT 6.0",
            identity: "Windows Desktop"
        },
        {
            string: navigator.platform,
            subString: "Windows NT 5.1",
            identity: "Windows Desktop"
        },
        {
            string: navigator.platform,
            subString: "Win",
            identity: "Windows Desktop"
        },
        {
            string: navigator.platform,
            subString: "iPhone Simulator",
            identity: "iPhone Simulator"
        },
        {
            string: navigator.platform,
            subString: "iPhone",
            identity: "iPhone"
        },
        {
            string: navigator.platform,
            subString: "iPod",
            identity: "iPod"
        },
        {
            string: navigator.platform,
            subString: "iPad",
            identity: "iPad"
        },
        {
            string: navigator.platform,
            subString: "AppleTV",
            identity: "AppleTV"
        },
        {
            string: navigator.platform,
            subString: "MacPPC",
            identity: "Apple Desktop"
        },
        {
            string: navigator.platform,
            subString: "Intel Mac",
            identity: "Apple Desktop"
        },
        {
            string: navigator.platform,
            subString: "Linux",
            identity: "Linux Desktop"
        }
    ]

}
browserDetect.init();

var widget = {
   media: function(p) {
      h = '<div class="widget">';
      h = h + '   <div class="widget-title">';
      if(p.title==undefined) {
         p.title = "Media Playback";
      };
      h = h + p.title;
      h = h + '   </div>';
      h = h + '   <div class="widget-body">';
      if(p.video!=undefined) {
         h = h + '<div><img class="dm-tiny-icon-left" src="http://www.deliveryman.nl/content/icontiny/video.png"/>';
         if(environment.video()==true) {
            h = h + 'HTML5 Video';
            h = h + '<img class="dm-tiny-icon-right" src="http://www.deliveryman.nl/content/icontiny/yes.png"/></div>';
         } else {
            h = h + 'HTML5 Video';
            h = h + ' <img class="dm-tiny-icon-right" src="http://www.deliveryman.nl/content/icontiny/no.png"/></div>';
         }
      };
      if(p.quicktime!=undefined) {
         h = h + '<div><img class="dm-tiny-icon-left" src="http://www.deliveryman.nl/content/icontiny/quicktime.png"/>';
         if(quicktime.version({major:7,minor:6,revision:6})==true) {
            h = h + 'QuickTime';
            h = h + '<img class="dm-tiny-icon-right" src="http://www.deliveryman.nl/content/icontiny/yes.png"/></div>';
         } else {
            h = h + '<a href="http://www.apple.com/quicktime/" target="_blank">Get QuickTime</a>';
            h = h + ' <img class="dm-tiny-icon-right" src="http://www.deliveryman.nl/content/icontiny/no.png"/></div>';
         }
      };
      if(p.flash!=undefined) {
         h = h + '<div><img class="dm-tiny-icon-left" src="http://www.deliveryman.nl/content/icontiny/flash.png"/>';
         if(flash.version({major:10,minor:6})==true) {
            h = h + 'Flash';
            h = h + '<img class="dm-tiny-icon-right" src="http://www.deliveryman.nl/content/icontiny/yes.png"/></div>';
         } else {
            h = h + '<a href="http://www.adobe.com/go/getflashplayer" target="_blank">Get Flash</a>';
            h = h + ' <img class="dm-tiny-icon-right" src="http://www.deliveryman.nl/content/icontiny/no.png"/></div>';
         }
      };
      h = h + '   </div>';
      h = h + '</div>';
      return h;
   }
}
var video = {
   embed: function(p) {
      var s = '';
      var h = '';
      if(p.title!=undefined) {
           h = h + '   <div id="' + p.id + '-title" class="dm-title ' + p.style + '">';
           h = h + '' + p.title;
           h = h + '      </div>\r';
      }
      s = s + '<video ';
      if (p.style != undefined) {
         s = s + ' class="'+p.style+'"';
      }
      if (p.width != undefined) {
         s = s + ' width="'+p.width+'"';
      }
      if (p.width == undefined) {
         p.width = "100%";
      } else if (p.width == "") {
         p.width = "640px";
      }
      if (p.height != undefined) {
         s = s + ' height="'+p.height+'"';
      }
      if (p.id != undefined) {
         s = s + ' id="'+p.id+'"';
      }
      if (p.id != undefined) {
         s = s + ' name="'+p.id+'"';
      }
      if (p.url != undefined) {
         s = s + ' src="'+p.url+'"';
      }
      if (p.airplay != undefined) {
         s = s + ' x-webkit-airplay="allow"';
      }
      if (p.controls != undefined && p.controls != "false") {
         s = s + ' controls';
      }
      if (p.loopstart != undefined) {
         s = s + ' loopstart="'+p.loopstart+'"';
      }
      if (p.loopend != undefined) {
         s = s + ' loopend="'+p.loopend+'"';
      }
      if (p.loop != undefined && p.loop != "false") {
         s = s + ' loop';
      }
      if (p.poster != undefined) {
         s = s + ' poster="'+p.poster+'"';
      }
      if (p.playcount != undefined) {
         s = s + ' playcount="'+p.playcount+'"';
      }
      if (p.start != undefined) {
         s = s + ' start="'+p.start+'"';
      }
      if (p.autoplay != undefined && p.autoplay != "false") {
         s = s + ' autoplay';
      }
      if (p.autobuffer != undefined && p.autobuffer != "false") {
         s = s + ' autobuffer';
      }
      s = s + '>\r';
      if (p.mp4 != undefined) {
         s = s + '  <source src="'+p.mp4+'" type="video/mp4"/>\r';
      }
      if (p.m4v != undefined) {
         s = s + '   <source src="'+p.m4v+'" type="video/x-m4v"/>\r';
      }
      if (p.mov != undefined) {
         s = s + '   <source src="'+p.mov+'" type="video/quicktime"/>\r';
      }
      if (p.ogg != undefined) {
         s = s + '   <source src="'+p.ogg+'" type="video/ogg; codecs=theora,vorbis"/>\r';
      }
      if (p.webm != undefined) {
         s = s + '   <source src="'+ p.webm +'" type="video/webm"/>\r';
      }
      s = s + '</video>\r'
      if (environment.browser() == 'Firefox' && environment.plugin('quicktime')==true && p.mov != undefined && p.ogg == undefined) {
         s = quicktime.embed({url:p.mov,poster:p.poster,scale:"Aspect",noWrap:"true"}) + '\r';
      } else if (environment.browser() == 'Firefox' && environment.plugin('quicktime')==true && p.m4v != undefined && p.ogg == undefined) {
         s = quicktime.embed({url:p.m4v,poster:p.poster,scale:"Aspect",noWrap:"true"}) + '\r';
      }
      h = h + s;
      if(p.description!=undefined) {
           h = h + '   <div id="' + p.id + '-title" class="dm-description ' + p.style + '">';
           h = h + '' + p.description;
           h = h + '      </div>\r';
      }
      //h = h + '      </div>';
      return h;
   },
   reset: function() {
      
   }
};
var cover = {
   embed: function(p) {
      var h = '<img';
      if(p.url!=undefined) {
        h = h + ' src="'+p.url+'"';
      }
     if (p.style != undefined) {
            h = h + ' class="'+p.style+'"';
        }
         if (p.height != undefined) {
            h = h + ' height="'+p.height+'"';
        }
         if (p.width != undefined) {
            h = h + ' width="'+p.width+'"';
        }
         if (p.id != undefined) {
            h = h + ' id="'+p.id+'"';
        }
         if (p.click != undefined) {
            h = h + ' onclick="'+p.click+'"';
        }
    var h = h + '/>';
    return h;
    }
};
var snippit = {
   embed: function(p) {
      var h = '';
      h = h + '<div id="'+p.id+'">' + interface.spinner() + '</div>';
      h = h + '<script type="text/javascript">$jqdm(document).ready(function(){$jqdm("#' + p.id + '").load("' + p.url + '");});</script>';
      return h;
   }
};
var venue = {
   embed: function(p) {
      var h = '';
      h = h + '';
      return h;
   },
   add: function(p) {
      var h = '';
      h = h + '';
      return h;
   },
   edit: function(p) {
      var h = '';
      h = h + '';
      return h;
   }
};
var event = {
   embed: function(p) {
      
   },
   add: function(p) {
      var h = '';
      h = h + '';
   },
   edit: function(p) {
      
   },
   list: function(p) {
      
   }
};
var albumcover = {
   embed: function(p) {
      var h = '<img';
      if(p.url!=undefined) {
        h = h + ' src="'+p.url+'"';
      }
     if (p.style != undefined) {
            h = h + ' class="'+p.style+'"';
        }
         if (p.height != undefined) {
            h = h + ' height="'+p.height+'"';
        }
         if (p.width != undefined) {
            h = h + ' width="'+p.width+'"';
        }
         if (p.id != undefined) {
            h = h + ' id="'+p.id+'"';
        }
         if (p.click != undefined) {
            h = h + ' onclick="'+p.click+'"';
        }
    var h = h + '/>';
    return h;
    }
};
var quicktime = {
   embed: function(p) {
      if(p.noWrap==undefined) {
         var h = '<div class="dm-wrapper-hd">';
      } else {
         var h = '';
      }
      if(p.title!=undefined) {
         h = h + '<div class="dm-title">' + p.title + '</div>';
      }
      h = h + '<object'; // + commonParams(p);
      h = h + ' classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
      h = h + ' codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=7,3,0,0"';
      if (p.style != undefined) {
         h = h + ' class="'+p.style+'"';
      }
      if (p.width != undefined) {
         if (p.width.indexOf("px")!=-1) {
            vWUnits = "px";
          }
         if (p.width.indexOf("em")!=-1) {
            vWUnits = "em";
          }
         if (p.width.indexOf("%")!=-1) {
            vWUnits = "%";
          }
          if(vWUnits==""){
             vWUnits = "px";
          }
         h = h + ' width="'+parseFloat(p.width)+vWUnits+'"';
      }
      if (p.height != undefined) {
         if (p.height.indexOf("px")!=-1) {
            vHUnits = "px";
         }
         if (p.height.indexOf("em")!=-1) {
            vHUnits = "em";
         }
         if (p.height.indexOf("%")!=-1) {
            vHUnits = "%";
         }
         if(vHUnits==""){
            vHUnits = "px";
         }
         if (p.controller != undefined) {
            if (p.controller == "true") {
               h = h + ' height="'+(parseFloat(p.height)+16)+vHUnits+'"';
            } else {
               h = h + ' height="'+(parseFloat(p.height))+vHUnits+'"';
            }
         } else {
            h = h + ' height="'+(parseFloat(p.height))+vHUnits+'"';
         }
       }
       h = h + '>\r';
       h = h + '<param name="type" value="video/quicktime"/>\r';
       h = h + '<param name="src" value="' + p.url + '"/>\r';
       if (p.controller != undefined) {
         h = h + '<param name="controller" value="'+p.controller+'"/>\r';
       }
       if (p.autoplay != undefined) {
         h = h + '<param name="autoplay" value="'+p.autoplay+'"/>\r';
       }
       if (p.scale != undefined) {
         h = h + '<param name="scale" value="'+p.scale+'"/>\r';
       } else {
         h = h + '<param name="scale" value="Aspect"/>\r';
       }
       if (p.bgcolor != undefined) {
          h = h + '<param name="bgcolor" value="' + p.bgcolor + '"/>\r';
       }
       if (p.loop != undefined) {
          h = h + '<param name="loop" value="' + p.loop + '"/>\r';
       }
       if (p.showlogo != undefined) {
          h = h + '<param name="showlogo" value="' + p.showlogo + '"/>\r';
       }
       if (p.dontflattenwhensaving != undefined) {
          h = h + '<param name="dontflattenwhensaving" value="' + p.dontflattenwhensaving + '"/>\r';
       }
       if (p.kioskmode != undefined) {
          h = h + '<param name="kioskmode" value="' + p.kioskmode + '"/>\r';
       }
       if (p.enablehref != undefined) {
          h = h + '<param name="enablehref" value="' + p.enablehref + '"/>\r';
       }
       if (p.volume != undefined) {
          h = h + '<param name="volume" value="' + p.volume + '"/>\r';
       }
       h = h + '<embed'; // + commonParams(p);
       if (p.height != undefined) {
         if (p.controller != undefined) {
            if (p.controller == "true") {
               h = h + ' height="'+(parseFloat(p.height)+16)+vHUnits+'"';
               h = h + ' controller="'+p.controller+'"';
            } else {
               h = h + ' height="'+(parseFloat(p.height))+vHUnits+'"';
               h = h + ' controller="'+p.controller+'"';
            }
         } else {
            h = h + ' height="'+(parseFloat(p.height))+vHUnits+'"';
         }
         if (p.width != undefined) {
            if (p.width.indexOf("px")!=-1) {
               vWUnits = "px";
            }
            if (p.width.indexOf("em")!=-1) {
               vWUnits = "em";
            }
            if (p.width.indexOf("%")!=-1) {
               vWUnits = "%";
            }
            if(vWUnits==""){
               vWUnits = "px";
            }
            h = h + ' width="'+parseFloat(p.width)+vWUnits+'"';
         }
      }
      h = h + ' type="video/quicktime"';
      if (p.id != undefined) {
         h = h + ' name="'+p.id+'"';
      }
      if (p.style != undefined) {
         h = h + ' class="'+p.style+'"';
      }
      if (p.autoplay != undefined) {
         h = h + ' autoplay="'+p.autoplay+'"';
      }
      if (p.showlogo != undefined) {
         h = h + ' showlogo="'+p.showlogo+'"';
      }
      if (p.volume != undefined) {
         h = h + ' volume="'+p.volume+'"';
      }
      if (p.enablehref != undefined) {
         h = h + ' enablehref="'+p.enablehref+'"';
      }
      if (p.dontflattenwhensaving != undefined) {
         h = h + ' dontflattenwhensaving="'+p.dontflattenwhensaving+'"';
      }
      if (p.scale != undefined) {
         h = h + ' scale="'+p.scale+'"';
      } else {
         h = h + ' scale="Aspect"';
      }
      if (p.enablejavascript != undefined) {
         h = h + ' enablejavascript="'+p.enablejavascript+'"';
      }
      if (p.url != undefined) {
         h = h + ' src="'+p.url+'"';
      }
      if (p.airplay != undefined) {
         h = h + ' airplay="Allow"';
      }
      if (p.bgcolor != undefined) {
         h = h + ' bgcolor="'+p.bgcolor+'"';
      }
      if (p.loop != undefined) {
         h = h + ' loop="'+p.loop+'"';
      }
      if (p.maxfps != undefined) {
         h = h + ' maxfps="'+p.maxfps+'"';
      }
      if (p.kioskmode != undefined) {
         h = h + ' kioskmode="'+p.kioskmode+'"';
      }
      h = h + '/>\r';
      h = h + '</object>\r';
      if(p.description!=undefined) {
         h = h + '<div class="dm-description">' + p.description + '</div>';
      }
      if(p.copyright!=undefined) {
         h = h + '<div class="dm-copyright">' + p.copyright + '</div>';
      }
      if(p.noWrap==undefined) {
         h = h + '</div>\r';
      } else {
         h = h + '\r';
      }
      //alert(h);
      return h;
   },
   example: function(l){
      var h = this.embed(l)
      return deliveryman.example(h);
   },
   string: function() {
      var plugs = navigator.plugins;
      var plugCount = plugs.length;
      for (i = 0; i <= plugCount; i++) {
         if(plugs[i].name.toLowerCase().indexOf("quicktime")!=-1) {
            return plugs[i].name;
         }
       }
       return false;
   },
   description: function() {
      var plugs = navigator.plugins;
      var plugCount = plugs.length;
      for (i = 0; i <= plugCount; i++) {
         if(plugs[i].name.toLowerCase().indexOf("quicktime")!=-1) {
            return deliveryman.example(plugs[i].description);
         }
       }
       return false;
   },
   version: function(v) {
       if(environment.browser()=="Safari Mobile") {
          return false;
       }
       var plugs = navigator.plugins;
       var plugCount = plugs.length;
       if (v.major==undefined) {
          for (i = 0; i <= plugCount; i++) {
             if(plugs[i].name.toLowerCase().indexOf("quicktime")!=-1) {
                return plugs[i].name.substring(18,plugs[i].name.length);
            }
         }
          return false;
       } else {
          for (i = 0; i <= plugCount; i++) {
             if(plugs[i].name.toLowerCase().indexOf("quicktime")!=-1) {
                if (v.minor==undefined) {
                   v.minor = 0;
                }
                if (v.revision==undefined) {
                   v.revision = 0;
                }
                var full = plugs[i].name.substring(18,plugs[i].name.length);
                var major = full.substring(0,full.indexOf("."));
                var minor = full.substring(full.indexOf(".")+1,full.lastIndexOf("r"));
                var revision = full.substring(full.lastIndexOf(".")+1,full.length);
                if (v.major<=major && v.minor<=minor && v.revision<=revision) {
                   return true;
               } else {
                  return false;
               }
            }
         }
          return false;
       }
   },
   canPlay: function(p) {
      return (navigator.mimeTypes[p]!=undefined);
   },
   play: function(i) {
      return commonPlay(i);
   },
   pause: function(i) {
      return commonStop(i);
   },
   stop: function(i) {
      return commonStop(i);
   },
   rewind: function(i) {
      var mediaObject = document.getElementByID(i);
      mediaObject.rewind();
      return  "";
   },
   step: function(i,numberOfFrames) {
      var mediaObject = document.getElementByID(i);
      mediaObject.step(numberOfFrames);
      return  "";
   },
   movieVersion: function(i) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.GetQuickTimeVersion();
   },
   movieLanguage: function(i) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.GetQuickTimeLanguage();
   },
   connectionSpeed: function(i) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.GetQuickTimeConnectionSpeed();
   },
   registered: function(i) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.GetIsQuickTimeRegistered();
   },
   resetProperties: function(i) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.GetResetPropertiesOnReload(theState);
   },
   setResetProperties: function(i,theState) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.SetResetPropertiesOnReload(theState);
   },
   reset: function() {
      
   }
}
         
         var vlc = {
            embed: function(p) {
               var h = '';
               if (p.align == "center") {
                  h = h + '<center>';
               }
               h = h + '<object' + commonParams(p);
               h = h + ' classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"';
               if (p.version == undefined) {
                  p.version = "0.8.6";
               }
               h = h + ' codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/"';
               if (p.height == undefined) {
                  p.height = 240;
               }
               h = h + ' height="'+(parseFloat(p.height))+'"';
               h = h + ' MRL="'+(p.url)+'"';
               h = h + ' events="True"';
                h = h + '>\r';
                h = h + '<param name="type" value="application/x-vlc-plugin"/>\r';
                if (p.scale != undefined) {
                     h = h + '<param name="zoom" value="'+p.scale+'"/>\r';
                } else {
                     h = h + '<param name="zoom" value="1"/>\r';
                }

                if (p.bgcolor != undefined) {
                   h = h + '<param name="bgcolor" value="' + p.bgcolor + '"/>\r';
                }
                if (p.autoplay != undefined) {
                   h = h + '<param name="autoPlay" value="' + p.autoplay + '"/>\r';
                }
                if (p.loop != undefined) {
                   h = h + '<param name="autoloop" value="' + p.loop + '"/>\r';
                }
                h = h + '<param name="movie" value="' + p.url + '"/>\r';
                h = h + '<embed' + commonParams(p);
                h = h + ' type="application/x-vlc-plugin"';
                h = h + ' progid="VideoLAN.VLCPlugin.2"';
                h = h + ' pluginspage="http://www.videolan.org/vlc/"';
               h = h + ' src="'+p.url+'"';
              
               h = h + ' height="'+(parseFloat(p.height))+'"';
               if (p.id != undefined) {
                  h = h + ' name="'+p.id+'"';
               }
               if (p.quality != undefined) {
                  h = h + ' quality="'+p.quality+'"';
               }
               if (p.scale != undefined) {
                  h = h + ' zoom="'+p.scale+'"';
               } else {
                  h = h + ' zoom="1"';
               }
               if (p.loop != undefined) {
                  h = h + ' autoLoop="'+p.loop+'"';
               }
               if (p.autoplay != undefined) {
                  h = h + ' autoPlay="'+p.autoplay+'"';
               }
               if (p.bgcolor != undefined) {
                  h = h + ' bgcolor="'+p.bgcolor+'"';
               }
               //h = h + ' AspectRatio="4:3"';
               h = h + '>\r';
               h = h + '</embed>\r</object>\r';
               if (p.align == "center") {
                  h = h + '</center>';
               }
               return h;
            },
            example: function(l){
               var h = this.embed(l)
               return deliveryman.example(h);
            },
            string: function() {
               var plugs = navigator.plugins;
               var plugCount = plugs.length;
               for (i = 0; i <= plugCount; i++) {
                  if(plugs[i].name.toLowerCase().indexOf("vlc")!=-1) {
                     return plugs[i].name;
                  }
                }
                return false;
            },
            description: function() {
               var plugs = navigator.plugins;
               var plugCount = plugs.length;
               for (i = 0; i <= plugCount; i++) {
                  if(plugs[i].name.toLowerCase().indexOf("vlc")!=-1) {
                     return deliveryman.example(plugs[i].description);
                  }
                }
                return false;
            },
            version: function(v) {
                var plugs = navigator.plugins;
                var plugCount = plugs.length;
                if (v.major==undefined) {
                   for (i = 0; i <= plugCount; i++) {
                      if(plugs[i].name.toLowerCase().indexOf("vlc")!=-1) {
                         var x = plugs[i].description.substring(8,plugs[i].description.length);
                         x = x.substring(0,x.toLowerCase().indexOf(","));
                         return x;
                     }
                  }
                   return false;
                } else {
                   for (i = 0; i <= plugCount; i++) {
                      if(plugs[i].name.toLowerCase().indexOf("vlc")!=-1) {
                         if (v.minor==undefined) {
                            v.minor = 0;
                         }
                         if (v.revision==undefined) {
                            v.revision = 0;
                         }
                         var full = plugs[i].description.substring((plugs[i].description.indexOf("Version")+8),plugs[i].description.length);
                         full = full.substring(0,x.toLowerCase().indexOf(" "));
                         var major = full.substring(0,full.indexOf("."));
                         var minor = full.substring(full.indexOf(".")+1,full.lastIndexOf("."));
                         var revision = full.substring(full.lastIndexOf(".")+1,full.length);
                         if (v.major<=major && v.minor<=minor && v.revision<=revision) {
                            return true;
                        } else {
                           return false;
                        }
                     }
                  }
                   return false;
                }
            },
        };
var image = {
   embed: function(p) {
      if (p.style == undefined) {
         p.style = vDMGlobalStyle;
      }
      if (p.format == undefined) {
         p.format = "landscape";
      }
      var h = '<div class="dm-image">';
      if(p.title!=undefined) {
         h = h + '<div class="dm-title ' + p.style + '">' + p.title + '</div>';
      }
      h = h + '<div class="dm-wrapper-' + p.format + '"><img class="dm-player-display ' + p.style + '"';
      if(p.url!=undefined) {
        h = h + ' src="'+p.url+'"';
      }
      if (p.height != undefined) {
         h = h + ' height="'+p.height+'"';
      }
      if (p.width != undefined) {
         h = h + ' width="'+p.width+'"';
      }
      if (p.id != undefined) {
         h = h + ' id="'+p.id+'"';
      }
      if (p.click != undefined) {
         h = h + ' onclick="'+p.click+'"';
      }
      h = h + '/></div>';
      if(p.description!=undefined) {
         h = h + '<div class="dm-description ' + p.style + '">' + p.description + '</div>';
      }
      h = h + '</div>';
      return h;
    },
    slideshow: function(p) {
      if (p.style == undefined) {
         p.style = vDMGlobalStyle;
      }
      if (p.format == undefined) {
         p.format = "landscape";
      }
      if (p.path == undefined) {
         p.path = "";
      }
      var h = '<div class="dm-slideshow">';
      if(p.title!=undefined) {
         h = h + '<div class="dm-title ' + p.style + '">' + p.title + '</div>';
      }
      h = h + '<div id="'+p.id+'" class="dm-wrapper-' + p.format + '" onclick="image.loadSlideshow(this)" data-path="' + p.path + '" data-playlist="' + p.playlist + '">'
      if(p.playlist!=undefined) {
         p.playlist = p.playlist.split(",");
      }
      h = h + '<img class="' + p.style + '"';
      if(p.path!=undefined) {
        h = h + ' src="' + p.path + p.playlist[0]+'"';
      }
      if (p.height != undefined) {
         h = h + ' height="'+p.height+'"';
      }
      if (p.width != undefined) {
         h = h + ' width="'+p.width+'"';
      }
      h = h + '/></div>';
      h = h + '<div id="'+p.id+'-indicator" class="dm-slideshow-indicator ' + p.style + '">';
      for (i = 1; i <= p.playlist.length; i++) {
         h = h + '<span>•&nbsp</span>';
      }
      h = h + '</div>';
      if(p.description!=undefined) {
         h = h + '<div class="dm-description ' + p.style + '">' + p.description + '</div>';
      }
      h = h + '</div>';

      return h;
    },
    loadSlideshow: function(p) {
       vCurrentSlideshowID = $jqdm(p).attr("id");
       vCurrentSlideshow = $jqdm(p).attr("data-playlist");
       vCurrentSlideshowPath = $jqdm(p).attr("data-path");
       vCurrentSlideshow = vCurrentSlideshow.split(",");
       vCurrentSlideshowNumber = 1;
       vCurrentSlideshowLength = vCurrentSlideshow.length;
       time.setTimeout({variable:"vDMSlideshow", task:"image.slideshowAdvance()", msecs:20});
    },
    slideshowAdvance: function() {
      if(vCurrentSlideshowNumber==vCurrentSlideshowLength) {
         vCurrentSlideshowNumber = 1;
      } else {
        vCurrentSlideshowNumber = vCurrentSlideshowNumber + 1
      }
      $jqdm(("#" + vCurrentSlideshowID + " img")).attr("src",(vCurrentSlideshowPath + vCurrentSlideshow[vCurrentSlideshowNumber-1]));
      $jqdm(("#" + vCurrentSlideshowID + "-indicator")).children().removeClass("dm-current-slide");
      $jqdm(("#" + vCurrentSlideshowID + "-indicator span:nth-child(" + vCurrentSlideshowNumber + ")")).addClass("dm-current-slide");
      
      
       time.setTimeout({variable:"vDMSlideshow", task:"image.slideshowAdvance()", msecs:5000});
    },
    slideshowsStop: function() {
    
    }
};
var flash = {
   embed: function(p) {
      if (p.bgcolor == undefined) {
         p.bgcolor = "white";
      }
      var h = '';
      if (p.align == "center") {
         h = h + '<center>\r';
      }
      h = h + '<object' + commonParams(p);
      h = h + ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
      h = h + ' codebase="?"';
      if (p.height == undefined) {
         p.height = "240";
      }
      if (p.width == undefined) {
         p.width = "320";
      }
      if (p.style != undefined) {
         h = h + ' class="'+(p.style)+'"';
      }
      h = h + ' height="'+(p.height)+'"';
       h = h + '>\r';
       h = h + '<param name="type" value="application/x-shockwave-flash"/>\r';
       if (p.flashvars != undefined) {
            h = h + '<param name="flashvars" value="'+p.flashvars+'"/>\r';
       }
       if (p.scale != undefined) {
            h = h + '<param name="scale" value="'+p.scale+'"/>\r';
       } else {
            h = h + '<param name="scale" value="showall"/>\r';
       }

       if (p.bgcolor != undefined) {
          h = h + '<param name="bgcolor" value="' + p.bgcolor + '"/>\r';
       }

       if (p.allowscriptaccess != undefined) {
          h = h + '<param name="allowscriptaccess" value="' + p.allowscriptaccess + '"/>\r';
       }

       if (p.allowfullscreen != undefined) {
          h = h + '<param name="allowfullscreen" value="' + p.allowfullscreen + '"/>\r';
       }
       
       h = h + '<param name="movie" value="' + p.url + '"/>\r';
       h = h + '<embed' + commonParams(p);
       h = h + ' type="application/x-shockwave-flash"';
       h = h + ' pluginspage="?"';
      h = h + ' src="'+p.url+'"';
     
      h = h + ' height="'+(p.height)+'"';
      if (p.id != undefined) {
         h = h + ' name="'+p.id+'"';
      }
      if (p.id != undefined) {
         h = h + ' id="'+p.id+'"';
      }
      if (p.url != undefined) {
         h = h + ' href="'+p.url+'"';
      }
      if (p.quality != undefined) {
         h = h + ' quality="'+p.quality+'"';
      }
      if (p.scale != undefined) {
         h = h + ' scale="'+p.scale+'"';
      } else {
         h = h + ' scale="showall"';
      }
      if (p.flashvars != undefined) {
         h = h + ' flashvars="'+p.flashvars +'"';
      }
      if (p.allowfullscreen != undefined) {
         h = h + ' allowfullscreen="'+p.allowfullscreen +'"';
      }
      if (p.allowscriptaccess != undefined) {
         h = h + ' allowscriptaccess="'+p.allowscriptaccess +'"';
      }
      if (p.loop != undefined) {
         h = h + ' loop="'+p.loop+'"';
      }
      if (p.style != undefined) {
         h = h + ' class="'+p.style+'"';
      }
      if (p.bgcolor != undefined) {
         h = h + ' bgcolor="'+p.bgcolor+'"';
      }
      h = h + '/>\r';
      h = h + '</object>\r';
      if (p.align == "center") {
         h = h + '</center>\r';
      }
      return h;
   },
   example: function(l){
      var h = this.embed(l)
      return deliveryman.example(h);
   },
   string: function() {
      var plugs = navigator.plugins;
      var plugCount = plugs.length;
      for (i = 0; i <= plugCount; i++) {
         if(plugs[i].name.toLowerCase().indexOf("flash")!=-1) {
            return plugs[i].name;
         }
       }
       return false;
   },
   description: function() {
      var plugs = navigator.plugins;
      var plugCount = plugs.length;
      for (i = 0; i <= plugCount; i++) {
         if(plugs[i].name.toLowerCase().indexOf("flash")!=-1) {
            return deliveryman.example(plugs[i].description);
         }
       }
       return false;
   },
   version: function(v) {
       if(environment.browser()=="Safari Mobile") {
          return false;
       }
       var plugs = navigator.plugins;
       var plugCount = plugs.length;
       if (v.major==undefined) {
          for (i = 0; i <= plugCount; i++) {
             if(plugs[i].name.toLowerCase().indexOf("flash")!=-1) {
                var x = plugs[i].description.substring(16,plugs[i].description.length);
                //x = x.substring(0,x.toLowerCase().indexOf(" "));
                return x;
            }
         }
          return false;
       } else {
          for (i = 0; i <= plugCount; i++) {
             if(plugs[i].name.toLowerCase().indexOf("flash")!=-1) {
                if (v.minor==undefined) {
                   v.minor = 0;
                }
                if (v.revision==undefined) {
                   v.revision = 0;
                }
                var full = plugs[i].description.substring(16,plugs[i].description.length);
                var major = full.substring(0,full.indexOf("."));
                var minor = full.substring(full.indexOf(".")+1,full.lastIndexOf(" "));
                if(full.lastIndexOf("r")!=-1) {
                    var revision = full.substring(full.lastIndexOf("r")+1,full.length);
                } else {
                    var revision = full.substring(full.lastIndexOf("d")+1,full.length);
                }
                if (v.major<=major && v.minor<=minor && v.revision<=revision) {
                   return true;
               } else {
                  return false;
               }
            }
         }
          return false;
       }
   },
   canPlay: function() {
      return (navigator.mimeTypes["application/x-shockwave-flash"]!=undefined);
   },
   play: function(i) {
      return commonPlay(i);
   },
   pause: function(i) {
      return commonStop(i);
   },
   stop: function(i) {
      return commonStop(i);
   },
   rewind: function(i) {
      var mediaObject = document.getElementByID(i);
      mediaObject.rewind();
      return  "";
   },
   step: function(i,numberOfFrames) {
      var mediaObject = document.getElementByID(i);
      mediaObject.step(numberOfFrames);
      return  "";
   },
   movieVersion: function(i) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.GetQuickTimeVersion();
   },
   movieLanguage: function(i) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.GetQuickTimeLanguage();
   },
   connectionSpeed: function(i) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.GetQuickTimeConnectionSpeed();
   },
   registered: function(i) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.GetIsQuickTimeRegistered();
   },
   resetProperties: function(i) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.GetResetPropertiesOnReload(theState);
   },
   setResetProperties: function(i,theState) {
      var mediaObject = document.getElementByID(i);
      return mediaObject.SetResetPropertiesOnReload(theState);
   }
};
var facebook = {
   like: function(p) {
      if(p.width==undefined) {
         p.width = "200px";
      }
      if(p.height==undefined) {
         p.height = "80px";
      }
      if(p.transparency ==undefined) {
         p.transparency = "false";
      }
      if(p.border==undefined) {
         p.border = "false";
      }
      if(p.url!=undefined) {
         p.url = ("http://www.facebook.com/plugins/like.php?href=" + escape(p.url) + "&amp;layout=standard&amp;show_faces=true&amp;width="+p.width+"&amp;action=like&amp;font=trebuchet+ms&amp;colorscheme=light&amp;height="+p.height);
      } else {
         p.url = ("http://www.facebook.com/plugins/like.php?href=" + escape("http://www.facebook.com") + "&amp;layout=standard&amp;show_faces=true&amp;width="+p.width+"&amp;action=like&amp;font=trebuchet+ms&amp;colorscheme=light&amp;height="+p.height);
      }
      return (iframe.embed({url: p.url, width: p.width, height:p.height, scrolling:"no", transparency:p.transparency}));
   }
}
var map = {
   embed: function(p) {

   }
}
var youtube = {
   embed: function(p) {
     var  h = '';
      if(p.width==undefined) {
         p.width = "100%";
      }
      if(p.height==undefined) {
         p.height = "98%";
      }
      if(p.style==undefined) {
         p.style = vDMGlobalStyle;
      }
      if(p.id!=undefined) {
         h = h + iframe.embed({id:p.id,url:("http://www.youtube.com/embed/"+p.id+""), width:p.width, height:p.height, style:p.style, title:p.title, description:p.description});
      }
      return h;
   },
   playlist: function(p) {
          var  h = '';
      if(p.width==undefined) {
         p.width = "100%";
      }
      if(p.height==undefined) {
         p.height = "100%";
      }
      if(p.style==undefined) {
         p.style = vDMGlobalStyle;
      }
      if(p.id!=undefined) {
         h = h + iframe.embed({url:("wp-content/plugins/deliveryman/dm-youtube-playlist.php?p="+p.id+""), width:p.width, height:p.height, style:p.style, title:p.title, description:p.description});
      }
      return h;
   }
}
var vimeo = {
   embed: function(p) {
     var  h = '';
      if(p.width==undefined) {
         p.width = "100%";
      }
      if(p.height==undefined) {
         p.height = "98%";
      }
      if(p.style==undefined) {
         p.style = vDMGlobalStyle;
      }
      if(p.id!=undefined) {
         h = h + iframe.embed({url:("http://player.vimeo.com/video/"+p.id), width:p.width, height:p.height, style:p.style, title:p.title, description:p.description});
      }
      return h;
   }
};
var earth = {
   embed: function(p) {

   },
   string: function() {
      var plugs = navigator.plugins;
      var plugCount = plugs.length;
      for (i = 0; i <= plugCount; i++) {
         if(plugs[i].name.toLowerCase().indexOf("earth")!=-1) {
            return plugs[i].name;
         }
      }
      return false;
      },
         description: function() {
            var plugs = navigator.plugins;
            var plugCount = plugs.length;
            for (i = 0; i <= plugCount; i++) {
                 if(plugs[i].name.toLowerCase().indexOf("earth")!=-1) {
                     return deliveryman.example(plugs[i].description);
            }
      }
      return false;
      }
}
var interface = {
   spinner: function(p) {
      var i=0;
      h = '<div class="spinner" style="width: 34px; height: 34px">';
      for (i=0;i<=11;i++) {
         h = h + '<div class="bar'+(i+1)+'"></div>';
      }
      h = h + '</div>';
      return h;
   },
   scrollView: function(p) {
            var mediaItems = p.data.length;
            if(p.orientation==undefined) {
               p.orientation = "horizontal";
            }
            var h = '<table class="dm-scroll-view-'+p.orientation+'">';
            if(p.orientation=="horizontal") {
               if(p.title!=undefined) { 
                  var h = h + '<tr>';
                  var h = h + '<td class="dm-scroll-view-title-horizontal" colspan="3">'+p.title+'</td>';
                  var h = h + '</tr>';
               }
               var h = h + '<tr>';
               var h = h + '<td class="dm-scroll-view-thumb-left">&lt;</td>';
               var h = h + '<td>';
            } else {
               if(p.title!=undefined) { 
                  var h = h + '<tr>';
                  var h = h + '<td class="dm-scroll-view-title-vertical">'+p.title+'</td>';
                  var h = h + '</tr>';
               }
               var h = h + '<tr>';
               var h = h + '<td class="dm-scroll-view-thumb-up">Up</td>';
               var h = h + '</tr>';
               var h = h + '</tr>';
               var h = h + '<td>';
            }
            h = h + '<div class="dm-scroll-view-strip-'+p.orientation+'">';
            h = h + '<table id="dm-scroll-view-strip">';
            if(p.orientation=="horizontal") {
               var h = h + '   <tr>';
            }
            for (i = 0; i <= mediaItems-1; i++) {
               if(p.orientation=="vertical") {
                  var h = h + '      <tr>'
               }
               var h = h + '      <td>';
               if(p.data[i].title!=undefined) {
                  var h = h + '         <div class="dm-scroll-view-item-title">'+p.data[i].title+'</div>';
               }
               var h = h + '         <div class="dm-scroll-view-item-icon" style="background-image: url(\''+p.data[i].icon+'\')"></div>';
               var h = h + '         <div class="dm-scroll-view-item-description">'+p.data[i].description+'</div>';
               var h = h + '      </td>';
               if(p.orientation=="vertical") {
                  var h = h + '      </tr>'
               }
            }
            if(p.orientation=="horizontal") {
               var h = h + '   </tr>';
            }
            var h = h + '</table>';
            var h = h + '</td>';
            if(p.orientation=="horizontal") {
               var h = h + '<td class="dm-scroll-view-thumb-right">&gt;</td>';
               var h = h + '</tr>';
            } else {
               var h = h + '</tr>';
               var h = h + '<tr>';
               var h = h + '<td class="dm-scroll-view-thumb-bottom">Down</td>';
               var h = h + '</tr>';
            }
            var h = h + '</table>';
            var h = h + '</div>';
            if(p.target!=undefined) {
               eval("$jqdm('#"+p.target+"').html(h);");
            }
   },
   menuView: function(p) {
            var menuItems = p.data.length;
            if(p.orientation==undefined) {
               p.orientation = "horizontal";
            }
            h = '<ul class="dm-menu-view-menu-'+p.orientation+'">';
            for (i = 0; i <= menuItems-1; i++) {
               h = h + '<li><a href="'+p.data[i].url+'">'+p.data[i].description+'</a></li>';
            }
            h = h + '</ul>';
            
            if(p.target!=undefined) {
               eval("$jqdm('#"+p.target+"').html(h);");
            }
      }
};
var time = {
   clock: function(p) {
      
   },
   setTimeout: function(p) {
      if(p.task!=undefined) {
         eval('var '+p.variable+' = setTimeout("'+p.task+'", '+p.msecs+')');
      }
   },
   clearTimeout: function(p) {
      if(p.task!=undefined) {
         eval('clearTimeout('+p.variable+')');
      }
   },
   setInterval: function(p) {
      if(p.task!=undefined) {
         eval('var '+p.variable+' = setInterval("'+p.task+'", '+p.msecs+')');
      }
   },
   clearInterval: function(p) {
      if(p.task!=undefined) {
         eval('clearInterval('+p.variable+')');
      }
   },
   repeat: function(p) {
      
   }
};
var network = {
   getJSON: function(p) {
      if(p.url!=undefined) {
         $jqdm.ajax({
            url: p.url,
            dataType: 'json',
            success: function(data) {
               if(p.call!=undefined) {
                  eval((p.call+"(data)"));
               }
            },
            error: function(data,m) {
               alert('Error.'+m);
            }
         });
      }
   }
};
      /* DeliveryMan Video Player Variables */
var DMVideoPlayerSelectionOffsetCounter = new Array();
var DMVideoPlayerSelectionWidth = 589;
var DMVideoPlayerSelectionOffset = 230;
var DMVideoPlayerCount = 0;
/* End DeliveryMan Video Player Variables */

var player = {
    video: function(p) {
         p.id = "DMVideoPlayer-" + DMVideoPlayerCount;
         if(p.style==undefined) {
            p.style = vDMGlobalStyle;
         }
         if(p.format==undefined) {
            p.format = "hd";
         }
         DMVideoPlayerSelectionOffsetCounter[DMVideoPlayerCount] = 0;
         var h = '';
         var s = '<div id="' + p.id + '" class="dm-player-player">';
        if(p.header!=undefined) {
           s = s + '   <div id="' + p.id + '-header" class="dm-player-header">';
           s = s + '       <img src="' + p.header +'" class="dm-player-header-image"/>';
           //s = s + '       <img src="'+p.adbanner+'" class="dm-player-header-image"/>';
           s = s + '      </div>';
        }
        s = s + '<div class="dm-player-content">';
        if(p.title!=undefined) {
           s = s + '   <div id="' + p.id + '-title" class="dm-title ' + p.style + '">';
           s = s + '' + p.title;
           s = s + '      </div>';
        }
        if(p.poster==undefined && p.cover!=undefined ) {
              s = s + '<div id="' + p.id + '-video" class=""><img src="'+p.cover+'" class="dm-player-content"/></div>';
           }
         if(p.poster!=undefined && p.cover==undefined ) {  
           if(p.playlist==undefined) {
              if(environment.platform()=="iPhone" || environment.platform()=="iPad") {
                   s = s + '<div id="' + p.id + '-video" class="">'+video.embed({controls:"true", autoplay:"true", width:"100%", poster: p.poster, url: (p.mov)})+'</div>';
                } else {
                   s = s + '<div class="dm-wrapper-' + p.format + '"><img onclick="player.loadVideo(this)" data-player="' + escape((video.embed({controls:"true", autoplay:"true",style: p.style, width:"100%",mov:p.mov,ogg:p.ogg,webm:p.webm}))) + '" id="' + p.id + '-video" src="' + p.poster + '" class="dm-player-display"/></div>';
                }
            }
         }
        if(p.poster==undefined && p.cover==undefined ) {  
           h = h + '      <div id="' + p.id + '-video" class="dm-wrapper-' + p.format + ' ' + p.style + '">';
           h = h + '         <h2>DeliveryMan Media Player</h2>';
           h = h + '         <p>Version 0.67<br/>Updated: Sunday January 9th 2011</p>';
           h = h + '         <p>Written by Peter Mitchell<br/>';
           h = h + '         &copy; 2010-2011 Peter Mitchell : All rights reserved</p>';
           h = h + '         <p>Browser: ' + environment.browser() + '<br/>';
           h = h + '         Platform: ' + environment.platform() + '<br/>';
           h = h + '         Supports video tag: ' + environment.video() + '<br/>';
           h = h + '         Plays H264 video: ' + environment.h264() + '<br/>';
           h = h + '         Plays OGV video: ' + environment.ogg() + '<br/>';
           h = h + '         Plays WebM video: ' + environment.webm() + '<br/>';
           h = h + '         Has Flash Plugin: ' + environment.plugin('flash') + '<br/>';
           h = h + '         Has Quicktime Plugin: ' + environment.plugin('quicktime') + '<br/></p>';
           h = h + '      </div>';
        }

        if(p.description!=undefined) {
           h = h + '      <div id="' + p.id + '-description" class="dm-description ' + p.style + '">';
           h = h + '' + p.description;
           h = h + '      </div>';
        }
        h = h + '</div>';
        if(p.playlist!=undefined) {
           h = h + '   <div class="dm-player-horizontal-spacer"></div>';
           h = h + '   <table class="dm-player-selector-wrapper" border="1"><tr>';
           h = h + '      <td id="' + p.id + '-left" class="dm-player-selector-left ' + p.style + '-left" onclick="player.scrollLeft('+DMVideoPlayerCount+')">|</td>';
           h = h + '      <td id="' + p.id + '-selector" class="dm-player-selector" data-url="'+p.playlist+'" data-style="' + p.style + '">';
           h = h + '         <scr'+'ipt type="text/javascript">document.write(interface.spinner({}));</scr'+'ipt>';
           h = h + '      </td>';
           h = h + '      <td id="' + p.id + '-right" class="dm-player-selector-right ' + p.style + '-right" onclick="player.scrollRight('+DMVideoPlayerCount+')">&gt;</td>';
           h = h + '   </tr></table>';
           time.setTimeout({variable:'t',task:'player.playlist('+DMVideoPlayerCount+')', msecs: 1000});

           }
           if(p.copyright!=undefined) {
              h = h + '   <div class="dm-player-copyright">';
              h = h + '      ' + p.copyright;
              h = h + '   </div>';
           }
           h = h + '</div>';
           var b = '';

           h = s + h;
         DMVideoPlayerCount = DMVideoPlayerCount + 1;
        return h;
    },
   load: function(p) {
      if(($jqdm(p).attr("data-poster"))!=undefined) {
         var poster = ', poster:"'+$jqdm(p).attr("data-poster")+'"';
      } else {
         var poster = '';
      };
      if(environment.platform()=="iPhone" || environment.platform()=="iPad") {
         if(($jqdm(p).attr("data-mp4"))!=undefined) {
            var mp4 = ', url:"'+$jqdm(p).attr("data-mp4")+'"';
         } else {
            var mp4 = '';
         };
         if(($jqdm(p).attr("data-m4v"))!=undefined) {
            var m4v = ', url:"'+$jqdm(p).attr("data-m4v")+'"';
         } else {
            var m4v = '';
         };
         if(($jqdm(p).attr("data-mov"))!=undefined) {
            var mov = ', mov:"'+$jqdm(p).attr("data-mov")+'"';
         } else {
            var mov = '';
         };
      } else {
         if(($jqdm(p).attr("data-mp4"))!=undefined) {
            var mp4 = ', mp4:"'+$jqdm(p).attr("data-mp4")+'"';
         } else {
            var mp4 = '';
         };
         if(($jqdm(p).attr("data-m4v"))!=undefined) {
            var m4v = ', m4v:"'+$jqdm(p).attr("data-m4v")+'"';
        } else {
            var m4v = '';
         };
         if(($jqdm(p).attr("data-mov"))!=undefined) {
            var mov = ', mov:"'+$jqdm(p).attr("data-mov")+'"';
        } else {
            var mov = '';
         };
         if(($jqdm(p).attr("data-ogg"))!=undefined) {
            var ogg = ', ogg:"'+$jqdm(p).attr("data-ogg")+'"';
         } else {
            var ogg = '';
         };
         if(($jqdm(p).attr("data-webm"))!=undefined) {
            var webm = ', webm:"'+$jqdm(p).attr("data-webm")+'"';
         } else {
           var webm = '';
         };
         if(($jqdm(p).attr("data-flv"))!=undefined) {
            var flv = ', flv:"'+$jqdm(p).attr("data-flv")+'"';
         } else {
           var flv = '';
         };
     };
          var videotarget = (p.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.getAttribute("id"));
          //alert(videotarget);
          //alert('video.embed({controls:"true",autoplay:"true"'+poster+mp4+m4v+mov+ogg+webm+'}))');
          if(environment.platform()=="iPhone" || environment.platform()=="iPad") {
             eval('var x = video.embed({controls:"true",width:"100%",autoplay:"true"'+poster+mp4+m4v+mov+'})'); // w+h+a+
      } else {
      eval('var x = video.embed({controls:"true",width:"100%",autoplay:"true"'+poster+mp4+m4v+mov+ogg+webm+flv+'})'); // w+h+a+
      }
      //alert(x);
      $jqdm('#'+videotarget+'-video').html(x);
      $jqdm("#"+videotarget+"-video").attr("style", ("background-image: url('" + $jqdm(p).attr("data-poster") + "');"));
      $jqdm('#'+videotarget+'-title').html($jqdm(p).attr("data-title"));
      $jqdm('#'+videotarget+'-description').html($jqdm(p).attr("data-description"));
      
   },
   loadVideo: function(t) {
   //alert(unescape($jqdm(t).attr("data-player")));
      $jqdm(t).parent().html(unescape($jqdm(t).attr("data-player")));
   },
playlist: function(p) {
      var st = $jqdm('#DMVideoPlayer-'+p+'-selector').attr('data-style')
      var s = $jqdm.getJSON($jqdm('#DMVideoPlayer-'+p+'-selector').attr('data-url'),
      function(data){
         var mediaItems = data.length;
         var h = '<div class="dm-player-scroller" id="DMVideoPlayer-'+p+'-scroller"><table><tr>';
         for (i = 0; i <= mediaItems-1; i++) {
            var mp4 = '';
            if(data[i].mp4!=undefined) {
               mp4 = ' data-mp4="' + data[i].mp4 + '"';
            };
            var m4v = '';
            if(data[i].m4v!=undefined) {
               m4v = ' data-m4v="' + data[i].m4v + '"';
            };
            var ogg = '';
            if(data[i].ogg!=undefined) {
               ogg = ' data-ogg="' + data[i].ogg + '"';
            };
            var webm = '';
            if(data[i].webm!=undefined) {
               webm = ' data-webm="' + data[i].webm + '"';
            };
            var mov = '';
            if(data[i].mov!=undefined) {
               mov = ' data-mov="' + data[i].mov + '"';
            };
            var flv = '';
            if(data[i].flv!=undefined) {
               flv = ' data-flv="' + data[i].flv + '"';
            };
            var wmv = '';
            if(data[i].wmv!=undefined) {
               wmv = ' data-wmv="' + data[i].wmv + '"';
            };
            var poster = '';
            if(data[i].poster!=undefined) {
               poster = ' data-poster="' + data[i].poster + '"';
            };
            var t = '';
            if(data[i].title!=undefined) {
               t = ' data-title="' + data[i].title + '"';
            };
            var d = '';
            if(data[i].description!=undefined) {
               d = ' data-description="' + data[i].description + '"';
            };
            h = h + '<td class="dm-player-icon ' + st + '"' + t + d + poster + mp4 + m4v + ogg + webm + mov + flv + wmv + ' onclick="player.load(this)">';
            if(data[i].title!=undefined) {
               h = h + '<div class="dm-player-thumbnail-title ' + st + '">' + data[i].title + '</div>';
            };
            if(data[i].thumbnail!=undefined) {
               h = h + '<div class="dm-player-thumbnail" style="background: url(' + data[i].thumbnail + ');"><img class="dm-player-thumbnail-start" src="http://www.deliveryman.nl/content/image/start-video.png"/></div>'; 
            };
            if(data[i].description!=undefined) {
               h = h + '<div class="dm-player-thumbnail-description ' + st + '">' + data[i].description + '</div>'; 
            }
            h = h + '</td>';
         }
         h = h + '</tr></table></div>';
         var x = parseFloat($jqdm(".dm-player-player").css("width")) - 50;
         DMVideoPlayerSelectionWidth = x;
         $jqdm('#DMVideoPlayer-'+p+'-selector').html(h);
$jqdm(".dm-player-scroller").css("width", x);
      });
   },
   scrollLeft: function(p) {
      if(DMVideoPlayerSelectionOffsetCounter[p]>=1) {
         DMVideoPlayerSelectionOffsetCounter[p] = DMVideoPlayerSelectionOffsetCounter[p] - DMVideoPlayerSelectionOffset;
         $jqdm('#DMVideoPlayer-'+p+'-scroller').animate({scrollLeft: DMVideoPlayerSelectionOffsetCounter[p]}, 'slow');
         if(DMVideoPlayerSelectionOffsetCounter[p]>=1) {
            $jqdm('#DMVideoPlayer-'+p+'-left').html('&lt;');
            $jqdm('#DMVideoPlayer-'+p+'-right').html('&gt;');
         } else {
            $jqdm('#DMVideoPlayer-'+p+'-left').html('|');
         }
      } else {
         DMVideoPlayerSelectionOffsetCounter[p] = 0;
         $jqdm('#DMVideoPlayer-'+p+'-left').html('|');
      }
   },
   scrollRight: function(p) {
      var videoSelectorLength = $jqdm('#DMVideoPlayer-'+p+'-scroller').width();
      if(DMVideoPlayerSelectionOffsetCounter[p]<=videoSelectorLength-DMVideoPlayerSelectionWidth) {
         DMVideoPlayerSelectionOffsetCounter[p] = DMVideoPlayerSelectionOffsetCounter[p] + DMVideoPlayerSelectionOffset;
         if(DMVideoPlayerSelectionOffsetCounter[p]>=videoSelectorLength-DMVideoPlayerSelectionWidth) {
            $jqdm('#DMVideoPlayer-'+p+'-right').html('|');
         } else {
            $jqdm('#DMVideoPlayer-'+p+'-right').html('&gt;');
            $jqdm('#DMVideoPlayer-'+p+'-left').html('&lt;');
         }
      } else {
         DMVideoPlayerSelectionOffsetCounter[p] = videoSelectorLength-(DMVideoPlayerSelectionWidth+4);
         $jqdm('#DMVideoPlayer-'+p+'-right').html('|');
      }
      //alert(DMVideoPlayerSelectionOffsetCounter[p]);
      $jqdm('#DMVideoPlayer-'+p+'-scroller').animate({scrollLeft: DMVideoPlayerSelectionOffsetCounter[p]}, 'slow');
   }
};
var quartz = {
            embed: function(p) {
               if (p.autoplay == undefined) {p.autoplay = "true"}
               var h = '';
               if (environment.plugin("quartz")==true) {
               if (p.align == "center") {
                  h = h + '<center>\r';
               }
               h = h + '<embed' + commonParams(p);
               h = h + ' type="application/x-quartzcomposer"';
               if (p.height != undefined) {
                  h = h + ' height="'+p.height+'"';
               }

               h = h + ' src="'+p.url+'"';
               if (p.above != undefined) {
                  h = h + ' above="'+p.above+'"';
               }
               if (p.opaque != undefined) {
                  h = h + ' opaque="'+p.opaque+'"';
               }
               if (p.oncopy != undefined) {
                  h = h + ' oncopy="'+p.oncopy+'"';
               }
               if (p.maxfps != undefined) {
                  h = h + ' maxfps="'+p.maxfps+'"';
               }
               if (p.autoplay != undefined) {
                  h = h + ' autoplay="'+p.autoplay+'"';
               }
               if (p.style != undefined) {
                  h = h + ' class="'+p.style+'"';
               }
               if (p.onloading == undefined) {
                     p.onloading = "quartzLoading";
               }
               if (p.onerror == undefined) {
                     p.onerror = "quartzError";
               }
               if (p.onload == undefined) {
                     p.onload = "quartzLoaded";
               }
               if (p.oncopy == undefined) {
                     p.oncopy = "quartzCopy";
               }
               h = h + ' onloading="'+p.onloading+'" onload="'+p.onload+'" onerror="'+p.onerror+'"/>\r';
               if (p.align == "center") {
                  h = h + '</center>\r';
               }
                
               } else {
                  h = deliveryman.unsupported("quartz",p.width,p.height);
               }
                return h;
            },
            example: function(l) {
               return deliveryman.example(this.embed(l));
            },
            canPlay: function() {
               return (navigator.mimeTypes["application/x-quartzcomposer"]!=undefined);
            },
            string: function() {
               var plugs = navigator.plugins;
               var plugCount = plugs.length;
               for (i = 0; i <= plugCount; i++) {
                  if(plugs[i].name.toLowerCase().indexOf("quartz")!=-1) {
                     return plugs[i].name;
                  }
                }
                return false;
            },
            description: function() {
               var plugs = navigator.plugins;
               var plugCount = plugs.length;
               for (i = 0; i <= plugCount; i++) {
                  if(plugs[i].name.toLowerCase().indexOf("quartz")!=-1) {
                     return deliveryman.example(plugs[i].description);
                  }
                }
                return false;
            },
            version: function(x) {
               if(x.major==undefined) {
                  if(environment.plugin("quartz")==false) {
                     return false;
                  } else {
                     if(environment.browser()=="Safari" && environment.version()>=4 && environment.platform()=="MacIntel") {
                        return "1.2";
                     }
                     if(environment.browser()=="AppleWebKit" && environment.version()>=530 && environment.platform()=="MacIntel") {
                        return "1.2";
                     }
                     return "1.0";
                  }
               } else {
                  if(x.minor!=undefined) {
                     if(x.major<=1 && x.minor<=2) {
                        return true;
                     } else {
                        return false;
                     }
                  } else {
                     if(x.major<=1) {
                        return true;
                     } else {
                        return false;
                     }
                  }
               }
            },
            play: function(i) {
               return commonPlay(i);
            },
            pause: function(i) {
               return commonPause(i);
            },
            stop: function(i) {
               return commonStop(i);
            },
            attributes: function(i) {
               var mediaObject = document.getElementByID(i);
               return mediaObject.attributes(i);
            }
        };
function quartzLoading(a) {
   ;
}

function quartzLoaded() {
   ;
}

function quartzError(err) {
   alert (err)
}

var iframe = {
            embed: function(p) {
               if(p.style==undefined) {
                  p.style = vDMGlobalStyle;
               }
               var h = '<div class="dm-iframe '+p.style+'">';
               if (p.title != undefined) {
                  h = h + '<div class="dm-title ' + p.style + '">'+p.title+'</div>';
               }
               h = h + '<iframe'; // + commonParams(p);
               if (p.url != undefined) {
                  h = h + ' src="'+p.url+'"';
               }
               if (p.width != undefined) {
                  h = h + ' width="'+p.width+'"';
               } else {
                  h = h + ' width="100%"';
               }
               if (p.id != undefined) {
                  h = h + ' id="'+p.id+'"';
               }
               if (p.height != undefined) {
                  h = h + ' height="'+p.height+'"';
               } else {
                  h = h + ' height="100%"';
               }
               if (p.frameborder == undefined) {
                  h = h + ' frameborder="0"';
               } else {
                  h = h + ' frameborder="'+p.frameborder+'"';
               }
               if (p.marginheight != undefined) {
                  h = h + ' marginheight="'+p.marginheight+'"';
               }
               if (p.marginwidth != undefined) {
                  h = h + ' marginwidth="'+p.marginwidth+'"';
               }
               if (p.scrolling != undefined) {
                  h = h + ' scrolling="'+p.scrolling+'"';
               }
               if (p.transparency != undefined) {
                  h = h + ' allowTransparency="'+ p.transparency +'"';
               }
               if (p.style != undefined) {
                  h = h + ' class="dm-wrapper-iframe '+p.style+'"';
               }
               h = h + '></iframe>\r';
                
               if (p.description != undefined) {
                  h = h + '<div class="dm-description ' + p.style + '">'+p.description+'</div>';
               }
                h = h + '</div>';
                return h;
            },
            example: function(l) {
               return deliveryman.example(this.embed(l));
            },
            description: function() {
                return 'iframe';
            }
        };function commonPlay(i) {
           var mediaObject = document.getElementByID(i);
           return mediaObject.play();
        }
        function commonPause(i) {
           var mediaObject = document.getElementByID(i);
           return mediaObject.pause();
        }
        function commonStop(i) {
           var mediaObject = document.getElementByID(i);
           return mediaObject.stop();
        }
function commonParams(p) {
               var commonHTML = '';
               if (p.id != undefined) {
                  commonHTML = commonHTML + ' id="'+p.id+'"';
               }
      if (p.width != undefined) {
         if (p.width.indexOf("px")!=-1) {
            vWUnits = "px";
          }
         if (p.width.indexOf("em")!=-1) {
            vWUnits = "em";
          }
         if (p.width.indexOf("%")!=-1) {
            vWUnits = "%";
          }
          if(vWUnits==""){
             vWUnits = "px";
          }
               commonHTML = commonHTML + ' width="'+parseFloat(p.width)+vWUnits+'"';
               return commonHTML;
            }
        }
// Replaces all instances of the given substring.
String.prototype.replaceAll = function(
           strTarget, // The substring you want to replace
           strSubString // The string you want to replace in.
        ){
           var strText = this;
        var intIndexOfMatch = strText.indexOf( strTarget );
         
        // Keep looping while an instance of the target string
        // still exists in the string.
        while (intIndexOfMatch != -1){
        // Relace out the current instance.
        strText = strText.replace( strTarget, strSubString )
         
        // Get the index of any next matching substring.
        intIndexOfMatch = strText.indexOf( strTarget );
        }
         
        // Return the updated string with ALL the target strings
        // replaced out with the new substring.
        return( strText );
};
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$jqdm", "g"), "");
}
/* 
Copyright (C) 2007 Apple Computer, Inc.  All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

var WebKitDetect = {  };

// If the user agent is WebKit, returns true. Otherwise, returns false.
WebKitDetect.isWebKit = function isWebKit()
{
    return RegExp(" AppleWebKit/").test(navigator.userAgent);
}

// If the user agent is WebKit, returns an array of numbers matching the "." separated 
// fields in the WebKit version number, with an "isNightlyBuild" property specifying
// whether the user agent is a WebKit nightly build. Otherwise, returns null.
//
// Example: 418.10.1 => [ 418, 10, 1 ] isNightlyBuild: false
WebKitDetect.version = function version() 
{
    /* Some example strings: 
            Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/418.9.1 (KHTML, like Gecko) Safari/419.3
            Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Safari/521.32
     */
     
    // grab (AppleWebKit/)(xxx.x.x)
    var webKitFields = RegExp("( AppleWebKit/)([^ ]+)").exec(navigator.userAgent);
    if (!webKitFields || webKitFields.length < 3)
        return null;
    var versionString = webKitFields[2];

    var isNightlyBuild = versionString.indexOf("+") != -1;

    // Remove '+' or any other stray characters
    var invalidCharacter = RegExp("[^\\.0-9]").exec(versionString);
    if (invalidCharacter)
        versionString = versionString.slice(0, invalidCharacter.index);
    
    var version = versionString.split(".");
    version.isNightlyBuild = isNightlyBuild;
    return version;
}

// If the user agent is a WebKit version greater than or equal to the version specified
// in the string minimumString, returns true. Returns false otherwise. minimumString 
// defaults to "".
//
// Example usage: WebKitDetect.versionIsAtLeast("418.10.1")
WebKitDetect.versionIsAtLeast = function versionIsAtLeast(minimumString)
{
    function toIntOrZero(s) 
    {
        var toInt = parseInt(s);
        return isNaN(toInt) ? 0 : toInt;
    }

    if (minimumString === undefined)
        minimumString = "";
    
    var minimum = minimumString.split(".");
    var version = WebKitDetect.version();

    if (!version)
        return false;
        
    if (version.isNightlyBuild)
        return true;

    for (var i = 0; i < minimum.length; i++) {
        var versionField = toIntOrZero(version[i]);
        var minimumField = toIntOrZero(minimum[i]);
        
        if (versionField > minimumField)
            return true;
        if (versionField < minimumField)
            return false;
    }

    return true;
}

WebKitDetect.isMobile = function isMobile()
{
    return WebKitDetect.isWebKit() && RegExp(" Mobile/").test(navigator.userAgent);
}

WebKitDetect.mobileDevice = function mobileDevice()
{
    if (!WebKitDetect.isMobile())
        return null;
        
    var fields = RegExp("(Mozilla/5.0 \\()([^;]+)").exec(navigator.userAgent);
    if (!fields || fields.length < 3)
        return null;
    return fields[2];
}

// Example: 1C28 => [ 1, C, 28 ]
WebKitDetect._mobileVersion = function _mobileVersion(versionString)
{
    var fields = RegExp("([0-9]+)([A-Z]+)([0-9]+)").exec(versionString);
    if (!fields || fields.length != 4)
        return null;
    return [ fields[1], fields[2], fields[3] ];
}

WebKitDetect.mobileVersion = function mobileVersion()
{
    // grab (Mobile/)(nxnnn)
    var fields = RegExp("( Mobile/)([^ ]+)").exec(navigator.userAgent);
    if (!fields || fields.length < 3)
        return null;
    var versionString = fields[2];
    
    return WebKitDetect._mobileVersion(versionString);
}

WebKitDetect.mobileVersionIsAtLeast = function mobileVersionIsAtLeast(minimumString)
{
    function toIntOrZero(s) 
    {
        var toInt = parseInt(s);
        return isNaN(toInt) ? 0 : toInt;
    }

    if (minimumString === undefined)
        minimumString = "";

    var minimum = WebKitDetect._mobileVersion(minimumString);
    var version = WebKitDetect.mobileVersion();

    if (!version)
        return false;
        
    var majorVersInt = toIntOrZero(version[0]);
    var majorMinInt = toIntOrZero(minimum[0]);
    if (majorVersInt > majorMinInt)
        return true;
    if (majorVersInt < majorMinInt)
        return false;
    
    var majorVersAlpha = version[1];
    var majorMinAlpha = minimum[1];
    if (majorVersAlpha > majorMinAlpha)
        return true;
    if (majorVersAlpha < majorMinAlpha)
        return false;
    
    var minorVersInt = toIntOrZero(version[2]);
    var minorMinInt = toIntOrZero(minimum[2]);
    if (minorVersInt > minorMinInt)
        return true;
    if (minorVersInt < minorMinInt)
        return false;
    
    return true;
}

