
$(window).load(function () { //als alle afbeeldingen geladen zijn
    aanbieding();
    $('.urlmaker').live('click', function () { $(this).select(); });

    //enkele images in mainImages tonen
    $('.content_center p>img').each(function () {
        if ($.trim($(this).parent().text()) == '') {
            $(this).parent().remove();
            var tmpImg = $(this);
            $('#mainImages').append(tmpImg);
        }
    });

    //nieuwsbrief
    $('.nieuwsbrief .mailadres').bind('focus', function () {
        $('.nieuwsbrief').css('background-image', $('.nieuwsbrief').css('background-image').replace('.jpg', '_ro.jpg'));
    }).bind('blur', function () {
        $('.nieuwsbrief').css('background-image', $('.nieuwsbrief').css('background-image').replace('_ro.jpg', '.jpg'));
    });


    //merken op frontpage
    $('.frontMerken img').css('opacity', 0.5).hover(function () {
        $(this).animate({ 'opacity': 1 });
    }, function () {
        $(this).animate({ 'opacity': 0.5 });
    }); ;


    //rundown titel uitklap
    $('div.rundown_item').hover(function () {
        var newH = $(this).find('.rundown_title h3')[0].scrollHeight - 7;
        $(this).find('.rundown_title h3').stop('true', 'true').animate({ 'height': newH + 'px' });
    }, function () {
        $(this).find('.rundown_title h3').animate({ 'height': '29px' });
    });
    //verwijder knop
    $('input.verwijder').css('opacity', 0.5).hover(function () {
        $(this).animate({ 'opacity': 1 });
    }, function () {
        $(this).animate({ 'opacity': 0.5 });
    });

    //detailpagina details-labels max breedte
    if ($('.detailLabel span').length) {
        var maxLbl = 0;
        $('.detailLabel span').each(function () {
            if ($(this).outerWidth() > maxLbl) {
                maxLbl = $(this).outerWidth();
            }
        });
        $('.detailLabel').css('width',maxLbl+8+'px');
        //console.log(maxLbl);
    }


    //================DETAILPAGINA THUMBNAILS==============
    if ($('#thumbSlider')) {
        var thumbs = $('#thumbSlider img').size();

        if (thumbs > 0) {
            $('#thumbSlider').before('<div class="detailthumbs"><div id="thumbcontainer"></div><a href="#" id="detailThumbsArrowUp">Up</a><a href="#" id="detailThumbsArrowDown">Down</a></div><div class="detailpic"></div>').after('<div style="clear:both;" />');
            $('#thumbSlider img').each(function (index) {
                var ima = $(this);
                var vH = ima.height();
                if (index == 0) {
                    $('.detailpic')
					.append('<a href="' + ima.attr('src').replace('thumb', 'large') + '" rel="group1" class="detailLarge active"><img src="' +
					ima.attr('src').replace('thumb', 'medium') + '" alt="' + ima.attr('alt') + '" /></a>');
                } else {
                    $('.detailpic')
					.append('<a href="' + ima.attr('src').replace('thumb', 'large') + '" rel="group1" class="detailLarge inactive" style="display:none;"><img src="' +
					ima.attr('src').replace('thumb', 'medium') + '" alt="' + ima.attr('alt') + '" /></a>');
                }
                //$('.detailLarge.inactive').fadeOut();
                $('.detailLarge').fancybox({
                    'width': 'auto',
                    'height': 'auto',
                    'autoDimensions': true,
                    'transitionIn': 'fade',
                    'transitionOut': 'fade',
                    'speedIn': 500,
                    'speedOut': 500,
                    'overlayShow': true,
                    'hideOnContentClick': false,
                    'overlayOpacity': 0.65,
                    'overlayColor': '#000000',
                    'showNavArrows': true,
                    'titleShow': true
                });
                $('#thumbcontainer').append('<a href="#" class="thumb"><img src="' + ima.attr('src') + '" alt="' + ima.attr('alt') + '" /></a>');
            });

            //thumbs acties
            $('.detailthumbs #thumbcontainer a').bind('click', function () {
                var vI = ($('.detailthumbs a').index($(this))) + 1;
                $('.detailLarge.active').fadeOut(100, function () {
                    $('.detailLarge:nth-child(' + vI + ')').fadeIn().removeClass('inactive').addClass('active');
                }).removeClass('active').addClass('inactive');
                $(this).blur();
                return false;
            });
            //thumbs scroller
            //            var contH = $('#thumbcontainer').outerHeight();
            //            var thumbH = $('.thumb:nth-child(1)').outerHeight(true);
            //            var maxH = thumbH + 102 - contH;
            //            if (($('#thumbcontainer').css('top').replace('px', '') == '0') && (contH > thumbH)) {
            //                $('#detailThumbsArrowDown').show();
            //            }
            //            $('#detailThumbsArrowDown').click(function () {
            //                $('.detailthumbs').animate({ 'height': '196px' });
            //                if ($('#detailThumbsArrowUp').is(':visible') == true) { vExtra = 0 } else { vExtra = 51 }
            //                $('#thumbcontainer').animate({ 'top': $('#thumbcontainer').css('top').replace('px', '') * 1 - thumbH + vExtra + 'px' }, function () {
            //                    if ($('#thumbcontainer').css('top').replace('px', '') <= maxH) {
            //                        $('#detailThumbsArrowDown').fadeOut();
            //                        $('.detailthumbs').animate({ 'height': '145px' });
            //                    }
            //                });
            //                $('#detailThumbsArrowUp').fadeIn();
            //                $(this).blur();
            //                return false;
            //            });
            //            $('#detailThumbsArrowUp').click(function () {
            //                $('.detailthumbs').animate({ 'height': '196px' });
            //                $('#thumbcontainer').animate({ 'top': $('#thumbcontainer').css('top').replace('px', '') * 1 + thumbH + 'px' }, function () {
            //                    if ($('#thumbcontainer').css('top').replace('px', '') >= 0) {
            //                        $('#thumbcontainer').animate({ 'top': $('#thumbcontainer').css('top').replace('px', '') * 1 - 51 + 'px' });
            //                        $('#detailThumbsArrowUp').fadeOut();
            //                        $('.detailthumbs').animate({ 'height': '145px' });
            //                    } else {
            //                        $('#detailThumbsArrowDown').fadeIn();
            //                    }
            //                });
            //                $('#detailThumbsArrowUp').fadeIn();
            //                $(this).blur();
            //                return false;
            //            });
            //            if (thumbs <= 4) {
            //                $('.detailthumbs').css('height', '70px');
            //            }

        }

    }

    //frontrotator

    if ($('#frontrotator')) {
        var frontTotal = $('#frontrotator .frontItem').size();
        var frontActive = 1;
        $('#frontrotator').append('<img id="mainImage" class="new" /><div class="tekstvlak"></div><div class="tekst"></div><div id="butNavigatie"></div><div id="mask"></div>');
        $('#frontrotator .tekstvlak').css('opacity', 0.5);
        $('#frontrotator #mainImage').attr('src', $('#frontrotator .frontItem:nth-child(1)').find('img').attr('src'));
        $('#frontrotator .tekst').html($('#frontrotator .frontItem:nth-child(1)').find('.frontText').html())
        var frontDuration = 3000;
        for (i = 0; i <= (frontTotal - 1); i = i + 1) {
            $('#frontrotator #butNavigatie').prepend('<a class="navButtons but' + (i + 1) + '" num="' + (i + 1) + '" href="' + (i + 1) + '"></a>');
        }
        $('#frontrotator #butNavigatie').append('<a href="#" class="arrowLeft">previous</a>').prepend('<a href="#" class="arrowRight">next</a>');
        $('#butNavigatie .but1').addClass('active');
    }

});
if ($('#frontrotator')) {
    $('#butNavigatie .arrowLeft').live('click', function () {
        clearTimeout(mytimer);
        curPos = $('#butNavigatie a.active').attr('href');
        if (curPos == 1) { curPos = $('#frontrotator .frontItem').size(); } else { curPos-- }
        frontRotate(curPos);
        $(this).blur();
        return false;
    });
    $('#butNavigatie .arrowRight').live('click', function () {
        clearTimeout(mytimer);
        curPos = $('#butNavigatie a.active').attr('href');
        if (curPos == $('#frontrotator .frontItem').size()) { curPos = 1; } else { curPos++ }
        frontRotate(curPos);
        $(this).blur();
        return false;
    });

    $('#butNavigatie .navButtons').live('click', function () {
        clearTimeout(mytimer);
        frontRotate($(this).attr('href'));
        $(this).blur();
        return false;
    });


    var mytimer;
    $(function () {
        mytimer = setInterval('frontRotate();', 4000);
    });

}

function frontRotate(var1){
	var frontTotal = $('#frontrotator .frontItem').size();
	var frontActive = parseInt($('#butNavigatie .active').attr('num'));
	frontActive ++;
	if (frontActive > frontTotal){frontActive = 1}	
	var fadeDur = 850;
	if (var1) {
		frontActive = var1;
			$('#frontrotator #mainImage.new').stop();
			$('#frontrotator #mainImage').removeClass('new').addClass('old').css('z-index',12).before('<img id="mainImage" class="new" border=0 />');
			$('#frontrotator #mainImage.new').css('z-index',15).hide().attr('src',$('#frontrotator .frontItem:nth-child('+frontActive+')').find('img').attr('src')).show()
						$('#frontrotator .tekst').html($('#frontrotator .frontItem:nth-child('+frontActive+')').find('.frontText').html());
						$('#butNavigatie .navButtons').removeClass('active');
						$('#butNavigatie .but'+frontActive).addClass('active');
				$('#frontrotator #mainImage.old').remove();
		}else{
			$('#frontrotator #mainImage').removeClass('new').addClass('old').css('z-index',12).before('<img id="mainImage" class="new" border=0 />');
			if ($('#frontrotator #mainImage.new').length != 0) {
				var newSrc = $('#frontrotator .frontItem:nth-child(' + frontActive + ')').find('img').attr('src');
				$('#frontrotator #mainImage.new')
				.css('z-index', 15)
				.hide()
				.attr('src', newSrc)
				.fadeIn(fadeDur, function () {
					$('#frontrotator .tekstvlak,#frontrotator .tekst').animate({'margin-bottom':-70},function(){
							$('#frontrotator .tekst').html($('#frontrotator .frontItem:nth-child('+frontActive+')').find('.frontText').html());
							$('#butNavigatie .navButtons').removeClass('active');
							$('#butNavigatie .but'+frontActive).addClass('active');
						}).animate({'margin-bottom':0});
					$('#frontrotator #mainImage.old').remove();
				});
			}
		}
}

//einde frontrotator

