//Copyright (C) 2007 by The.Modificator

function dniMonthNameDniScript(m)
{
	switch(m)
	{
		case 1:
			return "lífo"; // [first month] Cyan.
		case 2:
			return "líbro"; // [second month] Cyan.
		case 3:
			return "lísan"; // [third month] Cyan.
		case 4:
			return "lítar"; // [fourth month] Cyan.
		case 5:
			return "lívot"; // [fifth month] Cyan.
		case 6:
			return "lívofo"; // [sixth month] Cyan.
		case 7:
			return "lívobro"; // [seventh month] Cyan.
		case 8:
			return "lívosan"; // [eighth month] Cyan.
		case 9:
			return "lívotar"; // [ninth month] Cyan.
		case 10:
			return "lénovú"; // [tenth month] Cyan.
		default:
			return "©";
	}
}

function dniMonthName(m)
{
	switch(m)
	{
		case 1:
			return "Leefo"; // [first month] Cyan.
		case 2:
			return "Leebro"; // [second month] Cyan.
		case 3:
			return "Leesahn"; // [third month] Cyan.
		case 4:
			return "Leetar"; // [fourth month] Cyan.
		case 5:
			return "Leevot"; // [fifth month] Cyan.
		case 6:
			return "Leevofo"; // [sixth month] Cyan.
		case 7:
			return "Leevobro"; // [seventh month] Cyan.
		case 8:
			return "Leevosahn"; // [eighth month] Cyan.
		case 9:
			return "Leevotar"; // [ninth month] Cyan.
		case 10:
			return "Leenovoo"; // [tenth month] Cyan.
		default:
			return "(unk. month)";
	}
}

function _f(a)
{
	if(a<10)
		return "0"+a;
	return a;
}

function visualize_date_object(d,withseconds)
{
	if(typeof(withseconds)=='undefined')
		withseconds=false;

	var str = (d.getFullYear())
		+"-"
		+_f(d.getMonth()+1)
		+"-"
		+_f(d.getDate())
		+" "
		+_f(d.getHours())
		+":"
		+_f(d.getMinutes());
	if(withseconds)
		str+=":"+_f(d.getSeconds());
	return str;
}

function greg2dni_latintext(y,m,d,h,n,s)
{
	var out=greg2dni(y,m,d,h,n,s);
	return out[2] +
		". " +
		dniMonthName(out[1]) +
		" ("+_f(out[1])+".) " +
		_f(out[0]) +
		", " +
		_f(out[3]) +
		":" +
		_f(out[4]) +
		":" +
		_f(out[5]) +
		":" +
		_f(out[6]);
}

function greg2dni_dnitext(y,m,d,h,n,s)
{
	var out=greg2dni(y,m,d,h,n,s);

	return num2dniscriptnumsymbol(out[2]) + //yahr
		". " +
		dniMonthNameDniScript(out[1]) + //vailee name
		" - " +
		num2dniscriptnumsymbol(out[1]) + //vailee number
		". - " +
		num2dniscriptnumsymbol(out[0]) + //hahr
		" - " +
		num2dniscriptnumsymbol(out[3]) + //gahrtahvo
		"." +
		num2dniscriptnumsymbol(out[4]) + //tahvo
		"." +
		num2dniscriptnumsymbol(out[5]) + //gorahn
		"." +
		num2dniscriptnumsymbol(out[6]); //prorahn
}





///////////////////////////////
// D'ni number stuff
///////////////////////////////

function num2dniscriptnumsymbol(num)
{
	var ret="",arr;
	if(num==0 || num==1)
		return ""+num;
	
	arr=arabic2dni(num);
	for(counter = arr.length; counter >= 0; counter--)
	{
		ret+=""+num2dniscriptnumsymbol_single(arr[counter]);
	}
	return ret;
}

function num2dniscriptnumsymbol_single(num)
{
	switch(num)
	{
		case 25:
			return "|";
		case 24:
			return "\\";
		case 23:
			return "}";
		case 22:
			return "{";
		case 21:
			return "]";
		case 20:
			return "[";
		case 19:
			return "(";
		case 18:
			return "*";
		case 17:
			return "&";
		case 16:
			return "^";
		case 15:
			return "%";
		case 14:
			return "$";
		case 13:
			return "#";
		case 12:
			return "@";
		case 11:
			return "!";
		case 10:
			return ")";
		case 9:
			return "9";
		case 8:
			return "8";
		case 7:
			return "7";
		case 6:
			return "6";
		case 5:
			return "5";
		case 4:
			return "4";
		case 3:
			return "3";
		case 2:
			return "2";
		case 1:
			return "1";
		case 0:
			return "0";
		case "h":
		case "H":
			return ":";
	}
	return " ";
}


function arabic2dni(arab)
{
	var c=0;
	while(arab>Math.pow(25,c))
	{
		c++;
	}

	var ret=new Array();
	
	for(var i=c-1; i>=0; i--)
	{
		var tmp=Math.pow(25,i);
		ret[i]=Math.floor(arab/tmp);
		arab=arab-ret[i]*tmp;
	}
	
	return ret;
}


