CalculatorValue = "";
CalculatorCurrency = "RUR";
CalculatorID = 0;

/* ?????? ??? ?????????? ???????????. */
function CalculatorShowHide() {
	var Calculator 	= document.getElementById('Calculator');
	if(Calculator.style.display == "none")	Calculator.style.display = "";
	else Calculator.style.display = "none";
}

/* ????????? ?? ?????????? ?????? ????? ???????. */
function CalculatorRound(Value, Digits) {
	var Raise;
	Raise = Math.pow(10, Digits);
	return Math.round(Value*Raise)/Raise;
}

function ShowHide(id) {
	var Diva 	= document.getElementById(id);
	if(Diva.style.display == "none")	Diva.style.display = "";
	else Diva.style.display = "none";
}

/* ??????????? ?????. */
function Calculator() {

	var Value 			= document.getElementById('CalculatorValue').value;
	var Currency 		= document.getElementById('CalculatorCurrency').value;
	var Answer			= document.getElementById('CalculatorAnswer');
	var Pattern     = new RegExp("^[0-9]+(\\.[0-9]+)?$");
	Answer.innerHTML = '';
	if(Value != '' && Pattern.test(Value)) {
  	if(Currency == "RUR") {
   		Answer.innerHTML += ""+CalculatorRound((Value/EURCourse), 2)+" <font color='#000000'>EUR</font><br/>";
  		Answer.innerHTML += ""+CalculatorRound((Value/USDCourse), 2)+" <font color='#000000'>USD</font><br/>";
  	}
  	else if(Currency == "EUR") {
  		Answer.innerHTML += ""+CalculatorRound((Value*EURCourse), 2)+" <font color='#000000'>RUR</font><br/>";
  		Answer.innerHTML += ""+CalculatorRound(((Value*EURCourse)/USDCourse), 2)+" <font color='#000000'>USD</font><br/>";
  	}
  	else if(Currency == "USD") {
  		Answer.innerHTML += ""+CalculatorRound((Value*USDCourse), 2)+" <font color='#000000'>RUR</font><br/>";
  		Answer.innerHTML += ""+CalculatorRound(((Value*USDCourse)/EURCourse), 2)+" <font color='#000000'>EUR</font><br/>";
  	}
	}
}

/* ???????? ????? ????????????. */
function CalculatorTimer() {
	clearTimeout(CalculatorID);	
	var Value 		= window.document.getElementById('CalculatorValue').value;	
	var Currency 	= window.document.getElementById('CalculatorCurrency').value;
	if((Value != CalculatorValue) || (Currency != CalculatorCurrency)) {
		CalculatorValue = Value;
		CalculatorCurrency = Currency;
		Calculator();
	}
	CalculatorID = setTimeout("CalculatorTimer()", 500);
}

/* ?????? ??? ?????????? ????? ?????. */
function CoursesShowHide() {
	var Courses 	= document.getElementById('Courses');
	if(Courses.style.display == "none")	Courses.style.display = "";
	else Courses.style.display = "none";
}

/* ?????? ??? ?????????? ??????. */
function TariffShowHide() {
	var Tariff 	= document.getElementById('Tariff');
	if(Tariff.style.display == "none")	Tariff.style.display = "";
	else Tariff.style.display = "none";
}

/* ?????? ??? ?????????? ?????? ????????????. */
function RequestsShowHide() {
	var Requests = document.getElementById('Requests');
	if(Requests.style.display == "none")	Requests.style.display = "";
	else Requests.style.display = "none";
}

