
function add(kteryho){
	kde = "obs";
	vypln = document.getElementById(kde).value;		
	vsecko = vypln + kteryho;			
	document.getElementById(kde).value = vsecko;		
}
function alig(id){
 sirka_a = document.getElementById(id).offsetWidth+1;sirka = sirka_a - 1;
 if(sirka > 120){
  document.getElementById(id).style.marginLeft = '5px';
  document.getElementById(id).style.marginRight = '5px';
  document.getElementById(id).style.marginTop = '10px';
  document.getElementById(id).style.marginBottom = '10px';
 }
 if(sirka < 120){
  document.getElementById(id).style.marginLeft = '23px';
  document.getElementById(id).style.marginRight = '10px';
  document.getElementById(id).style.marginTop = '10px';
  document.getElementById(id).style.marginBottom = '0 px';
 }
}
function gila(id){
 sirka_a = document.getElementById(id).offsetWidth+1;sirka = sirka_a - 1;
 if(sirka > 500){
  document.getElementById(id).style.marginLeft = '0px';
  document.getElementById(id).style.marginRight = '0px';
  document.getElementById(id).style.marginTop = '10px';
  document.getElementById(id).style.marginBottom = '10px';
 }
 if(sirka < 500){
  document.getElementById(id).style.marginLeft = '73px';
  document.getElementById(id).style.marginRight = '73px';
  document.getElementById(id).style.marginTop = '10px';
  document.getElementById(id).style.marginBottom = '20px';
 }
}

function op(id){
 window.location.href="index.php?show=read/&f="+id;
}

function zarov(id){
 sirka_a = document.getElementById(id).offsetWidth+1;sirka = sirka_a - 1;
 if(sirka < 120){
  document.getElementById(id).style.marginLeft = '21px';
  document.getElementById(id).style.marginRight = '15px';
 }else{
  document.getElementById(id).style.marginLeft = '0px';
  document.getElementById(id).style.marginRight = '0px';
 }
}

function zarov_ri(id){
 sirka_a = document.getElementById(id).offsetWidth+1;sirka = sirka_a - 1;
 if(sirka < 120){
  document.getElementById(id).style.marginLeft = '21px';
  document.getElementById(id).style.marginRight = '15px';
 }else{
  document.getElementById(id).style.marginLeft = '0px';
  document.getElementById(id).style.marginRight = '0px';
 }
}

par=1;
function run_img(par){
 if(par==1){
	  document.getElementById('rychfot_2').style.display='none';
	  document.getElementById('rychfot_3').style.display='none';
	  document.getElementById('rychfot_1').style.display='block';
 }else if(par==2){
	  document.getElementById('rychfot_1').style.display='none';
	  document.getElementById('rychfot_3').style.display='none';
	  document.getElementById('rychfot_2').style.display='block';
	  document.getElementById('rychfot_2').style.visibility='visible';
 }else if(par==3){
	  document.getElementById('rychfot_1').style.display='none';
	  document.getElementById('rychfot_2').style.display='none';
	  document.getElementById('rychfot_3').style.display='block';
	  document.getElementById('rychfot_3').style.visibility='visible';
 } 
}

function run_imgs(){
	setTimeout("run_img(1)",3*1000);
	setTimeout("run_img(2)",6*1000);
	setTimeout("run_img(3)",9*1000);
}

function getMena(mena){
 return document.getElementById(mena).name;   //udělat zaokrouhlení na dvě desetiná místa!!
}

function trid_cislo(q){
 p="";qa=1;
	q=q+"";for(i=q.length;i>0;i--){p=q[(i-1)]+""+p;if(qa==3){qa=1;p=" "+p;}else{qa++;}}
 return p;
}

function pz_s(ret,id){
 if(document.getElementById(id+'_pocet')==null){return 0;}
 pocet=document.getElementById(id+'_pocet').options[document.getElementById(id+'_pocet').selectedIndex].value;
 mena=getMena(document.getElementById(id+'_currency').name);
 cost=document.getElementById(id+'_cost').name;
 cen=pocet*mena*cost;
 document.getElementById(id+'_final').innerHTML=trid_cislo(cen);
 if(ret=1){return cen;}
}

function pz_t(ret,id){
 if(document.getElementById(id+'_num')==null){return 0;}
 max = document.getElementById(id+'_num').name;
 cen=0;
 for(i=1;i<max;i++){
 	ted=id+'_pocet_'+i; tedcu=id+'_currency_'+i; tedco=id+'_cost_'+i; tedfi=id+'_final_'+i;   
	pcen=document.getElementById(ted).options[document.getElementById(ted).selectedIndex].value*getMena(document.getElementById(tedcu).name)*document.getElementById(tedco).name;
//	pcena=trid_cislo(pcen);
	pcena=pcen;
	document.getElementById(tedfi).innerHTML=pcena;
 	cen=cen*1+pcen*1;
 }
 if(max>2){document.getElementById(id+'_final').innerHTML=trid_cislo(cen);}
 if(ret){return cen;}
}