$(document).ready(function () {
	//=================================OPBOUW VAN DIT BESTAND============================================
	//Met de functies in dit bestand kunnen de standaard-elementen van de magnet worden opgeleukt.
	//Standaard staan deze functies aan en kunnen elementen hiervan gewijzigd worden.
	//Achter elke optie (of boven de functie) staat in het commentaar (zoals dit) beschreven wat je kunt wijzigen
	//Erboven staat ook hoe je de functies helemaal uit kunt zetten.
	//Daarna staat waar je eventueel de stylesheets moet/mag aanpassen

	//Om alles wat met jquery te maken heeft uit de site te halen kun je 
	//in de master alle includes uit de /js halen en alle stylesheets met het
	//woord 'jquery' er in.


	//======================================ALGEMENE SETTINGS============================================
	var popwidth = 700; //standaard breedte van de lightbox
	var popheight = 600; //standaard hoogte van de lightbox
	var VautoDimensions = true; //zet op true als lightbox zelf de afmetingen moet detecteren. Anders false. Bij False worden de bovenstaande waarden gebruikt

	//======================================SUPERSUCKERFISH-MENU============================================
	//uitzetten? verwijder de class 'supermenu' uit de ul van het menu in de master-page
	//in de standaard stylesheet (jquery.css) staan alle .supermenu styles. (Suckerfish styles.)
	supermenu(
		  'supermenu', //1: de class van de navigatie-ul
		  'v', //2: h voor horizontaal menu / v voor verticaal menu
		  '161', //3: breedte van het menu in het geval van een verticaal menu
		  'fade1', //4: fade1 om te faden / anders fade0
		  'slide0', //5: slide1 om te sliden / anders slide0
		  'slow', //6: snelheid van de animatie. Dit kan 'slow','medium','fast' zijn of een getal in milliseconden
		  500, //7: delay. De duur dat het submenu blijft staan wanneer je muis er vanaf is in milliseconden
		  'arrows1', //8: arrows1 om pijltjes bij menuitems met submenu's te laten zien. Anders arrows0
		  8, //9: de minimal breedte van een submenu in em (n.b. de breedte van de sub-ul wordt dynamisch aangepast adhv de tekst in de knoppen)
		  17//10: de maximale breedte van een submenu in em
		  );

	//======================================ACCORDEON-MENU============================================
	//uitzetten? verwijder de class 'accmenu' op de ul dan van het menu in de master-page
	//in de standaard stylesheet (jquery.css) staan alle .accmenu styles.
	accmenu('accmenu');

	//======================================FAQ======================================
	//class 'vraag' en class 'antwoord' kunnen gewijzigd worden
	accordion('vraag', 'antwoord');

	//======================================TAALKEUZEMENU============================================
	//uitzetten? Verander dan hier de classname van 'languagemenu' naar bv. 'languagemenuoff'
	//1: de classname van het taalmenu
	//2: delay. De duur dat het submenu blijft staan wanneer je muis er vanaf is in milliseconden
	//3: fade of slide
	languagemenu('languagemenu', 300, 'fade');

	//======================================FOTOALBUM============================================
	//uitzetten kan door voor de volgende regels een dubbele slash (zoals deze regel) te zetten.
	//stylesheet om aan te passen: galleriffic-2.css
	myGallery(
		  18, 			//1: het aantal thumbnail tonen per pagina
		  false, 		//2: navigatie boven thumbnails aan
		  true, 		//3: navigatie onder thumbnails aan
		  false, 		//4: toon div class='nav-controls' met volgende/vorige links
		  false,  		//5: start als slideshow
		  7000, 		//6: duratie tussen foto's in slideshow
		  true, 		//7: Opent klikken op de grote foto de originele foto in een lightbox?
		  'elastic', 	//8: Hoe opent de lightbox. Opties: 'elastic','fade' of 'none'
		  500, 			//9: Hoe lang duurt voorgaand effect in milliseconden
		  true			//10: Toon de titel onder de foto in de lightbox-vergroting
		  );

	//======================================LINKS IN LIGHTBOX OPENEN============================================
	//uitzetten kan door voor de volgende regel een dubbele slash (zoals deze regel) te zetten.
	//1: De tag waarnaar wordt gekeken. Dit kan een id, class, of iets zelfverzonnens zijn.
	//2: De waarde van de bovenstaande tag.
	//Wanneer dus linklb('title','popup') hieronder staat worden alle links met de volgende tag in een lightbox
	//geopend: title='popup'
	linklb('title', 'popup');

	//======================================MAGNIFIER============================================
	//Alle plaatjes in een paragraaf met als title 'zoom' krijgen een zoom-functie
	magnifier('title', 'zoom');

	$(document).bind("contextmenu", function (e) {
	    return false;
	});

	//TOON ALLE PRODUCTEN NA ZOEKEN
	$('.toon_alles').bind('click', function () {
		$(this).slideUp();
		$('.searchhidden').slideDown();
		return false;
	})

	//================IN- UITKLAPPEN MENU LINKS==============
	$('.filter .uitgeklapt').live('click', function () {
		if ($.browser.msie && parseInt($.browser.version) == 7) {
			$(this).next().hide();
		} else {
			$(this).next().slideUp();
		}
		$(this).removeClass('uitgeklapt').addClass('ingeklapt');
		$(this).blur();
		return false;
	});
	$('.filter .ingeklapt').live('click', function () {
		if ($.browser.msie && parseInt($.browser.version) == 7) {
			$(this).next().show();
		} else {
			$(this).next().slideDown();
		}
		$(this).removeClass('ingeklapt').addClass('uitgeklapt');
		$(this).blur();
		return false;
	});

	/*  //ZELF LEGGEN: DISABLED; NO LONGER NECCESSARY
	$(".legservice input").click(
	function () {
	if ($(".legservice input:last").is(':checked')) {
	$('.legset').slideDown();
	} else {
	$('.legset').slideUp();
	}
	$(this).blur();
	});
	$(function () {
	if ($("input[name=legservice]:last").is(':checked')) {
	$('.legset').show();
	}
	});*/


	
	tt();
	//FAQ
	$('.faq dt').click(function () {
		$(this).next('dd').slideToggle();
	});


	//TABS op detailpagina
	if ($('ul.tab')) {
		$('.tab_content').not('.active').hide();
		vLi = $('ul.tab li a');
		vLi.click(function (e) {
			switchTab($(this));
		});
	}
	function switchTab(tab) {
		vTab = tab.attr('href').replace('#', '.tab');
		$('.tab_content.active').hide().removeClass('active');
		$(vTab).show().addClass('active');
		$('ul.tab li').removeClass('active');
		tab.parent().addClass('active');
		tab.blur();
		return false;
	}

	//SCROLLEN NAAR BENEDEN
	$('.toOms').click(function () {
		$('html,body').animate({ scrollTop: $(".oms").offset().top }, 'slow');
		switchTab($('li.oms a'));
		return false;
	});
	$('.toSpec').click(function () {
		$('html,body').animate({ scrollTop: $(".spec").offset().top }, 'slow');
		switchTab($('li.spec a'));
		return false;
	});

	//FOTOVERGROTING OP VERGELIJKINGSPAGINA
	if ($('.vergelijkImg')) {
		$('.vergelijkImg').each(function () {
			vSrc = $(this).attr('src').replace('compare', 'large');
			$(this).wrap('<a rel="group2" href="' + vSrc + '" />');
		});
		$('.vergelijkImg').parent().fancybox({
			'width': 'auto',
			'height': 'auto',
			'autoDimensions': true,
			'transitionIn': 'fade',
			'transitionOut': 'fade',
			'speedIn': 500,
			'speedOut': 500,
			'overlayShow': true,
			'hideOnContentClick': false,
			'overlayOpacity': 0.65,
			'overlayColor': '#000000',
			'showNavArrows': true,
			'titleShow': true
		});
	}

	//COLUMNS IN DE SEO FOOTER
	$("#SEOwrap").columnize({ columns: 4, balance: true, dontsplit: "ul" });
	//$('#SEOwrap ul').makeacolumnlists({ cols: 4, colWidth: 0, equalHeight: false, startN: 1 });
	$('#SEOwrap .column:nth-child(4)').css({ 'border-right-width': '0px', 'margin-right': '0em' });
	//$('.column h3:nth-child(1)').css({ 'border-top-width': '0px', 'margin-top': '0px', 'padding-top': '0px', 'margin-right': '0px', 'margin-bottom': '0px', 'padding-bottom': '15px' });
	$('#SEOwrap .column:nth-child(5)').remove();
	//columns gelijktrekken
	var colMax = 0;
	$('#SEOwrap .column').each(function (index) {
		colH = $(this).height();
		if (colH > colMax) {
			colMax = colH;
		}
	});
	$('#SEOwrap .column').css('height', colMax);

	//=========================================================================================
	//=============================HIERONDER NIKS AANPASSEN!!!!================================

	//touchscreen friendly code
	var ua = navigator.userAgent;
	var checker = {
	    iphone: ua.match(/(iPhone|iPod|iPad)/),
	    blackberry: ua.match(/BlackBerry/),
	    android: ua.match(/Android/)
	};
	if (checker.iphone || checker.blackberry || checker.android) {
	    $('.supermenu').find('li > ul').closest('li').children('a').each(function () {
	        var $item = $(this);
	        // No .toggle() here as it's not possible to reset it.
	        $item.click(function (event) {
	            // Already clicked? proceed to the URI.
	            if ($item.hasClass('sf-clicked')) {
	                var $uri = $item.attr('href');
	                window.location = $uri;
	            }
	            else {
	                event.preventDefault();
	                $item.addClass('sf-clicked');
	            }
	        }).closest('li').mouseleave(function () {
	            // So, we reset everything.
	            $item.removeClass('sf-clicked');
	        });
	    });
	}

	function magnifier(v1, v2) {
		$('img[' + v1 + '*=' + v2 + ']').each(function () { $(this).wrap('<a href="' + $(this).attr('src').replace('_Content', '___Source') + '" rel="magnify"/>') });
		$('a[rel*=magnify]').magnify({ lensWidth: 200, lensHeight: 200, link: false, delay: 100 });
	}

	function accmenu() {
		if ($('.accmenu').length > 0) {
			$('.selected').each(function () {
				$(this).next('ul:first').addClass('ulselected');
				$(this).parent().parent('ul.ulselected').addClass('ulselectedparent');
			});
			initMenu();
		}
	}
	function initMenu() {
		$('.ulselectedparent').show();
		$('.ulselected').delay(100).slideDown();
		$('.accmenu li a').click(
		//    function() {
		//        $(this).next().slideToggle('normal');	
		//      }  
	);
	}


	//ACCORDION BUTTON ACTION	
	function accordion(v1, v2) {
		$("." + v2).hide();
		$("." + v1).click(function () {
			$("." + v2).slideUp('normal');
			$(this).next().slideDown('normal');
		});
	}

	function linklb(v1, v2) {
		$('img[' + v1 + '=' + v2 + ']').each(function () {
			$(this).wrap('<a href="' + $(this).attr('src').replace('_Content', '___Source') + '" ' + v1 + '="' + v2 + '"/>')
		});
		$('a[' + v1 + '="' + v2 + '"]').each(function () {
			var vurl = $(this).attr('href');
			var pathname = window.location.host;
			if ((vurl.indexOf('.jpg') >= 0) || (vurl.indexOf('.gif') >= 0) || (vurl.indexOf('.jpeg') >= 0) || (vurl.indexOf('.png') >= 0)) {
			} else {
				$(this).attr('id', '#actpop-' + $(this).index()).attr('href', '#pop-' + $(this).index()).after('<div style="display:none"><div class="popup" id="pop-' + $(this).index() + '"></div></div>');
			}
			$('#pop-' + $(this).index() + ' #mainContent').remove();
			if ((vurl.indexOf('.jpg') >= 0) || (vurl.indexOf('.gif') >= 0) || (vurl.indexOf('.jpeg') >= 0) || (vurl.indexOf('.png') >= 0)) {

			} else if (vurl.indexOf(pathname) >= 0) {
				$('#pop-' + $(this).index()).load(vurl + ' #mainContent span');
			} else {
				$(this).attr({ 'href': vurl, 'class': 'iframe' });
			}
			$(this).fancybox({
				'width': popwidth,
				'height': popheight,
				'autoDimensions': VautoDimensions,
				'transitionIn': 'fade',
				'transitionOut': 'fade',
				'speedIn': 500,
				'speedOut': 500,
				'overlayShow': true,
				'hideOnContentClick': false,
				'overlayOpacity': 0.65,
				'overlayColor': '#000000',
				'showNavArrows': false,
				'titleShow': false
			});
			//return false;
		});
	}

	function loadfancybox(target, lightbfx, lightdur, lightit) { // options > http://fancybox.net/api
		target.fancybox({
			'transitionIn': lightbfx,
			'transitionOut': lightbfx,
			'speedIn': lightdur,
			'speedOut': lightdur,
			'overlayShow': true,
			'hideOnContentClick': true,
			'overlayOpacity': 0.85,
			'overlayColor': '#000000',
			'showNavArrows': false,
			'titleShow': lightit
		});
	}

	// We only want these styles applied when javascript is enabled
	function myGallery(thumbs, toppag, botpag, NavControls, slidesh, ssdur, lighb, lightbfx, lightdur, lightit) {
		if ($('#thumbs').length > 0) {
			$('div.navigation').css({ 'width': '300px', 'float': 'left' });
			$('div.content').css('display', 'block');
			// Initialize Advanced Galleriffic Gallery
			var gallery = $('#thumbs').galleriffic({
				delay: ssdur,
				numThumbs: thumbs,
				preloadAhead: 14,
				enableTopPager: toppag,
				enableBottomPager: botpag,
				//maxPagesToShow:            7,
				imageContainerSel: '#slideshow',
				controlsContainerSel: '#controls',
				captionContainerSel: '#caption',
				loadingContainerSel: '#loading',
				renderSSControls: false,
				renderNavControls: NavControls,
				playLinkText: 'Start Slideshow',
				pauseLinkText: 'Pauzeer Slideshow',
				prevLinkText: '&lsaquo; Vorige foto',
				nextLinkText: 'Volgende foto &rsaquo;',
				nextPageLinkText: 'Volgende &rsaquo;',
				prevPageLinkText: '&lsaquo; Vorige',
				enableHistory: false,
				autoStart: slidesh,
				syncTransitions: true,
				defaultTransitionDuration: 1500,
				onSlideChange: function (prevIndex, nextIndex) {
					// 'this' refers to the gallery, which is an extension of $('#thumbs')
					this.find('ul.thumbs').children()
					.eq(prevIndex).fadeTo('fast', vaag).end()
					.eq(nextIndex).fadeTo('fast', 1.0);
				},
				onPageTransitionOut: function (callback) {
					this.fadeTo('fast', 0.0, callback);
				},
				onPageTransitionIn: function () {
					this.fadeTo('fast', 1.0)
				},
				onTransitionIn: function (slide, caption, isSync) {
					if (lighb == true) {
						loadfancybox($("span.current a"), lightbfx, lightdur, lightit);
					}
					var duration = this.getDefaultTransitionDuration(isSync);
					slide.fadeTo(duration, 1.0);
					caption.fadeTo(duration, 1.0);
				}
			});
			var vaag = 0.67;
			$('#thumbs ul.thumbs li a img').css('opacity', vaag);
			$('#thumbs ul.thumbs li a img').hover(function () {
				$(this).fadeTo('fast', 1);
			},
			 function () {
				 $(this).fadeTo('fast', vaag);
			 });
		}

	}

});                                                     //end

