jQuery.fn.exists = function () {
    return jQuery(this).length > 0;
}

/**
* Returns true if the current browser is Internet Explorer.
*/
function isIE() {
    return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

/* Homepage flash video's */
var flashVideos = [];

function playFlash(index) {
	var item = flashVideos[index];
	if(item) {
		var swfobj = new SWFObject(item[0], item[1], item[2], item[3], item[4], item[5]);
		swfobj.addParam("wmode", "transparent");
		swfobj.write(item[6]);
	}
}


function Trim(value) {
    value = value.replace(/^\s+/, '');
    value = value.replace(/\s+$/, '');
    return value;
}

jQuery.fn.labelify = function (c) { c = jQuery.extend({ text: "title", labelledClass: "" }, c); var d = { title: function (a) { return Trim(jQuery(a).attr("title")) }, label: function (a) { return Trim(jQuery("label[for=" + a.id + "]").text()) } }; var e; var f = jQuery(this); return jQuery(this).each(function () { if (jQuery(this).val() != '') return; if (typeof c.text === "string") { e = d[c.text] } else { e = c.text }; if (typeof e !== "function") { return } var a = e(this); if (!a) { return } jQuery(this).data("label", e(this).replace(/\n/g, '')); jQuery(this).focus(function () { if (this.value === jQuery(this).data("label")) { this.value = this.defaultValue; jQuery(this).removeClass(c.labelledClass) } }).blur(function () { if (this.value === this.defaultValue) { this.value = jQuery(this).data("label"); jQuery(this).addClass(c.labelledClass) } }); var b = function () { f.each(function () { if (this.value === jQuery(this).data("label")) { this.value = this.defaultValue; jQuery(this).removeClass(c.labelledClass) } }) }; jQuery(this).parents("form").submit(b); jQuery(window).unload(b); if (this.value !== this.defaultValue) { return } this.value = jQuery(this).data("label"); jQuery(this).addClass(c.labelledClass) }) };

/**
* Transforms a search block into a sliding two column search box. 
*/
function createHomeSearchBox() {

	if( jQuery('div.uqwrapper').hasClass('vakantiewerk')){
		return;
	}

    var selector = jQuery('#searchboxHome .searchblock');
    var links = jQuery('<div id="links"><span class="options">' + (typeof (moreOptions) === 'string' ? moreOptions : 'xxxxxxxxxxxx') + '</span></div>');
	
    jQuery(selector).wrap('<div class="searchBoxWindow"/>');
    jQuery(selector).parent().wrap('<div class="searchBoxWindowBottom"/>');
    jQuery(selector).parent().wrap('<div class="searchBoxWindowRight"/>');

    //create two boxes and place the fields
    jQuery(selector).append('<div class="searchwrapper"><div class="searchLeft"></div><div class="searchRight"></div><div class="clear"></div></div>');
    jQuery(selector).find('.textsearch').appendTo('.searchLeft');
    jQuery(selector).find('div[class*=fromzip], div[class*=client_city], div[class*=fromzip_maxdist], .button-container').appendTo('.searchLeft');
    jQuery(selector).find('.searchselectors>div').appendTo('.searchRight');
    jQuery(selector).find('.searchLeft').append(links);
	jQuery(selector).find('.button-container').prepend(links);

    jQuery('.searchLeft, .searchRight').addClass('searchselectors');

    jQuery(selector).find('.options').click(function () {
		var searchblock = jQuery('#searchboxHome .searchblock' );
	
        if (jQuery(this).hasClass('open')) {
            jQuery('div.searchRight').hide();
			
			if($.browser.msie && $.browser.version < 8){
				jQuery(searchblock).find('.button-container').animate({
					marginTop: "6px"
				}, 300, function(){ closeSearchBox(searchblock)} );
			}
			else{
				jQuery(searchblock).find('.button-container').animate({
					marginTop: "12px"
				}, 300, function(){ closeSearchBox(searchblock)});				
			}
        }
        else {
            jQuery(searchblock).animate({
                width: "492px",
                height: "297px",
                marginLeft: "0px"
            }, 200, function () {
				
               
                jQuery('.searchLeft').find('.options').addClass('open').text(typeof (quickSearch) === 'string' ? quickSearch : 'xxxxxxxxxxxx');

				jQuery('div.searchRight').fadeIn();
				
				if($.browser.msie && $.browser.version < 8){
					jQuery(this).parent().parent().parent().find('.button-container').animate({
						marginTop: "58px"
					}, 300);
				} 
				else{
						jQuery(this).parent().parent().parent().find('.button-container').animate({
							marginTop: "61px"
						}, 300);
				}

			});
			
			 jQuery('.searchLeft, .searchRight').css('height', '212px');

        }
    });
}

function closeSearchBox(elem){
	var searchblock = elem;

	jQuery(searchblock).animate({
		width: "243px",
		height: "245px",
		marginLeft: "255px"
	}, 200, function () {
		jQuery('.searchLeft, .searchRight').css('height', '160px');
		jQuery('.searchLeft').find('.options').removeClass('open').text(typeof (moreOptions) === 'string' ? moreOptions : 'xxxxxxxxxxxx');
	});
}

function linkContainer(){
    jQuery('#searchboxHome').each(function () {
        if (jQuery('#searchboxHome .linkblock').size() > 0) {
            var options = jQuery('#links');
            var link = jQuery('#searchboxHome .linkblock a');

            link.appendTo(options);
        }
    });
	
	 jQuery('#searchboxHome .searchblock').show();
}

function fixSurveyDiv() {
    jQuery('.ftpbuttons .pollbutton').each(function (count) {
        jQuery(this).addClass('button' + (count + 1)).hover(function () {
            jQuery(this).addClass('hover');
        }, function () {
            jQuery(this).removeClass('hover');
        });
    });
}

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 wrapMenu() {
    jQuery('#navigation ul.primary-nav>li').each(function (rootIndex) {
        var prev = null;
        var itemCount = 0;
		var rootcheck = 0;
		
		var belowMargin = 20;
		var maxHeight = 163;
	
		var currentHeight = 0;
		var currentWidth = 0;
		var next = 0;
		
	
		jQuery(this).children('ul').children('li').each(function (index){
			var self = jQuery(this);
			
			
			var listItemHeight = self.height();
			
			if(index != 0){
				if((currentHeight + listItemHeight + belowMargin) <= maxHeight){
					
					self.addClass('below');
					if(prev.children('ul').length <= 0){
						prev.append(jQuery('<ul></ul>').append(self));
					}else{
						prev.children('ul').append(self);
					}
					
					currentHeight = prev.height();					
				}
				else {
					currentHeight = self.height();
					prev = self;
				}
			}
			else{
				currentHeight = self.height();
				prev = self;
			}
		});
		
		jQuery(this).addClass('loaded');
    });
}

function customAlert(content, posX, posY) {

    var existingElement = document.getElementById('customAlert');
    if (existingElement) {
        document.body.removeChild(existingElement);
    }

    var element = document.createElement('div');
    var newDiv = document.createElement('div');
    element.id = 'customAlert';

    element.style.position = 'absolute';
    element.style.top = parseInt(posY) + 'px';
    element.style.left = parseInt(posX) + 'px';
    element.innerHTML = '<div id=\'customWrapper\'><div id=\'contentWrapper\'><a class=\'closealert\' href=\'javascript://\' onclick=\'document.body.removeChild(document.getElementById("customAlert"))\'>&nbsp;</a>' + content + '</div></div>';

    document.body.appendChild(element);
}

function addToBasket(e, element, url) {
    var evt = e || window.event;
	
	var inSmallMode = jQuery(element).closest('div.small').size() > 0;

    var posx = 0;
    var posy = 0;
    if (evt.pageX || evt.pageY) {
        posx = evt.pageX;
        posy = evt.pageY;
    }
    else if (evt.clientX || evt.clientY) {
        posx = evt.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
        posy = evt.clientY + document.body.scrollTop + document.documentElement.scrollTop;
    }
	
	if(inSmallMode){
	
		posx -= jQuery('.columnRight').offset().left;
		posy -= jQuery('.columnRight').offset().top;
		
		jQuery('#saveOptions .savethisjobsmall').one('click', function() {
			jQuery('#saveOptions').hide();
			$.get(
				url,
				function (data) {
					customAlert(data, posx, posy);
				});
		});
		
		jQuery('#saveOptions').show().css({ 'position': 'absolute', 'top': parseInt(posy) + 'px', 'left': parseInt(posx) + 'px'});
	}
	else {
		$.get(
			url,
			function (data) {
				customAlert(data, posx, posy);
			});
	}
}

function closeSave(){
	jQuery('#saveOptions').hide();
}

function moveTell() {
    if (jQuery('.columnRight .uniquefavouritesblock').size() > 0 && jQuery('.columnRight .mailafriendblock').size() > 0) {
        jQuery('.columnRight .mailafriendblock').appendTo(jQuery('.columnRight .uniquefavouritesblock'));
    }
}

function toggleComponents() {
	//rechterkolom 
	
	var panel1R = jQuery('.toggle .lastvisitedjobsblock');
	var panel2R = jQuery('.toggle .uniquefavouritesblock');
	
	jQuery('.toggle .uniquefavouritesblock .paging').hide();
	
	jQuery('h2', panel1R).addClass('opened');
	jQuery('.panelDiv', panel2R).hide();
	jQuery('h2', panel2R).addClass('closed');
	
	if ( jQuery(panel1R).length > 0 && jQuery(panel2R).length > 0) {
		jQuery('h2', panel1R).click( function(){checkPanels(panel1R, panel2R)}); 
		jQuery('h2', panel2R).click( function(){checkPanels(panel1R, panel2R)});

		if( navigator.userAgent.toLowerCase().indexOf('msie 7.0') != -1){
			jQuery(panel2R).css('position', 'relative'); 
		}
    }

	//linker kolom
	
	var panel1L = jQuery('.columnLeft .searchblock');
	var panel2L = jQuery('.columnLeft .jobnavigationblock');
	
	jQuery('h2', panel1L).addClass('closed');
	jQuery('.panelDiv', panel1L).hide();
	jQuery('h2', panel2L).addClass('opened');
	
	if ( jQuery(panel1L).length > 0 && jQuery(panel2L).length > 0) {
		jQuery('h2', panel1L).click( function(){checkPanels(panel1L, panel2L)}); 
		jQuery('h2', panel2L).click( function(){checkPanels(panel1L, panel2L)}); 
		
		jQuery('.col_left_top').css('min-height', '69px').css('height', '69px');
		
		jQuery('.contentRight .relatedjobsblock').hide()
		
		if( jQuery('.contentRight .searchresultsblock ul.results').length == 0){
			jQuery('.contentRight .searchresultsblock .resultcountinfo').hide();
			checkPanels(panel1L, panel2L);
		}	
    }
	
	function checkPanels(panel1, panel2){
		var open = panel1;
		var close = panel2;
	
		if( jQuery('.panelDiv', open).is(":visible") ){
			var open = panel2;
			var close = panel1;
		}
		
		if( navigator.userAgent.toLowerCase().indexOf('msie 7.0') != -1){
			jQuery('.bottomDiv', panel2R).hide();
		}
		
		jQuery('.panelDiv', close).slideUp();
		
		jQuery('.panelDiv', open).slideDown( function(){
				if( navigator.userAgent.toLowerCase().indexOf('msie 7.0') != -1){
					jQuery(panel2R).css('position', '').css('position', 'relative');
					jQuery('.bottomDiv', panel2R).show();
				}
		});
		
		
		jQuery('h2', close).addClass('closed').removeClass('opened');
		jQuery('h2', open).addClass('opened').removeClass('closed');
		
	}
}

function setHeight(which) { //IE 7 fix met sliding
    var div = jQuery(which);
	alert( div.height());
    div.css({height: div.height()});
}

function removePaging() {
    if (jQuery('.uniquefavouritesblock .paging a').size() == 6) {
        jQuery('.uniquefavouritesblock .paging').hide();
    }
    else {
        jQuery('.uniquefavouritesblock .paging').show();
    }
}

function activateSlider() {
    if (jQuery('.col_top_left_top .linklistblock').exists() && jQuery('#col_top_left_top .linklistblock li').size > 8) {
        jQuery('.col_top_left_top .linklistblock').twoRowSlider({ overflow: -1, loop: true, timer: 0 });
		jQuery('.controls').show();
    }
	else{
		if(jQuery('.col_top_left_top .linklistblock').exists()){
			jQuery('.col_top_left_top .linklistblock').twoRowSlider({ overflow: -1, loop: false, timer: 0 });
			jQuery('.controls').hide();
		}
	}
}

function setResultWidth() {
	
		jQuery('.resultcountinfo').each( function(){
			totalwidth = jQuery(this).parent().width() - 50;

			jQuery(this).width( totalwidth - jQuery(this).nextAll('.pages').width() );
		});
	
}

function activateFormElements() {

	if(jQuery('.searchblock .fromzip_maxdist').size() > 0){
		var href = window.location.href;
		
		if(href.indexOf('fromzip.maxdist') == -1)
		{
			var zipDistancesSelect = jQuery('.searchblock .fromzip_maxdist .input-select');
			if(zipDistancesSelect.val() == 0)
			{
				zipDistancesSelect.val('15');
			}
		}
	}
	
	/*var scaffoldradio = false;
	var oldradioname = jQuery('.editprofile_block .scaffoldradiobuttoneditor input').attr('name');
	if( jQuery('.editprofile_block .scaffoldradiobuttoneditor').length > 0 ){
		scaffoldradio = true;
		
		jQuery('.editprofile_block .scaffoldradiobuttoneditor input').attr('name', 'rbuttonsprofile');	
	}*/
	
	jQuery('input:radio, input:checkbox, .input-select, .itemsperpage select, .sorting select, .distanceselect select, .taggrouplistsearchblock select, .youropinionreport select, .viewoptions select').not('.searchLeft .input-select, .input-transfer, .youropinionrating input, .editprofile_block input:radio').richFormElement({ selectOptionBorder: 1, selectTextbarBorder: 8 });
    jQuery('.searchLeft .input-select').richFormElement({ selectOptionBorder: 1, selectTextbarBorder: 8, selectVisOptions: 2.5 });
	
	/* if(scaffoldradio){
		jQuery('.editprofile_block .scaffoldradiobuttoneditor input').attr('name', oldradioname);	
	}*/
	
	
	if( jQuery('.taggrouplistsearchblock').length > 0 ){
		jQuery('.taggrouplistsearchblock').each( function(){
			jQuery('.select-box', this).eq(1).addClass('second');
		});
	}
}

function setClassLabel(){
	
	if(jQuery('.jobsearhoption').exists()){
		jQuery('.checkbox, .radiobox').each(function(){
			var t = jQuery(this);
			jQuery('label', t).not(jQuery('label:first', t)).addClass('inputLabel');
		});
	}
}

jQuery(document).bind('slideChanged', function(event, currentPage, pageCount, animationTime){
	
	var index = currentPage - 1;
	playFlash(index);

});

function initScrollPane(){
	if( jQuery('.mm_wysiwyg_group').length == 0 ){
		jQuery('.col_left_bot').css('position', 'absolute').css('top', jQuery('.col_left_top').height() -10 + 'px').css('left', '0px').css('margin-top', '10px');
	}
}

function scrollPane(){
	if(typeof(useScroll) != 'undefined' && useScroll){
	
		initScrollPane();
		var pane = jQuery('.col_left_bot');
		var headerHoogte = jQuery('#content').offset().top; 
		var bottomOffset = jQuery('#col_left_three .back').position().top + jQuery('.col_left_bot').position().top + jQuery('.col_left_top').outerHeight();
		var extraSpace = jQuery('.col_left_bot').position().top + jQuery('.col_left_top').outerHeight();
		
		var maxScroll = (jQuery('.cm_top').height() - jQuery('.col_left_bot').height()) + jQuery('.col_left_top').height() + headerHoogte;
		
		var paneHeight = pane.height();
				
		jQuery(window).scroll(function(e){
			
			var scrollTop = jQuery(document).scrollTop();
			if (maxScroll>scrollTop) {			
				if(bottomOffset < (scrollTop + paneHeight))
				{
					pane.css('position', 'absolute').css('left', '0px').css('top', (bottomOffset - (paneHeight) - headerHoogte) + 'px').css('z-index', '10');	
				}
				if(scrollTop > (headerHoogte + jQuery('.col_left_top').height()))
				{
					pane.css('position', 'fixed').css('left', '').css('top', '0px').css('z-index', '10');
				} else {
					pane.css('position', 'absolute').css('left', '0px').css('top', jQuery('.col_left_top').height()-10 + 'px').css('margin-top', '10px');
				} 
			} else {
				pane.css('position', 'absolute').css('left', '0px').css('top', (maxScroll - jQuery('.col_left_top').height() - headerHoogte) + 'px').css('z-index', '10');	
			}
		});
	}
}

function setEmailAgent(){
	if( jQuery('.contentRight .searchresultsblock').length > 0 && jQuery('.contentRight .mailagentblock').length > 0){
		jQuery('.contentRight .searchresultsblock .viewoptions').prepend(jQuery('<div class="vacpermail">').append(jQuery('.contentRight .mailagentblock').show()));
	}
	else{
		jQuery('.mailagentblock').show();
	}
}

function searchBoxFix(){
	jQuery('.searchblock .input-text').keyup(function(){
		if( jQuery(this).attr('value').slice(-1) == '?' || jQuery(this).attr('value').slice(-1) == '!')
			 jQuery(this).attr('value',  jQuery(this).attr('value').slice(0,-1));
	});

}

function checkThreeColumnWhiteSpace(){
	if(jQuery('#three_column').length > 0){

		if( jQuery('.aboutthejob').length > 0){
			var regelafstand = 26;
			var heightHeader = jQuery('.columnOne h1:first').height();
			jQuery('.col_left_top').css('min-height', heightHeader - 4 + regelafstand + 'px');
			jQuery('.columnTwo .cr_top').css('min-height', heightHeader - 4 + regelafstand + 'px');
			
			jQuery('.columnLeft .cr_top').css('min-height', heightHeader - 4 + regelafstand + 'px');
			jQuery('.columnLeft .col_left_bot').css('top', heightHeader - 4 + regelafstand + 'px');
			
			if( navigator.userAgent.toLowerCase().indexOf('msie 7.0') != -1){
				jQuery('.columnTwo .lastvisitedjobsblock .panelDiv>ul').css('margin-top', '0px'); 
			}
		}
		else if( jQuery('.columnOne h2:first').height() > 50 && jQuery('.aboutthejob').length == 0 && jQuery('.columnOne h2:first').css('height') == 'auto'){
			var regelafstand = 22;
			jQuery('.col_left_top').css('min-height', jQuery('.columnOne h2:first').height() + regelafstand + 'px');
			jQuery('.columnTwo .cr_top').css('min-height', jQuery('.columnOne h2:first').height() + regelafstand + 'px');
		}
	}
}

function fixSliderTicks(){
	if( jQuery('.facetcategory').length > 0){
		jQuery('.facetcategory>.slider').each( function(){
			var ticks = jQuery('.sliderTick', this);
			if( ticks.length > 6){
				var aantalTicks = ticks.length;
				var tickNum = aantalTicks / 4;
				var tickNum = Math.ceil(tickNum);
				
				ticks.addClass('hideTick');
				jQuery('.sliderTick:nth-child(' + tickNum + 'n)', this).removeClass('hideTick');
				jQuery('.sliderTick:first-child, .sliderTick:last-child', this).removeClass('hideTick');
				
			}
		});
	}
	if( jQuery('.jobsearhoption').length > 0){
		jQuery('.jobsearhoption .doubleLabel').each( function(){
			var ticks = jQuery('.sliderTick', this);
			if( ticks.length > 4){
				var aantalTicks = ticks.length;
				var tickNum = aantalTicks / 4;
				var tickNum = Math.ceil(tickNum);
				
				ticks.addClass('hideTick');
				jQuery('.sliderTick:nth-child(' + tickNum + 'n)', this).removeClass('hideTick');
				jQuery('.sliderTick:first-child', this).removeClass('hideTick');
			}
		});
	}
}

function activateFaq(){
	if( jQuery('#faq').size() > 0 ){
	
		var allHeights = [];
	
		jQuery('#faq .plain-text').each( function(e){
			allHeights[e] = String(jQuery(this).height());
		});
	
		jQuery('#faq .plain-text').hide();
		jQuery('#faq .plain-text').animate({height: "0px"}, { queue:false, duration:0, easing: "linear" });
		
		jQuery('#faq h2').each( function(e){
			var index = e;
			jQuery(this).click( function(){
				if(this.className.indexOf('open')>=0){
					jQuery('#faq .plain-text').hide();
					jQuery('#faq h2').removeClass('open');
					jQuery('#faq .plain-text').height(0);					
				} else {
					jQuery('#faq .plain-text').hide();
					jQuery('#faq h2').removeClass('open');
					jQuery('#faq .plain-text').height(0);
				
					jQuery('#faq .plain-text').eq(index).show().animate({height: allHeights[index] + "px"}, { queue:false, duration:400, easing: "linear" });
					jQuery(this).addClass('open');
				}
			});
		});
		
		jQuery('#faq h2:last').addClass('last');
	}

}

function setFotoActiesAndProfileFixes(){	
	if( jQuery('#fotoactie').length > 0){
	
		jQuery("#fotoactie .results li:nth-child(6n)").addClass('lastonrow');
		
		var orgheight;
	
		jQuery("#fotoactie .results li").hover(
			
			function() {
				jQuery(this).css('z-index', '10');
				
				
				var staand = false;
				
				if( jQuery('img', this).height() > 110){
					staand = true;
					orgheight = jQuery('img', this).height();
				}
				
				var top   = '-15px';
				var height  = '133px';
				
				if(staand){
					top = '-' + (jQuery('img', this).height() - 85) / 2 + 'px';
					height = 'org';
				}
				
				jQuery(this).find('img').addClass("hover").css('position', 'absolute').stop()
					.animate({
						top: top, 
						left: '-20px', 
						width: '200px', 
						height: height
					}, 200);
			
			} , function() {
			
				var backheight = '106px';
				
				if( jQuery('img', this).height() > 135){
					backheight = '' + orgheight + 'px';
				}
		
				jQuery(this).find('img').removeClass("hover").stop().animate({
								top: '0', 
								left: '0', 
								width: '160px', 
								height: backheight,
								padding: '0px'
							}, 100, function(){ 
								jQuery(this).css('position', 'static');
								jQuery(this).css('height', 'auto');
								jQuery(this).parent().parent().css('z-index','0');
				});
				
		});
		
		function formatTitle(title, currentArray, currentIndex, currentOpts) {
			var firstname = jQuery('.photodetails .firstname').eq(currentIndex).text();
			var middlename = jQuery('.photodetails .middlename').eq(currentIndex).text();
			var lastname = jQuery('.photodetails .lastname').eq(currentIndex).text();
			var omschrijving = jQuery('.photodetails .description').eq(currentIndex).text();
			
			return '<div class="infototext"><div class="labeltxt name">Naam:</div><div class="namevalue"><span class="firstname">' + firstname + '</span><span class="middlename">' + middlename + '</span><span class="lastname">' + lastname + '</span></div><div class="omschrijving labeltxt">Omschrijving:</div><div class="omschrijvingtext">' + omschrijving + '</div><div class="pageinf">' + 'Foto ' + (currentIndex + 1) + ' / ' + currentArray.length + '</div></div>';
		}

		//Fancyboxen
		jQuery("a.fancyphoto").fancybox({
			titlePosition: 'over',
			titleFormat : formatTitle
		});
	}

	
	if( jQuery('#content .editprofile_block .scaffoldbinarypropertyeditor').length > 0){
		var resotext = '';
		
		if( jQuery('#content .editprofile_block').next().hasClass('htmlblock')){
			resotext = jQuery('#content .editprofile_block').next().text();
			
			if( jQuery('.dropable').length == 0){
				jQuery('#content .editprofile_block').next().hide()
			}
			
			jQuery('#content .scaffoldbinarypropertyeditor').after('<div class="editfield maxuploadtext">' + resotext +'</div>');
			
		}	
		
		if( jQuery('#content .editprofile_block').next().next().hasClass('displayarticleblock')){
			checkboxtext = jQuery('#content .editprofile_block').next().next().html();
			
			if( jQuery('.dropable').length == 0){
				jQuery('#content .editprofile_block').next().next().hide()
			}
			jQuery('#content .Fotactievoorwaarden .checkbox').after('<div class="actietext">' + checkboxtext + '</div>');
			
		}	
		
		var maxcharacters = 140;
		
		jQuery('#content .editprofile_block .scaffoldtextareaeditor').append('<div class="countchars"><span class="count">' + maxcharacters + '</span><span class="divide">/</span><span class="maxcount">' + maxcharacters + '</span></div>');
	
		var textarea = jQuery('#content .editprofile_block .textarea');
		var count = jQuery('.countchars .count');
		
		jQuery(textarea).attr('maxlength', maxcharacters);
		
		jQuery(textarea).keyup( function(){
			if(jQuery(textarea).val().length >= maxcharacters){
				jQuery(count).text('0');
			}
			jQuery(count).text(maxcharacters - jQuery(textarea).val().length); 
		});
		
		jQuery(textarea).keydown(function(e) {
			if( jQuery(textarea).val().length >= maxcharacters && (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 37 && e.keyCode != 39 && e.keyCode != 38 &&e.keyCode != 40)){
				return false;
			}
		});
	
	}

	if( jQuery('#content .editprofile_block .Login').length > 0){
		var logininput = jQuery('#content .editprofile_block .Login .input-text');
		jQuery(logininput).keydown( function(e){
			if( e.keyCode == 32){
				alert('Je gebruikersnaam kan geen spaties bevatten');
				return false;
			}
		});
		
		jQuery(logininput).keyup( function(){ jQuery(logininput).val( Trim(jQuery(logininput).val())); });
	}
	
}

function createPopUpVestigingen() {
	jQuery('.cr_top .userdetailsblock li').each(function() {
		var liElement = this;
		var popup = jQuery('<div class="popup">');
		//var divimage = jQuery('div:first', liElement).clone();
		//popup.append(divimage);
		popup.append(jQuery('div', liElement).not(jQuery('div:first', liElement)));
		jQuery('div:first', liElement).after(popup);
	});
	jQuery('.cr_top .userdetailsblock li').mouseover(function() {
		jQuery('.popup', this).show();
	}).mouseout(function() {
		jQuery('.popup', this).hide();
	});
}

jQuery(document).ready(function () {
	
	removePaging();

    moveTell();

    toggleComponents();

	wrapMenu();

	if(jQuery('.sharethis .block-output').length>0) {
		jQuery('.sharethis').css('margin-bottom', '10px');
	}	
	
	if(jQuery('.cm_bottom .surveycontainer').size() > 0){
		jQuery('.cm_bottom .surveycontainer .surveyquestion:even').addClass('evenRow')
	}	
	
	jQuery('.columnOne h1:first, .contentRight h1:first').addClass('fc');
	
	if( jQuery('.columnRight .columnOne h1').length == 0){
		 jQuery('.columnRight .columnOne h2:first').addClass('fc');
	}
	if( jQuery('.columnRight h1').length == 0){
		 jQuery('.columnRight h2:first').addClass('fc');
	}
	
	if( jQuery('.resultcountinfo').exists()){
		setResultWidth();
	}

	jQuery(".textsearch .input-text, .footerSearch .input-text").not( jQuery('#searchboxHome .textsearch .input-text, #searchboxHome .textbox input, .input-text[type="file"]')).labelify({ text: "label", labelledClass: "highlight" });

	fixSurveyDiv();

	createPopUpVestigingen();
	jQuery('a.moreless').toggle( function(){
			jQuery(this).addClass('open');
		}, 
		function(){
			jQuery(this).removeClass('open');
	});
	
	jQuery('li.facet>a').click( function(){
		var checkBoxA = jQuery(this).prev('div');
		if( jQuery('a', checkBoxA).hasClass('checked') )
			jQuery('a', checkBoxA).removeClass('checked');
		else
			jQuery('a', checkBoxA).addClass('checked');
	});

    if (jQuery('.pollblock .button-container input:last').exists()) {
        jQuery('.pollblock .button-container input:last').addClass('pollHide');
    }

    if (jQuery('.columnOne .jobreactionblock').length != 0) {
        jQuery('.columnOne .jobreactionblock').prependTo('.jobID');
    }

	changeForm();
	
	if( jQuery('.uqwrapper').length > 0)
		activateFormElements();
		
	if ( jQuery('.columnLeft .searchblock').length > 0 && jQuery('.columnLeft .jobnavigationblock').length > 0) {
	
		jQuery('.columnLeft .searchblock').show();
		jQuery('.columnLeft .jobnavigationblock').show();
	}

	setClassLabel();
	
	setEmailAgent();
	
	searchBoxFix();
	
	checkThreeColumnWhiteSpace();
	
	jQuery('.pages a[disabled="disabled"], .paging a[disabled="disabled"]').attr('disabled', '');
	
	jQuery('.pages').each(function(e){
		if( e % 2)
			jQuery(this).addClass('paging2');
	});
	jQuery('.paging').each(function(e){
		if( e % 2)
			jQuery(this).addClass('paging2');
	});
	
	jQuery('.pollblock .button-container').after('<div class="clear"></div>');
	
	fixSliderTicks();
	
	activateFaq();
	
	setFotoActiesAndProfileFixes();
	scrollPane();
});
