// 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 to give the anchor of a tooltiptext a class to be able to style it differently from the other tags.
    function changeTooltiphost() {
      jQuery('.tooltipHost').each(
        function() {
            var t=this;
            var parent = jQuery(t).parent();
            parent.addClass('tooltipanchor');
        });
    }
      
function moveButtoncontainer()
{
	jQuery('.addreactionblock .formholder, .mailafriendblock .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 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 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 changeSearchResults() {
    jQuery('.searchresultsblock').each(function() {
        var block = this;
        var newPages = jQuery('.pages',block).clone();
        jQuery('.results',block).before(newPages);
        jQuery('.pages a.previous',block).before(jQuery("<span>Pagina's: </span>"));
        jQuery('.pages a',block).mouseover(function(){jQuery(this).addClass('smallhover')}).mouseout(function(){jQuery(this).removeClass('smallhover')});
        jQuery('.pages a.next, .pages a.previous',block).mouseover(function(){jQuery(this).addClass('largehover')}).mouseout(function(){jQuery(this).removeClass('largehover')});
    });
}


/** Customer Specific **/
jQuery(function(){
	var counter = 0;

	changePreviousNext();
	changeTooltiphost();
	moveButtoncontainer();
	changeForm();
	changeFormButton();
	changeSearchResults();
	CreateButton('#topright .displayarticleblock a, .button-container input, .button-container a, .categorybutton, .mailafriendblock a, .basketaddblock a, .objectbasketblock .remove a, .button-container .button, .product .articlelist_readmorelink');
	jQuery('#topright .articlelistblock li').mouseover(function(){jQuery(this).addClass('infohover')}).mouseout(function(){jQuery(this).removeClass('infohover')});
    jQuery('#topright .displayarticleblock td').mouseover(function(){jQuery(this).addClass('infohover')}).mouseout(function(){jQuery(this).removeClass('infohover')});
	jQuery('.surveycontainer div:eq(1)').addClass('firstDiv');
	jQuery('.mailafriendblock:eq(1)').addClass('sub');
    jQuery('.input-text, .input-textarea, .input-select, .texteditor').not(jQuery('.button-container input')).focus(function(){jQuery(this).addClass('hover');jQuery(this).addClass('focus')}).blur(function(){jQuery(this).removeClass('hover');jQuery(this).removeClass('focus');});  
    jQuery('.input-text, .input-textarea, .input-select, .texteditor').not(jQuery('.button-container input')).mouseover(function(){jQuery(this).addClass('hover')}).mouseout(function(){jQuery(this).removeClass('hover')});  

	jQuery('#sub_right_right .articlelistblock li').each(function() {
	if (counter++ % 2 == 0){
		jQuery(this).addClass('even');
	}});
	
	jQuery('#sub_right_left .articlelistblock li').each(
		function() {
		   var summary = jQuery('.articlelist_summary', this);
		   var anchor = jQuery('p.articlelist_link a', this);
		   
		   summary.append(anchor);
	});		
	
	var totalHeight = jQuery('#middle').height();
	var heightMiddleLeft = jQuery('#main_left').height();
	var heightMiddleRight = jQuery('#main_right').height();
	
	if(heightMiddleLeft > heightMiddleRight){
		jQuery('#main_right').height((totalHeight));
	}
	if(heightMiddleRight > heightMiddleLeft){
		jQuery('#main_left').height((totalHeight));
	}
	
});