/*
 * Superfish v1.4.8 - jQuery menu widget
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */
;(function($){
	$.fn.superfish = function(op){

		var sf = $.fn.superfish,
			c = sf.c,
			$arrow = $(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),
			over = function(){
				var $$ = $(this), menu = getMenu($$);
				clearTimeout(menu.sfTimer);
				$$.showSuperfishUl().siblings().hideSuperfishUl();
			},
			out = function(){
				var $$ = $(this), menu = getMenu($$), o = sf.op;
				clearTimeout(menu.sfTimer);
				menu.sfTimer=setTimeout(function(){
					o.retainPath=($.inArray($$[0],o.$path)>-1);
					$$.hideSuperfishUl();
					if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
				},o.delay);	
			},
			getMenu = function($menu){
				var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
				sf.op = sf.o[menu.serial];
				return menu;
			},
			addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
			
		return this.each(function() {
			var s = this.serial = sf.o.length;
			var o = $.extend({},sf.defaults,op);
			o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
				$(this).addClass([o.hoverClass,c.bcClass].join(' '))
					.filter('li:has(ul)').removeClass(o.pathClass);
			});
			sf.o[s] = sf.op = o;
			
			$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
				if (o.autoArrows) addArrow( $('>a:first-child',this) );
			})
			.not('.'+c.bcClass)
				.hideSuperfishUl();
			
			var $a = $('a',this);
			$a.each(function(i){
				var $li = $a.eq(i).parents('li');
				$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
			});
			o.onInit.call(this);
			
		}).each(function() {
			var menuClasses = [c.menuClass];
			if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
			$(this).addClass(menuClasses.join(' '));
		});
	};

	var sf = $.fn.superfish;
	sf.o = [];
	sf.op = {};
	sf.IE7fix = function(){
		var o = sf.op;
		if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
			this.toggleClass(sf.c.shadowClass+'-off');
		};
	sf.c = {
		bcClass     : 'sf-breadcrumb',
		menuClass   : 'sf-js-enabled',
		anchorClass : 'sf-with-ul',
		arrowClass  : 'sf-sub-indicator',
		shadowClass : 'sf-shadow'
	};
	sf.defaults = {
		hoverClass	: 'sfHover',
		pathClass	: 'overideThisToUse',
		pathLevels	: 1,
		delay		: 800,
		animation	: 'fadeslide',
		speed		: 'normal',
		autoArrows	: true,
		dropShadows : true,
		disableHI	: false,		// true disables hoverIntent detection
		onInit		: function(){}, // callback functions
		onBeforeShow: function(){},
		onShow		: function(){},
		onHide		: function(){}
	};
	$.fn.extend({
		hideSuperfishUl : function(){
			var o = sf.op,
				not = (o.retainPath===true) ? o.$path : '';
			o.retainPath = false;
			var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
					.find('>ul').stop(true,true).hide().css('visibility','hidden');
			o.onHide.call($ul);
			return this;
		},
		showSuperfishUl : function(){
			var o = sf.op,
				sh = sf.c.shadowClass+'-off',
				$ul = this.addClass(o.hoverClass)
					.find('>ul:hidden').css('visibility','visible');
			sf.IE7fix.call($ul);
			if (o.animation == 'fadeslide'){
				o.animation = {opacity:'show',height:'show'};
			}else
			if (o.animation == 'none'){
				o.animation = {opacity:'show'};
				o.speed = 0;
			}else
			if (o.animation == 'fade'){
				o.animation = {opacity:'show'};
			}else
			if (o.animation == 'slide'){
				o.animation = {height:'show'};
			}
			o.onBeforeShow.call($ul);
			
			$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
			return this;
		}
	});

})(jQuery);


/*
 * Supersubs v0.2b - jQuery plugin
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 *
 * This plugin automatically adjusts submenu widths of suckerfish-style menus to that of
 * their longest list item children. If you use this, please expect bugs and report them
 * to the jQuery Google Group with the word 'Superfish' in the subject line.
 *
 */

;(function($){ // $ will refer to jQuery within this closure

	$.fn.supersubs = function(options){
		var opts = $.extend({}, $.fn.supersubs.defaults, options);
		// return original object to support chaining
		return this.each(function() {
			// cache selections
			var $$ = $(this);
			// support metadata
			var o = $.meta ? $.extend({}, opts, $$.data()) : opts;
			// get the font size of menu.
			// .css('fontSize') returns various results cross-browser, so measure an em dash instead
			var fontsize = $('<li id="menu-fontsize">&#8212;</li>').css({
				'padding' : 0,
				'position' : 'absolute',
				'top' : '-999em',
				'width' : 'auto'
			}).appendTo($$).width(); //clientWidth is faster, but was incorrect here
			// remove em dash
			$('#menu-fontsize').remove();
			// cache all ul elements
			$ULs = $$.find('ul');
			// loop through each ul in menu
			$ULs.each(function(i) {	
				// cache this ul
				var $ul = $ULs.eq(i);
				// get all (li) children of this ul
				var $LIs = $ul.children();
				// get all anchor grand-children
				var $As = $LIs.children('a');
				// force content to one line and save current float property
				var liFloat = $LIs.css('white-space','nowrap').css('float');
				// remove width restrictions and floats so elements remain vertically stacked
				var emWidth = $ul.add($LIs).add($As).css({
					'float' : 'none',
					'width'	: 'auto'
				})
				// this ul will now be shrink-wrapped to longest li due to position:absolute
				// so save its width as ems. Clientwidth is 2 times faster than .width() - thanks Dan Switzer
				.end().end()[0].clientWidth / fontsize;
				// add more width to ensure lines don't turn over at certain sizes in various browsers
				emWidth += o.extraWidth;
				// restrict to at least minWidth and at most maxWidth
				if (emWidth > o.maxWidth)		{ emWidth = o.maxWidth; }
				else if (emWidth < o.minWidth)	{ emWidth = o.minWidth; }
				emWidth += 'em';
				// set ul to width in ems
				$ul.css('width',emWidth);
				// restore li floats to avoid IE bugs
				// set li width to full width of this ul
				// revert white-space to normal
				$LIs.css({
					'float' : liFloat,
					'width' : '100%',
					'white-space' : 'normal'
				})
				// update offset position of descendant ul to reflect new width of parent
				.each(function(){
					var $childUl = $('>ul',this);
					var offsetDirection = $childUl.css('left')!==undefined ? 'left' : 'right';
					$childUl.css(offsetDirection,emWidth);
				});
			});
			
		});
	};
	// expose defaults
	$.fn.supersubs.defaults = {
		minWidth		: 9,		// requires em unit.
		maxWidth		: 25,		// requires em unit.
		extraWidth		: 0			// extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
	};
	
})(jQuery); // plugin code ends


//z-index fix for IE7
if ($.browser.msie){
var zIndexNumber = 1000;
$('#navigatie').find('li').each(function(i){
	$(this).css('z-index',zIndexNumber);
zIndexNumber -= 10;
});
};

