function tbShow(imgURL, posY) {

	if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
		$("body","html").css({height: "100%", width: "100%"});
		//$("html").css("overflow","hidden");
	}
	if(document.getElementById("TBoverlay") === null){
		//Afbeelding wordt geladen/Image is loading
		$("body").append("<div id='TBoverlay' class='loading'></div><div id='TBwindow'></div>");
		
		//onclick remove block
		$("#TBoverlay").click(tbRemove);
		$("#TBwindow").click(tbRemove);
		
		//set overlay to cover entire page
		$("#TBoverlay").css({
			"height": $(document).height(),
			"width": $(document).width()
		});
		$("#TBwindow").css({
			"display": "block"
		});
		
		//center image
		loadImg(imgURL, posY);
	}
}

function loadImg(url, posY){
	var img = new Image();
	
	url = '/fileadmin/declercq/Afbeeldingen_vergrotingen/' + url;
	
        $(img).load(function () {
            
            $(this).hide();
            $('#TBwindow').removeClass('loading').append(this);
            
            // fade our image in to create a nice effect
	    $(this).fadeIn();
	    
	    posLeft = ( $(document).width() - $(this).width() )/2;
	    posTop = ( $(window).height() - $(this).height() )/2;
	    
	    $('#TBwindow').css({
    		"left": posLeft,
    		"top" : posTop
    	    });
	    
	    if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
	    
	    	$('#TBwindow').css({
    		   "top" : document.documentElement.scrollTop + ($(window).height() - $(this).height() )/2,
    		   "left" : ( $(document).width() - $(this).width() )/2
    	    	});
	    }
	     
	    //correction for images bigger than window
	    if($(window).height() < $(this).height()){
	    
	    	posTop = posY -150;
	    	$('#TBwindow').css({
	    		"position" :"absolute",
	    		"top" : posTop
	    	});
	    }
            
        }).error(function () {
            // notify the user that the image could not be loaded
            alert("afbeelding kan niet geladen worden");
        }).attr('src', url);
		
}

function tbRemove() {
 	$("#TBimageOff").unbind("click");
	$("#TBcloseWindowButton").unbind("click");
	$("#TBwindow").fadeOut("fast",function(){$('#TBwindow,#TBoverlay,#TBHideSelect').trigger("unload").unbind().remove();});
	$("#TBload").remove();
	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
		$("body","html").css({height: "auto", width: "auto"});
		$("html").css("overflow","");
	}
	document.onkeydown = "";
	document.onkeyup = "";
	return false;
}

function tbDetectMacXFF() {
  var userAgent = navigator.userAgent.toLowerCase();
  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
    return true;
  }
}