function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function openPlayer() {
	window.open('http://player.omroep.nl/?aflid=3294708','player','width=800,height=560,scrollbars=no');
}

window.progOpened = '';
function openProg(progid) {
  thisItem = document.getElementById(progid);
	if (thisItem.style.display!='none') {
	thisItem.style.display='none';
	window.progOpened = '';
	}	
	else {
	thisItem.style.display='';
	if ( window.progOpened!='' ){
		document.getElementById(window.progOpened).style.display='none';
		}
	window.progOpened = progid;
	}
}

window.faqOpened = '';
function openFaq(faqid) {
  thisFaqItem = document.getElementById(faqid);
  thisAntwItem = document.getElementById('antw' + faqid);
  
	if (thisAntwItem.style.display!='none') {
	thisAntwItem.style.display='none';
	thisFaqItem.className = 'veelGesteldeVraag veelGesteldeVraagOff';
	window.faqOpened = '';
	}	
	else {
	thisAntwItem.style.display='block';
	thisFaqItem.className = 'veelGesteldeVraag veelGesteldeVraagOn';
	if ( window.faqOpened!='' ){
		document.getElementById('antw' + window.faqOpened).style.display='none';
		document.getElementById(window.faqOpened).className = 'veelGesteldeVraag veelGesteldeVraagOff';
		}
	window.faqOpened = faqid;
	}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function OpenLiveWeb(url)
{
  if (url && url != "")
  {
     if (url.match(/^javascript:/))
     { eval(url); }
     else
     {
        //OpenPopupSized(url, 475, 265, 50, 50);
        window.open (url, 'player','width=475,height=265,left=50,top=50');
     }
   }
}

function isReady(form) {
    if (form.naam.value == "" || form.naam.value == null) {
      alert("Geen naam opgegeven!");
      form.name.focus();
      return false;
    }
    re = /^.+\@\[?(\w|[-.])+\.[a-zA-Z]{2,3}|[0-9]{1,3}\]?\$/;
    if (!re.test(form.email.value)) {
      alert("Geen geldig email adres opgegeven.");
      form.email.focus();
      return false;
    }
    if (form.titel.value == "" || form.titel.value == null) {
      alert("Geen titel opgegeven!");
      form.titel.focus();
      return false;
    }
    if (form.bericht.value == "" || form.bericht.value == null) {
      alert("Geen bericht opgegeven!");
      form.bericht.focus();
      return false;
    }
    return true;
  }
  
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' moet een geldig emailadres zijn.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is verplicht.\n'; }
  } if (errors) alert('Het formulier kan nog niet worden verstuurd:\n'+errors);
  if (errors == '') document.getElementById('mailform').submit();  
  document.MM_returnValue = (errors == '');

}


var myrules = {
	'.results' : function(el){
		el.onmouseover = function(){
			this.className = 'resultsOn clearfix'
		}
		el.onmouseout = function(){
			this.className = 'results clearfix'
		}
	},
	'td.description' : function(el){
		el.onmouseover = function(){
			this.className = 'description descriptionOn'
		}
		el.onmouseout = function(){
			this.className = 'description'
		}
	},
	'td.item' : function(el){
		el.onmouseover = function(){
			this.className = 'item descriptionOn'
		}
		el.onmouseout = function(){
			this.className = 'item'
		}
	},
	'li.linkBoxSmall' : function(el){
		el.onmouseover = function(){
			this.style.backgroundcolor = '#E4F81D';
		}
	},
	'td.programma' : function(el) {
		el.onclick = function() {
			openProg('desc' + this.id);
		}
				el.onmouseover = function(){
			this.className = 'programma programmaOn'
		}
		el.onmouseout = function(){
			this.className = 'programma'
		}
	},
	'.veelGesteldeVraag' : function(el){
		el.onclick = function(){
			openFaq(this.id);
		}
	}
};
var Behaviour = {
	list : new Array,
	register : function(sheet){
		Behaviour.list.push(sheet);
	},
	start : function(){
		Behaviour.addLoadEvent(function(){
			Behaviour.apply();
		});
	},
	apply : function(){
		for (h=0;sheet=Behaviour.list[h];h++){
			for (selector in sheet){
				list = document.getElementsBySelector(selector);
				if (!list){
					continue;
				}
				for (i=0;element=list[i];i++){
					sheet[selector](element);
				}
			}
		}
	},
	addLoadEvent : function(func){
		var oldonload = window.onload;
		
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				oldonload();
				func();
			}
		}
	}
}
Behaviour.start();
function getAllChildren(e) {
  return e.all ? e.all : e.getElementsByTagName('*');
}
document.getElementsBySelector = function(selector) {
  if (!document.getElementsByTagName) {
    return new Array();
  }
  var tokens = selector.split(' ');
  var currentContext = new Array(document);
  for (var i = 0; i < tokens.length; i++) {
    token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
    if (token.indexOf('#') > -1) {
      var bits = token.split('#');
      var tagName = bits[0];
      var id = bits[1];
      var element = document.getElementById(id);
      if (tagName && element.nodeName.toLowerCase() != tagName) {
        return new Array();
      }
      currentContext = new Array(element);
      continue;
    }
    if (token.indexOf('.') > -1) {
      var bits = token.split('.');
      var tagName = bits[0];
      var className = bits[1];
      if (!tagName) {
        tagName = '*';
      }
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      continue;
    }
    if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
      var tagName = RegExp.$1;
      var attrName = RegExp.$2;
      var attrOperator = RegExp.$3;
      var attrValue = RegExp.$4;
      if (!tagName) {
        tagName = '*';
      }
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      var checkFunction;
      switch (attrOperator) {
        case '=':
          checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
          break;
        case '~': 
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
          break;
        case '|':
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
          break;
        case '^':
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
          break;
        case '$':
          checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
          break;
        case '*':
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
          break;
        default :
          checkFunction = function(e) { return e.getAttribute(attrName); };
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (checkFunction(found[k])) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      continue;
    }
    if (!currentContext[0]){
    	return;
    }
    tagName = token;
    var found = new Array;
    var foundCount = 0;
    for (var h = 0; h < currentContext.length; h++) {
      var elements = currentContext[h].getElementsByTagName(tagName);
      for (var j = 0; j < elements.length; j++) {
        found[foundCount++] = elements[j];
      }
    }
    currentContext = found;
  }
  return currentContext;
}
Behaviour.register(myrules);

//omroep.nl script

function OpenLiveWeb(url)
{
	if (url && url != "")
  	{
     if (url.match(/^javascript:/))
     {
        eval(url);
     }
     else
     {
        window.open (url, 'player','width=475,height=265,left=50,top=50,resizable=1');
     }
   }
}

function OpenPopupSized(url,theWidth,theHeight,theLeft,theTop, extra)
{
  var features = "width=" + theWidth + ",height=" + theHeight + ",left=" + theLeft + ",top=" + theTop;

  if (extra && extra != "")
  {
    features += "," + extra;
  }

  open(url, "", features); 
} 