function locate_elm(n, d)
	{
		var p,i,x;
		
		if(!d) d=document;
		
		if((p=n.indexOf("?"))>0&&parent.frames.length)
			{
				d=parent.frames[n.substring(p+1)].document;
				n=n.substring(0,p);
			}
		
		if(!(x=d[n])&&d.all)
		x=d.all[n];
		
		for (i=0;!x&&i<d.forms.length;i++)
		x=d.forms[i][n];
		
		for(i=0;!x&&d.layers&&i<d.layers.length;i++)
		x=gaseste(n,d.layers[i].document);
		
		if(!x && d.getElementById)
		x=d.getElementById(n);
		
		return x;
	}
	

function FormatNumberBy3(num, decpoint, sep) {
  // check for missing parameters and use defaults if so
  if (arguments.length == 2) {
    sep = ",";
  }
  if (arguments.length == 1) {
    sep = ",";
    decpoint = ".";
  }
  // need a string for operations
  num = num.toString();
  // separate the whole number and the fraction if possible
  a = num.split(decpoint);
  x = a[0]; // decimal
  y = a[1]; // fraction
  z = "";


  if (typeof(x) != "undefined") {
    // reverse the digits. regexp works from left to right.
    for (i=x.length-1;i>=0;i--)
      z += x.charAt(i);
    // add seperators. but undo the trailing one, if there
    z = z.replace(/(\d{3})/g, "$1" + sep);
    if (z.slice(-sep.length) == sep)
      z = z.slice(0, -sep.length);
    x = "";
    // reverse again to get back the number
    for (i=z.length-1;i>=0;i--)
      x += z.charAt(i);
    // add the fraction back in, if it was there
    if (typeof(y) != "undefined" && y.length > 0)
      x += decpoint + y;
  }
  return x;
}	
	
function fa_lei()
	{
		var ie, iu, sl, se, su;
		ie=locate_elm('in_euro');
		iu=locate_elm('in_usd');
		sl=locate_elm('suma_lei');
		se=locate_elm('suma_euro');
		su=locate_elm('suma_usd');
	
		
		vie=parseFloat(ie.value.replace(/\./g, '').replace(/\,/g, '.'));
		viu=parseFloat(iu.value.replace(/\./g, '').replace(/\,/g, '.'));
		vsl=parseFloat(sl.value.replace(/\./g, '').replace(/\,/g, '.'));
		vse=parseFloat(se.value.replace(/\./g, '').replace(/\,/g, '.'));
		vsu=parseFloat(su.value.replace(/\./g, '').replace(/\,/g, '.'));
		
		vse2=vsl/vie*100;
		vse2=Math.round(vse2);
		vse2=vse2/100;
		
		
		vsu2=vsl/viu*100;
		vsu2=Math.round(vsu2);
		vsu2=vsu2/100;
		
		se.value=FormatNumberBy3(vse2).replace(/\,/g , 'x').replace(/\./g, ',').replace(/x/g, '.');
		su.value=FormatNumberBy3(vsu2).replace(/\,/g , 'x').replace(/\./g, ',').replace(/x/g, '.');
		
		if(se.value=='NaN')
			{
				se.value='';
			}
		if(su.value=='NaN')
			{
				su.value='';
			}
		
		
	}	
	
function fa_eur()
	{
		var ie, iu, sl, se, su;
		ie=locate_elm('in_euro');
		iu=locate_elm('in_usd');
		sl=locate_elm('suma_lei');
		se=locate_elm('suma_euro');
		su=locate_elm('suma_usd');
		
		
		
		vie=parseFloat(ie.value.replace(/\./g, '').replace(/\,/g, '.'));
		viu=parseFloat(iu.value.replace(/\./g, '').replace(/\,/g, '.'));
		vsl=parseFloat(sl.value.replace(/\./g, '').replace(/\,/g, '.'));
		vse=parseFloat(se.value.replace(/\./g, '').replace(/\,/g, '.'));
		vsu=parseFloat(su.value.replace(/\./g, '').replace(/\,/g, '.'));
		
		vsl2=vse*vie*100;
		vsl2=Math.round(vsl2);
		vsl2=vsl2/100;
		
		vsl=vsl2;
		
		vsu2=vsl/viu*100;
		vsu2=Math.round(vsu2);
		vsu2=vsu2/100;
		
		sl.value=FormatNumberBy3(vsl2).replace(/\,/g , 'x').replace(/\./g, ',').replace(/x/g, '.');
		su.value=FormatNumberBy3(vsu2).replace(/\,/g , 'x').replace(/\./g, ',').replace(/x/g, '.');
		
		
		if(sl.value=='NaN')
			{
				sl.value='';
			}
		if(su.value=='NaN')
			{
				su.value='';
			}
		
		
	}	
	
