$(function(){

		function getallgames01(elshand){
			var games=new Array(),
				els=$(elshand);
			els.each(function(i){
				games[i] = new Array();
				var that=$(this);
				games[i][0] = that.find($("strong")).text();
				games[i][1] = that.find($("span.splone a")).attr('href');
				games[i][2] = that.find('span.splone').text();
			});
			return games;
		}
		
		var allgames01=getallgames01('#dirsort01 li'),
			allgames02=getallgames01('#dirsort02 li');
		
		var str1=$("#dirsort01").html(),
			str2=$("#dirsort02").html(),
			dstr1='',
			dstr2='',
			t=new Array(),
			t2=new Array();
		allgames01.reverse();
		for (var i=0; i<allgames01.length; i++) {
			t.push('<li><strong>' + allgames01[i][0] + '</strong><span class="splone"><a href="' + allgames01[i][1] + '">' + allgames01[i][2] + '</a></span></li>');
		}
		dstr1=t.join('');

		allgames02.reverse();
		for (var i=0; i<allgames02.length; i++) {
			t2.push('<li><strong>' + allgames02[i][0] + '</strong><span class="splone"><a href="' + allgames02[i][1] + '">' + allgames02[i][2] + '</a></span></li>');
		}
		dstr2=t2.join('');

		$("#dirsortbtn a").click(function(){
			var index=$("#dirsortbtn a").index(this);
			if(index){
				$(this).attr('class','d_sort d_sort_cur');
				$(this).siblings().attr('class','u_sort');
				$("#dirsort01").html(dstr2);
				$("#dirsort02").html(dstr1);
			}else{
				$(this).attr('class','u_sort u_sort_cur');
				$(this).siblings().attr('class','d_sort');
				$("#dirsort01").html(str1);
				$("#dirsort02").html(str2);
			}
			return false;
		});
		
		function ifrecor(){
			//if($("#recorconid a").length){
				//$("#recorconid a").first().clone().appendTo(".lastrecord");
				//$(".lastrecord strong").remove();
			//}
		}
		ifrecor();
		
		
		
});