// JScript source code
function makeButton()
{
	jQuery('.searchresultsblock .pages .previous, .searchresultsblock .pages .next, .jobreactionblock a, .button-container input, .button-container a, .buttons input, .quickorder input, .checkout a, .button-container ul li a, .categorybutton, .mailafriendblock a, .mailagentblock a, .clearbasket a, .basketaddblock a, .objectbasketblock .remove a, .button-container .button').each(function(){
		var button = this;
		if(button.type != 'hidden') {
		    jQuery(button).wrap('<span class="candywrapper"></span>');
		    jQuery(button).after('<span class="candyextra"></span>');
		} else {
		jQuery(button).css('display','none');
		}
	});
}

function moveButtoncontainer(){
	jQuery('.addreactionblock .formholder').each(
		function() {
			var t = this;
			var buttonContainer = jQuery('.button-container', t);
			
			jQuery(t).after(buttonContainer);
		}
	);
}
	
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 moveButtoncontainer(){
	jQuery('.addreactionblock .formholder').each(
		function() {
			var t = this;
			var buttonContainer = jQuery('.button-container', t);
			
			jQuery(t).after(buttonContainer);
		}
	);
}

function showCorrectObject(block){
	var LiCounter = 0;
	var blocks =  jQuery('#s_content .block-output');
	jQuery(blocks).css('display','none');
	jQuery('#s_link .linklistblock li').each(function(){
		var t = this;
		LiCounter++;
		if(t==block){
			if(blocks[LiCounter])	{
				jQuery(blocks[LiCounter]).css('display','block');
			}
		} 
	});
}	


/* forum */
function ChangeImage(width){
    jQuery('.displayforumblock .post .content img').each( function() {
        var t = this;
        var imgWidth = t.width;
        var imgHeight = t.height;
        
        if(imgWidth >width)
        {
            var multipleFactor = width / imgWidth;
            var newHeight = imgHeight * multipleFactor;

            jQuery(t).css('width',width + 'px');
            jQuery(t).css('height', newHeight + 'px');
        }
    });
}


function blockQuote(){
    jQuery('.displayforumblock .post').each(function() {
        
        var blockQuote = jQuery('blockquote', this)
        var step = 0;
        
        while (blockQuote.length>0)
        {
            blockQuote = jQuery('blockquote',blockQuote)
            step++;
            if (step%2==1)
            {
                jQuery(blockQuote).removeClass('even');
                jQuery(blockQuote).addClass('odd');
            }
            else
            {
                jQuery(blockQuote).removeClass('odd');
                jQuery(blockQuote).addClass('even');
            }
            
        }
    });

}

function makeHeight(){
    var extra = 0;
    if(navigator.appName!="Netscape"){
        extra +=10;
    } 

    jQuery('.displayforumblock ul .row, .forumstatusblock ul .row').each( function() {
        var t = this;
		var dd = jQuery('dd',t);
        var dt = jQuery('dt',t);
        var lastpost = jQuery('lastpost',t);
        var maxHeight = jQuery(t).height();
        if(jQuery(dt).height<maxHeight){
            jQuery(dt).height(maxHeight);
        }

        if(jQuery(lastpost).heigth<maxHeight){
            jQuery(lastpost).height(maxHeight);
        }

        jQuery('dd',t).each(function() {
            var ddItem = this;
            if(jQuery(ddItem).height()<maxHeight)
            {
            jQuery(ddItem).height(maxHeight);
            }
        });

    });
}

jQuery(document).ready(function(){
	var aantalli = 1;
	var counter = 0;
	makeButton();
	moveButtoncontainer();
	changeForm();
	jQuery('.mailafriendblock:eq(1)').addClass('sub');
	
	jQuery('#s_content .linkblock a').each(function() {
		var anchor = this;
		var image = '<img width="24px" height="17px" src="../themes/themes.alcohol/images/dubbel.gif" alt="">';
		anchor.innerHTML = anchor.innerHTML + image;
	});       

	jQuery('#topcontent .searchblock label').labelAsWatermark(true);
	var blocks =  jQuery('#s_content .block-output');
		if(blocks[0]) {
			jQuery(blocks[0]).css('display','block');
	}
	
	jQuery('#s_link li').each(function(){
		var t = this;
		t.onmouseover=function(){showCorrectObject(t);};
	});

	jQuery('.articlelistblock  li').each(
		function() {
		   var summary = jQuery('.articlelist_summary', this);
		   var anchor = jQuery('p.articlelist_link a', this);
		   
		   summary.append(anchor);
	});		

	jQuery('.joblistblock ul li, .searchresultsblock ul li').each(function() {
		if (counter++ % 2 == 0){
			jQuery(this).addClass('even');
		}
	});
});
