if (typeof vpro === "undefined" || !vpro) {
    window.vpro = {};
}


/**
* json2.js
*/
/*
http://www.JSON.org/json2.js
2009-09-29
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
/*jslint evil: true, strict: false */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
if (!this.JSON) {
this.JSON = {};
}
(function () {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function (key) {
return isFinite(this.valueOf()) ?
this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z' : null;
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function (key) {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ?
'"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string' ? c :
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' :
'"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0 ? '[]' :
gap ? '[\n' + gap +
partial.join(',\n' + gap) + '\n' +
mind + ']' :
'[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
k = rep[i];
if (typeof k === 'string') {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0 ? '{}' :
gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
mind + '}' : '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function' ?
walk({'': j}, '') : j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());
/**
* jquery/jquery-jsonp.js
*/
// jquery.jsonp 1.1.3 (c)2010 Julian Aubourg | MIT License
// http://code.google.com/p/jquery-jsonp/
(function(d){var b=function(n){return n!==undefined&&n!==null},m=function(p,n,o){b(p)&&p.apply(n,o)},e=function(n){setTimeout(n,0)},f="",a="&",k="?",l="success",g="error",i=d("head"),h={},c={callback:"C",url:location.href},j=function(s){s=d.extend({},c,s);var r=s.beforeSend,A=0;s.abort=function(){A=1};if(b(r)&&(r(s,s)===false||A)){return s}var q=s.success,o=s.complete,v=s.error,C=s.dataFilter,G=s.callbackParameter,w=s.callback,D=s.cache,n=s.pageCache,t=s.url,I=s.data,x=s.timeout,z,H,F,E;t=b(t)?t:f;I=b(I)?((typeof I)=="string"?I:d.param(I)):f;b(G)&&(I+=(I==f?f:a)+escape(G)+"=?");!D&&!n&&(I+=(I==f?f:a)+"_"+(new Date()).getTime()+"=");z=t.split(k);if(I!=f){H=I.split(k);E=z.length-1;E&&(z[E]+=a+H.shift());z=z.concat(H)}F=z.length-2;F>0&&(z[F]+=w+z.pop());var p=z.join(k),B=function(J){b(C)&&(J=C.apply(s,[J]));m(q,s,[J,l]);m(o,s,[s,l])},y=function(J){m(v,s,[s,J]);m(o,s,[s,J])},u=h[p];if(n&&b(u)){e(function(){b(u.s)?B(u.s):y(g)});return s}e(function(){if(A){return}var J=d("<iframe style='display:none' />").appendTo(i),L=J[0],N=L.contentWindow||L.contentDocument,P=N.document,K,Q,R=function(S,T){n&&!b(T)&&(h[p]=f);K();y(b(T)?T:g)},M=function(T){N[T]=undefined;try{delete N[T]}catch(S){}},O=w=="E"?"X":"E";if(!b(P)){P=N;N=P.getParentNode()}P.open();N[w]=function(S){A=1;n&&(h[p]={s:S});e(function(){K();B(S)})};N[O]=function(S){(!S||S=="complete")&&!A++&&e(R)};s.abort=K=function(){clearTimeout(Q);P.open();M(O);M(w);P.write(f);P.close();J.remove()};P.write(['<html><head><script src="',p,'" onload="',O,'()" onreadystatechange="',O,'(this.readyState)"><\/script></head><body onload="',O,'()"></body></html>'].join(f));P.close();x>0&&(Q=setTimeout(function(){!A&&R(f,"timeout")},x))});return s};j.setup=function(n){d.extend(c,n)};d.jsonp=j})(jQuery);
/**
* jquery/jquery-easycouch.js
*/
/*
* jQuery.easyCouch
* - Provides an easy way to query CouchDB, with a special focus on JSONP support
* and other servers than 'localhost'
*
* EXAMPLE
* var dbc = $.easyCouch({
* "server" : "http://mycouchserver.domain.com",
* "jsonp" : true,
* "debug" : function(data) {
* console.log("[DEBUG]", data);
* }
* });
*
* dbc.db("cooldb").all_docs(function(data) {
* console.log(data);
* });
*
* dbc.db("cooldb").view(
* {
* "designdoc" : "designdoc",
* "view" : "get-all-and-more"
* },
* {
* "key" : "1234",
* },
* function(data) {
* console.log(data);
* }
* );
*
* (c) 2010 VPRO Digitaal, the Netherlands / Hay Kranen < http://www.vpro.nl/digitaal >
*
*/
(function($) {
$.easyCouch = function(config) {
// Extend the defaults with the arguments the caller might give
$.extend({
"server" : "http://localhost",
"jsonp" : false,
"debug" : false
}, config);
// Public methods
this.all_dbs = function(cb, opts) {
ajax({
"cb" : cb,
"url" : "/_all_dbs",
"opts" : opts
});
}
this.db = function(dbname, opts) {
return {
// Properties
"dbname" : dbname,
"url" : "/" + encodeURIComponent(dbname) + "/",
// Methods
// Get all documents
"all_docs" : function(cb, opts) {
ajax({
"cb" : cb,
"url" : this.url + "_all_docs",
"opts" : opts
});
},
// Get a single document
"get" : function(id, cb, opts) {
ajax({
"cb" : cb,
"url" : this.url + encodeDocId(id),
"opts" : opts
});
},
// Get a view
"view" : function(args, opts, cb) {
ajax({
"cb" : cb,
"url" : this.url + "_design/" + args.designdoc + "/_view/" +
args.view,
"opts" : opts
});
}
}
} // this.db()
function debug(arg) {
if (config.debug) {
config.debug(arg);
}
}
// Private utility methods
function ajax(args) {
var url = config.server + args.url;
if (args.opts) {
url += encodeOptions(args.opts);
}
if (config.jsonp) {
// Add a '?callback=?' to the end of the string for JSONP
url += (args.opts) ? '&' : '?';
url += 'callback=?';
}
if (config.debug) {
// Debug is defined as a function that you can use to debug your
// output
debug($.extend(args, {
"constructedUrl" : url
}));
}
$.jsonp({
"url" : url,
"beforeSend" : function() {
debug("Doing a JSONP call for: " + url);
},
"error" : function() {
args.cb({
"error" : "No data for this request"
});
},
"success" : function(data) {
debug(data);
args.cb(data);
}
});
// For now we use the jQuery.jsonp library
/*
// Execute the query
$.getJSON(url, function(data) {
// Debug the output as well?
if (config.debug) {
config.debug(data);
}
args.cb(data);
});
*/
}
// Convert a options object to an url query string.
// ex: {key:'value',key2:'value2'} becomes '?key="value"&key2="value2"'
function encodeOptions(options) {
var buf = [];
if (typeof(options) === "object" && options !== null) {
for (var name in options) {
if ($.inArray(name, ["error", "success"]) >= 0) {
continue;
}
var value = options[name];
if ($.inArray(name, ["key", "startkey", "endkey"]) >= 0) {
value = toJSON(value);
}
buf.push(encodeURIComponent(name) + "=" + encodeURIComponent(value));
}
}
return buf.length ? "?" + buf.join("&") : "";
}
function encodeDocId(docID) {
var parts = docID.split("/");
if (parts[0] == "_design") {
parts.shift();
return "_design/" + encodeURIComponent(parts.join('/'));
}
return encodeURIComponent(docID);
}
function toJSON(obj) {
// Extra check if the JSON object is available, else you need the json2.js
// library
if (typeof JSON == "undefined") {
alert("A browser with native JSON support or the json2.js libray is required");
}
return obj !== null ? JSON.stringify(obj) : null;
}
return this;
}
})(jQuery);
/**
* jquery/jquery-coverslide.js
*/
/*
* jQuery coverslide
* Turns any stack of <li> elements into a cool sliding caroussel
* (c) 2010 VPRO Digitaal, the Netherlands / Hay Kranen < http://www.vpro.nl/digitaal >
*/
(function($) {
$.fn.coverslide = function(args) {
// Check if the selector has any elements, else return false
if (this.length == 0) {
return false;
}
args = args || {};
var ul = this,
marginTotal, marginSpace,
animationTime = 300, fadeTime = 100,
length = $(ul).find("li").length;
// Build an index of all elements in the site
function buildIndex() {
$(ul).find("li").each(function(i) {
// Set the z-index, because we're going to use that for indexing
$(this).css('z-index', i);
});
$(ul).find("li:last .hover").hide();
}
function getSlideByZ(z) {
var found;
$(ul).find("li").each(function() {
if ($(this).css('z-index') == z) {
found = $(this);
return false;
}
});
return found;
}
function spaceElements() {
var $first = $(ul).find("li:first");
marginTotal = ($(ul).width()) - ($first.width());
marginSpace = marginTotal / (length - 1);
$(ul).find("li").each(function(i) {
$(this).animate({
"left" : (i * marginSpace) + "px"
}, 1000);
});
}
function slideAll(time) {
// Time is a bit of a hack
time = (animationTime / time) || animationTime;
// First slide out the first element
var $last = getSlideByZ(length - 1);
$last.animate({
"left" : '+=' + $last.width()
}, time, function() {
// Give new z-index to all
$(ul).find("li").each(function() {
var oldZ = Number($(this).css('z-index'));
var newZ = (oldZ + 1) % length;
$(this).css('z-index', newZ);
switch(newZ) {
case 0:
$(this).animate({
"left" : '0px'
}, time);
break;
default:
$(this).animate({
"left" : '+=' + marginSpace
}, time);
}
});
});
return false;
}
// TODO: this could be more elegant
function isTop($el) {
if (typeof $el.jquery == "undefined") {
$el = $($el);
}
return $el.css('z-index') == (length - 1);
}
// IE6 and IE7 contain a bug that prevents <img> tags inside a <a> to
// be clickable and also doesn't show a pointer cursor.
// This functions detects if you're using IE6/IE7 and returns true/false
function isIE() {
var version = $.browser.version.substr(0,1);
return (typeof $.browser.msie !== "undefined") && (version === "6" || version === "7");
}
function autoRotate() {
var interval = args.autoRotate * 1000, inUl = false;
$(ul).find("li").hover(
function() {
inUl = true;
},
function() {
inUl = false;
}
);
setInterval(function() {
if (!inUl) {
slideAll();
}
}, interval);
}
function init() {
buildIndex();
spaceElements();
if (isIE()) {
$(ul).find("a").each(function() {
$(this).css('cursor', 'pointer');
});
}
$(ul).find("li").each(function() {
$(this).click(function() {
if (isTop(this)) {
if (isIE()) {
window.location.href = $(this).find("a").attr('href');
}
return true;
}
var $el = $(this);
$(this).find(".hover").fadeOut(fadeTime, function() {
// Okay, let's check if we need to repeat this function
// That's a bit of a hack, but otherwise it's pretty complex
var z = (length - 1) - $el.css('z-index');
for (var i = 0; i < z; i++) {
slideAll(z);
}
});
return false;
});
$(this).hover(
function() {
if (isTop(this)) {
return false;
}
// IE doesn't correctly support opacity on elements with
// transparent PNG's, so we just show instead of fade
if ($.support.opacity) {
$(this).find(".hover").fadeIn(fadeTime);
} else {
$(this).find(".hover").show();
}
},
function() {
if (isTop(this)) {
return false;
}
if ($.support.opacity) {
$(this).find(".hover").fadeOut(fadeTime);
} else {
$(this).find(".hover").hide();
}
}
);
});
if (args.autoRotate) {
autoRotate();
}
$(document).keydown(function(e) {
if ((e.keyCode == 37) || (e.keyCode == 39)) {
slideAll();
}
});
}
init();
}
})(jQuery);
/**
* jquery/jquery-gmap.js
*/
/**
* jQuery gMap
*
* @url http://gmap.nurtext.de/
* @author Cedric Kastner <cedric@nur-text.de>
* @version 1.0.0
*/
(function(f){function e(g){return typeof g=="object"&&g instanceof Array}f.fn.gMap=function(g){if(!window.GBrowserIsCompatible||!GBrowserIsCompatible())return this;var a=f.extend({},f.fn.gMap.defaults,g);return this.each(function(){gmap=new GMap2(this);if(!a.latitude&&!a.longitude)if(e(a.markers)&&a.markers.length>=1){a.latitude=a.markers[0].latitude;a.longitude=a.markers[0].longitude}else{a.latitude=34.885931;a.longitude=9.84375;a.zoom=2}gmap.setCenter(new GLatLng(a.latitude,a.longitude),a.zoom);
if(a.controls.length==0)gmap.setUIToDefault();else for(var b=0;b<a.controls.length;b++)eval("gmap.addControl(new "+a.controls[b]+"());");a.scrollwheel==true&&a.controls.length!=0&&gmap.enableScrollWheelZoom();gicon=new GIcon;gicon.image=a.icon.image;gicon.shadow=a.icon.shadow;gicon.iconSize=e(a.icon.iconsize)?new GSize(a.icon.iconsize[0],a.icon.iconsize[1]):a.icon.iconsize;gicon.shadowSize=e(a.icon.shadowsize)?new GSize(a.icon.shadowsize[0],a.icon.shadowsize[1]):a.icon.shadowsize;gicon.iconAnchor=
e(a.icon.iconanchor)?new GPoint(a.icon.iconanchor[0],a.icon.iconanchor[1]):a.icon.iconanchor;gicon.infoWindowAnchor=e(a.icon.infowindowanchor)?new GPoint(a.icon.infowindowanchor[0],a.icon.infowindowanchor[1]):a.icon.infowindowanchor;for(b=0;b<a.markers.length;b++){var d=a.markers[b],c=new GMarker(new GPoint(d.longitude,d.latitude),gicon);if(d.html){GEvent.addListener(c,"click",function(){c.openInfoWindowHtml('<div class="gmap_marker">'+d.html+"</div>")});c&&gmap.addOverlay(c);d.popup==true&&c.openInfoWindowHtml('<div class="gmap_marker">'+
d.html+"</div>")}else c&&gmap.addOverlay(c)}})};f.fn.gMap.defaults={latitude:0,longitude:0,zoom:6,markers:[],controls:[],scrollwheel:true,icon:{image:"http://www.google.com/mapfiles/marker.png",shadow:"http://www.google.com/mapfiles/shadow50.png",iconsize:[20,34],shadowsize:[37,34],iconanchor:[9,34],infowindowanchor:[9,2]}}})(jQuery);
/**
* jquery/jquery-hotkeys.js
*/
(function(jQuery){jQuery.fn.__bind__=jQuery.fn.bind;jQuery.fn.__unbind__=jQuery.fn.unbind;jQuery.fn.__find__=jQuery.fn.find;var hotkeys={version:'0.7.9',override:/keypress|keydown|keyup/g,triggersMap:{},specialKeys:{27:'esc',9:'tab',32:'space',13:'return',8:'backspace',145:'scroll',20:'capslock',144:'numlock',19:'pause',45:'insert',36:'home',46:'del',35:'end',33:'pageup',34:'pagedown',37:'left',38:'up',39:'right',40:'down',109:'-',112:'f1',113:'f2',114:'f3',115:'f4',116:'f5',117:'f6',118:'f7',119:'f8',120:'f9',121:'f10',122:'f11',123:'f12',191:'/'},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":"\"",",":"<",".":">","/":"?","\\":"|"},newTrigger:function(type,combi,callback){var result={};result[type]={};result[type][combi]={cb:callback,disableInInput:false};return result;}};hotkeys.specialKeys=jQuery.extend(hotkeys.specialKeys,{96:'0',97:'1',98:'2',99:'3',100:'4',101:'5',102:'6',103:'7',104:'8',105:'9',106:'*',107:'+',109:'-',110:'.',111:'/'});jQuery.fn.find=function(selector){this.query=selector;return jQuery.fn.__find__.apply(this,arguments);};jQuery.fn.unbind=function(type,combi,fn){if(jQuery.isFunction(combi)){fn=combi;combi=null;}
if(combi&&typeof combi==='string'){var selectorId=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();var hkTypes=type.split(' ');for(var x=0;x<hkTypes.length;x++){delete hotkeys.triggersMap[selectorId][hkTypes[x]][combi];}}
return this.__unbind__(type,fn);};jQuery.fn.bind=function(type,data,fn){var handle=type.match(hotkeys.override);if(jQuery.isFunction(data)||!handle){return this.__bind__(type,data,fn);}
else{var result=null,pass2jq=jQuery.trim(type.replace(hotkeys.override,''));if(pass2jq){result=this.__bind__(pass2jq,data,fn);}
if(typeof data==="string"){data={'combi':data};}
if(data.combi){for(var x=0;x<handle.length;x++){var eventType=handle[x];var combi=data.combi.toLowerCase(),trigger=hotkeys.newTrigger(eventType,combi,fn),selectorId=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();trigger[eventType][combi].disableInInput=data.disableInInput;if(!hotkeys.triggersMap[selectorId]){hotkeys.triggersMap[selectorId]=trigger;}
else if(!hotkeys.triggersMap[selectorId][eventType]){hotkeys.triggersMap[selectorId][eventType]=trigger[eventType];}
var mapPoint=hotkeys.triggersMap[selectorId][eventType][combi];if(!mapPoint){hotkeys.triggersMap[selectorId][eventType][combi]=[trigger[eventType][combi]];}
else if(mapPoint.constructor!==Array){hotkeys.triggersMap[selectorId][eventType][combi]=[mapPoint];}
else{hotkeys.triggersMap[selectorId][eventType][combi][mapPoint.length]=trigger[eventType][combi];}
this.each(function(){var jqElem=jQuery(this);if(jqElem.attr('hkId')&&jqElem.attr('hkId')!==selectorId){selectorId=jqElem.attr('hkId')+";"+selectorId;}
jqElem.attr('hkId',selectorId);});result=this.__bind__(handle.join(' '),data,hotkeys.handler)}}
return result;}};hotkeys.findElement=function(elem){if(!jQuery(elem).attr('hkId')){if(jQuery.browser.opera||jQuery.browser.safari){while(!jQuery(elem).attr('hkId')&&elem.parentNode){elem=elem.parentNode;}}}
return elem;};hotkeys.handler=function(event){var target=hotkeys.findElement(event.currentTarget),jTarget=jQuery(target),ids=jTarget.attr('hkId');if(ids){ids=ids.split(';');var code=event.which,type=event.type,special=hotkeys.specialKeys[code],character=!special&&String.fromCharCode(code).toLowerCase(),shift=event.shiftKey,ctrl=event.ctrlKey,alt=event.altKey||event.originalEvent.altKey,mapPoint=null;for(var x=0;x<ids.length;x++){if(hotkeys.triggersMap[ids[x]][type]){mapPoint=hotkeys.triggersMap[ids[x]][type];break;}}
if(mapPoint){var trigger;if(!shift&&!ctrl&&!alt){trigger=mapPoint[special]||(character&&mapPoint[character]);}
else{var modif='';if(alt)modif+='alt+';if(ctrl)modif+='ctrl+';if(shift)modif+='shift+';trigger=mapPoint[modif+special];if(!trigger){if(character){trigger=mapPoint[modif+character]||mapPoint[modif+hotkeys.shiftNums[character]]||(modif==='shift+'&&mapPoint[hotkeys.shiftNums[character]]);}}}
if(trigger){var result=false;for(var x=0;x<trigger.length;x++){if(trigger[x].disableInInput){var elem=jQuery(event.target);if(jTarget.is("input")||jTarget.is("textarea")||jTarget.is("select")||elem.is("input")||elem.is("textarea")||elem.is("select")){return true;}}
result=result||trigger[x].cb.apply(this,[event]);}
return result;}}}};window.hotkeys=hotkeys;return jQuery;})(jQuery);
/**
* jquery/jquery-imagehover.js
*/
/*
* jQuery.imageHover
* (c) 2010 VPRO Digitaal, the Netherlands / Frank Bosma < http://www.vpro.nl/digitaal >
*/
(function($) {
// images are expected to be backed by black
$.fn.imageHover = function(){
return $(this).each(function(){
var trgt = $(this);
(function(){
var target = trgt;
var body = $('body');
var img = target.find('img');
var oldOp = new Array();
img.each(function(){
oldOp.push($(this).css('opacity'));
});
target.bind('mouseenter', function(){
img.each(function(idx){
$(this).css('opacity', oldOp[idx] * 0.7);
});
}).bind('mouseleave', function(){
img.each(function(idx){
$(this).css('opacity', oldOp[idx]);
});
});
})();
});
};
})(jQuery);
/**
* jquery/jquery-overviewlistitem.js
*/
/*
* jQuery.overviewListItem
* (c) 2010 VPRO Digitaal, the Netherlands / Frank Bosma < http://www.vpro.nl/digitaal >
*/
(function($) {
$.fn.overviewListItem = function(){
return $(this).each(function(){
$(this).bind('mouseenter', function(){
$(this).css("cursor", "pointer");
}).bind('mouseleave', function(){
$(this).css("cursor", "default");
}).bind('click', function(){
var a = $(this).find('a');
if( a.length > 0){
var af = a.eq(0);
if((af.attr("target"))){
if(af.attr("target") != "_blank"){
window.location = af.attr("href");
}
}else{
window.location = af.attr("href");
}
}
});
});
};
})(jQuery);
/**
* jquery/jquery-social-b.js
*/
// Bookmarks
(function($){
$.socialbookmark={
findRelElm: function(elm){
var jelm = $(elm),
ref = jelm.attr('href'),
find = ref.indexOf('#');
ref = ref.substr(find);
return ref;
},
handler: function(){
if($.socialbookmark.actElm && !$($.socialbookmark.actElm).is(':hidden')){
$.socialbookmark.hide();
} else {
$.socialbookmark.show.call(this);
}
return false;
},
hideNotinActElm: function(e){
var jElm = $(e.target);
if(jElm.is($.socialbookmark.actElm) || jElm.parents($.socialbookmark.actElm).size()){
return;
}
$.socialbookmark.hide();
},
show:function(){
var ref = $.socialbookmark.findRelElm(this);
$(ref).animate({height: 'show',opacity: 'show'}, {duration: 400});
$.socialbookmark.actElm = ref;
$(document).bind('click', $.socialbookmark.hideNotinActElm);
return false;
},
actElm: null,
hide: function(){
$($.socialbookmark.actElm).animate({height: "hide", opacity: "hide"});
$('body').unbind('click', $.socialbookmark.hideNotinActElm);
},
init: function(sel){
var jElm = $(sel);
if(jElm.size()){
var ref = $.socialbookmark.findRelElm(jElm[0]);
$(ref).css({display: 'none'});
jElm.click($.socialbookmark.handler);
}
}
};
})(jQuery);
/**
* jquery/jquery-stickyfooter.js
*/
/**
* jQuery.stickyFooter
* (c) 2010 VPRO Digitaal, the Netherlands / Hay Kranen < http://www.vpro.nl/digitaal >
*
* Resize one element to make the container of that element as high as the
* full page. Handy for making a footer 'stick' to the bottom of the page.
*
* This function expects an object with the following properties
* - baseElement : the element that is the container for the rest of the page
* - resizeElement : the element you want to resize
* - manualHeight : you can use this value to manually trim the value that
* resizeElement is resized to
***/
(function($) {
$.fn.stickyFooter = function(args) {
// First calculate the height of all elements
var noResizeHeight = 0;
$(args.baseElement + " > div").each(function() {
if (this.id != $(args.resizeElement).attr('id')) {
noResizeHeight += $(this).height();
}
});
// This can be handy sometimes
if (args.manualHeight) noResizeHeight += args.manualHeight;
var contentHeight = noResizeHeight + $(args.resizeElement).height();
// Resize if the height of the window is higher than the content height
if ($(window).height() > contentHeight) {
var newHeight = $(window).height() - noResizeHeight;
$(args.resizeElement).height(newHeight);
}
}
})(jQuery);
/**
* ../../../../module/media/js/vpro/media/media.js
*/
/**
* package vpro.media
*/
if (window.vpro){
(function(){
if(!vpro.media){
vpro.media = {};
}
})();
}
/**
* vpro/vpro-media-mediaobject.js
*/
/**
* vpro.media.MediaObject
* (C) 2010 - VPRO Digitaal / Hay Kranen < http://www.vpro.nl/digitaal >
*/
if (typeof vpro.media == "undefined") {
vpro.media = {};
}
(function($){
vpro.media.MediaObject = function(args) {
args = args || {};
// Shortcuts for lazy people
var vDate = vpro.util.date,
vString = vpro.util.string,
currentData,
dbc = $.easyCouch({
"server" : (args.server) ? args.server : "http://api.vpro.nl",
"jsonp" : true
});
this.getProgram = function (urn, cb) {
dbc.db("media").get(urn, function(d) {
if (d.error) {
cb({
"error" : "No data found for this urn"
});
return false;
}
// Re-format to a friendly format
var mapping = {
"title" : d.title,
"description" : d.description,
"events" : [],
"duration" : new Date(d.duration),
"genres" : d.genres,
"previousepisode" : {},
"nextepisode" : {},
"locations" : d.locations
};
// Do we have scheduleevents?
if (d.scheduleEvents) {
$.each(d.scheduleEvents, function(key, event) {
mapping.events.push({
"broadcasters" : vString.implode(", ", event.broadcasters),
"rerun" : event.rerun,
"date" : vDate.parseIso8601(event.start)
});
});
}
currentData = d;
cb(mapping);
});
}
this.getNextGroupBroadcast = function (urn, cb) {
dbc.db("media").view(
{
"designdoc" : "schedule",
"view" : "events-by-group-id-and-start"
},
{
"startkey" : [urn, vDate.createIso8601()],
"endkey" : [urn, {}],
"limit" : 1,
"include_docs" : true
},
function(data) {
if (data.error || data.rows.length < 1) {
return false;
}
var doc = data.rows[0].doc;
// MGNL-540: We need to take care of reruns in the 'future'
// Search all the rows and take the first one that isn't in
// the past
for (var i in doc.scheduleEvents) {
var event = doc.scheduleEvents[i];
var eventStart = vDate.parseIso8601(event.start);
var now = new Date();
if (eventStart > now) {
// Okay, this is still in the future
break;
}
}
cb({
"title" : doc.title,
"date" : eventStart,
"channel" : event.channel,
"rerun" : event.rerun
});
}
);
}
this.getProgramsByGroupId = function (urn, cb) {
dbc.db("media").view(
{
"designdoc" : "media", // used to be 'schedule', see MSE-123
"view" : "programs-by-group-id"
},
{
"key" : urn,
"include_docs" : true
},
function(data) {
cb(data);
}
);
}
this.getAllDocs = function(cb) {
dbc.db("media").all_docs(function(data) {
cb(data);
}, {
"include_docs" : true
});
}
return this;
} // vpro.media.MediaObject
})(jQuery);
/**
* vpro/vpro-util.js
*/
// Util basic namespace
vpro.util = {
// Javascript port of PHP's print_r()
// From: http://www.openjs.com/scripts/others/dump_function_php_print_r.php
"dump" : function(arr, level) {
var dumped_text = "";
if(!level) level = 0;
//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += " ";
if(typeof(arr) == 'object') { //Array/Hashes/Objects
for(var item in arr) {
var value = arr[item];
if(typeof(value) == 'object') { //If it is an array,
dumped_text += level_padding + "'" + item + "' ...\n";
dumped_text += vpro.util.dump(value,level+1);
} else {
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
}
}
} else { //Stings/Chars/Numbers etc.
dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
},
// Wraps around different consoles, such as Firebug's
"log" : function() {
if (typeof console !== "undefined") {
console.log(arguments);
}
}
};
/**
* vpro/vpro-util-date.js
*/
/* Date utils */
vpro.util.date = {
"dateString" : function(nr, pad, data) {
pad = pad || false;
var date = data[nr];
if (pad) {
date = date.slice(0, pad);
}
return date;
},
"dayString" : function(nr, pad) {
// Note that Javascript always returns sunday as the first day of the
// week
return vpro.util.date.dateString(nr, pad, [
'zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag',
'zaterdag'
]);
},
"monthString" : function(nr, pad) {
return vpro.util.date.dateString(nr, pad, [
'januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli',
'augustus', 'september', 'oktober', 'november', 'december'
]);
},
"parseIso8601" : function(string) {
if (typeof string == "undefined") {
return false;
}
var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
"(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
"(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
var d = string.match(new RegExp(regexp));
var offset = 0;
var date = new Date(d[1], 0, 1);
if (d[3]) { date.setMonth(d[3] - 1); }
if (d[5]) { date.setDate(d[5]); }
if (d[7]) { date.setHours(d[7]); }
if (d[8]) { date.setMinutes(d[8]); }
if (d[10]) { date.setSeconds(d[10]); }
if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); }
if (d[14]) {
offset = (Number(d[16]) * 60) + Number(d[17]);
offset *= ((d[15] == '-') ? 1 : -1);
}
return date;
},
"createIso8601" : function(date) {
date = date || new Date();
// Shortcut for lazy people
var zero = vpro.util.string.zero;
return vpro.util.string.printf("%s-%s-%sT%s:%s+01",
date.getUTCFullYear(),
zero(date.getMonth() + 1),
zero(date.getDate()),
zero(date.getHours()),
zero(date.getMinutes())
);
}
};
/**
* vpro/vpro-util-string.js
*/
/* String utils */
vpro.util.string = {
"repeat" : function(i,m) {
for (var o = []; m > 0; o[--m] = i) {
// Nada
}
return(o.join(''));
},
"printf" : function() {
// from http://code.google.com/p/sprintf/
var i = 0, a, f = arguments[i++], o = [], m, p, c, x;
while (f) {
if (m = /^[^\x25]+/.exec(f)) {
o.push(m[0]);
} else if (m = /^\x25{2}/.exec(f)) {
o.push('%');
} else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
if (((a = arguments[m[1] || i++]) == null)) {
throw("vpro.util.string.printf(): Too few arguments, or one of you arguments is undefined: " + i);
}
if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) {
throw("vpro.util.string.printf(): Expecting number but found " + typeof(a));
}
switch (m[7]) {
case 'b': a = a.toString(2); break;
case 'c': a = String.fromCharCode(a); break;
case 'd': a = parseInt(a); break;
case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
case 'o': a = a.toString(8); break;
case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
case 'u': a = Math.abs(a); break;
case 'x': a = a.toString(16); break;
case 'X': a = a.toString(16).toUpperCase(); break;
}
a = (/[def]/.test(m[7]) && m[2] && a > 0 ? '+' + a : a);
c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
x = m[5] - String(a).length;
p = m[5] ? str_repeat(c, x) : '';
o.push(m[4] ? a + p : p + a);
} else {
throw ("vpro.util.string.printf(): Unknown exception");
}
f = f.substring(m[0].length);
} // while(f)
return o.join('');
},
"enquote" : function(arg) {
return vpro.util.string.printf('"%s"', arg);
},
"implode" : function(glue, pieces) {
glue = glue || "";
pieces = pieces || [];
var str = "";
for (var key in pieces) {
var value = pieces[key];
str += value;
// Don't put the glue after the last piece
if (key < (pieces.length - 1)) {
str += glue;
}
}
return str;
},
"zero" : function(nr) {
if (nr > 9) {
return nr;
}
return '0' + nr;
}
}; // vpro.util.string;
/**
* tegenlicht.js
*/
/*
* Tegenlicht global functions
*
* This contains all functions for the Tegenlicht site
*/
(function($) {
window.Tegenlicht = {
"hacks" : {
"init" : function() {
// Easier click for the latest comments
$(".latestcomments li").click(function() {
var link = $(this).find(".link a").attr('href');
window.location = link;
});
// The second div.box in the #footer should have a special class
$("#footer div.box:first").addClass('first');
var self = window.Tegenlicht.hacks;
self.commentField();
self.switchDesign();
self.alignContent();
self.hideFreemarkerErrors();
self.kickerToSubtitle();
self.removeTitleFromA();
},
// Very ugly way to hide lots of fields in the comment form
"commentField" : function() {
var mt = $("#your-comment input[name='messageTitle']");
if( mt.length > 0){
mt.parents('div').eq(0).hide();
}
},
"switchDesign" : function() {
// Using the Konami code :)
var input = "";
var pattern = "38384040373937396665";
// Lol, in IE $(window).keydown doesn't work, but $(document) does!
$(document).keydown(function(e) {
input += e ? e.keyCode : event.keyCode;
if (input.indexOf(pattern) != -1) {
$("body").wrap('<marquee scrollamount="100"></marquee>');
}
});
},
"hideFreemarkerErrors" : function() {
$("xmp").each(function() {
var $b = $(this).parent().parent().parent().find("b");
if ($b.html() === null) return true;
if (!$b.html().match(/freemarker/i)) return true;
var fmError = $(this).html();
var $fmDiv = $b.parent();
var html = '<div class="box freemarker-error"><h1 style="color:red;font-size:1.8em;' +
'border-bottom: 10px solid red;">' +
'Foutmelding</h1><p>Deze pagina bevat een fout waardoor ' +
'de pagina niet getoond kan worden zoals gebruikelijk. ' +
'U kunt de redactie mailen om ze hiervan op de hoogte te ' +
'stellen.</p><p><a href="#" class="freemarker-error">Klik hier om de ' +
'volledige foutmelding te zien</a></p>' +
'<textarea rows="40" cols="80" class="freemarker-error" style="display:none; ' +
'font-size:1.2em;overflow:auto;">' +
fmError + '</textarea></div>';
$fmDiv.attr('style', '').html(html);
$("a.freemarker-error").click(function() {
$("textarea.freemarker-error").slideToggle();
});
});
},
"alignContent" : function() {
function getBorders(selector){
if(typeof selector == "string"){
return $(selector);
}else{
return ($("#main > *").filter(function(){
return ($(this).css("borderTopStyle") == "solid" || $(this).css("borderBottomStyle") == "solid");
}));
}
}
function getTop(borders){
if (borders.length > 0) {
var b=borders.eq(0);
if (b.css("borderTopStyle") == "solid") {
return b.position().top + (parseFloat(b.css("marginTop"))) - mainTop;
}
else {
return (b.position().top + b.outerHeight(true) - ( parseFloat(b.css("paddingBottom"))) - mainTop);
}
}
return 0;
}
function alignBorders(selector){
return (getTop(getBorders(selector)));
}
function alignToAd(ad){
var top = getTop(getBorders());
var adTitle = firstChild.find("> h3");
if(adTitle.length > 0){
top -= adTitle.eq(0).outerHeight(true);
}
return top;
}
//Aligns the #extra content with #main's black border
var main = $("#main");
var extras = $("#extras");
if (main.length > 0 && extras.length > 0) {
var bodyId = $("body").attr("id");
var mainTop = main.position().top;
var remH = 0;
switch (bodyId) {
case "newsoverview":
case "episodeoverview":
case "theme":
case "fileoverview":
case "categories":
remH = alignBorders();
break;
case "article":
remH = alignBorders("#main h1");
break;
case "search-results":
//align with the ad or borders
if(extras.children().length > 0){
var firstChild = extras.children().eq(0);
if(firstChild.is('.vpro-ster-banner')){
remH = alignToAd(firstChild);
}else{
remH = alignBorders();
}
}
break;
default:
break;
}
if( remH > 0){
extras.css("marginTop", remH);
}
}
},
removeTitleFromA : function(){
// MGNL-3950
// a tags in the page should not have a title attribute
$("#main .pager a").attr("title", null);
},
kickerToSubtitle : function(){
//deal with kickers
var kicked = $('h1:has(em[class=""])');
if( kicked.length > 0){
kicked.each(function(){
var em = $(this).find('em[class=""]').remove().html();
$(this).after('<p class="kicker">'+ em +'</p>');
});
}
}
}, // hacks
// Functions specific for the author instance of Magnolia, hence the edit mode
"author" : {
"init" : function() {
this.editShortcuts();
this.disableFooterEditingOutsideHome();
// disable bubbling of editbar clicks (for teasers and overview items)
$("table[class^='mgnlControlBar']").bind("click", function(e){
e.stopPropagation();
});
},
"editShortcuts" : function() {
// Adds a few handy shortcuts for the editing mode on the website
var loc = String(document.location);
$(document).bind("keydown", "Alt+p", function() {
mgnlPreview(loc.indexOf('mgnlPreview=true') === -1);
});
$("body").focus();
},
"disableFooterEditingOutsideHome" : function() {
// MGNL-645 Editing the footer outside the homepage gives an error
// so we disable that and alert the user instead
if ($("body").attr('id') === "home") return false;
$("#site-info .mgnlControlBarSmall")
.html(''.concat(
'<span class="mgnlControlButtonSmall">',
'Ga naar de homepage om de footer te bewerken',
'</span>'
))
.css('cursor', 'pointer')
.click(function(e) {
$("#nav-sec-home a").click();
});
}
}, // author
"episode" : {
"init" : function() {
if (typeof vpro.pageproperties != "undefined") {
window.Tegenlicht.episode.fillInfo(vpro.pageproperties.mediaUrn);
}
},
"showError" : function(msg, hideright) {
if (msg) {
$("#stage .error").html(msg);
}
$("#stage .error").show();
$("#stage .nojslink").hide();
if (hideright) {
$("#stage .schedule").hide();
}
},
"getLocationsMetaData" : function(locations) {
// Loop over locations, get the url, and find out the format
var urls = [];
$.each(locations, function() {
if (!this.url) return true;
// Don't push files that are smallband
if (this.url.indexOf("/sb.") !== -1) return true;
urls.push({
"url" : this.url,
"type" : $.htmlPlayerUtil.getTypeByUrl(this.url)
});
});
return (urls.length < 1) ? false : urls;
},
"getPreferredLocation" : function (locations) {
var pref = [
"application/x-nebo-silverlight-player",
"video/x-ms-wmv"
];
// Loop over all preferences and locations, if we can't find any
// preferenced types all bets are off and we simply take the first 1
for (var i in pref) {
var p = pref[i];
for (var j in locations) {
var loc = locations[j];
if (loc.type == p) {
return loc;
}
}
}
return locations[0];
},
"showRealPlayer" : function(src) {
var width = 630,
height = 291;
$("#episodeplayer").html(vpro.util.string.printf(''.concat(
'<object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="%s" height="%s"><param name="src" value="%s"><param name="type" value="audio/x-pn-realaudio-plugin"><param name="autostart" value="true"><param name="controls" value="imagewindow"><param name="maintainaspect" value="true"><param name="console" value="video"><embed src="%s" width="%s" height="%s" type="audio/x-pn-realaudio-plugin" autostart="true" controls="imagewindow" maintainaspect="true" console="video"></embed></object><br><object classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width="%s" height="60"><param name="type" value="audio/x-pn-realaudio-plugin"><param name="autostart" value="true"><param name="controls" value="all"><param name="console" value="video"><embed type="audio/x-pn-realaudio-plugin" width="%s" height="60" autostart="true" controls="all" console="video"></embed></object>'),
width, height, src, src, width, height, width, width
));
},
"showEpisodePlayer" : function(locations) {
locations = this.getLocationsMetaData(locations);
if (!locations) return false;
var location = this.getPreferredLocation(locations);
// Realplayer?
if (location.type.indexOf("vnd.rn-real") !== -1) {
this.showRealPlayer(location.url);
return false;
}
// Okay, show the player
try {
$("#episodeplayer").htmlPlayer({
"autoplay" : false,
"src" : location.url,
"_templateid" : "htmlplayer-template"
});
} catch (e) {
window.Tegenlicht.episode.showError(''.concat(
"Deze aflevering kan helaas (nog) niet worden getoond. <br />",
"U kunt proberen om deze aflevering te bekijken door ",
'<a href="' + location.url + '">op deze link te klikken</a>.',
'<br />Technische foutcode: ' + e.message
));
}
},
"fillInfo" : function(urn) {
var self = this,
MediaObject = vpro.media.MediaObject(),
firstRepeat,
repeats;
MediaObject.getProgram(urn, function(d) {
// A program might note exist OR a program might be available
// but have no locations or events, and hence, no information
if (d.error || (d.events.length === 0 && typeof d.locations === "undefined")) {
window.Tegenlicht.episode.showError(false, true);
return;
}
// Just a handy shortcut for 'vpro.util.string' and 'vpro.util.date'
var vDate = vpro.util.date,
vString = vpro.util.string,
firstDate;
if (d.events.length < 1) {
// Some episodes do not have an original broadcast date,
// hide the whole schedule in those cases
firstDate = new Date();
$("#stage .schedule").hide();
} else {
firstDate = d.events[0].date;
}
// Check if there are any repeats
if (d.events.length < 1) {
$("#stage .firstrepeat").hide();
} else {
// First format
var repeatStrings = [];
for (var i = 1; i < d.events.length; i++) {
var date = d.events[i].date;
repeatStrings.push(vString.printf(
"Herhaling: %s %s %s %s:%s %s",
vDate.dayString(date.getDay()),
date.getDate(),
vDate.monthString(date.getMonth()),
vString.zero(date.getHours()),
vString.zero(date.getMinutes()),
(typeof d.events[i].channel != "undefined") ? d.events[i].channel : ""
));
}
// Special case for the very first broadcast
firstRepeat = repeatStrings.shift();
// Make <li> elements for all repeats
repeats = "";
$.each(repeatStrings, function(key, value) {
repeats += vString.printf('<li class="metafont">%s</li>', value);
});
// Check if we only have one repeat, in that case, hide the
// 'more' button
if (d.events.length == 2) {
$("#stage .firstrepeat a").hide();
}
}
// Create a mapping for the episodeinfo block
var mapping = {
".schedule .day" : firstDate.getDate(),
".schedule .month" : vDate.monthString(firstDate.getMonth(), 3),
".schedule-right h3" : vDate.monthString(firstDate.getMonth()) + " " + firstDate.getFullYear(),
".schedule-right h4 span" : firstRepeat,
".schedule-right .more" : repeats,
".nownext.left h4" : d.previousepisode.title,
".nownext.left .more a" : d.previousepisode.description,
".nownext.right h4" : d.nextepisode.title,
".nownext.right .more a" : d.nextepisode.description
};
$.each(mapping, function(name) {
$("#stage " + name).html(mapping[name]);
});
if (d.locations) {
self.showEpisodePlayer(d.locations);
} else {
self.showError(false, false);
}
});
}
}, // Episode
"global" : {
"fillNextBroadcast" : function(d) {
$("#nav-meta").html(''.concat(
'<h2>Volgende uitzending</h2>',
'<div class="date">',
'<div class="day">' + d.day + '</div>',
'<div class="month">' + d.month + '</div>',
'</div>',
'<section>',
'<h3>' + d.title + '</h3>',
'<time datetime="' + d.datetime + '">' + d.date_time_channel + '</time>',
'</section>'
)).show();
},
"getNextBroadcast" : function(urn) {
var MediaObject = vpro.media.MediaObject();
MediaObject.getNextGroupBroadcast(urn, function(d) {
if (d.error) {
return false;
}
// Just a handy shortcut for 'vpro.util.string' and 'vpro.util.date'
var vDate = vpro.util.date, vString = vpro.util.string;
// Format the whole datetime string
var datetime = vString.printf(
"%s %s %s %s:%s %s %s",
vDate.dayString(d.date.getDay()),
d.date.getDate(),
vDate.monthString(d.date.getMonth()),
vString.zero(d.date.getHours()),
vString.zero(d.date.getMinutes()),
d.channel,
(d.rerun) ? "(H)" : "" // When this is a rerun, add a (H) behind the date
);
window.Tegenlicht.global.fillNextBroadcast({
"day" : d.date.getDate(),
"month" : vDate.monthString(d.date.getMonth(), 3),
"title" : d.title,
"date_time_channel" : datetime,
"datetime" : ''.concat(
d.date.getFullYear(), '-',
vString.zero(d.date.getMonth()), '-',
vString.zero(d.date.getDay()), 'T',
vString.zero(d.date.getHours()), ':',
vString.zero(d.date.getMinutes()), '+01:00'
)
});
});
return;
},
fixNpo : function(){
var npo = $("#npo-button");
if( npo.length){
var script = npo.attr("data-script");
if( script){
$.getScript(script);
}
}
}
},
"init" : {
"jQuery" : function() {
// Fill the episode paragraph
window.Tegenlicht.global.getNextBroadcast(vpro.pageproperties.groupUrn);
// Page-specific inits
if ($("body").attr('id')) {
window.Tegenlicht.episode.init();
}
$(".teaser.latest ul > li, .teaser.latest ol > li, .tegenlicht-teaser").overviewListItem();
$(".teaser.latest ul > li, .teaser.latest ol > li, .tegenlicht-teaser").filter(function(){
return (!$(this).is('.section'));
}).imageHover();
$("#extras .infofile > a, #extras .upcoming a.next-episode").imageHover();
if($(".pageshare-right li.share").length > 0){
$.socialbookmark.init("li.share a");
}
if($(".pageshare-left").length > 0){
if(!$(".pageshare-left").is('.noprint')){
$(".pageshare-left > ul").prepend('<li class="print"><a href="#">Print</a></li>');
$(".pageshare-left li.print a").bind('click', function(){
window.print();
return false;
});
}
}
window.Tegenlicht.hacks.init();
// Init coverslide
$(".coverslide ul").coverslide({
"autoRotate" : 10
});
window.Tegenlicht.global.fixNpo();
}
} // init
};
/******* GLOBAL INIT *******/
$(document).ready(function() {
window.Tegenlicht.init.jQuery();
});
})(jQuery);

