function makeButton(block) {
    jQuery(block).each(function() {
        var button = this;
        if (button.type != 'hidden') {
            jQuery(button).wrap('<span class="candywrapper"></span>');
        } else {
            jQuery(button).css('display', 'none');
        }
    });
}

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 createHover() {
    jQuery('.button-container input').mouseover(function() { jQuery(this).addClass('hover'); }).mouseout(function() { jQuery(this).removeClass('hover'); });
    jQuery('.candywrapper').mouseover(function() { jQuery(this).addClass('wraphover'); }).mouseout(function() { jQuery(this).removeClass('wraphover'); });
    jQuery('.pollbutton').mouseover(function() { jQuery(this).addClass('pollhover'); }).mouseout(function() { jQuery(this).removeClass('pollhover'); });
    jQuery('#cc_bottom .searchresultsblock ul li').mouseover(function() { jQuery(this).addClass('listHover'); }).mouseout(function() { jQuery(this).removeClass('listHover'); });
}

function createOddEven(component, elements) {
    jQuery(component).each(function() {
        var block = this;
        var counter = 0;
        jQuery(elements, block).not(jQuery(elements + " " + elements, block)).each(function() {
            var element = this;
            counter++;
            if (counter % 2 == 0) {
                jQuery(this).addClass('even');
            }
        });
    });
}
	
jQuery(document).ready(function() {
makeButton('#contentcenter .button-container input, #contentcenter .mailafriendblock a, #contentcenter .viewreactionsblock a, .jobreactionblock a, .basketaddblock a, .htmlblock a.print, .htmlblock a.callme'); 
    createHover();
    createOddEven('.linklistblock', 'li');
    changeForm();
	jQuery(".searchblock .jobsearhoption:nth-child(even)").addClass('even');

});