$(document).ready(function(){
						   
// Footer
	$('#footer span').each(function(){
		$(this).hover(function(){
			$(this).animate({ opacity: 0.5 }, 500);
		},function(){
			$(this).animate({ opacity: 1.0 }, 500);
		});
	});

// Main menu
	$('#lang span').each(function(){
		$(this).hover(function(){
			$(this).animate({ top: '-=3' }, 300);
		},function(){
			$(this).animate({ top: '+=3' }, 300);
		});
	});
	
	$('#what-new ').each(function(){
		$(this).hover(function(){
			$('#what-new img').animate({ top: '-=5' }, 500);
		},function(){
			$('#what-new img').animate({ top: '+=5' }, 500);
		});
	});
	
	$('#i-l').each(function(){
		$(this).hover(function(){
			$('#i-l img').animate({ top: '-=5' }, 500);
		},function(){
			$('#i-l img').animate({ top: '+=5' }, 500);
		});
	});
	
	$('#ct').each(function(){
		$(this).hover(function(){
			$('#ct img').animate({ left: '+=5' }, 500);
		},function(){
			$('#ct img').animate({ left: '-=5' }, 500);
		});
	});

// ajax	
	var url = window.location.href;
	var c_url = url.split('#');
	var id = c_url[1];
	var id2 = c_url[2];
	ajax(id,id2);
	
	function ajax (param,param2) {
	  $.ajax({
		  url: "../includes/ajax.php",
		  type: "POST",
		  data: ({ id : param, id2 : param2 }),
		  cache: false,
		  dataType: "html",
		  beforeSend: function(){
			$("div#main-content").append('<div id="loading">&nbsp;</div>')  
		  },
		  success: function(msg){
			  $("div#main-content").empty().append(msg)
			  // lang	
			  var url = window.location.href;
			  var viUrl = '<a href="' + url.replace('/en/','/vi/') + '"><img src="../images/vi.png" /></a>';
			  var enUrl = '<a href="' + url.replace('/vi/','/en/') + '"><img src="../images/en.png" /></a>';
			  $("#lang #en").empty().append(enUrl);
			  $("#lang #vi").empty().append(viUrl);
		  }
	  });
	}
	
	$('#footer a,#main-menu a,#logo a').click(function(){
		  var href = $(this).attr('href');
		  if(href.indexOf('#') != -1) href = href.split('#');
		  id = href[1];
		  id2 = href[2];
		  ajax(id,id2);
	});
	
});
