$(document).ready(function() {

	$('#filter').load('modules/Shop/templates/snippets/filter.php');
});

function setFolderId(id) {

	$("input[type=checkbox]").each(function() {  
	this.checked = false;  
	}); 

	if(id) {
		$('input#'+id).attr('checked', true);
	}

	updateFilter();

}

function updateFilter(page_nr) {

	var folders = [];
	var colors = [];
	var sizes = [];
	var modes = [];
	var page = page_nr;
	
    $('#mode :checked').each(function() {
      modes.push($(this).val());
    });
	
	$('#divers :checked').each(function() {
      modes.push($(this).val());
    });
	
	$('#merken :checked').each(function() {
      folders.push($(this).val());
    });
	
	$('#kleuren :checked').each(function() {
      colors.push($(this).val());
    });
	
	$('#maten :checked').each(function() {
      sizes.push($(this).val());
    });

	$('#content').load('index.php #content', {'a_shop' : 'view-folder', 'folders' : folders, 'colors' : colors, 'sizes' : sizes, 'page' : page, 'mode' : modes}, function(){
		
	});
}

function openProduct(item_id, page_nr) {

	var folders = [];
	var colors = [];
	var sizes = []; 
	var modes = [];
	var id = item_id;
	var page = page_nr
		
	$('#mode :checked').each(function() {
      modes.push($(this).val());
    });
	
    $('#merken :checked').each(function() {
      folders.push($(this).val());
    });
	
	$('#kleuren :checked').each(function() {
      colors.push($(this).val());
    });
	
	$('#maten :checked').each(function() {
      sizes.push($(this).val());
    });
	
	var body = document.getElementsByTagName('body').item(0);	
	var script = document.createElement('script');
	script.src = 'js/nivoslider.js';
	script.type = 'text/javascript';
	body.appendChild(script);	
	
	$('#content').load('index.php #content', {'a_shop' : 'view-item', 'folders' : folders, 'colors' : colors, 'sizes' : sizes, 'mode' : modes, 'id' : id, 'page' : page_nr, 'ajax' : 'ok'}, function(){
		
		$('#view_item_image_container').slider({
			preload: false,
			preloadImage: 'img/loading.gif',
			effect: 'slide, fade',
			crossfade: true,
			slideSpeed: 350,
			fadeSpeed: 500,
			generateNextPrev: true,
			generatePagination: false
		});
							
		$(document).ready(function() {
						
			$.getScript('js/fancybox.js', function(){
				$("a#swf").fancybox();	
			})			
			
		});	
	});
}

function toggleList(id) {

	$('#'+id).toggle('slow');
}

function setSize(value) {

	$('.sizes').css({'font-weight' : 'normal', 'color' : '#666'});
	$('a#size_' + value).css({'font-weight' : 'bold', 'color' : 'black'});
	document.forms['view_item_form'].var_2.value= value;	
}

function resetFilter() {

	$("input[type=checkbox]").each(function() {  
		this.checked = false;  
	});
	
	$().load();
	
	$('#filter').load('modules/Shop/templates/snippets/filter.php');
	
	updateFilter();
}

function checkIfSizeSelected() {

	if(document.getElementById('var_2').value == '') {
	
		alert('U dient eerst een maat te selecteren!');	
		
		return false;
	}
}
