		function langToggle(checkbox) {
			var counter =0;
			if($(checkbox).hasClass('item')) {
				$(checkbox).removeClass('item').addClass('active');
			} 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 #EN").removeClass('item').addClass('active');
			} 

			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 cupToggle(checkbox) {
                        var counter =0;
                        if($(checkbox).hasClass('item')) {
                                //if this is the ALL button, remove all others
                                if($(checkbox).attr('id') == "ALL") {
                                        $('.cup_size 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
                        $('.cup_size a.active').each(function(index) {
                                counter++;
                        });
                        if(counter == 0) {
                                $(".cup_size #ALL").removeClass('item').addClass('active');
                        } else {
                                $(".cup_size #ALL").removeClass('active').addClass('item');
                        }

                        reloadHome();
                        return false;
                }


		setTimeout("reloadHome();",60000);

		function reloadHome() {
			$('#ajaxcontainer').html('<div class="Left-Content"><img  style="padding-left:271px;padding-top:50px" src="/Images/ajax.gif"/></div>');
			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');
                                }
                        });


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


			href = href + hreflang + hrefgender + hrefage + hrefcup_size;
			savePrefs();	
			// go find all active items and create URL
			$.getJSON('ajax.php' + href, function(data) {
				$('#ajaxcontainer').html(data.html);
			});

			return false;
		}

		function reloadPage(href) {
			$('#ajaxcontainer').html('<div class="Left-Content"><img  style="padding-left:271px;padding-top:50px" src="/Images/ajax.gif"/></div>');
			$.getJSON('ajax.php' + href, function(data) {
                                $('#ajaxcontainer').html(data.html);
                        });
                        return false;
		}



		function savePrefs() {
			var checkbox;

                        $('.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() {
			var checkbox = readCookie('checkbox');
			if(checkbox != null) {
				// reset all boxes , and then activate those saved
                                $('.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();
			}
		}