/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.2, 09.03.2009
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    09.03.2009 Version 1.2
 *    - Update for jQuery 1.3.x, removed @ from selectors
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};
})(jQuery);

//supermenu
function supermenu(classofmenu,horver,v_width,fade1,slide1,speed,delay,arrows,ssmin,ssmax){
	if (horver == 'v'){
		$("ul."+classofmenu).addClass('sf-vertical');
		$(".sf-vertical, .sf-vertical li").css('width',v_width+"px");
		$(".sf-vertical li ul,.sf-vertical li.sfHover ul").css('left',v_width+"px");
	}
	var vspeed = speed;
	var vdelay = delay;	
	var vani = 'fadeslide';
	if(fade1 == "fade1" && slide1 == "slide1"){vani = 'fadeslide'}else
	if(fade1 == "fade0" && slide1 == "slide0"){vani = 'none'}else	
	if(fade1 == "fade1"){vani = 'fade'}else
	if(slide1 == "slide1"){vani = 'slide'}
	var varrows = false;
	if (arrows == 'arrows1'){varrows = true}
	$("ul."+classofmenu).supersubs({ 
		minWidth:    ssmin,   // minimum width of sub-menus in em units 
		maxWidth:    ssmax,   // maximum width of sub-menus in em units 
		extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
						   // due to slight rounding differences and font-family 
	}).superfish({ 
		delay:       vdelay,                            // one second delay on mouseout 
		animation:   vani,  							// fade-in and slide-down animation 
		speed:       vspeed,                          // faster animation speed 
		autoArrows:  varrows,                           // disable generation of arrow mark-up 
		dropShadows: false ,                         // disable drop shadows 
		onInit:        function(){},     			  // callback function fires once Superfish is initialised – 'this' is the containing ul 
		onBeforeShow:  function(){},     			  // callback function fires just before reveal animation begins – 'this' is the ul about to open 
		onShow:        function(){},     			  // callback function fires once reveal animation completed – 'this' is the opened ul 
		onHide:        function(){}     			 // callback function fires after a sub-menu has closed – 'this' is the ul that just closed     
		});								  			// call supersubs first, then superfish, so that subs are 
													 // not display:none when measuring. Call before initialising 
													 // containing tabs for same reason. 

}

//==================================
function languagemenu(classname,timout,fx){
	var fx = fx;
	var langlist = $('.'+classname);
	if(langlist.length > 0){
		langlist.css({'display':'none','position':'absolute','top':'0px','left':'0px'});
		langlist.wrap('<div id="langwrap" style="position:relative;"/>');
		$('#langwrap').wrap('<div id="langposition"/>');
		langlist.before('<div id="activelang" style="position:absolute;top:0px;left:0px;"><a href="javascript:void(0);" style="display:block;">'+$('.languagemenu li a.selected,.languagemenu li a.open,.languagemenu li a.openselected').html()+'</a></div>');	

			
			function showmenu(){
				if(fx == 'fade'){
					langlist.stop(true,true).fadeIn();
				}else if (fx == 'slide'){
					langlist.stop(false,true).slideDown();					
				}
			}
			function hidemenu(){
				if(fx == 'fade'){
					langlist.fadeOut();
				}else if (fx == 'slide'){
					langlist.slideUp();					
				}
			}
			
			$("#activelang a") 
			.mouseover( function() { 
					showmenu(); 
			}) 
			.mouseout( function() { 
					t = setTimeout(function(){ 
							hidemenu()                                      
					}, timout); // adjust your time here 
			}); 


			langlist.hover(function(){ 
					clearTimeout(t); 
			},function(){ 
					hidemenu();                                              
			}); 
	}

}
//shuffle function
//$('ul').shuffle();
//var arr = [1,2,3,4,5,6];
//arr = $.shuffle(arr);
(function($){
  $.fn.shuffle = function() {
	return this.each(function(){
	  var items = $(this).children();
	  return (items.length)
		? $(this).html($.shuffle(items))
		: this;
	});
  }
 
  $.shuffle = function(arr) {
	for(
	  var j, x, i = arr.length; i;
	  j = parseInt(Math.random() * i),
	  x = arr[--i], arr[i] = arr[j], arr[j] = x
	);
	return arr;
  }
})(jQuery);
/**
 * jQuery.timers - Timer abstractions for jQuery
 * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
 * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
 * Date: 2009/10/16
 * http://plugins.jquery.com/project/timers
 * @author Blair Mitchelmore
 * @version 1.2
 *
 **/

jQuery.fn.extend({
	everyTime: function(interval, label, fn, times) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, times);
		});
	},
	oneTime: function(interval, label, fn) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, 1);
		});
	},
	stopTime: function(label, fn) {
		return this.each(function() {
			jQuery.timer.remove(this, label, fn);
		});
	}
});

jQuery.extend({
	timer: {
		global: [],
		guid: 1,
		dataKey: "jQuery.timer",
		regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
		powers: {
			// Yeah this is major overkill...
			'ms': 1,
			'cs': 10,
			'ds': 100,
			's': 1000,
			'das': 10000,
			'hs': 100000,
			'ks': 1000000
		},
		timeParse: function(value) {
			if (value == undefined || value == null)
				return null;
			var result = this.regex.exec(jQuery.trim(value.toString()));
			if (result[2]) {
				var num = parseFloat(result[1]);
				var mult = this.powers[result[2]] || 1;
				return num * mult;
			} else {
				return value;
			}
		},
		add: function(element, interval, label, fn, times) {
			var counter = 0;
			
			if (jQuery.isFunction(label)) {
				if (!times) 
					times = fn;
				fn = label;
				label = interval;
			}
			
			interval = jQuery.timer.timeParse(interval);

			if (typeof interval != 'number' || isNaN(interval) || interval < 0)
				return;

			if (typeof times != 'number' || isNaN(times) || times < 0) 
				times = 0;
			
			times = times || 0;
			
			var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {});
			
			if (!timers[label])
				timers[label] = {};
			
			fn.timerID = fn.timerID || this.guid++;
			
			var handler = function() {
				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
			};
			
			handler.timerID = fn.timerID;
			
			if (!timers[label][fn.timerID])
				timers[label][fn.timerID] = window.setInterval(handler,interval);
			
			this.global.push( element );
			
		},
		remove: function(element, label, fn) {
			var timers = jQuery.data(element, this.dataKey), ret;
			
			if ( timers ) {
				
				if (!label) {
					for ( label in timers )
						this.remove(element, label, fn);
				} else if ( timers[label] ) {
					if ( fn ) {
						if ( fn.timerID ) {
							window.clearInterval(timers[label][fn.timerID]);
							delete timers[label][fn.timerID];
						}
					} else {
						for ( var fn in timers[label] ) {
							window.clearInterval(timers[label][fn]);
							delete timers[label][fn];
						}
					}
					
					for ( ret in timers[label] ) break;
					if ( !ret ) {
						ret = null;
						delete timers[label];
					}
				}
				
				for ( ret in timers ) break;
				if ( !ret ) 
					jQuery.removeData(element, this.dataKey);
			}
		}
	}
});

jQuery(window).bind("unload", function() {
	jQuery.each(jQuery.timer.global, function(index, item) {
		jQuery.timer.remove(item);
	});
});

// * Usage:
// * $.random(int);
// * $.randomBetween(min, max);
$.extend({
	random: function(X) {
		return Math.floor(X * (Math.random() % 1));
	},
	randomBetween: function(MinV, MaxV) {
	  return MinV + $.random(MaxV - MinV + 1);
	}
});


