/*

Ten skrypt służy do obsługi formulrza rezerwacji
stanowiska dla wystawcy przy przypisywaniu.

*/


function getElem(id) {
	return document.getElementById(id);
}

//function updateStallType(id) {
// h = getElem(id);
// alert(document.getElementById(id).name);
// alert('-'+h.name+'-')
// type = h.name;
// getElem('stall_type').value = type;
//}

function initForms() {

 //wybrane stanowisko
 stall = getElem('stall');
 stallValue = stall.value;

 //wybrany płatnosc
 payment = getElem('payment');
 paymentValue = payment.value;

 //cena podstawowa price_1
 price1 = getElem('price_1');
 price1Value = price1.value;

 //ilosc quantity
 quantity = getElem('quantity');
 quantityValue = quantity.value;


 //cena pomozona przez ilosc price2
 price2 = getElem('price_2');
 price2Value = price2.value;

 //teraz dodaje 22% vat
/* price2Value = price2Value*0.22;*/


 //ostateczna cena koncowa (uzalezniona od stanowiska (%))
 price3 = getElem('price_3');
 price3Value = price3.value;

 //teraz obliczamy wszystko co pobralismy

 price2Value = paymentValue * quantityValue;
 price1Value = paymentValue;

 price3Value = (price2Value+(price2Value*0.22)) * stallValue;


 //teraz uaktualniam formularze;
 price1.value = price1Value;
 price2.value = price2Value;
 price3.value = price3Value;

 //jesli ktoras z wartosci jest ujemna to blokuje wysylanie
 if(price1.value < 0) {
 	submit = getElem('button');
 	submit.disabled = 'true';
 } else {
 	submit = getElem('button');
 	submit.disabled = '';
 }


}
function setStall(value) {
	getElem('id_stall').value = value;
}
function setPayment(value) {
	getElem('id_payment').value = value;
}