var containerHeight = function() {
	var headerHeight				= $('#headerDiv').outerHeight({ margin: true });
	var breadCrumbHeight			= $('#breadCrumbSearchDiv').outerHeight({ margin: true });
	var footerHeight				= $('#footerDiv').outerHeight({ margin: true });
	var menuHeight					= $('#menuDiv').height()
	var windowHeight				= $(window).height()
	var documentHeight				= $(document).height()
	var newHeight					= windowHeight

	if(documentHeight > windowHeight){
		newHeight = documentHeight
	}

	var newInnerPageWrapperHeight	= newHeight - headerHeight - breadCrumbHeight - footerHeight - 10		//wordt zowel in IE als FF identiek gerenderd

	if( newHeight > $('#pageWrapperDiv').height()){
		$('#pageWrapperDiv').height(newHeight);
	}

	if(newInnerPageWrapperHeight > $('#innerPageWrapperDiv').height()){
		$('#innerPageWrapperDiv').height(newInnerPageWrapperHeight);
	}

	if($('#menuDiv').html() == ""){
		//indien er geen submenu staat de hoogte ook niet in de hoogtebepaling meenemen:
		menuHeight = 0
	}

	$('#contentWrapperDiv').height($('#innerPageWrapperDiv').height());
	$('#contentMiddleWrapperDiv').height($('#innerPageWrapperDiv').height() - $('#contentTopDiv').height() - $('#contentBottomDiv').height());
	$('#menuColorDiv').height($('#contentWrapperDiv').height() - $('#menuHeaderWrapperDiv').height() - menuHeight - $('#fotoLeftDiv').height());

	$("#menuColorDiv").show();
};

$(document).ready(function(){
	$(window).load(function(){

		for(var i = 0 ; i < document.images.length; i++){
			if(document.images[i].className == "boxImg"){
				document.images[i].vspace = "0px"
				document.images[i].hspace = "0px"

				if(document.images[i].width > 208){
					document.images[i].width = 208
				}
			}
		}

		wisselBestek();

		$('ul.sitemap li:last-child').addClass('last');

		$('.referentieImg').fixImageSize();
		$('.referentieImgLast').fixImageSize();

		containerHeight();

		if(document.overspanningForm){
			if((document.overspanningForm.aantalProducten) && (document.overspanningForm.serieId)){
				if(document.overspanningForm.aantalProducten.value == "1"){
					rowGroupClick(document.overspanningForm.serieId.value);
				}
			}
		}
    });

	$(window).resize(function(){
		containerHeight();
    });

	$("#fotoLeftDiv").corner("round bl 15px cc:#ffffff");
	$("#fotoLeftDiv").corner("round br 15px cc:#ffffff");

	$("#loadingDiv").ajaxStart(function(){
		$(this).show();
	});
	$("#loadingDiv").ajaxStop(function(){
		$(this).hide();
		if(typeof $.facebox != "undefined"){
			$('a[rel*=facebox]').facebox({
				loading_image : '_Images/loading.gif',
				close_image   : '_Images/closelabel.gif'
			})
		}
		containerHeight();
	});
});

jQuery(document).ready(function($) {
	if(typeof $.facebox != "undefined"){
		$('a[rel*=facebox]').facebox({
			loading_image : '_Images/loading.gif',
			close_image   : '_Images/closelabel.gif'
		})
	}
})

$.fn.fixImageSize = function(){   
	return this.each(function(){   
		var tag = $(this);   
		var width = tag.attr("width");
		var height= tag.attr("height");

		$(this).hide()
		if(width >= 183){
			this.width = 183
		}
		if(height >= 111){
			this.height = 111
		}
		$(this).show()
	});   
};  

var mailaFriend = function(){
	document.mailaFriendForm.URL.value	= document.location
	document.mailaFriendForm.action		= "default.asp?pageID=25"
	document.mailaFriendForm.submit()
}

var bookmarksite = function(){
	var performBookmark = false

	if((navigator.appName.search(/internet explorer/gi) > -1) || (navigator.appName.search(/firefox/gi) > -1) || (navigator.appName.search(/opera/gi) > -1)){
		performBookmark = true
	}

	if(performBookmark){
		var title	= document.title
		var url		= document.location

		if (window.sidebar) // firefox
			window.sidebar.addPanel(title, url, "");
		else if(window.opera && window.print){ // opera
			var elem = document.createElement('a');
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar');
			elem.click();
		} 
		else if(document.all)// ie
		window.external.AddFavorite(url, title);
	}else{
		alert("Uw browser ondersteunt het automatisch aanmaken van bookmarks niet, u dient dit handmatig te doen.")
	}
}
