function getObj(name)
{
//alert("id="+name);
  if (document.getElementById)
  {
  	this.o = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.o = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.o = document.layers[name];
   	this.style = document.layers[name];
  }
}

function adjustIFrameSize (iwin, winp) 
{
  if (iwin.document.height) {
    var ifElement = parent.document.getElementById(iwin.name);
    ifElement.style.height = iwin.document.height + 40 + 'px';
  }
  else if (document.all) {
  
    var ifElement = parent.document.all[iwin.name];
    if (iwin.document.compatMode &&  iwin.document.compatMode != 'BackCompat') 
    {
      ifElement.style.height = iwin.document.documentElement.scrollHeight + 25 + 'px';
    }
    else {	
      ifElement.style.height = iwin.document.body.scrollHeight + 'px';
    }	
  }
  aWinSize (winp);
}

function aWinSize (iwin) 
{
  if (iwin.document.height) { // netscape, mozilla
	var h = iwin.document.height + 40;
	var w = iwin.innerWidth + 6;  
	var ah = screen.availHeight;
	var aw = screen.availWidth;
	h = ah > h ? h : ah ;
	w = aw > w ? w : aw ;
	iwin.resizeTo(w, h);
  }
  else if (document.all) {
    if (iwin.document.compatMode &&  iwin.document.compatMode != 'BackCompat') 
    {// opera
      var h = iwin.document.documentElement.scrollHeight + 30;
      var w = iwin.document.documentElement.scrollWidth  + 25;

	var ah = screen.availHeight;
	var aw = screen.availWidth;
	h = ah > h ? h : ah ;
	w = aw > w ? w : aw ;
	iwin.resizeTo(w, h);
    }
    else { // ie
      var h = iwin.document.body.scrollHeight + 80;
      var w = document.body.offsetWidth+8; //iwin.document.body.scrollWidth  + 80;

	var ah = screen.availHeight;
	var aw = screen.availWidth;
	h = ah > h ? h : ah ;
	w = aw > w ? w : aw ;
	iwin.resizeTo(w, h);
    }
  }
}
function ss(){event.srcElement.className="on";}
function uu(){event.srcElement.className="in";}
function OnVGC(f)
{
var vg = f.V_g.options[f.V_g.selectedIndex].value;
switch (vg){
case 'LTL': i='0'; break;
case 'USD': i='1'; break;
case 'EUR': i='2'; break;
}
for(j=0;j<=max_i;j++)
 {
  for(k=0;k<=2;k++)
  {
    wId='id_'+j+k; //co = document.all(wId); co.style.display = i==k ? "" : "none"; 
	id_show(wId, (i==k ? true : false));
  }
 }
} 

function id_show(id, show) { 
if (document.getElementById) { // DOM3 = IE5, NS6
  if (show){
    document.getElementById(id).style.display = ''; 
  } else {
    document.getElementById(id).style.display = 'none'; 
  }
} else { 
  if (document.layers) {
    if (show){
      document.id.display = ''; 
    } else {
      document.id.display = 'none'; 
    }
  } else {
    if (show){
      document.all.id.style.display = ''; 
    } else {
      document.all.id.style.display = 'none'; 
    }
  } 
}
}

function ch_bx_i(i)
{

function check_id(ee)
{
	ee = ee.substr(3,i); 
	var ff=document.FORM1;
	//eval("var ich = ff.D_c"+ee);
	//eval("var isu = ff.D_s"+ee);
	var ich = new getObj("D_c"+ee);
	var isu = new getObj("D_s"+ee);
	
	OnC(ff);
	if(ich.o.checked==true){
		isu.o.className="in";
		isu.o.disabled=false;
		//isu.o.readonly='';
		return (true); 
	}else
	{ 
		isu.o.className="in1";
		isu.o.disabled=true;
		//isu.o.value="";
		//isu.o.readonly=true;
		return (false); 
	}
}

if(!document.all)
{
	function doIt(e) { return (check_id(e.target.id)); } 
//	document.onmouseup = doIt;
	return(document.onclick = doIt);
}else{
	var ee = event.srcElement.id;
	return(check_id(ee));
   }
}

function ch_ka(ich_name, isu_name, v, sub_mit)
{
	var ff = document.forms['FORM1'];
	var ich = new getObj(ich_name);		
	var isu = new getObj(isu_name);	 
	/////////////////////-> OnC(ff); nukelta zemiau
	
	if(ich.o.checked==true){
		//alert(ee+" "+isu.disabled); 
		isu.o.className="in";
		isu.o.disabled=false;		
		isu.o.value = v; //
		//isu.readonly='';
		if(sub_mit) OnC(ff);
		return (false); //true
	}
	else
	{ 
		//alert(ee+" "+isu.disabled); 
		isu.o.className="in1";
		isu.o.disabled=true;
		isu.o.value="";	//
		//isu.readonly=true;		
		if(sub_mit) OnC(ff);
		return (false); // false
	}	
}

