
		function langToggle(checkbox) {
			var counter =0;
			if($(checkbox).hasClass('item')) {
				//if this is the ALL button, remove all others
				if($(checkbox).attr('id') == "ALL") {
					$('.lang a.active').each(function(index) {
						$(this).removeClass('active').addClass('item');
					});
				}
				$(checkbox).removeClass('item').addClass('active');
				counter--;
			} else {
				$(checkbox).removeClass('active').addClass('item');
			}
			// remove the All or add the ALL if nothing is selected
			$('.lang a.active').each(function(index) {
				counter++;
			});
			if(counter == 0) {
				$(".lang #ALL").removeClass('item').addClass('active');
			} else {
				$(".lang #ALL").removeClass('active').addClass('item');
			}

			reloadHome();	
			return false;
		}



                function genderToggle(checkbox) {
                        counter =0;
                        if($(checkbox).hasClass('item')) {
                                $(checkbox).removeClass('item').addClass('active');
                        } else {
                                $(checkbox).removeClass('active').addClass('item');
                        }
                        // add the F if nothing is selected
                        $('.gender a.active').each(function(index) {
                                counter++;
                        });
                        if(counter == 0) {
                                $(".gender #F").removeClass('item').addClass('active');
                        } 

                        reloadHome();
                        return false;
                }



                function ageToggle(checkbox) {
                        var counter =0;
                        if($(checkbox).hasClass('item')) {
                                //if this is the ALL button, remove all others
                                if($(checkbox).attr('id') == "ALL") {
                                        $('.age a.active').each(function(index) {
                                                $(this).removeClass('active').addClass('item');
                                        });
                                }
                                $(checkbox).removeClass('item').addClass('active');
                                counter--;
                        } else {
                                $(checkbox).removeClass('active').addClass('item');
                        }
                        // remove the All or add the ALL if nothing is selected
                        $('.age a.active').each(function(index) {
                                counter++;
                        });
                        if(counter == 0) {
                                $(".age #ALL").removeClass('item').addClass('active');
                        } else {
                                $(".age #ALL").removeClass('active').addClass('item');
                        }

                        reloadHome();
                        return false;
                }

                function filterToggle(checkbox) {
                        if($(checkbox).hasClass('item')) {
                                $(checkbox).removeClass('item').addClass('active');
                        } else {
                                $(checkbox).removeClass('active').addClass('item');
                        }
                        reloadHome();
                        return false;
                }


		function reloadHome() {
			$('#ajaxcontainer').html('<img id="ajaxloader" style="padding-left:171px;padding-top:50px" src="Images/ajax2.gif"/>');
			href = "?size=" + thumbsize + "&userlang=" + userlang;

			// Get lang
			var hreflang = "&lang=";
			$('.lang a.active').each(function(index) {
			 	if(index == 0) {
					hreflang = hreflang + $(this).attr('id');
				} else { 
					hreflang = hreflang + ',' + $(this).attr('id');
				}
  			});

			// Get gender
                        var hrefgender = "&gender=";
                        $('.gender a.active').each(function(index) {
                                if(index == 0) {
                                        hrefgender = hrefgender + $(this).attr('id');
                                } else {
                                        hrefgender = hrefgender + ',' + $(this).attr('id');
                                }
                        });

                        // Get age
                        var hrefage = "&age=";
                        $('.age a.active').each(function(index) {
                                if(index == 0) {
                                        hrefage = hrefage + $(this).attr('id');
                                } else {
                                        hrefage = hrefage + ',' + $(this).attr('id');
                                }
                        });


			href = href + hreflang + hrefgender + hrefage;
			savePrefs();
			// we hebben op checkboxes geklikt dus reset nickname search
                        $('#query').val('');
			// reset kaartje
			$('#MapWrap').css({'backgroundPosition' : '-4160px'});
			currentpos = "-4160px 50%";
			// go find all active items and create URL
			$.getJSON('ajax.php' + href, function(data) {
				$('#ajaxcontainer').html(data.html);
			});
			return false;
		}

                function reloadPage(href,resetmap) {
	                        $('#ajaxcontainer').html('<img  style="padding-left:171px;padding-top:50px" src="Images/ajax2.gif"/>');

			$('#query').val('');
			if(resetmap) {
				$('#MapWrap').css({'backgroundPosition' : '-4160px'});
				currentpos = "-4160px 50%";
			}
                        $.getJSON('ajax.php' + href, function(data) {
                                $('#ajaxcontainer').html(data.html);
                        });
                        return false;
                }

                function savePrefs() {
                        var checkbox;
                        $('.lang a.active').each(function(index) {
                                if(index == 0) {
                                        checkbox = '.lang #' + $(this).attr('id');
                                } else {
                                        checkbox = checkbox + ':.lang #' + $(this).attr('id');
                                }
                        });

                        $('.gender a.active').each(function(index) {
                                        checkbox = checkbox + ':.gender #' + $(this).attr('id');
                        });

                        $('.age a.active').each(function(index) {
                                        checkbox = checkbox + ':.age #' + $(this).attr('id');
                        });



                        createCookie('checkbox',checkbox,356);
                }

                function reloadPrefs() {
			return false;
                        var checkbox = readCookie('checkbox');
                        if(checkbox != null) {
                                // reset all boxes , and then activate those saved
                                $('.lang a.active').each(function(index) {
                                        $(this).removeClass('active').addClass('item');
                                });
                                $('.gender a.active').each(function(index) {
                                        $(this).removeClass('active').addClass('item');
                                });
                                $('.age a.active').each(function(index) {
                                        $(this).removeClass('active').addClass('item');
                                });

                                var ca = checkbox.split(':');
                                for(var i=0;i < ca.length;i++) {
                                        var c = ca[i];
                                        $(c).removeClass('item').addClass('active');
                                }
                                reloadHome();
                        }
                }


