var backup;
function $(id){
	return document.getElementById(id);
}
function cache(id){
	if($('json_src')){
		document.body.removeChild($('json_src'));
	}
	var js = document.createElement('script');
	js.id = 'json_src';
	js.src = '/json/'+id+'.js';
	document.body.appendChild(js);
}
function callback(s){
	backup = $('results').innerHTML;
	var html = '<ul class="sb_results" id="wg0">';
	$('i_back').innerHTML = '<h2>缓存快照</h2>\
<ul>\
<li><a href="javascript:backback();">返回搜索</a></li>\
</ul>';
	html += '<li>软件名称(Title): <a href="/page/'+s.id+'.html">'+s.title+'</a></li>';
	if(s.version != null)
		html += '<li>版本号(Version): '+s.version+'</li>';
	if(s.description != null)
		html += '<li>软件摘要(Description): '+s.description+'</li>';
	html += '<li>软件介绍(Overview): '+s.overview+'</li>';
	if(s.keywords != null)
		html += '<li>相关标签(Related Tags): '+s.keywords+'</li>';
	html += '<li>首要分类(Primary Category): <a href="/primary_category/'+encodeURI(s.primary_category)+'/">'+s.primary_category+'</a></li>';
	html += '<li>次要分类(Secondary Category): <a href="/secondary_category/'+encodeURI(s.secondary_category)+'/">'+s.secondary_category+'</a></li>';
	html += '<li>许可协议(License): <a href="/license/'+encodeURI(s.license)+'/">'+s.license+'</a></li>';
	if(s.country != null)
		html += '<li>软件性质(Country): <a href="/country/'+encodeURI(s.country)+'/">'+s.country+'</a></li>';
	html += '<li>语言版本(Language): <a href="/language/'+encodeURI(s.language)+'/">'+s.language+'</a></li>';
	if(s.author != null && s.url != null){
		if(/^www/.test(s.author)){
			s.author = 'http://' + s.author;
		}
		html += '<li>软件作者(Author A): <a href="'+s.url+'" target="_blank">'+s.author+'</a></li>';
	}
	else if(s.author != null){
		if(/^www/.test(s.author)){
			s.author = 'http://' + s.author;
		}
		if(/^http:/.test(s.author)){
			html += '<li>软件作者(Author B): <a href="'+s.author+'" target="_blank">'+s.author+'</a></li>';
		}
		else{
			html += '<li>软件作者(Author C): '+s.author+'</li>';
		}
	}
	else if(s.url != null){
		if(/^www/.test(s.author)){
			s.author = 'http://' + s.author;
		}
		html += '<li>软件作者(Author D): <a href="'+s.url+'" target="_blank">'+url.author+'</a></li>';
	}
	if(s.email != null)
		html += '<li>电子邮件(E-Mail): '+s.email+'</li>';
	if(s.official != null)
		html += '<li>官方下载(Official Download): <a href="'+s.official+'" target="_blank">'+s.official+'</a></li>';
	html += '<li>文件大小(File Size): '+s.size+'</li>';
	html += '<li>操作系统(OS): '+s.os+'</li>';
	html += '<li>软件评级(Star): '+s.star+'</li>';
	html += '<li>下载页面(Download): <a href="'+s.referer+'" target="_blank">'+s.referer+'</a></li>';
	html += '<li>发布时间(Published): '+s.published+'</li>';
	html += '</ul>';
	$('results').innerHTML = html;
}
function backback(){
	$('results').innerHTML = backup;
	$('i_back').innerHTML = '';
}