/*
* @name BeautyTips
* @desc a tooltips/baloon-help plugin for jQuery
*
* @author Jeff Robbins - Lullabot - http://www.lullabot.com
* @version 0.9.5-rc1  (5/20/2009)
*/
jQuery.bt = { version: "0.9.5-rc1" }; (function ($) { jQuery.fn.bt = function (content, options) { if (typeof content != "string") { var contentSelect = true; options = content; content = false; } else { var contentSelect = false; } if (jQuery.fn.hoverIntent && jQuery.bt.defaults.trigger == "hover") { jQuery.bt.defaults.trigger = "hoverIntent"; } return this.each(function (index) { var opts = jQuery.extend(false, jQuery.bt.defaults, jQuery.bt.options, options); opts.spikeLength = numb(opts.spikeLength); opts.spikeGirth = numb(opts.spikeGirth); opts.overlap = numb(opts.overlap); var ajaxTimeout = false; if (opts.killTitle) { $(this).find("[title]").andSelf().each(function () { if (!$(this).attr("bt-xTitle")) { $(this).attr("bt-xTitle", $(this).attr("title")).attr("title", ""); } }); } if (typeof opts.trigger == "string") { opts.trigger = [opts.trigger]; } if (opts.trigger[0] == "hoverIntent") { var hoverOpts = jQuery.extend(opts.hoverIntentOpts, { over: function () { this.btOn(); }, out: function () { this.btOff(); } }); $(this).hoverIntent(hoverOpts); } else { if (opts.trigger[0] == "hover") { $(this).hover(function () { this.btOn(); }, function () { this.btOff(); }); } else { if (opts.trigger[0] == "now") { if ($(this).hasClass("bt-active")) { this.btOff(); } else { this.btOn(); } } else { if (opts.trigger[0] == "none") { } else { if (opts.trigger.length > 1 && opts.trigger[0] != opts.trigger[1]) { $(this).bind(opts.trigger[0], function () { this.btOn(); }).bind(opts.trigger[1], function () { this.btOff(); }); } else { $(this).bind(opts.trigger[0], function () { if ($(this).hasClass("bt-active")) { this.btOff(); } else { this.btOn(); } }); } } } } } this.btOn = function () { if (typeof $(this).data("bt-box") == "object") { this.btOff(); } opts.preBuild.apply(this); $(jQuery.bt.vars.closeWhenOpenStack).btOff(); $(this).addClass("bt-active " + opts.activeClass); if (contentSelect && opts.ajaxPath == null) { if (opts.killTitle) { $(this).attr("title", $(this).attr("bt-xTitle")); } content = $.isFunction(opts.contentSelector) ? opts.contentSelector.apply(this) : eval(opts.contentSelector); if (opts.killTitle) { $(this).attr("title", ""); } } if (opts.ajaxPath != null && content == false) { if (typeof opts.ajaxPath == "object") { var url = eval(opts.ajaxPath[0]); url += opts.ajaxPath[1] ? " " + opts.ajaxPath[1] : ""; } else { var url = opts.ajaxPath; } var off = url.indexOf(" "); if (off >= 0) { var selector = url.slice(off, url.length); url = url.slice(0, off); } var cacheData = opts.ajaxCache ? $(document.body).data("btCache-" + url.replace(/\./g, "")) : null; if (typeof cacheData == "string") { content = selector ? $("<div/>").append(cacheData.replace(/<script(.|\s)*?\/script>/g, "")).find(selector) : cacheData; } else { var target = this; var ajaxOpts = jQuery.extend(false, { type: opts.ajaxType, data: opts.ajaxData, cache: opts.ajaxCache, url: url, complete: function (XMLHttpRequest, textStatus) { if (textStatus == "success" || textStatus == "notmodified") { if (opts.ajaxCache) { $(document.body).data("btCache-" + url.replace(/\./g, ""), XMLHttpRequest.responseText); } ajaxTimeout = false; content = selector ? $("<div/>").append(XMLHttpRequest.responseText.replace(/<script(.|\s)*?\/script>/g, "")).find(selector) : XMLHttpRequest.responseText; } else { if (textStatus == "timeout") { ajaxTimeout = true; } content = opts.ajaxError.replace(/%error/g, XMLHttpRequest.statusText); } if ($(target).hasClass("bt-active")) { target.btOn(); } } }, opts.ajaxOpts); jQuery.ajax(ajaxOpts); content = opts.ajaxLoading; } } var shadowMarginX = 0; var shadowMarginY = 0; var shadowShiftX = 0; var shadowShiftY = 0; if (opts.shadow && !shadowSupport()) { opts.shadow = false; jQuery.extend(opts, opts.noShadowOpts); } if (opts.shadow) { if (opts.shadowBlur > Math.abs(opts.shadowOffsetX)) { shadowMarginX = opts.shadowBlur * 2; } else { shadowMarginX = opts.shadowBlur + Math.abs(opts.shadowOffsetX); } shadowShiftX = (opts.shadowBlur - opts.shadowOffsetX) > 0 ? opts.shadowBlur - opts.shadowOffsetX : 0; if (opts.shadowBlur > Math.abs(opts.shadowOffsetY)) { shadowMarginY = opts.shadowBlur * 2; } else { shadowMarginY = opts.shadowBlur + Math.abs(opts.shadowOffsetY); } shadowShiftY = (opts.shadowBlur - opts.shadowOffsetY) > 0 ? opts.shadowBlur - opts.shadowOffsetY : 0; } if (opts.offsetParent) { var offsetParent = $(opts.offsetParent); var offsetParentPos = offsetParent.offset(); var pos = $(this).offset(); var top = numb(pos.top) - numb(offsetParentPos.top) + numb($(this).css("margin-top")) - shadowShiftY; var left = numb(pos.left) - numb(offsetParentPos.left) + numb($(this).css("margin-left")) - shadowShiftX; } else { var offsetParent = ($(this).css("position") == "absolute") ? $(this).parents().eq(0).offsetParent() : $(this).offsetParent(); var pos = $(this).btPosition(); var top = numb(pos.top) + numb($(this).css("margin-top")) - shadowShiftY; var left = numb(pos.left) + numb($(this).css("margin-left")) - shadowShiftX; } var width = $(this).btOuterWidth(); var height = $(this).outerHeight(); if (typeof content == "object") { var original = content; var clone = $(original).clone(true).show(); var origClones = $(original).data("bt-clones") || []; origClones.push(clone); $(original).data("bt-clones", origClones); $(clone).data("bt-orig", original); $(this).data("bt-content-orig", { original: original, clone: clone }); content = clone; } if (typeof content == "null" || content == "") { return; } var $text = $('<div class="bt-content"></div>').append(content).css({ padding: opts.padding, position: "absolute", width: (opts.shrinkToFit ? "auto" : opts.width), zIndex: opts.textzIndex, left: shadowShiftX, top: shadowShiftY }).css(opts.cssStyles); var $box = $('<div class="bt-wrapper"></div>').append($text).addClass(opts.cssClass).css({ position: "absolute", width: opts.width, zIndex: opts.wrapperzIndex, visibility: "hidden" }).appendTo(offsetParent); if (jQuery.fn.bgiframe) { $text.bgiframe(); $box.bgiframe(); } $(this).data("bt-box", $box); var scrollTop = numb($(document).scrollTop()); var scrollLeft = numb($(document).scrollLeft()); var docWidth = numb($(window).width()); var docHeight = numb($(window).height()); var winRight = scrollLeft + docWidth; var winBottom = scrollTop + docHeight; var space = new Object(); var thisOffset = $(this).offset(); space.top = thisOffset.top - scrollTop; space.bottom = docHeight - ((thisOffset + height) - scrollTop); space.left = thisOffset.left - scrollLeft; space.right = docWidth - ((thisOffset.left + width) - scrollLeft); var textOutHeight = numb($text.outerHeight()); var textOutWidth = numb($text.btOuterWidth()); if (opts.positions.constructor == String) { opts.positions = opts.positions.replace(/ /, "").split(","); } if (opts.positions[0] == "most") { var position = "top"; for (var pig in space) { position = space[pig] > space[position] ? pig : position; } } else { for (var x in opts.positions) { var position = opts.positions[x]; if ((position == "left" || position == "right") && space[position] > textOutWidth + opts.spikeLength) { break; } else { if ((position == "top" || position == "bottom") && space[position] > textOutHeight + opts.spikeLength) { break; } } } } var horiz = left + ((width - textOutWidth) * 0.5); var vert = top + ((height - textOutHeight) * 0.5); var points = new Array(); var textTop, textLeft, textRight, textBottom, textTopSpace, textBottomSpace, textLeftSpace, textRightSpace, crossPoint, textCenter, spikePoint; switch (position) { case "top": $text.css("margin-bottom", opts.spikeLength + "px"); $box.css({ top: (top - $text.outerHeight(true)) + opts.overlap, left: horiz }); textRightSpace = (winRight - opts.windowMargin) - ($text.offset().left + $text.btOuterWidth(true)); var xShift = shadowShiftX; if (textRightSpace < 0) { $box.css("left", (numb($box.css("left")) + textRightSpace) + "px"); xShift -= textRightSpace; } textLeftSpace = ($text.offset().left + numb($text.css("margin-left"))) - (scrollLeft + opts.windowMargin); if (textLeftSpace < 0) { $box.css("left", (numb($box.css("left")) - textLeftSpace) + "px"); xShift += textLeftSpace; } textTop = $text.btPosition().top + numb($text.css("margin-top")); textLeft = $text.btPosition().left + numb($text.css("margin-left")); textRight = textLeft + $text.btOuterWidth(); textBottom = textTop + $text.outerHeight(); textCenter = { x: textLeft + ($text.btOuterWidth() * opts.centerPointX), y: textTop + ($text.outerHeight() * opts.centerPointY) }; points[points.length] = spikePoint = { y: textBottom + opts.spikeLength, x: ((textRight - textLeft) * 0.5) + xShift, type: "spike" }; crossPoint = findIntersectX(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textBottom); crossPoint.x = crossPoint.x < textLeft + opts.spikeGirth / 2 + opts.cornerRadius ? textLeft + opts.spikeGirth / 2 + opts.cornerRadius : crossPoint.x; crossPoint.x = crossPoint.x > (textRight - opts.spikeGirth / 2) - opts.cornerRadius ? (textRight - opts.spikeGirth / 2) - opts.CornerRadius : crossPoint.x; points[points.length] = { x: crossPoint.x - (opts.spikeGirth / 2), y: textBottom, type: "join" }; points[points.length] = { x: textLeft, y: textBottom, type: "corner" }; points[points.length] = { x: textLeft, y: textTop, type: "corner" }; points[points.length] = { x: textRight, y: textTop, type: "corner" }; points[points.length] = { x: textRight, y: textBottom, type: "corner" }; points[points.length] = { x: crossPoint.x + (opts.spikeGirth / 2), y: textBottom, type: "join" }; points[points.length] = spikePoint; break; case "left": $text.css("margin-right", opts.spikeLength + "px"); $box.css({ top: vert + "px", left: ((left - $text.btOuterWidth(true)) + opts.overlap) + "px" }); textBottomSpace = (winBottom - opts.windowMargin) - ($text.offset().top + $text.outerHeight(true)); var yShift = shadowShiftY; if (textBottomSpace < 0) { $box.css("top", (numb($box.css("top")) + textBottomSpace) + "px"); yShift -= textBottomSpace; } textTopSpace = ($text.offset().top + numb($text.css("margin-top"))) - (scrollTop + opts.windowMargin); if (textTopSpace < 0) { $box.css("top", (numb($box.css("top")) - textTopSpace) + "px"); yShift += textTopSpace; } textTop = $text.btPosition().top + numb($text.css("margin-top")); textLeft = $text.btPosition().left + numb($text.css("margin-left")); textRight = textLeft + $text.btOuterWidth(); textBottom = textTop + $text.outerHeight(); textCenter = { x: textLeft + ($text.btOuterWidth() * opts.centerPointX), y: textTop + ($text.outerHeight() * opts.centerPointY) }; points[points.length] = spikePoint = { x: textRight + opts.spikeLength, y: ((textBottom - textTop) * 0.5) + yShift, type: "spike" }; crossPoint = findIntersectY(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textRight); crossPoint.y = crossPoint.y < textTop + opts.spikeGirth / 2 + opts.cornerRadius ? textTop + opts.spikeGirth / 2 + opts.cornerRadius : crossPoint.y; crossPoint.y = crossPoint.y > (textBottom - opts.spikeGirth / 2) - opts.cornerRadius ? (textBottom - opts.spikeGirth / 2) - opts.cornerRadius : crossPoint.y; points[points.length] = { x: textRight, y: crossPoint.y + opts.spikeGirth / 2, type: "join" }; points[points.length] = { x: textRight, y: textBottom, type: "corner" }; points[points.length] = { x: textLeft, y: textBottom, type: "corner" }; points[points.length] = { x: textLeft, y: textTop, type: "corner" }; points[points.length] = { x: textRight, y: textTop, type: "corner" }; points[points.length] = { x: textRight, y: crossPoint.y - opts.spikeGirth / 2, type: "join" }; points[points.length] = spikePoint; break; case "bottom": $text.css("margin-top", opts.spikeLength + "px"); $box.css({ top: (top + height) - opts.overlap, left: horiz }); textRightSpace = (winRight - opts.windowMargin) - ($text.offset().left + $text.btOuterWidth(true)); var xShift = shadowShiftX; if (textRightSpace < 0) { $box.css("left", (numb($box.css("left")) + textRightSpace) + "px"); xShift -= textRightSpace; } textLeftSpace = ($text.offset().left + numb($text.css("margin-left"))) - (scrollLeft + opts.windowMargin); if (textLeftSpace < 0) { $box.css("left", (numb($box.css("left")) - textLeftSpace) + "px"); xShift += textLeftSpace; } textTop = $text.btPosition().top + numb($text.css("margin-top")); textLeft = $text.btPosition().left + numb($text.css("margin-left")); textRight = textLeft + $text.btOuterWidth(); textBottom = textTop + $text.outerHeight(); textCenter = { x: textLeft + ($text.btOuterWidth() * opts.centerPointX), y: textTop + ($text.outerHeight() * opts.centerPointY) }; points[points.length] = spikePoint = { x: ((textRight - textLeft) * 0.5) + xShift, y: shadowShiftY, type: "spike" }; crossPoint = findIntersectX(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textTop); crossPoint.x = crossPoint.x < textLeft + opts.spikeGirth / 2 + opts.cornerRadius ? textLeft + opts.spikeGirth / 2 + opts.cornerRadius : crossPoint.x; crossPoint.x = crossPoint.x > (textRight - opts.spikeGirth / 2) - opts.cornerRadius ? (textRight - opts.spikeGirth / 2) - opts.cornerRadius : crossPoint.x; points[points.length] = { x: crossPoint.x + opts.spikeGirth / 2, y: textTop, type: "join" }; points[points.length] = { x: textRight, y: textTop, type: "corner" }; points[points.length] = { x: textRight, y: textBottom, type: "corner" }; points[points.length] = { x: textLeft, y: textBottom, type: "corner" }; points[points.length] = { x: textLeft, y: textTop, type: "corner" }; points[points.length] = { x: crossPoint.x - (opts.spikeGirth / 2), y: textTop, type: "join" }; points[points.length] = spikePoint; break; case "right": $text.css("margin-left", (opts.spikeLength + "px")); $box.css({ top: vert + "px", left: ((left + width) - opts.overlap) + "px" }); textBottomSpace = (winBottom - opts.windowMargin) - ($text.offset().top + $text.outerHeight(true)); var yShift = shadowShiftY; if (textBottomSpace < 0) { $box.css("top", (numb($box.css("top")) + textBottomSpace) + "px"); yShift -= textBottomSpace; } textTopSpace = ($text.offset().top + numb($text.css("margin-top"))) - (scrollTop + opts.windowMargin); if (textTopSpace < 0) { $box.css("top", (numb($box.css("top")) - textTopSpace) + "px"); yShift += textTopSpace; } textTop = $text.btPosition().top + numb($text.css("margin-top")); textLeft = $text.btPosition().left + numb($text.css("margin-left")); textRight = textLeft + $text.btOuterWidth(); textBottom = textTop + $text.outerHeight(); textCenter = { x: textLeft + ($text.btOuterWidth() * opts.centerPointX), y: textTop + ($text.outerHeight() * opts.centerPointY) }; points[points.length] = spikePoint = { x: shadowShiftX, y: ((textBottom - textTop) * 0.5) + yShift, type: "spike" }; crossPoint = findIntersectY(spikePoint.x, spikePoint.y, textCenter.x, textCenter.y, textLeft); crossPoint.y = crossPoint.y < textTop + opts.spikeGirth / 2 + opts.cornerRadius ? textTop + opts.spikeGirth / 2 + opts.cornerRadius : crossPoint.y; crossPoint.y = crossPoint.y > (textBottom - opts.spikeGirth / 2) - opts.cornerRadius ? (textBottom - opts.spikeGirth / 2) - opts.cornerRadius : crossPoint.y; points[points.length] = { x: textLeft, y: crossPoint.y - opts.spikeGirth / 2, type: "join" }; points[points.length] = { x: textLeft, y: textTop, type: "corner" }; points[points.length] = { x: textRight, y: textTop, type: "corner" }; points[points.length] = { x: textRight, y: textBottom, type: "corner" }; points[points.length] = { x: textLeft, y: textBottom, type: "corner" }; points[points.length] = { x: textLeft, y: crossPoint.y + opts.spikeGirth / 2, type: "join" }; points[points.length] = spikePoint; break; } var canvas = document.createElement("canvas"); $(canvas).attr("width", (numb($text.btOuterWidth(true)) + opts.strokeWidth * 2 + shadowMarginX)).attr("height", (numb($text.outerHeight(true)) + opts.strokeWidth * 2 + shadowMarginY)).appendTo($box).css({ position: "absolute", zIndex: opts.boxzIndex }); if (typeof G_vmlCanvasManager != "undefined") { canvas = G_vmlCanvasManager.initElement(canvas); } if (opts.cornerRadius > 0) { var newPoints = new Array(); var newPoint; for (var i = 0; i < points.length; i++) { if (points[i].type == "corner") { newPoint = betweenPoint(points[i], points[(i - 1) % points.length], opts.cornerRadius); newPoint.type = "arcStart"; newPoints[newPoints.length] = newPoint; newPoints[newPoints.length] = points[i]; newPoint = betweenPoint(points[i], points[(i + 1) % points.length], opts.cornerRadius); newPoint.type = "arcEnd"; newPoints[newPoints.length] = newPoint; } else { newPoints[newPoints.length] = points[i]; } } points = newPoints; } var ctx = canvas.getContext("2d"); if (opts.shadow && opts.shadowOverlap !== true) { var shadowOverlap = numb(opts.shadowOverlap); switch (position) { case "top": if (opts.shadowOffsetX + opts.shadowBlur - shadowOverlap > 0) { $box.css("top", (numb($box.css("top")) - (opts.shadowOffsetX + opts.shadowBlur - shadowOverlap))); } break; case "right": if (shadowShiftX - shadowOverlap > 0) { $box.css("left", (numb($box.css("left")) + shadowShiftX - shadowOverlap)); } break; case "bottom": if (shadowShiftY - shadowOverlap > 0) { $box.css("top", (numb($box.css("top")) + shadowShiftY - shadowOverlap)); } break; case "left": if (opts.shadowOffsetY + opts.shadowBlur - shadowOverlap > 0) { $box.css("left", (numb($box.css("left")) - (opts.shadowOffsetY + opts.shadowBlur - shadowOverlap))); } break; } } drawIt.apply(ctx, [points], opts.strokeWidth); ctx.fillStyle = opts.fill; if (opts.shadow) { ctx.shadowOffsetX = opts.shadowOffsetX; ctx.shadowOffsetY = opts.shadowOffsetY; ctx.shadowBlur = opts.shadowBlur; ctx.shadowColor = opts.shadowColor; } ctx.closePath(); ctx.fill(); if (opts.strokeWidth > 0) { ctx.shadowColor = "rgba(0, 0, 0, 0)"; ctx.lineWidth = opts.strokeWidth; ctx.strokeStyle = opts.strokeStyle; ctx.beginPath(); drawIt.apply(ctx, [points], opts.strokeWidth); ctx.closePath(); ctx.stroke(); } opts.preShow.apply(this, [$box[0]]); $box.css({ display: "none", visibility: "visible" }); opts.showTip.apply(this, [$box[0]]); if (opts.overlay) { var overlay = $('<div class="bt-overlay"></div>').css({ position: "absolute", backgroundColor: "blue", top: top, left: left, width: width, height: height, opacity: ".2" }).appendTo(offsetParent); $(this).data("overlay", overlay); } if ((opts.ajaxPath != null && opts.ajaxCache == false) || ajaxTimeout) { content = false; } if (opts.clickAnywhereToClose) { jQuery.bt.vars.clickAnywhereStack.push(this); $(document).click(jQuery.bt.docClick); } if (opts.closeWhenOthersOpen) { jQuery.bt.vars.closeWhenOpenStack.push(this); } opts.postShow.apply(this, [$box[0]]); }; this.btOff = function () { var box = $(this).data("bt-box"); opts.preHide.apply(this, [box]); var i = this; i.btCleanup = function () { var box = $(i).data("bt-box"); var contentOrig = $(i).data("bt-content-orig"); var overlay = $(i).data("bt-overlay"); if (typeof box == "object") { $(box).remove(); $(i).removeData("bt-box"); } if (typeof contentOrig == "object") { var clones = $(contentOrig.original).data("bt-clones"); $(contentOrig).data("bt-clones", arrayRemove(clones, contentOrig.clone)); } if (typeof overlay == "object") { $(overlay).remove(); $(i).removeData("bt-overlay"); } jQuery.bt.vars.clickAnywhereStack = arrayRemove(jQuery.bt.vars.clickAnywhereStack, i); jQuery.bt.vars.closeWhenOpenStack = arrayRemove(jQuery.bt.vars.closeWhenOpenStack, i); $(i).removeClass("bt-active " + opts.activeClass); opts.postHide.apply(i); }; opts.hideTip.apply(this, [box, i.btCleanup]); }; var refresh = this.btRefresh = function () { this.btOff(); this.btOn(); }; }); function drawIt(points, strokeWidth) { this.moveTo(points[0].x, points[0].y); for (i = 1; i < points.length; i++) { if (points[i - 1].type == "arcStart") { this.quadraticCurveTo(round5(points[i].x, strokeWidth), round5(points[i].y, strokeWidth), round5(points[(i + 1) % points.length].x, strokeWidth), round5(points[(i + 1) % points.length].y, strokeWidth)); i++; } else { this.lineTo(round5(points[i].x, strokeWidth), round5(points[i].y, strokeWidth)); } } } function round5(num, strokeWidth) { var ret; strokeWidth = numb(strokeWidth); if (strokeWidth % 2) { ret = num; } else { ret = Math.round(num - 0.5) + 0.5; } return ret; } function numb(num) { return parseInt(num) || 0; } function arrayRemove(arr, elem) { var x, newArr = new Array(); for (x in arr) { if (arr[x] != elem) { newArr.push(arr[x]); } } return newArr; } function canvasSupport() { var canvas_compatible = false; try { canvas_compatible = !!(document.createElement("canvas").getContext("2d")); } catch (e) { canvas_compatible = !!(document.createElement("canvas").getContext); } return canvas_compatible; } function shadowSupport() { try { var userAgent = navigator.userAgent.toLowerCase(); if (/webkit/.test(userAgent)) { return true; } else { if (/gecko|mozilla/.test(userAgent) && parseFloat(userAgent.match(/firefox\/(\d+(?:\.\d+)+)/)[1]) >= 3.1) { return true; } } } catch (err) { } return false; } function betweenPoint(point1, point2, dist) { var y, x; if (point1.x == point2.x) { y = point1.y < point2.y ? point1.y + dist : point1.y - dist; return { x: point1.x, y: y }; } else { if (point1.y == point2.y) { x = point1.x < point2.x ? point1.x + dist : point1.x - dist; return { x: x, y: point1.y }; } } } function centerPoint(arcStart, corner, arcEnd) { var x = corner.x == arcStart.x ? arcEnd.x : arcStart.x; var y = corner.y == arcStart.y ? arcEnd.y : arcStart.y; var startAngle, endAngle; if (arcStart.x < arcEnd.x) { if (arcStart.y > arcEnd.y) { startAngle = (Math.PI / 180) * 180; endAngle = (Math.PI / 180) * 90; } else { startAngle = (Math.PI / 180) * 90; endAngle = 0; } } else { if (arcStart.y > arcEnd.y) { startAngle = (Math.PI / 180) * 270; endAngle = (Math.PI / 180) * 180; } else { startAngle = 0; endAngle = (Math.PI / 180) * 270; } } return { x: x, y: y, type: "center", startAngle: startAngle, endAngle: endAngle }; } function findIntersect(r1x1, r1y1, r1x2, r1y2, r2x1, r2y1, r2x2, r2y2) { if (r2x1 == r2x2) { return findIntersectY(r1x1, r1y1, r1x2, r1y2, r2x1); } if (r2y1 == r2y2) { return findIntersectX(r1x1, r1y1, r1x2, r1y2, r2y1); } var r1m = (r1y1 - r1y2) / (r1x1 - r1x2); var r1b = r1y1 - (r1m * r1x1); var r2m = (r2y1 - r2y2) / (r2x1 - r2x2); var r2b = r2y1 - (r2m * r2x1); var x = (r2b - r1b) / (r1m - r2m); var y = r1m * x + r1b; return { x: x, y: y }; } function findIntersectY(r1x1, r1y1, r1x2, r1y2, x) { if (r1y1 == r1y2) { return { x: x, y: r1y1 }; } var r1m = (r1y1 - r1y2) / (r1x1 - r1x2); var r1b = r1y1 - (r1m * r1x1); var y = r1m * x + r1b; return { x: x, y: y }; } function findIntersectX(r1x1, r1y1, r1x2, r1y2, y) { if (r1x1 == r1x2) { return { x: r1x1, y: y }; } var r1m = (r1y1 - r1y2) / (r1x1 - r1x2); var r1b = r1y1 - (r1m * r1x1); var x = (y - r1b) / r1m; return { x: x, y: y }; } }; jQuery.fn.btPosition = function () { function num(elem, prop) { return elem[0] && parseInt(jQuery.curCSS(elem[0], prop, true), 10) || 0; } var left = 0, top = 0, results; if (this[0]) { var offsetParent = this.offsetParent(), offset = this.offset(), parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0} : offsetParent.offset(); offset.top -= num(this, "marginTop"); offset.left -= num(this, "marginLeft"); parentOffset.top += num(offsetParent, "borderTopWidth"); parentOffset.left += num(offsetParent, "borderLeftWidth"); results = { top: offset.top - parentOffset.top, left: offset.left - parentOffset.left }; } return results; }; jQuery.fn.btOuterWidth = function (margin) { function num(elem, prop) { return elem[0] && parseInt(jQuery.curCSS(elem[0], prop, true), 10) || 0; } return this["innerWidth"]() + num(this, "borderLeftWidth") + num(this, "borderRightWidth") + (margin ? num(this, "marginLeft") + num(this, "marginRight") : 0); }; jQuery.fn.btOn = function () { return this.each(function (index) { if (jQuery.isFunction(this.btOn)) { this.btOn(); } }); }; jQuery.fn.btOff = function () { return this.each(function (index) { if (jQuery.isFunction(this.btOff)) { this.btOff(); } }); }; jQuery.bt.vars = { clickAnywhereStack: [], closeWhenOpenStack: [] }; jQuery.bt.docClick = function (e) { if (!e) { var e = window.event; } if (!$(e.target).parents().andSelf().filter(".bt-wrapper, .bt-active").length && jQuery.bt.vars.clickAnywhereStack.length) { $(jQuery.bt.vars.clickAnywhereStack).btOff(); $(document).unbind("click", jQuery.bt.docClick); } }; jQuery.bt.defaults = { trigger: "hover", clickAnywhereToClose: true, closeWhenOthersOpen: false, shrinkToFit: false, width: "200px", padding: "10px", spikeGirth: 10, spikeLength: 15, overlap: 0, overlay: false, killTitle: true, textzIndex: 9999, boxzIndex: 9998, wrapperzIndex: 9997, offsetParent: null, positions: ["most"], fill: "rgb(255, 255, 102)", windowMargin: 10, strokeWidth: 1, strokeStyle: "#000", cornerRadius: 5, centerPointX: 0.5, centerPointY: 0.5, shadow: false, shadowOffsetX: 2, shadowOffsetY: 2, shadowBlur: 3, shadowColor: "#000", shadowOverlap: false, noShadowOpts: { strokeStyle: "#999" }, cssClass: "", cssStyles: {}, activeClass: "bt-active", contentSelector: "$(this).attr('title')", ajaxPath: null, ajaxError: "<strong>ERROR:</strong> <em>%error</em>", ajaxLoading: "<blink>Loading...</blink>", ajaxData: {}, ajaxType: "GET", ajaxCache: true, ajaxOpts: {}, preBuild: function () { }, preShow: function (box) { }, showTip: function (box) { $(box).show(); }, postShow: function (box) { }, preHide: function (box) { }, hideTip: function (box, callback) { $(box).hide(); callback(); }, postHide: function () { }, hoverIntentOpts: { interval: 300, timeout: 500} }; jQuery.bt.options = {}; })(jQuery);