function fa_usd()
	{
		var ie, iu, sl, se, su;
		ie=locate_elm('in_euro');
		iu=locate_elm('in_usd');
		sl=locate_elm('suma_lei');
		se=locate_elm('suma_euro');
		su=locate_elm('suma_usd');
		
		
		
		vie=parseFloat(ie.value.replace(/\./g, '').replace(/\,/g, '.'));
		viu=parseFloat(iu.value.replace(/\./g, '').replace(/\,/g, '.'));
		vsl=parseFloat(sl.value.replace(/\./g, '').replace(/\,/g, '.'));
		vse=parseFloat(se.value.replace(/\./g, '').replace(/\,/g, '.'));
		vsu=parseFloat(su.value.replace(/\./g, '').replace(/\,/g, '.'));
		
		vsl2=vsu*viu*100;
		vsl2=Math.round(vsl2);
		vsl2=vsl2/100;
		
		vsl=vsl2;
		
		vse2=vsl/vie*100;
		vse2=Math.round(vse2);
		vse2=vse2/100;
		
		sl.value=FormatNumberBy3(vsl2).replace(/\,/g , 'x').replace(/\./g, ',').replace(/x/g, '.');
		se.value=FormatNumberBy3(vse2).replace(/\,/g , 'x').replace(/\./g, ',').replace(/x/g, '.');
		
		
		if(sl.value=='NaN')
			{
				sl.value='';
			}
		if(se.value=='NaN')
			{
				se.value='';
			}

		
		
	}


	
var cursor = {x:0, y:0};
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
	
	
function new_win_user(s, p, lang)
	{
			
		if(document.all)
			{
				sx=window.screenLeft;
				sy=window.screenTop;
			}
		else
			{
				sx=window.screenX;
				sy=window.screenY;
			}
			
		if(document.all)
			{
				if(document.compatMode == "CSS1Compat")
					{
						tx=document.body.parentNode.scrollLeft;
						ty=document.body.parentNode.scrollTop;
					}
				else
					{
						tx=document.body.scrollLeft;
						ty=document.body.scrollTop;
					}
			}
		else
			{
				tx=window.scrollX;
				ty=window.scrollY;
			}
		
		if(cursor.y<130)
			{
				y=10;
			}
		else
			{
				y=cursor.y-130;
			}
		if(cursor.x<380)
			{
				x=10;
			}
		else
			{
				x=cursor.x-380;
			}
		
		x=x+sx-tx;
		y=y+sy-ty;
  		window.open("pop.php?id="+s+"&pagina="+p+"&lang="+lang,"","WIDTH=600,HEIGHT=520, TOP="+y+" ,LEFT="+x+"");
	}
	
	
function new_win_user3(s)
	{
			
		if(document.all)
			{
				sx=window.screenLeft;
				sy=window.screenTop;
			}
		else
			{
				sx=window.screenX;
				sy=window.screenY;
			}
			
		if(document.all)
			{
				if(document.compatMode == "CSS1Compat")
					{
						tx=document.body.parentNode.scrollLeft;
						ty=document.body.parentNode.scrollTop;
					}
				else
					{
						tx=document.body.scrollLeft;
						ty=document.body.scrollTop;
					}
			}
		else
			{
				tx=window.scrollX;
				ty=window.scrollY;
			}
		
		if(cursor.y<130)
			{
				y=10;
			}
		else
			{
				y=cursor.y-130;
			}
		if(cursor.x<380)
			{
				x=10;
			}
		else
			{
				x=cursor.x-380;
			}
		
		x=x+sx-tx;
		y=y+sy-ty;
  		window.open("popp.php?id="+s,"","WIDTH=700,HEIGHT=520, TOP="+y+" ,LEFT="+x+"");
	}
	

function new_win_user2(s, p, lang)
	{
			
		if(document.all)
			{
				sx=window.screenLeft;
				sy=window.screenTop;
			}
		else
			{
				sx=window.screenX;
				sy=window.screenY;
			}
			
		if(document.all)
			{
				if(document.compatMode == "CSS1Compat")
					{
						tx=document.body.parentNode.scrollLeft;
						ty=document.body.parentNode.scrollTop;
					}
				else
					{
						tx=document.body.scrollLeft;
						ty=document.body.scrollTop;
					}
			}
		else
			{
				tx=window.scrollX;
				ty=window.scrollY;
			}
		
		if(cursor.y<130)
			{
				y=10;
			}
		else
			{
				y=cursor.y-130;
			}
		if(cursor.x<380)
			{
				x=10;
			}
		else
			{
				x=cursor.x-380;
			}
		
		x=x+sx-tx;
		y=y+sy-ty;
  		window.open("pop2.php?id="+s+"&pagina="+p+"&lang="+lang,"","WIDTH=600,HEIGHT=600, TOP="+y+" ,LEFT="+x+"");
	}


function UpdateCursorPosition(e)
	{
		cursor.x = e.pageX;
		cursor.y = e.pageY;
	}
function UpdateCursorPositionDocAll(e)
	{
		cursor.x = event.clientX;
		cursor.y = event.clientY;
	}