var http = createRequestObject();

function createRequestObject() 
{
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer") ro = new ActiveXObject("Microsoft.XMLHTTP");
    else ro = new XMLHttpRequest();
    return ro;
}

function sndReq(id, lange)
{
	http.open("get", "/misc/onedayratesother.php?idm="+id+"&lange="+lange);
	http.onreadystatechange = handleResponse;
	http.send(null);
}

function handleResponse()
{
    if(http.readyState == 4)
	{
        var response = http.responseText;
        var update = new Array();
        update = response.split("|");
//		alert(update[0]+"-----"+update[1]+"++++"+update[2]+"-----"+update[3])
		if (update[0]=="graphs") document.getElementById("graphs").innerHTML = update[1];
		if (update[0] && update[1] && document.getElementById(update[0]))
		{
			document.getElementById(update[0]).innerHTML = update[1];
		}
    }
}
function goAjax(url)
{
//	alert(url);
    http.open("get", url);
   	http.onreadystatechange = handleResponse;
    http.send(null);
}
function Hidden(id, style)
{
	if (document.getElementById(id))
	{
		if (style == "table-row")
		{
				if (ie4) document.getElementById(id).style.display="inline";
				else document.getElementById(id).style.display=style;
		}
		else
		document.getElementById(id).style.display=style;
	}
}
function hides()
{
	document.getElementById("cabinet_info").style.display="none";
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
function save(lang)
{
	flag=true;
	re = /^\s*$/;
	re2 = /^\d+$/;
	re3= /([^<)\s]+@\S+\.[^>(\s]+)/;
	re4 = /^[\d \-\+\(\)]+$/;
	{
		if (!re3.test(document.registration.login.value)) 
		{
			if (lang==2) alert("Enter your login");
			else alert("Введите логин");
			document.registration.login.focus();
			return;
		}
		if (document.registration.login.value.length<4) 
		{
			if (lang==2) alert("User name should be more than 4 characters");
			else alert("Логин должен быть более 4 символов");
			document.registration.login.focus();
			return;
		}
		if (document.registration.pass)
		{
			if (re.test(document.registration.pass.value) || (document.registration.pass.value=="******")) 
			{
				if (lang==2) alert("Enter your password");
				else alert("Введите пароль");
				document.registration.pass.focus();
				return;
			}
			if ((document.registration.pass.value.length<4)||(document.registration.pass.value.length>15)) 
			{
				if (lang==2) alert("The password should be between 4 and 15 characters");
				else alert("Пароль должен быть более 4 и менее 15 символов");
				document.registration.pass.focus();
				return;
			}
			if (document.registration.pass.value!=document.registration.re_passwd.value)
			{
				if (lang==2) alert("Passwords do not match");
				else alert("Несовпадение паролей");
				document.registration.re_passwd.focus();
				return;
			}
		}
		if (re.test(document.registration.name.value))
		{
			if (lang==2) alert("Enter your name");
			else alert("Введите имя");
			document.registration.name.focus();
			return;
		}
		document.registration.submit();
	}
}
function GO(mode)
{
	if (mode=="sendpass") document.SendPasswd.submit();
	else
	{
		document.formlogin.mode.value=mode;
		document.formlogin.submit();
	}
}
function Show(mode, lang)
{
	if (lang==1) str="Информация загружается...";
	else str="downloading...";
	url="/misc/info.php?mode="+mode+"&new=1";
	document.getElementById("cabinet_info_text").innerHTML=str;
	Hidden("cabinet_info", "inline");
	goAjax(url);
}
function OrderPrognose(currency_id)
{
	document.CurrencyPrognose.currency_id.value=currency_id;
//	document.CurrencyPrognose.numweek.value=document.getElementById("cur"+currency_id).value;
	document.CurrencyPrognose.submit();
}