//TOOLTIPS
function tt() {
	$('.tooltip').bt({
		showTip: function (box) {
			$(box).fadeIn(400);
		},
		hideTip: function (box, callback) {
			$(box).animate({ opacity: 0 }, 300, callback);
		}
	});
	$('input').bt({
		trigger: ['focus', 'blur'],
		positions: ['right'],
		showTip: function (box) {
			$(box).fadeIn(400);
		},
		hideTip: function (box, callback) {
			$(box).animate({ opacity: 0 }, 300, callback);
		},
		width: 100
	});
}
//======================================================================================================================

/*
Columnize Plugin for jQuery
Version: v0.10

Copyright (C) 2008-2010 by Lutz Issler

Systemantics GmbH
Am Lavenstein 3
52064 Aachen
GERMANY

Web:    www.systemantics.net
Email:  hello@systemantics.net

This plugin is distributed under the terms of the
GNU Lesser General Public license. The license can be obtained
from http://www.gnu.org/licenses/lgpl.html.

*/

(function () {
	var cloneEls = new Object();
	var numColsById = new Object();
	var uniqueId = 0;

	function _layoutElement(elDOM, settings, balance) {
		// Some semi-global variables
		var colHeight;
		var colWidth;
		var col;
		var currentColEl;
		var cols = new Array();
		var colNum = 0;
		var colSet = 0;

		var el = jQuery(elDOM);

		// Save numCols property for this element
		// (needed for pagination)
		numColsById[elDOM.id] = settings.columns;

		// Remove child nodes
		el.empty();

		// Macro function (with side effects)
		function _newColumn() {
			colNum++;

			// Add a new column
			col = document.createElement("DIV");
			col.className = settings.column;
			el.append(col);
			currentColEl = col;
			colWidth = jQuery(col).width();
			cols.push(col);

			// Add the same subnode nesting to the new column
			// as there was in the old column
			for (var j = 0; j < subnodes.length; j++) {
				newEl = subnodes[j].cloneNode(false);
				if (j == 0 || innerContinued) {
					jQuery(newEl).addClass(settings.continued);
				}
				currentColEl.appendChild(newEl);
				currentColEl = newEl;
			}
		}

		// Returns the margin-bottom CSS property of a certain node
		function _getMarginBottom(currentColEl) {
			var marginBottom = parseInt(jQuery(currentColEl).css("marginBottom"));
			if (marginBottom.toString() == 'NaN') {
				marginBottom = 0;
			}
			var currentColElParents = jQuery(currentColEl).parents();
			for (var j = 0; j < currentColElParents.length; j++) {
				if (currentColElParents[j] == elDOM) {
					break;
				}
				var curMarginBottom = parseInt(jQuery(currentColElParents[j]).css("marginBottom"));
				if (curMarginBottom.toString() != 'NaN') {
					marginBottom = Math.max(marginBottom, curMarginBottom);
				}
			}
			return marginBottom;
		}

		// Advance to next sibling on el or a parent level
		function _skipToNextNode() {
			while (currentEl && currentColEl && !currentEl.nextSibling) {
				currentEl = currentEl.parentNode;
				currentColEl = currentColEl.parentNode;
				var node = subnodes.pop();
				// Hack: delete the previously saved HREF
				if (node == "A") {
					href = null;
				}
			}
			if (currentEl) {
				currentEl = currentEl.nextSibling;
			}
		}

		// Take the height from the element to be layouted
		var maxHeight = settings.height
			? settings.height
			: parseInt(el.css("maxHeight"));
		if (balance || isNaN(maxHeight) || maxHeight == 0) {
			// We are asked to balance the col lengths
			// or cannot get the column length from the container,
			// so chose a height that will produce >numCols< columns
			col = document.createElement("DIV");
			col.className = settings.column;
			jQuery(col).append(jQuery(cloneEls[elDOM.id]).html());
			el.append(col);
			var lineHeight = parseInt(el.css("lineHeight"));
			if (!lineHeight) {
				// Assume a line height of 120%
				lineHeight = Math.ceil(parseInt(el.css("fontSize")) * 1.2);
			}
			colHeight = Math.ceil(jQuery(col).height() / settings.columns);
			if (colHeight % lineHeight > 0) {
				colHeight += lineHeight;
			}
			elDOM.removeChild(col);
			if (maxHeight > 0 && colHeight > maxHeight) {
				// Balance only to max-height
				colHeight = maxHeight;
			}
		} else {
			colHeight = maxHeight;
		}

		// Take the minimum height into account
		var minHeight = settings.minHeight
			? settings.minHeight
			: parseInt(el.css("minHeight"));
		if (minHeight) {
			colHeight = Math.max(colHeight, minHeight);
		}

		// Start with first child of the initial node
		var currentEl = cloneEls[elDOM.id].children(":first")[0];
		var subnodes = new Array();
		var href = null;
		var lastNodeType = 0;
		_newColumn();
		if (colHeight == 0 || colWidth == 0) {
			// We cannot continue with zero height or width
			return false;
		}
		while (currentEl) {
			if (currentEl.nodeType == 1) {
				// An element node
				var newEl;
				var $currentEl = jQuery(currentEl);
				if ($currentEl.hasClass("dontSplit")
					|| $currentEl.is(settings.dontsplit)) {
					// Don't split this node. Instead, clone it completely
					var newEl = currentEl.cloneNode(true);
					currentColEl.appendChild(newEl);
					if (col.offsetHeight > colHeight) {
						// The column gets too long, start a new colum
						_newColumn();
					}
					_skipToNextNode();
				} else {
					// Clone the node and append it to the current column
					var newEl = currentEl.cloneNode(false);
					currentColEl.appendChild(newEl);
					if (col.offsetHeight - _getMarginBottom(currentColEl) > colHeight) {
						// The column gets too long, start a new colum
						currentColEl.removeChild(newEl);
						var toBeInsertedEl = newEl;
						_newColumn();
						currentColEl.appendChild(toBeInsertedEl);
						newEl = toBeInsertedEl;
					}
					if (currentEl.firstChild) {
						subnodes.push(currentEl.cloneNode(false));
						currentColEl = newEl;
						currentEl = currentEl.firstChild;
					} else {
						_skipToNextNode();
					}
				}
				lastNodeType = 1;
			} else if (currentEl.nodeType == 3) {
				// A text node
				var newEl = document.createTextNode("");
				currentColEl.appendChild(newEl);
				// Determine the current bottom margin
				var marginBottom = _getMarginBottom(currentColEl);
				// Append word by word
				var words = currentEl.data.split(" ");
				for (var i = 0; i < words.length; i++) {
					if (lastNodeType == 3) {
						newEl.appendData(" ");
					}
					newEl.appendData(words[i]);
					currentColEl.removeChild(newEl);
					currentColEl.appendChild(newEl);
					if (col.offsetHeight - marginBottom > colHeight) {
						// el column is full
						// Remove the last word
						newEl.data = newEl.data.substr(0, newEl.data.length - words[i].length - 1);

						// Remove the last node if empty
						var innerContinued;
						if (jQuery(currentColEl).text() == "") {
							jQuery(currentColEl).remove();
							innerContinued = false;
						} else {
							innerContinued = true;
						}

						// Start a new column
						_newColumn();

						// Add a text node at the bottom level
						// in order to continue the column
						newEl = document.createTextNode(words[i]);
						currentColEl.appendChild(newEl);
					}
					lastNodeType = 3;
				}
				_skipToNextNode();
				lastNodeType = 0;
			} else {
				// Any other node (comments, for instance)
				_skipToNextNode();
				lastNodeType = currentEl.nodeType;
			}
		}
		return cols;
	};

	jQuery.fn.columnize = function (settings) {
		settings = jQuery.extend({
			column: "column",
			continued: "continued",
			columns: 2,
			balance: true,
			height: false,
			minHeight: false,
			cache: true,
			dontsplit: ""
		}, settings);
		this.each(function () {
			var jthis = jQuery(this);

			var id = this.id;
			if (!id) {
				// Get a new id
				id = "jcols_" + uniqueId;
				this.id = id;
				uniqueId++;
			}

			if (!cloneEls[this.id] || !settings.cache) {
				cloneEls[this.id] = jthis.clone(true);
			}

			// Layout the columns
			var cols = _layoutElement(this, settings, settings.balance);
			if (!cols) {
				// Layout failed, restore the object's contents
				jthis.append(cloneEls[this.id].children().clone(true));
			}
		});
		return this;
	}
})();

