// FOS Web Site System JavaScript
// 19.06.05

Ver = (((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) >= 3 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 ))); MS = (document.all) ? 1 : 0; Ascii = 0;

function Wait(TimeDelay, Url)
{	Url= "location.href = '" + Url + "'";
	setTimeout(Url, TimeDelay);
}

function OnChange(This, FileName, Name)
{	location.href = FileName + "&" + Name + "=" + This.options[This.selectedIndex].value;
}

function OnSubmit()
{	var RetValue = true;
	for(i = 0; i < ReqForms.length; i = i + 1)
		if (ReqForms[i] == 1) with (document.forms[0].elements[i])
		{	if (type == "select-one")
			{	if (options[selectedIndex].value == 0) RetValue = false;
			} else if (value == 0 | value == "") RetValue = false;
			if (!RetValue)
			{	alert("Вы должны ввести обязательные поля !");
				if (type != "select-one") select();
				focus();
				break;
			}
		}
	return RetValue;
}

function CheckSpace(Num)
{	with (document.forms[0].elements[Num])
	{	if (value.indexOf(" ") == -1) return true;
		alert("Введен недопустимый символ !");
		focus();
	}
	return false;
} // CheckSpace

function CheckN(File_Name, Num, Name_ID, Value_ID)
{	Url = "?";
	if (Num)
	{	if (Name_ID != "")
			if (Value_ID)
			{	ReqForms = new Array;
				for (i = 0; i < Num; i = i + 1) ReqForms[i] = 1;
				if (!OnSubmit()) return false;
				for (i = 0; i < Num; i = i + 1)
					for (j = i + 1; j < Num; j = j + 1)
					with (document.forms[0].elements[j])
						if (document.forms[0].elements[i].value == value)
						{	alert("Вы должны ввести уникальное число !");
							select();
							focus();
							return false;
						}
		}
		Url = Url + Name_ID + "=" + Value_ID + "&";
	}
	Url = File_Name + Url + "Values=";
	for (i = 0; i < Num; i = i + 1)
		with (document.forms[0].elements[i])
			if (name != '' && value != null) Url = Url + name + "," + value + ",";
	location.href = Url;
	return true;
}

function FindDefaultIndex(Num)
{ with(document.forms[0].elements[Num])
	for (i = length - 1; i > 0; i = i - 1)
		if (options[i].defaultSelected) return options[i].index;
	return 0;
}

function AsciiCode(e)
{	if (!MS)
	{	Ascii = e.which;
		document.routeEvent(e);
	}
	if (!MS) Ascii = event.keyCode;
	if (Ascii == 13 & Enter)
		if (OnSubmit()) document.forms[0].submit();
		else return false;
}
Enter = 1;
if (!MS) document.captureEvents(Event.KEYPRESS);
document.onkeypress = AsciiCode;

if (Ver)
	if (!MS)
	{	Blck = new Array(2);
		Blck[0] = new Image(); Blck[1] = new Image();
		Blck[0].src = "/img/7x7.gif"; Blck[1].src = "/img/pnt.gif";
	}

function SI(Cur, Def, Num)
{	if (Ver && Cur != Def)
		if (MS)
		{	document.all["P" + Cur].src = Num ? "/img/pnt.gif" : "/img/7x7.gif";
			document.all["P" + Def].src = Num ? "/img/7x7.gif" : "/img/pnt.gif";
		} else	
		{	document[Cur].src = Blck[Num].src;
			document[Def].src = Blck[Num ? 0 : 1].src;
				}
} // SI

Dollar = "<A HREF=\"/fos/dollar.vkm\"><IMG SRC=\"/fos/img/dollar.gif\" BORDER=\"0\">";
Dollar += "<IMG SRC=\"/fos/img/" + Math.floor(Course_D / 100) + ".gif\" BORDER=\"0\">";
Dollar += "<IMG SRC=\"/fos/img/" + Math.floor((Course_D - Math.floor(Course_D / 100) * 100) / 10) + ".gif\" BORDER=\"0\">";
if (Course_D % 10) Dollar += "<IMG SRC=\"/fos/img/pnt.gif\" BORDER=\"0\"><IMG SRC=\"/fos/img/" + Course_D % 10 + ".gif\" BORDER=\"0\">";
Dollar += "</A>";

Euro = "<A HREF=\"/fos/euro.vkm\"><IMG SRC=\"/fos/img/euro.gif\" BORDER=\"0\">";
Euro += "<IMG SRC=\"/fos/img/" + Math.floor(Course_E / 100) + ".gif\" BORDER=\"0\">";
Euro += "<IMG SRC=\"/fos/img/" + Math.floor((Course_E - Math.floor(Course_E / 100) * 100) / 10) + ".gif\" BORDER=\"0\">";
if (Course_E % 10) Euro += "<IMG SRC=\"/fos/img/pnt.gif\" BORDER=\"0\"><IMG SRC=\"/fos/img/" + Course_E % 10 + ".gif\" BORDER=\"0\">";
Euro += "</A>";