function ch_bx_i_new(id, i, v)
{
	var ee = id.substr(3,i); 	
	var ich_name = "D_c"+ee;
	var isu_name = "D_s"+ee;	 
	///////-> OnC(ff); nukelta zemiau
	ch_ka(ich_name, isu_name, v, true);	
}

//function ch_bx_2a(){  return (ch_bx_i(2)); }
//function ch_bx(){ return (ch_bx_i(1)); }

function ch_bx_2a(id, v){  return (ch_bx_i_new(id, 2, v)); }
function ch_bx(id, v){ return (ch_bx_i_new(id, 1, v)); }

function ch_bx_2(){ 
	var ee = event.srcElement.id;
	ee = ee.substr(3,1); 
	var ff=document.FORM1;
	//eval("var ich = ff.D_c"+ee+"0");
	//eval("var iii = ff.iii"+ee);
	//eval("var ppp = ff.ppp"+ee);

	var ich = new getObj("D_c"+ee+"0");
	var iii = new getObj("iii"+ee);
	var ppp = new getObj("ppp"+ee);
	
	if(ich.o.checked==true){
/*
		OnC(ff);
*/
		iii.o.className="in";
		iii.o.disabled=false;
		ppp.o.className="in";
		ppp.o.disabled=false;
		sk_ip();
		//isu.readonly='';
		return (true); 
	}else
	{ 
		iii.o.className="in1";
		iii.o.disabled=true;
		ppp.o.className="in1";
		ppp.o.disabled=true;
		sk_ip();
		//isu.readonly=true;
		return (true); 
	}
}

function sk_ip(){
	var f=document.FORM1;
	var p_4=0;
	for(var i=1; i<=7; i++)
	{	
		//if(i!=4) if(eval("f.D_c"+i+"0.checked")==true){
			//eval("p_4+=Fl(f.i"+i+".value) * Fl(f.p"+i+".value)");
		//}
		
		var d_c = new getObj("D_c"+i+"0");
		var f_i = new getObj("i"+i);
		var f_p = new getObj("p"+i);
		
		if(i!=4) if(d_c.o.checked==true){
			p_4+=Fl(f_i.o.value) * Fl(f_p.o.value);
		}
	}
	f.p_4.value=Fl(p_4/100+0.00);
	return (true);
}

function OnE(form){ 
	if(event.keyCode==13){  
		event.returnValue=false; 
		var ee = event.srcElement.id;
		ee = ee.substr(1,1); 
		document.FORM1.tabgo.value=ee;
		OnC(form);
		return (true); } 
event.returnValue=true;
}
function OnSb(){ document.FORM1.button2.disabled=true; }
function _OnE(form){ if(event.keyCode==13){  event.returnValue=false; OnC(form);  return (true); } event.returnValue=true;}
function OnChb(form){ OnSb(); form.submit(); return (true);}
//function OCV(form){ form.t_pavad.options[form.t_pavad.selectedIndex].value=form.t_var.options[form.t_var.selectedIndex].value; OC(form);}
function OCV(form){ form.t_pavad.value=form.t_var.options[form.t_var.selectedIndex].value; OC(form); }
function m(form){ form.c.value="v"; OnSb(); form.submit(); return (true);}
function OnCIF(form){ var r=window.event.srcElement.tagName; if(r !='SELECT' && r !='INPUT' && r!='IMG' && r!='A'){ OnC(form);}}
function OnC(form){ var ss = form.s.value;  if(ss < 1){ form.c.value="c"; if(form.Amzius) form.p.value=(form.Amzius.options ? form.Amzius.options[form.Amzius.selectedIndex].text : form.Amzius.value); OnSb(); form.submit(); return (true); } form.s.value = 0; }
function _OnC(form){ var ss = form.s.value;   if(ss<1){ m(form);	return (true); form.c.value="c"; form.p.value=form.Amzius.options[form.Amzius.selectedIndex].text; OnSb(); form.submit(); return (true);} form.s.value = 0;}
function On_C(form){ form.p.value=form.Amzius.options[form.Amzius.selectedIndex].text; OnSb(); form.submit(); return (true);}
function show_popup_window (){	window.open ("gyvyb.html", "popup","left=10,top=10,width=760,height=400,scrollbars=yes");}
function fnPrint() { window.print();}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
