<!--
function Initialize()
{
	UpdatePriceList();
	ShowSubCat('catSub'+groupaID,'cat'+groupaID);
	subItem =  GetObject('sub'+groupaID+'_'+formatID);
	if(subItem != null){
		subItem.className = 'cSubS';
	}
}

function PriceListItem(printID, code, from, to, price, multiper){
  this.printID = printID;
  this.code = code;
  this.from = from;
  this.to = to;
  this.price = price;
  this.multiper = multiper;
}
function PaperItem(paperID, name, price, description){
  this.paperID = paperID;
  this.name = name;
  this.price = price;
  this.description = description;
}
function PrintTypeItem(typeID, name, description){
  this.typeID = typeID;
  this.name = name;
  this.description = description;
}
function FormatPrice(value){
	value = Math.round(value).toString();
	while(value.length <3){
		value = "0"+value;
	}
	l = value.length;
	value = value.substr(0,l-2)+"."+value.substr(l-2);
	return value;
}

function UpdatePriceList(){
	var type = document.priceForm.type;
	var paper = document.priceForm.paper;
	var priceLayer = GetObject('priceLayer');
	
	if(type != null && paper != null){
		si = paper.options.selectedIndex;
		paper = PaperList[paper.options[si].value];
		if(paper != null){			
			var text = '<table border="0" cellspacing="0" cellpadding="0" align="right"><tr><td class="plHeader">ilość</td><td class="plHeader">cena j. netto</td><td class="plHeader">cena j. brutto</td></tr>';
			si = type.options.selectedIndex;
			list = PriceList[type.options[si].value];
			for(i = 0; i < list.length; i++){ 
				cena = ((paper.price/list[i].multiper*2)+parseInt(list[i].price));
				text += '<tr><td class="plLine">'+list[i].from+'-'+list[i].to+'</td><td class="plLine">'+FormatPrice(cena)+' zł</td><td class="plLine">'+FormatPrice(cena*1.22)+' zł</td></tr>';
			}
			text += '</table>';
			if(priceLayer != null){
				priceLayer.innerHTML = text;
			}
			layer = GetObject('paperLayer')
			if(layer != null){
				layer.innerHTML = paper.description;
			}
			type = TypeList[type.options[si].value];
			layer = GetObject('typeLayer')
			if(layer != null){
				layer.innerHTML = type.description;
			}
		}
	}
	Calculate();
}
function Calculate(){
	var amount = parseInt(document.calculator.amount.value);
	if(!isNaN(amount)){
		amount = Math.round(amount);
		newAmount = Math.ceil(amount / kwant) * kwant;
		if(newAmount != amount){
			layer = GetObject('kwantInfo');
			if(layer != null){
				layer.className = 'plInfoError';
			}
		}else{
			layer = GetObject('kwantInfo');
			if(layer != null){
				layer.className = 'plInfo';
			}
		}
		amount = newAmount;
		document.calculator.amount.value = amount;
		var type = document.priceForm.type;
		var paper = document.priceForm.paper;
		var price = 0;
		if(type != null && paper != null){
			si = paper.options.selectedIndex;
			paper = PaperList[paper.options[si].value];
			if(paper != null){
				si = type.options.selectedIndex;
				list = PriceList[type.options[si].value];
				status = false;
				for(i = 0; i < list.length; i++){ 
					if(amount >= list[i].from && amount <= list[i].to){
						price = (paper.price/list[i].multiper*2)+parseInt(list[i].price);
						status = true;
						break;
					}
				}
				if(!status){
					price = (paper.price/list[list.length-1].multiper*2)+parseInt(list[list.length-1].price);
				}
			}
		}
		
		price = amount*Math.round(price);
		/*if(price < 3500){
			price = 3500;
			layer = GetObject('priceInfo');
			if(layer != null){
				layer.className = 'plInfoError';
			}
		}else{
			layer = GetObject('priceInfo');
			if(layer != null){
				layer.className = 'plInfo';
			}
		}*/
		document.calculator.net.value = FormatPrice(price) + ' zł';
		document.calculator.gross.value = FormatPrice(price*1.22) + ' zł';
	}
}


//-->