﻿var i = 0;
var chardictNewSize = "315";
var chardictIsNew = true;
var chardict = new Array("2010/8", "2010/7", 
	"2010/6", "2010/5", "2010/4", "2010/3", "2010/2", "2010/1",
	"2009/12", "2009/11", "2009/10", "2009/9", "2009/8", "2009/7", 
	"2009/6", "2009/5", "2009/4", "2009/3", "2009/2", "2009/1", 
	"2008/12", "2008/11", "2008/10", "2008/9", "2008/8", "2008/7", 
	"2008/6", "2008/5", "2008/4", "2008/3", "2008/2", "2008/1",
	"2007/12", "2007/11", "2007/10", "2007/9", "2007/8", "2007/7", "2007/6"
);

var worddictNewSize = "132";
var worddictIsNew = true;
var worddict = new Array("2010/8", "2010/7",
	"2010/6", "2010/5", "2010/4", "2010/3", "2010/2", "2010/1",
	"2009/12", "2009/11", "2009/10","2009/9", "2009/8", "2009/7", 
	"2009/6", "2009/5", "2009/4", "2009/3", "2009/2", "2009/1", 
	"2008/12", "2008/11", "2008/10", "2008/9", "2008/8", "2008/7", 
	"2008/6", "2008/5", "2008/4", "2008/3", "2008/2", "2008/1",
	"2007/12", "2007/11", "2007/10", "2007/9", "2007/8", "2007/7", "2007/6"
);

var pinyindictNewSize = "67";
var pinyindictIsNew = true;
var pinyindict = new Array("2010/8", "2010/7",
	"2010/6", "2010/5", "2010/4", "2010/3", "2010/2", "2010/1",
	"2009/12", "2009/11", "2009/10", "2009/9", "2009/8", "2009/7", 
	"2009/6", "2009/5", "2009/4", "2009/3", "2009/2", "2009/1", 
	"2008/12", "2008/11", "2008/10", "2008/9", "2008/8", "2008/7", 
	"2008/6", "2008/5", "2008/4", "2008/3", 
	"2007/12", "2007/9", "2007/8", "2007/7", "2007/6"
);

var pthworddictNewSize = "42";
var pthworddictIsNew = false;
var pthworddict = new Array("2010/6", "2010/4", "2010/3", "2010/2", "2010/1",
	"2009/12", "2009/11", "2009/7", "2009/6", "2009/5", "2009/4", "2009/3", "2009/2", "2009/1", 
	"2008/12", "2008/9", "2008/4", "2008/3", "2008/2", "2008/1",
	"2007/12", "2007/9"
);

var newIcon = '<img src="images/new.gif" alt="new" width="28" height="11">';

function GetDateCode(d)
{
	var temp = d.split('/');
	return temp[0].Right(2) + temp[1].PadLeft(2, '0'); 
}

function NewCharDictLink()
{
	return '<a href="download.php?file=chardict'+GetDateCode(chardict[0])+'">下載單字字典</a> (' + chardictNewSize + ' KB)';
}

function CharDictLatestDate()
{
	var tempDate = chardict[0].split('/');
	return '更新日期：'+tempDate[0]+'年'+tempDate[1]+'月';
}

function CharDictTableContent()
{
	var returnContent = '<tr>';
	for (var i = 1; i < chardict.length; ++i)
	{
		var tempDate = chardict[i].split('/');
		returnContent += '<td width="150">'+tempDate[0]+'年'+tempDate[1]+'月 <a href="download.php?file=chardict'+GetDateCode(chardict[i])+'">下載</a></td>'
		if (i%4==0 && i+1<chardict.length)
		{
			returnContent += "</tr><tr>";
		}
	}
	for (var i = 0; ((chardict.length-1)%4) && (i < 4-((chardict.length-1)%4)); ++i)
	{
		returnContent += '<td></td>';
	}
	returnContent += '</tr>';
	
	return returnContent;
}

function NewWordDictLink()
{
	return '<a href="download.php?file=worddict'+GetDateCode(worddict[0])+'">下載廣普對照字典</a> (' + worddictNewSize + ' KB)';
}

function WordDictLatestDate()
{
	var tempDate = worddict[0].split('/');
	return '更新日期：'+tempDate[0]+'年'+tempDate[1]+'月';
}

function WordDictTableContent()
{
	var returnContent = '<tr>';
	for (var i = 1; i < worddict.length; ++i)
	{
		var tempDate = worddict[i].split('/');
		returnContent += '<td width="150">'+tempDate[0]+'年'+tempDate[1]+'月 <a href="download.php?file=worddict'+GetDateCode(worddict[i])+'">下載</a></td>'
		if (i%4==0 && i+1<worddict.length)
		{
			returnContent += "</tr><tr>";
		}
	}
	for (var i = 0; ((worddict.length-1)%4) && (i < 4-((worddict.length-1)%4)); ++i)
	{
		returnContent += '<td></td>';
	}
	returnContent += '</tr>';
	
	return returnContent;
}

function NewPinYinDictLink()
{
	return '<a href="download.php?file=pinyindict'+GetDateCode(pinyindict[0])+'">下載拼音字典</a> (' + pinyindictNewSize + ' KB)';
}

function PinYinDictLatestDate()
{
	var tempDate = pinyindict[0].split('/');
	return '更新日期：'+tempDate[0]+'年'+tempDate[1]+'月';
}

function PinYinDictTableContent()
{
	var returnContent = '<tr>';
	for (var i = 1; i < pinyindict.length; ++i)
	{
		var tempDate = pinyindict[i].split('/');
		returnContent += '<td width="150">'+tempDate[0]+'年'+tempDate[1]+'月 <a href="download.php?file=pinyindict'+GetDateCode(pinyindict[i])+'">下載</a></td>'
		if (i%4==0 && i+1<pinyindict.length)
		{
			returnContent += "</tr><tr>";
		}
	}
	for (var i = 0; ((pinyindict.length-1)%4) && (i < 4-((pinyindict.length-1)%4)); ++i)
	{
		returnContent += '<td></td>';
	}
	returnContent += '</tr>';
	
	return returnContent;
}

function NewPTHWordDictLink()
{
	return '<a href="download.php?file=pthworddict'+GetDateCode(pthworddict[0])+'">下載普通話用語字典</a> (' + pthworddictNewSize + ' KB)';
}

function PTHWordDictLatestDate()
{
	var tempDate = pthworddict[0].split('/');
	return '更新日期：'+tempDate[0]+'年'+tempDate[1]+'月';
}

function PTHWordDictTableContent()
{
	var returnContent = '<tr>';
	for (var i = 1; i < pthworddict.length; ++i)
	{
		var tempDate = pthworddict[i].split('/');
		returnContent += '<td width="150">'+tempDate[0]+'年'+tempDate[1]+'月 <a href="download.php?file=pthworddict'+GetDateCode(pthworddict[i])+'">下載</a></td>'
		if (i%4==0 && i+1<pthworddict.length)
		{
			returnContent += "</tr><tr>";
		}
	}
	for (var i = 0; ((pthworddict.length-1)%4) && (i < 4-((pthworddict.length-1)%4)); ++i)
	{
		returnContent += '<td></td>';
	}
	returnContent += '</tr>';
	
	return returnContent;
}