function Browser(){
this.iE = navigator.appName.toLowerCase().indexOf('microsoft') != -1 ? 1 : 0;
this.mac = navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 1 : 0;
this.win = navigator.userAgent.toLowerCase().indexOf('windows') != -1 ? 1 : 0;
this.safari = navigator.userAgent.toLowerCase().indexOf('safari') != -1 ? 1 : 0;
this.opera = navigator.userAgent.toLowerCase().indexOf('opera') != -1 ? 1 : 0;
this.mozilla = navigator.appName.toLowerCase().indexOf('netscape') != -1 && !this.safari ? 1 : 0;
this.winMozilla = this.mozilla && this.win ? 1 : 0;
this.winIE = this.iE && this.win && !this.opera ? 1 : 0;
this.macIE = this.iE && this.mac ? 1 : 0;
}
var browser = new Browser();
// framebuster
if (window!= top)top.location.href=location.href;
// getElementById
function getEl(el){
return document.getElementById(el);
};
// addStyle
function addStyle(selector,properties){
if (document.styleSheets) {
var s = document.getElementsByTagName('STYLE');
if (s.length == 0){
var sheet = document.createElement('style');
sheet.setAttribute('type','text/css');
document.getElementsByTagName('HEAD')[0].appendChild(sheet);}
if (browser.winIE){
var lastSheet = document.styleSheets[document.styleSheets.length - 1];
lastSheet.addRule(selector, properties);}
else {var lastSheet = s[0];
lastSheet.appendChild(document.createTextNode(selector + ' { ' + properties + ' }'));}
}
};
/*
* media player , mdi, aug 2006
* adapted for 2K, mdi, okt 2007
* TODO: size doesn't work well, strange behaviour in FF en IE
*/
// check if the proper media player version is installed
function hasWMPPlugin(){
// windows ie
if (window.ActiveXObject){
try{
var obj = new ActiveXObject("WMPlayer.OCX");
obj = null;
return 1;
}
catch(e){
return 0;
}
}
//other
else if(navigator.plugins.length){
for (var i = 0; i < navigator.plugins.length; i++){
if (navigator.plugins[i].name.toLowerCase().indexOf('windows media') != -1){
return 1;
}
}
}
return 0;
};
//embedded media Class
var windowsMediaPlayers = [];
function WindowsMediaPlayer(oArg){
// instance variables
this.id = oArg.id;
this.uri = oArg.uri;
this.width = oArg.width ? oArg.width : 400;
this.height = oArg.height ? oArg.height : 333;
this.mimeType = 'video/x-ms-asf-plugin';
this.hasWMPPlugin = hasWMPPlugin();
//type="video/x-ms-asf-plugin"
this.type = 'application/x-oleobject';
windowsMediaPlayers[this.id] = this;
// functions
//hide and show content
if (this.hasWMPPlugin){
addStyle('#' + this.id + '-container .alternate-content','display:none !important;');
}
// create (window onload)
this.create = function(){
// embed the player
if (!this.hasWMPPlugin || !getEl(this.id + '-container')){
return;
}
this.embedPlayer();
};
//do all the checks and implement the player
this.embedPlayer = function(){
var container = getEl(this.id + '-container');
var w = '';
if (browser.mac){
w += '';
}
else {
var wData = ' data="' + this.uri +'"';
var wClassid = '';
if (browser.winIE){
wData = '';
wClassid = ' classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"'; // 7 and up
//wClassid = ' classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"'; // < 7
}
w += '';
}
container.innerHTML = w;
};
//play fullscreen
this.playFullScreen = function(){
var player = getEl(this.id);
if (player.playState==3){ // gives error if not playing, 3 = playing
player.setAttribute('fullScreen', 'true');
}
else {
alert('Het video-bestand kan alleen op het volledige scherm \nworden getoond indien deze afspeelt.')
}
};
};
// create all the media objects
function createWindowsMediaPlayers(){
for (var i in windowsMediaPlayers){
windowsMediaPlayers[i].create();
}
};
// window.onload
if (window.addEventListener){
window.addEventListener('load', createWindowsMediaPlayers,false);
}
else if (window.attachEvent){
window.attachEvent("onload", createWindowsMediaPlayers);
}
/*
* end media player
*/
/* init */
if (browser.winMozilla){
getEl('countdown-container').style.marginLeft = '-30px';
var cDWidth = 480;
var cDHeight = 315;
}
else {
var cDWidth = 440;
var cDHeight = 315;
}
var countdown = new WindowsMediaPlayer({
uri: "media/boek7_aftelfilmpjes/potter_nog_0_dagen.wmv",
id:"countdown",
width:cDWidth,
height:cDHeight
});