currencies_equal={'RUR':'РУБ','USD':'USD','EUR':'EUR'};

function translate(currency)
{
	currency1=currency;
	on_change_currency(currency1);
}

function modify_currency(id,currency_out)
{
	var i,str,str1;
	for (i=0;i<prices.length;i++)
	{
		if (prices[i]['id']==id)
		{
			price_out=prices[i][currency_out];
			break;
		}
	}
	str1=number_string(price_out);
	if (currency1=='RUR')
	{
		str1=str1.substr(0,str1.length-8).concat('00');
	}
	return str1.concat('&nbsp;').concat('<b>').concat(currencies_equal[currency1]).concat('</b>');
}

function number_string(price_out)
{
	var str;
	str='';
	price_out=escape(price_out);
	while(price_out.length>3)
	{
		str=(price_out.substr(price_out.length-3,3)).concat('&nbsp;').concat(str);
		price_out=price_out.substr(0,price_out.length-3);
	}
	str='&nbsp;'.concat(price_out).concat('&nbsp;').concat(str);
	return str;
}

function on_change_currency(currency1)
{
	var kav;
	str=document.body.innerHTML;
	re=RegExp("(price_([0-9]{1,5}))","i");
	result=str.match(re);
	str1="";
	str4="";
	str2=str;
	ua = navigator.userAgent;
	if ((ua.indexOf('Gecko')!=-1)||(ua.indexOf('Opera')!=-1))
	{
		kav=1;
	}
	else
	{
		kav=0;
	}
	while(result!=null)
	{	
	  id=parseInt(result[2]);
	  str3=str2.substr(0,str2.indexOf(result[1])+result[1].length+1+kav);
	  str2=str2.substr(str2.indexOf(result[1])+result[1].length+1+kav,str2.length-str2.indexOf(result[1])-result[1].length-1-kav);
	  str5=str2.substr(0,str2.indexOf('<'));
	  if ((str5!='по запросу')&&(str5!='договорная'))
	  {
		  document.getElementById('price_'.concat(id)).innerHTML=modify_currency(id,currency1);
	  }
	  str2=str2.substr(str2.indexOf('<'),str2.length-str2.indexOf('<'));
	  str4=str4.concat(str3);
	  result=str2.match(re);
	}
	str4=str4.concat(str2);
}

