/* http://www.dustindiaz.com/getelementsbyclass/ 
How it works

It’s simple. It works just how you think getElementsByClass would work, except better.

   1. Supply a class name as a string.
   2. (optional) Supply a node. This can be obtained by getElementById, or simply by just throwing in “document” (it will be document if don’t supply a node)). It’s mainly useful if you know your parent and you don’t want to loop through the entire D.O.M.
   3. (optional) Limit your results by adding a tagName. Very useful when you’re toggling checkboxes and etcetera. You could just supply “input“. Or, if you’re like me, and you said Good Bye to IE5, you can use the “*” asterisk as a catch-all (meaning ‘any element).

See getElementsByClass() in action Have Fun! 
*/
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
/* waarden van stijlen uit de stylsheet opvragen, voor zowel IE als gecko-bràwsers */
/* http://www.naarvoren.nl/artikel/css_modificatie/ */
function getRealStyle(id,styleName) {
	var element = document.getElementById(id);
	var realStyle = null;
	if (element.currentStyle)
		realStyle = element.currentStyle[styleName];
	else if (window.getComputedStyle)
	realStyle = window.getComputedStyle(element,null)[styleName];
	return realStyle;
}
function getVar(name)
/* haalt GET-variabelen uit de url */
/* http://scripts.franciscocharrua.com/javascript-get-variables.php */
         {
         get_string = document.location.search;         
         return_value = '';
         
         do { //This loop is made to catch all instances of any get variable.
            name_index = get_string.indexOf(name + '=');
            
            if(name_index != -1)
              {
              get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);
              
              end_of_value = get_string.indexOf('&');
              if(end_of_value != -1)                
                value = get_string.substr(0, end_of_value);                
              else                
                value = get_string;                
                
              if(return_value == '' || value == '')
                 return_value += value;
              else
                 return_value += ', ' + value;
              }
            } while(name_index != -1)
            
         //Restores all the blank spaces.
         space = return_value.indexOf('+');
         while(space != -1)
              { 
              return_value = return_value.substr(0, space) + ' ' + 
              return_value.substr(space + 1, return_value.length);
							 
              space = return_value.indexOf('+');
              }
          
         return(return_value);        
         }
/** COOKIES **/
/** http://www.quirksmode.org/js/cookies.html **/
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
/** END COOKIES **/
/* The JavaScript Source!! http://javascript.internet.com 
 emailcheck */
function checkEmail(email) {
	return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
}
//  End -->

function equalizeColumns() {
	P7_equalCols2(0,'LeftSet','DIV','MiddleSet','DIV','RightSet','DIV');
}

// browserdetectie
// bron: http://gmatter.wordpress.com/2006/11/21/another-way-to-detect-ie7-in-javascript/
function browserIsMac() {
	return (navigator.appVersion.indexOf('Mac')!=-1) ? true : false;
}
function browserIsIEmac() {
	return ((document.all)&&(isMac)) ? true : false;
}
function browserIsIE5() {
	return ((document.all)&&(navigator.appVersion.indexOf('MSIE 5.')!=-1)) ? true : false;
}
function browserIsIE6() {
	return document.all && navigator.appVersion.indexOf('MSIE 6.')!=-1;
//	if ((document.all)&&(navigator.appVersion.indexOf('MSIE 6.')!=-1)) return true else return false;
}
function browserIsIE7() {
	return ((document.all)&&(navigator.appVersion.indexOf('MSIE 7.')!=-1)) ? true : false;
}
function browserIsFirefox() {
	return (navigator.userAgent.indexOf('Firefox')!=-1)?true:false;
}
function browserIsNetscape() {
	return (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;
}
//

/* dynamische subnav uitzetten voor printen */
function hideSubNav() {
	subnav = getElementsByClass('SubNav');	
	for (i = 0; i < subnav.length; i++)	{
		subnav[i].style.visibility = 'hidden';
		subnav[i].style.position = 'static';
		subnav[i].style.top = -500;
//		subnav[i].style.top = '-500px';
		subnav[i].style.left = -500;
//		subnav[i].style.left = '-500px';
		subnav[i].style.zIndex = -500;
	}
	subnavitem = getElementsByClass('SubNavItem');	
	for (i = 0; i < subnavitem.length; i++)	{
		subnavitem[i].style.visibility = 'hidden';
		subnavitem[i].style.position = 'static';
		subnavitem[i].style.top = -500;
//		subnav[itemi].style.top = '-500px';
		subnavitem[i].style.left = -500;
//		subnav[itemi].style.left = '-500px';
		subnavitem[i].style.zIndex = -500;
	}
}
function showSubNav() {
	subnav = getElementsByClass('SubNav');	
	for (i = 0; i < subnav.length; i++)	{
		subnav[i].style.visibility = 'visible';
	}
	subnavitem = getElementsByClass('SubNavItem');	
	for (i = 0; i < subnavitem.length; i++)	{
		subnavitem[i].style.visibility = 'visible';
	}
}
/*************************/

/*multiple onload events*/
/* Voeg een functie toe  door OLadd('functie') */
/* run de onloadhandler zo vaak je wil door OLonload() */
function OLstart(){
	window.onload = onloadstart;
}
function onloadstart(){
	for(var i = 0;i < onloadhandlerarray.length;i++)
	if(onloadhandlerarray[i]){
		eval(onloadhandlerarray[i]);
		}
}
function OLadd(func){
	onloadhandlerarray[onloadhandlerarray.length] = func;
}
var onloadhandlerarray = new Array();

function deletep7(){
	/*removeElement('p7eq1');
	removeElement('p7eq3');
	removeElement('p7eq5');	
	OLstart();*/
	document.getElementById('p7eq1').style.paddingBottom=0;
	document.getElementById('p7eq3').style.paddingBottom=0;
	document.getElementById('p7eq5').style.paddingBottom=0;
}
/* om een flashfilmpje te kunnen besturen vanuit javascript - probleem in firefox */
function getFlashMovieObject(movieName)
{
  if (window.document[movieName]) 
  {
      return window.document[movieName];
  }
  if (navigator.appName.indexOf("Microsoft Internet")==-1)
  {
    if (document.embeds && document.embeds[movieName])
      return document.embeds[movieName]; 
  }
  else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
  {
    return document.getElementById(movieName);
  }
}	
function removeElement(id)
{
	if (document.getElementById(id)){
	var Node=document.getElementById(id);
	Node.parentNode.removeChild(Node);
	}
}
//next line to remove IE Flickering
try { document.execCommand('BackgroundImageCache', false, true);} catch(e) {}
OLstart();