$(document).ready(function(){
	$('#menu ul').children("li").each(function(){
		$(this).children('span').children('a').each(function(){
          	$(this).click(function(e){
				if($(this).attr('id') == 'switch_langs'){
				
				}
				else{
					e.preventDefault();
					var url = $(this).attr('href');
					var selected_item = this;
					
					if(url != 'wine_list.htm' && url != 'events.htm'){
						$.ajax({url:'content_' + url, cache:false,success:function(data) {
							$('#primarycontent').html(data);
							$('.menu_current').attr('class', 'menu_default');
							$(selected_item).attr('class', 'menu_current');
						
							if(url == 'gallery.htm' || url == 'gallery_en.htm'){
								 load_gallery();
							
							}
						
							if(url == 'contacts.htm')
								initialize();
						}});
					}
					
					if(url == 'events.htm' || url == 'events_en.htm'){
						$("#primarycontent").html('');
						setupEvent();			
						
						$('.menu_current').attr('class', 'menu_default');
						$(selected_item).attr('class', 'menu_current');
					}
					
					if(url == 'wine_list.htm'){
						$("#primarycontent").html('');
						fillVinoTable2();
						
						$('.menu_current').attr('class', 'menu_default');
						$(selected_item).attr('class', 'menu_current');
					}
					
					if(document.getElementById && document.getElementById("primarycontent") && document.getElementById("primarycontent").getBoundingClientRect){
						var height = document.getElementById("primarycontent").getBoundingClientRect();
						$('#content').css('height', Math.round(height + 20) + 'px !important');		
					}
				}
			});   
		
		});
	});
});


