function NiftyCheck()
{
if(!document.getElementById || !document.createElement)
    return(false);
var b=navigator.userAgent.toLowerCase();
if(b.indexOf("msie 5")>0 && b.indexOf("opera")==-1)
    return(false);
return(true);
}

function Rounded(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    AddTop(v[i],bk,color,"",size);
    AddBottom(v[i],bk,color,"",size);
    }
}

function RoundedTop(selector,bk,color,pos,size){
var i;
var v=getElementsBySelector(selector);
for(i=0;i<v.length;i++)
{
    AddTop(v[i],bk,color,pos,size);
}
}

function RoundedBottom(selector,bk,color,pos,size){
var i;
var v=getElementsBySelector(selector);
for(i=0;i<v.length;i++)
    AddBottom(v[i],bk,color,pos,size);
}

function AddTop(el,bk,color,pos,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
if( pos && (pos=="r" || pos=="l" ) )
	cn+=pos;
d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,pos,size){
var i;
var d=document.createElement("b");
var cn="r";
var lim=4;
if(size && size=="small"){ cn="rs"; lim=2}
if( pos && (pos=="r" || pos=="l" ) )
	cn+=pos;
d.className="rbottom";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=document.createElement("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    d.appendChild(x);
    }
el.appendChild(d,el.firstChild);
}

function getElementsBySelector(selector){
var i;
var s=[];
var selid="";
var selclass="";
var tag=selector;
var objlist=[];
if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    objlist.push(document.getElementById(selid));
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
	//alert( v[i].className );
	var classes = v[i].className.split(' ');
	for( j=0; j<classes.length; j++ )
	{
	    if(classes[j]==selclass){
	        objlist.push(v[i]);
	        }
	}
}
return(objlist);
}

/**
Ronde hoekjes maken van de divs
*/
function roundedInitiate(){
 	if(!NiftyCheck())
 	return;

 	// menu's linkerkant (licht en donker groen)
 	RoundedTop( "div.menuDark", "#e8e8f3", "#85b916", "l" );
 	RoundedTop( "div.menuLight", "#e8e8f3", "#c9dc98", "l" );
 	RoundedBottom( "div.menuDark", "#e8e8f3", "#85b916", "l" );
 	RoundedBottom( "div.menuLight", "#e8e8f3", "#c9dc98", "l" );

 	// zoekbox
 	RoundedTop( "div.searchBox", "#e8e8f3", "#85b916", "l" );
 	RoundedBottom( "div.searchBox", "#e8e8f3", "#85b916", "l" );

 	// header(s)
 	RoundedTop( "div#logonHeader", "#e8e8f3", "#04378b" );

 	RoundedTop( "div#hLeft", "#e8e8f3", "#04378b", "l" );
 	RoundedBottom( "div#hLeft", "#e8e8f3", "#04378b", "l" );
 	RoundedTop( "div#hRight", "#e8e8f3", "#04378b", "r" );
 	RoundedBottom( "div#hRight", "#e8e8f3", "#04378b", "r" );


 	// footer
 	Rounded( "div#centerFooter", "#e8e8f3", "#04378b")

 	// menu rechterkant (lichtgroen)
 	RoundedTop( "div.menuBoxRightLight", "#e8e8f3", "#c9dc98", "r" );
 	RoundedBottom( "div.menuBoxRightLight", "#e8e8f3", "#c9dc98", "r" );
 	// menu rechterkant (donkergroen)
 	RoundedTop( "div.menuBoxRightDark", "#e8e8f3", "#85b916", "r" );
 	RoundedBottom( "div.menuBoxRightDark", "#e8e8f3", "#85b916", "r" );
}


function addCaptionsToImages() {
	wrapImagesInDiv( 'captionFigure', ['align', 'style'], [ 'float', 'text-align' ] );
}

function wrapImagesInDiv( className, attributes, styles ) {
	//var images = document.getElementsByClassName(className);
 	var images = $('img.captionFigure');
 	for ( var i = 0; i < images.length; ++i ) {
 		var img = images[i];
 		// Lift the image out of the page and insert a div under it.
 		var parent = img.parentNode;
 		var frame = document.createElement('div');
 		var txt = document.createTextNode(img.getAttribute('title'));

 		parent.insertBefore(frame, img);
 		parent.removeChild(img);
 		frame.appendChild(img);
 		frame.appendChild(txt);
 		// These are special cases.  We always copy these from the image to the
 		// div.
 		frame.style.width = parseInt( img.getAttribute('width') ) + 4 + 'px';
 		frame.className = img.className;
 		// Copy specified attributes and style properties from the image to the
 		// div.
 		var cssFloat = null;
 		for ( var j = 0; j < attributes.length; ++j ) {
 			if( (attributes[j] == 'align') && (img.getAttribute(attributes[j]) == 'right' || img.getAttribute(attributes[j]) == 'left'))
 			{
 				cssFloat = img.getAttribute(attributes[j]);
 			}
 			else
 			{
 				frame.setAttribute(attributes[j], img.getAttribute(attributes[j]));
 			}
 		}
 		for ( var j = 0; j < styles.length; ++j ) {
 			frame.style[styles[j]] = img.style[styles[j]];
 		}
 		frame.style.width = parseInt( img.getAttribute('width') ) + 4 + 'px';
 		if( cssFloat != null )
 		{
 			frame.style.cssFloat = cssFloat;
 		}
 	}
}


function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}