/*
Column layout
Version: v0.5

Copyright (C) 2008 by Systemantics, Bureau for Informatics

Lutz Issler
Mauerstr. 10-12
52064 Aachen
GERMANY

Web:    www.systemantics.net
Email:  mail@systemantics.net

This script is NOT open source. If you want to use this script,
please contact Systemantics in order to obtain a licence.
*/
var COLUMN_LAYOUT = {
	// Fields
	buttonClassName: "",
	buttonBackText: "",
	buttonNextText: "",
	numCols: 1000,
	numColsById: new Object(),
	fixedCols: false,
	balanceSinglePage: false,
	cloneEls: new Object(),
	// Sets the button properties
	setPageProperties: function (buttonClassName, buttonNextText, buttonBackText) {
		this.buttonClassName = buttonClassName;
		this.buttonBackText = buttonBackText;
		this.buttonNextText = buttonNextText;
	},
	// Sets the number of columns
	setCols: function (numCols) {
		this.numCols = numCols;
	},
	// Sets whether or not there should be exactly >numCols< columns
	setFixedCols: function (fixedCols) {
		this.fixedCols = fixedCols;
	},
	// Sets whether or not to balance the length of the columns
	// if there is only a single page
	setBalanceMode: function (balanceMode) {
		this.balanceSinglePage = balanceMode;
	},
	// Internal: Create a button
	createButton: function (text, handler) {
		button = document.createElement("A");
		button.className = COLUMN_LAYOUT.buttonClassName;
		button.href = "#";
		button.onclick = handler;
		button.appendChild(document.createTextNode(text));
		return button;
	},
	// Internal: Layout an element
	_layoutElement: function (el, colClassName, fixedCols) {
		// Some semi-global variables
		var colHeight;
		var colWidth;
		var col;
		var currentColEl;
		var cols = new Array();
		var colNum = 0;
		var colSet = 0;

		// Save numCols property for this element
		this.numColsById[el.id] = this.numCols;

		// Remove child nodes
		while (el.hasChildNodes()) {
			el.removeChild(el.firstChild);
		}

		// Macro function (with side effects)
		function _newColumn() {
			colNum++;
			col = document.createElement("DIV");
			col.id = el.id + "__col" + (colSet * COLUMN_LAYOUT.numCols + colNum);
			col.className = colClassName;
			el.appendChild(col);
			currentColEl = col;
			colWidth = col.clientWidth;
			cols.push(col);
		}

		// Initialize the column height
		if (fixedCols) {
			// Chose a height that results in exactly >numCols< columns
			var lineHeight = parseInt(DHTMLAPI.getComputedStyle(el, "line-height"));
			col = document.createElement("DIV");
			col.className = colClassName;
			for (var i = 0; i < this.cloneEls[el.id].childNodes.length; i++) {
				col.appendChild(this.cloneEls[el.id].childNodes[i].cloneNode(true));
			}
			el.appendChild(col);
			colHeight = Math.ceil(DHTMLAPI.getElementHeight(col) / this.numCols);
			if (colHeight % lineHeight > 0) {
				colHeight += lineHeight;
			}
			el.removeChild(col);
		} else {
			// Take the height from the element to be layouted
			colHeight = DHTMLAPI.getElementHeight(el);
		}

		// Start with first child of the initial node
		var currentEl = this.cloneEls[el.id].firstChild;
		var subnodes = new Array();
		var href = null;
		var lastNodeType = 0;
		_newColumn();
		while (currentEl) {
			if (currentEl.nodeType == 1) {
				// An element node
				// Create a similar node and append it to the current column
				var newEl = currentEl.cloneNode(false);
				currentColEl.appendChild(newEl);
				if (currentEl.firstChild) {
					subnodes.push(currentEl.cloneNode(false));
					currentColEl = newEl;
					currentEl = currentEl.firstChild;
				} else {
					// Advance to next sibling on this or a parent level
					while (currentEl && !currentEl.nextSibling) {
						currentEl = currentEl.parentNode;
						currentColEl = currentColEl.parentNode;
						var node = subnodes.pop();
						// Hack: delete the previously saved HREF
						if (node == "A") {
							href = null;
						}
					}
					if (currentEl) {
						currentEl = currentEl.nextSibling;
					}
				}
				lastNodeType = 1;
			} else if (currentEl.nodeType == 3) {
				// A text node
				var newEl = document.createTextNode("");
				currentColEl.appendChild(newEl);
				// Append word by word
				var words = currentEl.data.split(/ /);
				for (var i = 0; i < words.length; i++) {
					if (lastNodeType == 3) {
						newEl.appendData(" ");
					}
					newEl.appendData(words[i]);
					if (col.offsetHeight > colHeight) {
						// This column is full

						if (!fixedCols && colNum == COLUMN_LAYOUT.numCols) {
							// Add the "next" button
							col.appendChild(COLUMN_LAYOUT.createButton(COLUMN_LAYOUT.buttonNextText, function (e) {
								if (!e) var e = window.event;
								var ids = (e.target ? e.target : e.srcElement).parentNode.getAttribute("id").split("__");
								var col = parseInt(ids[1].substr(3));
								for (var i = 1; i <= col; i++) {
									DHTMLAPI.setDisplayMode(ids[0] + "__col" + i, "none");
								}
								for (var i = col + 1; i <= col + COLUMN_LAYOUT.numColsById[ids[0]]; i++) {
									DHTMLAPI.setDisplayMode(ids[0] + "__col" + i, "block");
								}
							}));
							do {
								// Remove words until the "next" button
								// fits into the current column
								newEl.data = newEl.data.substr(0, newEl.data.length - words[i].length - 1);
								i--;
							} while (i >= 0 && col.offsetHeight > colHeight);
							i++;

							colNum = 0;
							colSet++;
						} else {
							// Remove only the last word
							newEl.data = newEl.data.substr(0, newEl.data.length - words[i].length - 1);
						}

						// Start a new column
						_newColumn();

						// Add the same subnode nesting to the new column
						// as there was in the old column
						for (var j = 0; j < subnodes.length; j++) {
							newEl = subnodes[j].cloneNode(false);
							currentColEl.appendChild(newEl);
							currentColEl = newEl;
						}

						// Add a text node at the bottom level
						// in order to continue the column
						newEl = document.createTextNode(words[i]);
						currentColEl.appendChild(newEl);
					}
					lastNodeType = 3;
				}
				// Advance to next sibling on this or a parent level
				while (currentEl && !currentEl.nextSibling) {
					currentEl = currentEl.parentNode;
					currentColEl = currentColEl.parentNode;
					var node = subnodes.pop();
					// Hack: delete the previously saved HREF
					if (node == "A") {
						href = null;
					}
					lastNodeType = 0;
				}
				if (currentEl) {
					currentEl = currentEl.nextSibling;
				}
			} else {
				// Any other node (comments, for instance)
				// Advance to next sibling on this or a parent level
				lastNodeType = currentEl.nodeType;
				while (currentEl && !currentEl.nextSibling) {
					currentEl = currentEl.parentNode;
					currentColEl = currentColEl.parentNode;
					var node = subnodes.pop();
					// Hack: delete the previously saved HREF
					if (node == "A") {
						href = null;
					}
				}
				if (currentEl) {
					currentEl = currentEl.nextSibling;
				}
			}
		}
		if (colSet > 0 && colNum <= COLUMN_LAYOUT.numCols) {
			col.appendChild(COLUMN_LAYOUT.createButton(
				COLUMN_LAYOUT.buttonBackText,
				function (e) {
					if (!e) var e = window.event;
					var ids = (e.target ? e.target : e.srcElement).parentNode.getAttribute("id").split("__");
					var col = parseInt(ids[1].substr(3));
					for (var i = col - COLUMN_LAYOUT.numColsById[ids[0]] + 1; i <= col; i++) {
						DHTMLAPI.setDisplayMode(ids[0] + "__col" + i, "none");
					}
					for (var i = 1; i <= COLUMN_LAYOUT.numColsById[ids[0]]; i++) {
						DHTMLAPI.setDisplayMode(ids[0] + "__col" + i, "block");
					}
				}
			));
		}
		return cols;
	},
	// Layouts the specified element
	layoutElement: function (el, colClassName) {
		if (el == null) {
			return;
		}

		// Clone original node for later traversal
		if (!this.cloneEls[el.id]) {
			this.cloneEls[el.id] = el.cloneNode(true);
		}

		// Layout the columns
		var cols = this._layoutElement(el, colClassName, this.fixedCols);

		// Check whether we have to re-run the algorithm
		// to balance the column lengths
		if (this.balanceSinglePage && cols.length <= this.numCols) {
			this._layoutElement(el, colClassName, true);
		}

		// Hide all columns with index > numCols
		for (var i = this.numCols; i < cols.length; i++) {
			cols[i].style.display = "none";
		}
	},
	// Layouts all DIV elements which belong to the specified CSS class
	layoutAll: function (className, colClassName) {
		var divs = document.getElementsByTagName("DIV");
		var search = new RegExp(".*\\b" + className + "\\b.*");
		for (var d = 0; d < divs.length; d++) {
			if (search.test(divs[d].className)) {
				this.layoutElement(divs[d], colClassName);
			}
		}
	}
}

//vanvoor alleen laten zien als er een van-prijs is
function aanbieding() {
    $('.rundown_item').each(function () {
        //console.log('!' + $(this).find('.van').text());
        if ($(this).find('.van').text() != '') {
            $(this).find('.voorprijs').show().parent().find('.vanprijs').show(); //.next().hide();
        } else {

        }

    });
}

