/* * VWSMovie object * inspired on: * - swfobject (http://blog.deconcept.com/swfobject/) * - GTObject (http://blog.deconcept.com/2005/01/26/web-standards-compliant-javascript-quicktime-detect-and-embed/) * * Author: Marc Gerritsen (m.gerritsen@minvws.nl) * Version: 1.0 (10-01-2007) * Works on: Inernet Eplorer 6, Firefox 1.5 * Description: Can detect flash version and if quitime is installed * Generates correct HTML for movie display * Can replace a HTML element with movie html * * * Usage: * myMovie = new multiMovie("id", width, height); * myMovie.addMovie("filename"); / supports mov, wmv, flv * myMovie.write("htmlelementid"); // script puts movie html inside html element * * */ //MultiMovie multiMovie = function(id, width, height) { this.id = id; this.width = width; this.height = height; this.movies = new Object(); this.captions = new Object(); this.image = ""; } multiMovie.prototype.addMovie = function(filename) { var temp = filename.split("/"); var thefile = temp[temp.length - 1]; var file = thefile.split("."); var type = file[file.length - 1]; if(type == "mp4") type = "mov"; this.movies[type] = filename; } multiMovie.prototype.addImage = function(filename) { this.image = filename; } multiMovie.prototype.addCaption = function(type, filename) { this.captions[type] = filename; } multiMovie.prototype.write = function(elementid) { var version = getFlashPlayerVersion(); if(version.major < 8 || this.movies["flv"] == undefined) { // not correct flash player found so check if there is quicktime installed if(isQTInstalled() && this.movies["mov"] != undefined) { // Quicktime plugin is detected // be sure to add 15px to the height to allow for the controls height = parseInt(this.height) + 16; var movieObject = new VWSMovie(this.movies["mov"], this.id, this.width, height); movieObject.addParam("autostart", "false"); movieObject.addParam("autoplay", "false"); movieObject.showMovie(elementid); } else if (this.movies["wmv"] != undefined) { height = parseInt(this.height) + 70; //if nothing else works show windows media player var movieObject = new VWSMovie(this.movies["wmv"], this.id, this.width, height); movieObject.addParam("Showcontrols", "true"); movieObject.addParam("autoStart", "false"); movieObject.addParam("showStatusbar", "true"); movieObject.addParam("src", this.movies["wmv"]) movieObject.showMovie(elementid); } else { alert("nothing to place"); } } else { height = parseInt(this.height) + 20; // correct flash version, show flashplayer with flashvideo var movieObject = new VWSMovie("/movie.swf", this.id, this.width, height); // if id= fullscreen then its fullscreen if(this.id == "fullscreen") { movieObject.addFlashVars("fullscreenmode", "true"); movieObject.addFlashVars("autostart", "true"); } else { movieObject.addFlashVars("autostart", "false"); } //set image if there is a image defined if(this.image != "") movieObject.addFlashVars("image", this.image); if (this.captions["flv"] != undefined) { movieObject.addFlashVars("captions", this.captions["flv"]); } movieObject.addFlashVars("fsreturnpage", "index.html"); movieObject.addFlashVars("fullscreenpage", "fullscreen.jsp"); movieObject.addFlashVars("callback","statistics.asp"); //movieObject.addFlashVars("showfsbutton", "true"); movieObject.addFlashVars("showdigits", "true"); movieObject.addFlashVars("showbuttons", "true"); movieObject.addFlashVars("bufferlength","10"); movieObject.addFlashVars("backcolor","0x000000"); movieObject.addFlashVars("frontcolor","0xFFFFFF"); movieObject.addFlashVars("lightcolor","0xFFFFFF"); movieObject.addFlashVars("file", this.movies["flv"]); //path from flash file location movieObject.showMovie(elementid); //give fullscreen focus for tabbing if(this.id == "fullscreen") { var el = document.getElementById("fullscreen"); el.focus(); } } } // movie object and functions VWSMovie = function(filename, id, width, height) { this.filename = filename; this.id = id; this.width = width; this.height = height; this.params = new Object(); this.flashvars = new Object(); }; // function add params to VWSMovie object VWSMovie.prototype.addParam = function(name, value) { this.params[name] = value; } // function that is used vby other VWSMovie functions VWSMovie.prototype.getParams = function() { return this.params; } // function to add flash variables to object VWSMovie.prototype.addFlashVars = function(name, value) { this.flashvars[name] = value; } // function that is used by other functions VWSMovie.prototype.getFlashVars = function() { return this.flashvars; } // function that is used by other functions VWSMovie.prototype.getParamTags = function() { var paramTags = ""; for (var param in this.getParams()) { paramTags += ''; } if (paramTags == "") { paramTags = null; } return paramTags; } /* * HTML generetor functions * * */ //function that generates quicktime html, different for ie or navigator browsers VWSMovie.prototype.getQuicktimeHTML = function() { var qtHTML = ""; //if (navigator.plugins && navigator.plugins.length) { // not ie qtHTML += ''; qtHTML += ''; qtHTML += ''; if (this.getParamTags() != null) { qtHTML += this.getParamTags(); } qtHTML += ''; }*/ return qtHTML; } //function that generates windows media player html VWSMovie.prototype.getWinmediaHTML = function() { var wHTML = ''; wHTML = ''; wHTML += ''; if (this.getParamTags() != null) { wHTML += this.getParamTags(); } wHTML += '"; swfHTML += ""; swfHTML += ""; if (this.getParamTags() != null) { swfHTML += this.getParamTags(); } if(flashVars != '') swfHTML += ""; swfHTML+=""; } return swfHTML; } //replace element with moviehtml, the get+movie+HTML functions VWSMovie.prototype.showMovie = function(elementID) { //first check what kind of file it is var temp = this.filename.split("/"); var thefile = temp[temp.length - 1]; var file = thefile.split("."); var filetype = file[file.length - 1]; if(filetype == "mp4") filetype = "mov"; var element = document.getElementById(elementID); //alert(file[1]); if(filetype == 'swf') { element.innerHTML = this.getFlashHTML(); } else if (filetype == 'mov' || filetype == 'mp4') { element.innerHTML = this.getQuicktimeHTML(); } else if (filetype == 'wmv') { element.innerHTML = this.getWinmediaHTML(); } else alert('don\'t know what to do with filetype: ' + filetype); } /* * Detector functions * * */ // Function gets flashplauyer version, if flash is not installed it returns major:0 minor:0 revesion:0 function getFlashPlayerVersion(){ var version = new FlashPlayerVersion([0,0,0]); if(navigator.plugins && navigator.mimeTypes.length){ var x=navigator.plugins["Shockwave Flash"]; if(x && x.description){ version = new FlashPlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split(".")); } }else{ try{ var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); } catch(e){ try{ var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); version = new FlashPlayerVersion([6,0,21]); axo.AllowScriptAccess="always"; } catch(e){ if(version.major==6){return version;} } try{ axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch(e){} } if(axo!=null){ version=new FlashPlayerVersion(axo.GetVariable("$version").split(" ")[1].split(",")); } } return version; }; //object used by the getFlashPlayerVersion function FlashPlayerVersion = function(player){ this.major = player[0]!=null?parseInt(player[0]):0; this.minor = player[1]!=null?parseInt(player[1]):0; this.rev = player[2]!=null?parseInt(player[2]):0; }; // function checks if quicktime is installed function isQTInstalled() { var qtInstalled = false; qtObj = false; if (navigator.plugins && navigator.plugins.length) { for (var i=0; i < navigator.plugins.length; i++ ) { var plugin = navigator.plugins[i]; if (plugin.name.indexOf("QuickTime") > -1) { qtInstalled = true; } } } else { execScript('on error resume next: qtObj = IsObject(CreateObject("QuickTimeCheckObject.QuickTimeCheck.1"))','VBScript'); qtInstalled = qtObj; } return qtInstalled; } /* * General functions / html functions * * */ //function hides or shows an element function toggle(objid) { //alert(objid); var el = document.getElementById(objid); if ( el.className == 'close' ) { el.className = 'open'; } else { el.className = 'close'; } } function toggleDiv() { if(document.getElementById('drop_down_videos').style.display == 'none') { document.getElementById('drop_down_videos').style.display = 'block'; document.getElementById('header_alt_videos').className = 'divOpen'; } else { document.getElementById('drop_down_videos').style.display = 'none'; document.getElementById('header_alt_videos').className = 'divDicht'; } } function renameLink(id, text) { linkname = document.getElementById(id); linkname.innerHTML = text; } // gives all anchers with given rel attribute name with onclick="return blank(this.href)" function openBlank() { var filetypes = new Array("pdf", "wmv", "mov", "mp4", "flv", "3gp"); myAnchors = document.getElementsByTagName('a'); for (i=0; i' + newName + ''; // close the download video list toggle(ulID); toggle("movieToggleLink_" + liID); } } // funtion to check if a value is in a array, returns true or false function in_array(myArray, value) { for(var i=0; i < myArray.length; i++) { if(myArray[i] == value) return true; } return false; } function hideElement(ids) { var arElements = ids.split(","); for(var i=0; i< arElements.length; i++) { var id = arElements[i]; var element = document.getElementById(id); if(element) { element.parentNode.removeChild(element); } } }