function Trim(value) {
  value = value.replace(/^\s+/,''); 
  value = value.replace(/\s+$/,'');
  return value;
}

// JScript source code
    function CreateButton(Component)
    {
        jQuery(Component).each(function() {

                var newLeft = jQuery('<div class="button_left">');
                var newRight = jQuery('<div class="button_right">');
                var newContent = jQuery('<div class="button_content">');
                var newInput = jQuery('<div class="total-button">');
                var t = this;
                
                if (t.type!="hidden")
                {
                    jQuery(t).before(newInput);
                    jQuery(t).before(newLeft);

                    newInput.append(newLeft);
                    jQuery(t).before(newContent);                                

                    newInput.append(newContent);
                    newContent.prepend(t);    

                    jQuery(t).after(newRight);
                    newInput.append(newRight);
                    
                    
                    if(Component!=".displayarticleblock .buttonstyle") {
                        if (navigator.appName=="Netscape")
                        {
                            jQuery(newInput[0]).width((jQuery(newLeft[0]).width() + jQuery(newRight[0]).width() + jQuery(t).width() + 4))
                        }
                    }
                }
            }
        );
    }
      
    function moveButtoncontainer()
    {
        jQuery('.addreactionblock .formholder').each(
            function() {
                
                var t = this;
                var buttonContainer = jQuery('.button-container', t);
                
                jQuery(t).after(buttonContainer);
            }
        );
    }
     
    function changeFirstNavigation()
    {
        var firstElement = jQuery('#nav_content .navigationblock ul li.fc a');
        if(firstElement) {
            firstElement[0].innerHTML = 'Home';
        }
    } 
    
    function changeForm()
    {
        jQuery('.surveycontainer .q_multipleresponse').each(
            function() {
                
                var t = this;
                var newDiv = jQuery('<div class="checkboxes">');
                var spanText = jQuery('.question-text',t);
                var getTables = jQuery('table',t);
                var getSelect = jQuery('select',t);
                var breakIt  = jQuery('br',t);             
                var element = new Array;
                var type = new Array;
                var aantalChilds;
                
                if ((getTables.length+getSelect.length)==0)
                {
                    breakIt.remove();
                    aantalChilds = t.childNodes.length;
                    
                    for (var x = 0; x<aantalChilds;x++)
                    {
                        if (t.childNodes[x].tagName=='INPUT')
                        {    
                            element[x] = t.childNodes[x];
                            type[x] = t.childNodes[x].tagName;
                        }
                        
                        if (t.childNodes[x].tagName=="LABEL")
                        {
                            element[x] = t.childNodes[x];
                            type[x] = t.childNodes[x].tagName;
                        }
                    }
                    
                    for (var x = 0; x<aantalChilds;x++)
                    {
                        if(element[x] =='object');                        
                        {
                            newDiv.append(element[x]);
                        }
                        if(type[x] == 'LABEL')
                        {
                            newDiv.append(jQuery('<br>'));
                        }
                    }
                        
                    spanText.after(newDiv);
                }
            }
        );
    }

function hoverTab() {
    jQuery('.tabnavigationblock ul li').each( function() {
        var t=this;
        jQuery(t).mouseover(function(){jQuery(t).addClass('menu_hover')}).mouseout(function(){jQuery(t).removeClass('menu_hover')});
    });
    
    jQuery('.linklistblock ul li').each(function() {
        var t=this;
        jQuery(t).mouseover(function(){jQuery(t).addClass('menu_hover')}).mouseout(function(){jQuery(t).removeClass('menu_hover')});    
    });
}

function changeJoblist() {
    jQuery('.jobboardmodule .radiobutton, .jobboardmodule .checkbox').not(jQuery('.jobreactionblock .radiobutton')).each(function() {
        var t = this;
        var newDiv = jQuery('<div>');
        var children = t.childNodes;
        var fields = new Array;
        var labels = new Array;
        var labelnr = 0;
        
        for (var x=0;x<children.length;x++) {
        
            if(children[x].tagName=="LABEL") {
                labelnr++;
                var label1 = children[x];
            }

            if (children[x].tagName=="LABEL" & labelnr>1) {
                fields[x] = children[x];
                labels[x] = 'label';
            }
            
            if (children[x].tagName=="INPUT" ) {
                fields[x] = children[x];
            }
        }
        
        jQuery(label1).after(jQuery(newDiv));
        
        for (var y=1;y<fields.length;y++) {
            if(fields[y]) {
                jQuery(newDiv).append(jQuery(fields[y]));
            }
            if(labels[y]=='label') {    
                jQuery(fields[y]).after(jQuery('<br/>'));
            }
        }
        
    });
}

function removeEmptyParagraph() {
    jQuery('.displayjob p').each( function() {
        var t=this;
        
        if(t.innerHTML=="") {
            jQuery(t).css('display','none');
        }
    });
}

function changeFormButton() {
    jQuery('.surveycontainer').each( function() {
        var t=this;
        var formQuestions = jQuery('.surveyquestion',t);
        if (formQuestions.length==0) {
            var plainText = jQuery('.plain-text', t);
            if(plainText)
            {
                jQuery('.button-container', t).addClass("firstbox");
            }
        }
    });
}
   