function pz_e(ret,ktera){
 if(document.getElementById('pz_sl_'+ktera+'_cost')==null){return 0;}
 cost=document.getElementById('pz_sl_'+ktera+'_cost').name;
 pocet=document.getElementById('pz_sl_'+ktera).options[document.getElementById('pz_sl_'+ktera).selectedIndex].value;
 cen=1*cost*pocet;
 document.getElementById('pz_sl_'+ktera+'_fi').innerHTML=trid_cislo(cen);
 if(ret){return cen;}
}



function secti_select_krat_poctem(z, untill, krat_poctem){
	secti_select('ter','cen_1os');
	cena_1os = document.getElementById(z).options[document.getElementById(z).selectedIndex].value;
}



function pz_sum(){
	cen = document.getElementById('ter').options[document.getElementById('ter').selectedIndex].value;
	if(cen == "soldout"){alert("Litujeme, ale tento termín je již vyprodaný.");return false;}
	document.getElementById('cen_1os').innerHTML=trid_cislo(cen);

	krat_pocet=document.getElementById('poc_os').options[document.getElementById('poc_os').selectedIndex].value;
	cen_allos=krat_pocet*cen;
	document.getElementById('cen_pocos').innerHTML=trid_cislo(cen_allos);
 cena=cen_allos;
 cena+=pz_s(1,'breakfast');
 cena+=pz_s(1,'dinner');
 cena+=pz_s(1,'social');
 cena-=pz_s(1,'disc_ss');
 cena+=pz_s(1,'doubleroom');
 cena+=pz_s(1,'cab');
 cena+=pz_t(1,'ftax');
 cena+=pz_t(1,'vis');
 cena+=pz_t(1,'ev');
 cena-=pz_e(1,'f');
 cena-=pz_e(1,'s');
 cena-=pz_e(1,'t');

 document.getElementById('pz_final').innerHTML=trid_cislo(cena);
}

function pb_sum(){
	vys=0;
	cen = document.getElementById('ter').options[document.getElementById('ter').selectedIndex].value;
	if(cen == "soldout"){alert("Litujeme, ale tento termín je již vyprodaný.");return false;}
	document.getElementById('cen_1os').innerHTML=trid_cislo(cen);

	zp = document.getElementById('kt').value;
	cen_allos=0;
	
	if(zp==2){
		cen_allos=cen*document.getElementById('poc_os').options[document.getElementById('poc_os').selectedIndex].value;	
	}else if(zp==3){
		cen_allos=cen*document.getElementById('poc_os').options[document.getElementById('poc_os').selectedIndex].value;
	}else{
		cen_allos=cen*document.getElementById('poc_os').options[document.getElementById('poc_os').selectedIndex].value;
	}

	document.getElementById('cen_pocos').innerHTML=trid_cislo(cen_allos);
	
	nupr=1;
	while(1){krat=0;ceni=0;
		if(!document.getElementById('pr_yon_'+nupr)){ break;}
		if(document.getElementById('pr_yon_'+nupr).value=="2"){
			krat=document.getElementById('pr_'+nupr).options[document.getElementById('pr_'+nupr).selectedIndex].value;
		}else{
			if(document.getElementById('pr_'+nupr).options[document.getElementById('pr_'+nupr).selectedIndex].value=="2"){
			krat=1;}else{krat=0;}
		}q='cur_pr_'+nupr;

		if(document.getElementById('cur_pr_'+nupr)){
			ceni=getMena(document.getElementById('cur_pr_'+nupr).value)*krat*document.getElementById('cen_pr_'+nupr).value;
		}else{
			proc=document.getElementById('pro_pr_'+nupr).value*cen/100;
			ceni=krat*proc;
 		}

		document.getElementById('c_pr_'+nupr).innerHTML=trid_cislo(ceni);
		cen_allos+=ceni;
	nupr++;
	}
	nupr=1;
	while(1){krat=0;ceni=0;
		if(!document.getElementById('sl_yon_'+nupr)){ break;}
		if(document.getElementById('sl_yon_'+nupr).value=="2"){
			krat=document.getElementById('sl_'+nupr).options[document.getElementById('sl_'+nupr).selectedIndex].value;
		}else{
			if(document.getElementById('sl_'+nupr).options[document.getElementById('sl_'+nupr).selectedIndex].value=="2"){
			krat=1;}else{krat=0;}
		}q='cur_sl_'+nupr;

		if(document.getElementById('cur_sl_'+nupr)){
			ceni=getMena(document.getElementById('cur_sl_'+nupr).value)*krat*document.getElementById('cen_sl_'+nupr).value;
		}else{
			proc=document.getElementById('pro_sl_'+nupr).value*cen/100;
			ceni=krat*proc;
			ceni=krat*cen-ceni;
 		}
		document.getElementById('c_sl_'+nupr).innerHTML=trid_cislo(ceni);
		cen_allos-=ceni;
	nupr++;
	}

	document.getElementById('pb_final').innerHTML=trid_cislo(cen_allos);

}





