function changeCena(cena)
{
	var suma = document.getElementById('sumazam').innerHTML;
	cena = parseFloat(cena);
	suma = parseFloat(suma);

	var cenapok = cena.toFixed(2);
 
 
	if (document.getElementById('checkprezent').checked == true)
	{
		liczba=suma+cena;
		document.getElementById('cenaprezentu').innerHTML=cenapok;
	}
	else
	{
		liczba=suma-cena;
		document.getElementById('cenaprezentu').innerHTML='0';	
	}
 
	var result = liczba.toFixed(2);
	document.getElementById('sumazam').innerHTML = result;
 
}
 
function PrzeliczCene(cena, suma, paczka, id_dostawcy)
{
	cena = parseFloat(cena);
	suma = parseFloat(suma);
	paczka = parseFloat(paczka);

	liczba=cena+suma;
	
	if (document.getElementById('checkprezent'))
		{
		if (document.getElementById('checkprezent').checked == true)
			{
			liczba=liczba+paczka;
			}
		}
 
	var result = liczba.toFixed(2);
	var cena = cena.toFixed(2);

	el = document.getElementById('sumazam'); 
	el.innerHTML = result;
	
	el = document.getElementById('cenadost').innerHTML = cena;
	
	id_platnosci = document.getElementById('select_platnosci').value;
	/*
	if(id_dostawcy == 14 && id_platnosci != 11) {
		document.getElementById('select_platnosci').selectedIndex = 2;
	} else if(id_dostawcy == 5 && id_platnosci == 11) {
		document.getElementById('select_platnosci').selectedIndex = 0;
	}
	*/
	//document.getElementById('cena_dostawca_hidden').value =cena;
}

function ZmienDostawe(id_platnosci)
{
	//id_dostawcy = document.getElementById('select_dostawa').value;
	suma = document.getElementById('suma_pom').value;
	if(id_platnosci != 11) {
		//document.getElementById('select_dostawa').selectedIndex = 0;
		//document.getElementById('select_dostawa').onchange();
		cena = document.getElementById('cena_pocz_pom').value;
		PrzeliczCene(cena, suma, 10, 5);
	} else if(id_platnosci == 11) {
	//za pobraniem - zmiana ceny
		cena = document.getElementById('cena_pobranie_pom').value;
		PrzeliczCene(cena, suma, 10, 5);
		//document.getElementById('select_dostawa').selectedIndex = 1;
		//document.getElementById('select_dostawa').onchange();
	}
}
 
function ZaznaczBox(idzan)
{
 var all = document.getElementById('all'+idzan).value;
 
 if (document.getElementById('gl'+idzan).checked == true) 
 {
  for (i = 1; i <= all; i++) 
  {
   document.getElementById('zaint'+idzan+'_'+i).checked = true;  
  }
 }
 else 
 {
  for (i = 1; i <= all; i++) 
  {
   document.getElementById('zaint'+idzan+'_'+i).checked = false;
  }
 }
 
}
 
function DisplayPlatnosci(id)
{
    var div = document.getElementById('DivPlatnosci');
 
 if (id == 3) div.style.display = "block";
 else div.style.display = "none";
}
 
function MM_jumpMenu(targ,selObj,restore)
{ //v3.0
 eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value+"'");
 if (restore) selObj.selectedIndex=0;
}
 
function ShowHide(id,ilosc) 
{
  var divtemp;
  var div=document.getElementById('podkategorie'+id);
  if(div.style.display == "none") div.style.display = "block";
  //else div.style.display = "none";
  
  
  for(i=1; i<=ilosc; i++)
  {
   if(i!=id)
   {
    divtemp=document.getElementById("podkategorie"+i);
    divtemp.style.display = "none";
   }
  } 
}
 
function ShowHide2(nron)
{
 var stan;
 if (nron == 1)
 {
  document.getElementById("p1").style.display = "block"; 
  document.getElementById("p2").style.display = "none"; 
 }
 else
 {
  document.getElementById("p2").style.display = "block"; 
  document.getElementById("p1").style.display = "none"; 
 }
}
 

function DisplayDostawcy(id)
{
    var plat1 = document.getElementById('plat1');
 var plat2 = document.getElementById('plat2');
    var plat3 = document.getElementById('plat3'); 
 
 if( (id==1) || (id==4) )
 {
  plat1.disabled=true;  
  plat2.disabled=false;  
  plat3.disabled=true;  
  plat2.checked=true;  
 }
 if( (id==2) || (id==3) )
 {
  plat1.disabled=false;  
  plat2.disabled=true;  
  plat3.disabled=false;  
  plat1.checked=true;    
 }
 DisplayPlatnosci(2);
}


jQr(document).ready(function(){  

	jQr('#wystaw_fvat').bind('click', function() {
		check_fvat();
	});
	
	check_fvat();
	
	baner_id = 1;
	baner_max = jQr('.baner_main_a').length;
	
	jQr(".baner_main_a").bind("click", function() {
		jQr(".baner_main_a").attr('class', 'baner_main_a');
		jQr(this).attr('class', 'baner_main_a baner_main_a_selected');
		
		jQr(".main_baners").hide();
		jQr("#"+ jQr(this).attr('rel')).show();
		
		baner_id = jQr(this).attr('rel');
		baner_id = baner_id.replace('main_baner_', '');
		
		return false;
	});
	
	v = setTimeout("rotate_banners()", 10*1000);
});

function check_fvat() {
	if ( document.getElementById('wystaw_fvat') != undefined && document.getElementById('wystaw_fvat').checked == true ) {
		jQr('#field_firma').parent().parent().show();
		jQr('#field_firmaulica').parent().parent().show();
		jQr('#field_firmakod').parent().parent().show();
		jQr('#field_firmamiasto').parent().parent().show();
		jQr('#field_firmanip').parent().parent().show();
	} else {
		jQr('#field_firma').parent().parent().hide();
		jQr('#field_firmaulica').parent().parent().hide();
		jQr('#field_firmakod').parent().parent().hide();
		jQr('#field_firmamiasto').parent().parent().hide();
		jQr('#field_firmanip').parent().parent().hide();
	}
}

function rotate_banners() {
	baner_max = jQr('.baner_main_a').length;
	
	if ( baner_id == baner_max ) {
		baner_id = 1;
	} else {
		baner_id = parseInt(baner_id)+1;
	}
	
	jQr("a[rel='main_baner_"+baner_id+"']").click();
	v = setTimeout("rotate_banners()", 10*1000);
}