function changePreviousNext() {
    jQuery('.searchresultsblock .pages .previous').each( function() {
        var t = this;
        
        var classes=t.className.split(" ");
        
        for(var x = 0;x<classes.length;x++) {
            if (classes[x]=="inactive") {
                jQuery(t).addClass('inactiveprev');
            }
        }
    });
    
    jQuery('.searchresultsblock .pages .next').each( function() {
        var t = this;
        
        var classes=t.className.split(" ");
        
        for(var x = 0;x<classes.length;x++) {
            if (classes[x]=="inactive") {
                jQuery(t).addClass('inactivenext');
            }
        }
    });    
}

function replaceText() {

    jQuery("#navigatie ul li a").not(jQuery("#navigatie li li a")).imageReplace({font: 'GoudySans Md BT', transparentcolor: '#7FA4C7' });

    jQuery('#text h1, #text h2').not(jQuery('#text .plain-text h2')).imageReplace({font: 'GoudySans Md BT', transparentcolor: '#7FA4C7', maxwidth: '300px' });
    jQuery('#hometext h1, #hometext h2').not(jQuery('#hometext .plain-text h2')).imageReplace({font: 'GoudySans Md BT', transparentcolor: '#7FA4C7', maxwidth: '320px' });
    jQuery('#homeleft h1, #homeleft h2').not(jQuery('#homeleft .plain-text h2')).imageReplace({font: 'GoudySans Md BT', transparentcolor: '#7FA4C7', maxwidth: '280px' });
    jQuery('#homecenter h1, #homecenter h2').not(jQuery('#homecenter .plain-text h2')).imageReplace({font: 'GoudySans Md BT', maxwidth: '310px' });
    jQuery('#homeright h1, #homeright h2').not(jQuery('#homeright .plain-text h2')).imageReplace({font: 'GoudySans Md BT', maxwidth: '290px' });
    jQuery('#cl_top h1, #cl_top h2').not(jQuery('#cl_top .plain-text h2')).imageReplace({font: 'GoudySans Md BT', maxwidth: '270px' });
    jQuery('#cl_center h1, #cl_center h2').not(jQuery('#cl_center .plain-text h2')).imageReplace({font: 'GoudySans Md BT', transparentcolor: '#AEC4DB', maxwidth: '270px' });
    jQuery('#cl_bottom h1, #cl_bottom h2').not(jQuery('#cl_bottom .plain-text h2')).imageReplace({font: 'GoudySans Md BT', maxwidth: '270px' });
    jQuery('#cr_left h1, #cr_left h2').not(jQuery('#cr_left .plain-text h2')).imageReplace({font: 'GoudySans Md BT', maxwidth: '400px' });
    jQuery('#cr_right h1, #cr_right h2').not(jQuery('#cr_right .plain-text h2')).imageReplace({font: 'GoudySans Md BT', maxwidth: '250px' });
    jQuery('#footerleft h1, #footerleft h2').not(jQuery('#footerleft .plain-text h2')).imageReplace({font: 'GoudySans Md BT', transparentcolor: '#004990', maxwidth: '300px' });
    jQuery('#footercenter h1, #footercenter h2').not(jQuery('#footercenter .plain-text h2')).imageReplace({font: 'GoudySans Md BT', transparentcolor: '#004990', maxwidth: '400px' });
    jQuery('#footerright h1, #footerright h2').not(jQuery('#footerright .plain-text h2')).imageReplace({font: 'GoudySans Md BT', transparentcolor: '#004990', maxwidth: '250px' });
    jQuery('h2').not(jQuery('.plain-text h2')).imageReplace({font: 'GoudySans Md BT' });
}

function setSameHeight() {
    var leftHeight  = jQuery('#footerleft').height();
    var centerHeight = jQuery('#footercenter').height();
    var rightHeight = jQuery('#footerright').height();
    var extra = 0;
    
    var maxHeight =  Math.max(leftHeight ,centerHeight);
    maxHeight =  Math.max(rightHeight,maxHeight);
    
    if(navigator.appName.toLowerCase() != 'netscape') {
        extra = 20;
    }
    
    var value = 0;
    
    if(leftHeight==maxHeight) {
        jQuery('#footercenter').height((maxHeight + extra) + 'px');
        jQuery('#footerright').height((maxHeight + extra) + 'px');
    }
    if(centerHeight==maxHeight) {
        jQuery('#footerleft').height((maxHeight + extra) + 'px');
        jQuery('#footerright').height((maxHeight + extra) + 'px');
    }
    if(rightHeight==maxHeight) {
        jQuery('#footerleft').height((maxHeight + extra) + 'px');
        jQuery('#footercenter').height((maxHeight + extra) + 'px');
    }
}

function randomFiveFooter() {
    jQuery('#footer .searchresultsblock').each(function() {
        var block = this;
        var listItems = jQuery('ul li', block);
        var listCount = listItems.length;
        
        for (var x = 0;x<5;x++) {
            var randomValue = Math.round(Math.random()*(listCount-1));
            if(jQuery(listItems[randomValue]).css('display')=="block"){
                x--;
            }
            jQuery(listItems[randomValue]).css('display','block');
        }
    });
    
    setSameHeight();
 
}

jQuery(function(){
    //CreateButton('.button-container input');
    //CreateButton('.linkblock input');
    //CreateButton('.linklistblock input');
    //CreateButton('.registrationlink');
    //CreateButton('.eventregistrationblock .addperson a');
    randomFiveFooter();
    moveButtoncontainer();
    changeForm();
    hoverTab();
    changeJoblist();
    removeEmptyParagraph();
    changeFormButton();
    changePreviousNext();
    replaceText();
});

