var $j = jQuery.noConflict();

$j(document).ready(function(){
	
	var gallery = $j("#thumbs");
	if (gallery.size() > 0){
		gallery.galleriffic({
			delay:                     5000,
			numThumbs:                 15,
			preloadAhead:              10,
			enableTopPager:            true,
			enableBottomPager:         true,
			maxPagesToShow:            7,
			imageContainerSel:         '#slideshow',
			controlsContainerSel:      '#controls',
			captionContainerSel:       '#caption',
			loadingContainerSel:       '#loading',
			renderSSControls:          false,
			renderNavControls:         false,
			playLinkText:              'Play Slideshow',
			pauseLinkText:             'Pause Slideshow',
			prevLinkText:              '&lsaquo; Previous Photo',
			nextLinkText:              'Next Photo &rsaquo;',
			nextPageLinkText:          'Next &rsaquo;',
			prevPageLinkText:          '&lsaquo; Prev',
			enableHistory:             false,
			autoStart:                 true,
			syncTransitions:           true,
			defaultTransitionDuration: 900,
			clicknext:false
		});
	}
	
	var caption = $j("ul.thumbs p");
	
	caption.hide();
	caption.eq(0).show().prev().addClass("active-item");
	
	$j("ul.thumbs a.thumb").click(function(ev) {
		if(!$j(this).hasClass("active-item")) {
			$j("a.thumb").removeClass("active-item");
			$j(this).addClass("active-item");
			$j("ul.thumbs p").slideUp('normal');
			$j(this).next().slideDown('normal');
		}
	});
   
	$j("#nav li.active").prev().find("a").css("background-image", "none");
	
	$j("#lampenwijzer_selector").change(function(ev){
		$j(this).closest("form").submit();
	});
	
	var audio = $j("audio");
	if (audio.size() > 0){
		audio.mediaelementplayer({
			audioWidth:300
		});
	}
	
//	var compare = $j("#product_comparison");
//	if (compare.size() > 0){
//		if ($j('#product_comparison td:contains("Niet beschikbaar bij dit product")').length > 0) {
//			$j(this).parent().hide();
//		}
//	}
	// hide table row in comparison table when all products have no value for the attribute
    $j('#product_comparison .attributes-row td:contains("Niet beschikbaar bij dit product")').removeClass("attr");
    $j('#product_comparison .attributes-row td:contains("Nee")').removeClass("attr");
	$j("#product_comparison .attributes-row tr").each(function() {
		if ($j(this).find("td.attr").length === 0) {
			 $j(this).hide();
		}
	});
	$j("#sStore").change(function() {
		var anders = $j("div.anders");
		if($j("#sStore option[value='anders']:selected").length){
			anders.show();
		} else {
			anders.hide();
		}
	});

	$j("#sDatepicker").datepicker({
		monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
		'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
		monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun',
		'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
		dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
		dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
		dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
		dateFormat: 'dd-mm-yy', firstDay: 1,
		prevText: '←', prevStatus: 'Bekijk de vorige maand',
		prevJumpText: '«', nextJumpStatus: 'Bekijk het vorige jaar',
		nextText: '→', nextStatus: 'Bekijk de volgende maand',
		nextJumpText: '»', nextJumpStatus: 'Bekijk het volgende jaar',
		currentText: 'Vandaag', currentStatus: 'Bekijk de huidige maand',
		todayText: 'Vandaag', todayStatus: 'Bekijk de huidige maand',
		clearText: 'Wissen', clearStatus: 'Wis de huidige datum',
		closeText: 'Sluiten', closeStatus: 'Sluit zonder verandering',
		yearStatus: 'Bekijk een ander jaar', monthStatus: 'Bekijk een andere maand',
		weekText: 'Wk', weekStatus: 'Week van het jaar',
		dayStatus: 'dd-mm-yyyy', defaultStatus: 'Kies een datum',
		isRTL: false,
		maxDate: '+0d'
	});
});
