var timeIndex;
var finalTimeDatas;
var refineDatas;
var lastDatas;

function showdata(url,locate,jump){
	


	
	 j$.get(url + '?' + Math.ceil(Math.random() * 100),function(text){
	mtdatas = eval("("+text+")");

	recent();
	refData();
	for(i = 0; i<timeIndex.length;i++ ){
		if(refineDatas[timeIndex[i]].cate3 !=""){
			if (refineDatas[timeIndex[i]].data1.length > 15){
							refineDatas[timeIndex[i]].data1 = refineDatas[timeIndex[i]].data1.slice(0,15) + '...';
			} 
	
			j$('#e_' + locate).html('<a href="' + jump + '" target="_blank">' + refineDatas[timeIndex[0]].data1 + '</a>');
			break;
		}
	}
	for(i = 0; i<timeIndex.length;i++ ){
		if(timeIndex[i] > recentT){
			if(refineDatas[timeIndex[i]].cate1 != "" && refineDatas[timeIndex[i]].cate3 != ""){
				
					if (refineDatas[timeIndex[i]].data1.length > 15){
						refineDatas[timeIndex[i]].data1 = refineDatas[timeIndex[i]].data1.slice(0,15) + '...';
					}
					
					j$('#e_' + locate).html('<a href="' + jump + '" target="_blank">' + refineDatas[timeIndex[i]].data1 + '</a>');
				
					
					break
			}
		}
	}
	
	});
	
}






function recent(){
	timeIndex = new Array;
	finalTimeDatas = new Array;
	refineDatas = new Array
	lastDatas = new Array
	var now = new Date();
	recentY = now.getFullYear();
	recentM = now.getMonth();
	recentD = now.getDate();
	
	recentT = now.getTime();
}



function refData(){
	
	var timeDatas = new Array;
	
	
	
	for(i = 0; i<mtdatas.length -1; i++){
		
			timeDatas.push(mtdatas[i].data3);
		
	}
	
	for(i = 0; i<timeDatas.length; i++){
		
		var rTDatas = new Array;
		var aTDatas = new Array;
	
		rTDatas = timeDatas[i].split("?");
		
		for(j=0; j<rTDatas.length; j++){
			if(!rTDatas[j]){
				break;
			} else {
				aTDatas.push(rTDatas[j]);
			}	
		}
		
		var thisTime
		var afDatas = new Array;
		for(j=0; j<aTDatas.length;j++){
			thisTime = new Date();
			bfDatas = new Array;
			bfDatas = aTDatas[j].split("/");
			
			if(mtdatas[i].cate2 != ''){
				if(bfDatas[1] == 12){
					
					thisTime.setFullYear(bfDatas[0] -(-1));
					thisTime.setMonth(0);
					
				} else {
					thisTime.setFullYear(bfDatas[0]);
					thisTime.setMonth(bfDatas[1]);
				}
				thisTime.setDate(0);
				thisTime.setHours(0);
				thisTime.setMinutes(0);
				
			} else{
				thisTime.setFullYear(bfDatas[0]);
				if(bfDatas[1] != 00){
					thisTime.setMonth(bfDatas[1] - 1)
				} else {
					thisTime.setMonth(bfDatas[1])
				};
				thisTime.setDate(bfDatas[2]);
				thisTime.setHours(bfDatas[3]);
				thisTime.setMinutes(bfDatas[4]);
			}
			if(bfDatas[5] == '00'){
				bfDatas[5] = i * 6;
			}
			thisTime.setSeconds(bfDatas[5]);
			thisTime.setMilliseconds(0);
			
			if(thisTime.getTime() > recentT){
				bfDatas[6] = thisTime.getDay();
				afDatas.push(bfDatas);
			}
		}

		var thisTime2 = new Array();
		if(afDatas.length != 0){
			thisTime2 = new Date();
			
			
			if(mtdatas[i].cate2 != ''){
				if(afDatas[0][1] == 12){
					thisTime2.setFullYear(afDatas[0][0] -(-1));
					thisTime2.setMonth(0);
					
				} else {
					thisTime2.setFullYear(afDatas[0][0]);
					thisTime2.setMonth(afDatas[0][1]);
				}
				thisTime2.setDate(0);
				thisTime2.setHours(0);
				thisTime2.setMinutes(0);

			} else{
				thisTime2.setFullYear(afDatas[0][0]);
				if(bfDatas[1] != 0){
					thisTime2.setMonth(afDatas[0][1] - 1)
				} else {
					thisTime2.setMonth(afDatas[0][1])
				
				};
			
				thisTime2.setDate(afDatas[0][2]);
				thisTime2.setHours(afDatas[0][3]);
				thisTime2.setMinutes(afDatas[0][4]);
				
			}
			thisTime2.setSeconds(afDatas[0][5]);
			thisTime2.setMilliseconds(0);
			
			
			timeIndex.push(thisTime2.getTime());
			
		} else {
			timeIndex.push(mtdatas[i].data0);
		}
		
		mtdatas[i].data3 = afDatas;
		
	}

	for(i = 0; i< timeIndex.length; i++){
		
		refineDatas[timeIndex[i]] = mtdatas[i];
	}
	
	timeIndex.sort();
	

}
