function km_extendedOnload() {
	if (window.hidePob)
		get_object('pob_'+hidePob).style.display='none';
}
var buy={
	addItem: function(id) {
		window.location.href='index.cfm?pg='+pg+'&act=addItm&id='+id;
	},
	updateCart: function(theForm) {
		var zitId_array=theForm.zitIdList.value.split(',');
		var totalPrice=shippingCost;
		var zitPrice,zitQty,zitTotalPrice,zitId;
		for (var i=0;i<zitId_array.length;i++) {
			zitId=zitId_array[i];
			zitPrice=eval('theForm.zitPrice_'+zitId).value;
			zitQty=parseInt(eval('theForm.zitQty_'+zitId).value);
			if (isNaN(zitQty)) {
				zitQty=0;
				eval('theForm.zitQty_'+zitId+'.value=0;');
			}
			zitTotalPrice=zitQty*zitPrice;
			get_object('itemTotalPrice_'+zitId).innerHTML=zitTotalPrice+' Kr';
			totalPrice+=zitTotalPrice;
		}
		get_object('table_buy_toPayAmount').innerHTML=totalPrice+' Kr';
	},
	purchase: function(theForm) {
		var er='';
		if (trim(theForm.f_name.value).length == 0)
			er+='\n* Namn måste anges';
		if (trim(theForm.f_address.value).length == 0)
			er+='\n* Adress måste anges';
		if (trim(theForm.f_zip.value).length == 0)
			er+='\n* Postort måste anges';
		if (trim(theForm.f_city.value).length == 0)
			er+='\n* Stad måste anges';
		if (trim(theForm.f_phone.value).length == 0)
			er+='\n* Telefon måste anges';
		if (er.length == 0)
			buy.commitPurchase(theForm);
		else
			alert("Felmeddelande:"+er);
	},
	commitPurchase: function(theForm) {
		theForm.act.value='buyCDs';
		theForm.ZOR_int_Total.value=parseInt(get_object('table_buy_toPayAmount').innerHTML);
		theForm.submit();
	},
	saveCartQty: function(theForm) {
		theForm.act.value='saveCartQty';
		theForm.submit();
	},
	emptyCart: function(theForm) {
		theForm.act.value='emptyCart';
		theForm.submit();
	}
}
var tickets={
	get: function(evId) {
		window.location.href='index.cfm?pg='+pg+'&evId='+evId+'#buyTicket';
	},
	buy: function(theForm) {
		var er='';
		if (this.getTicketTotal() == 0)
			er+='\n* Du måste välja minst en biljett';
		if (trim(theForm.f_firstname.value).length == 0)
			er+='\n* Förnamn måste anges';
		if (trim(theForm.f_lastname.value).length == 0)
			er+='\n* Efternamn måste anges';
		if (trim(theForm.f_address.value).length == 0)
			er+='\n* Adress måste anges';
		if (trim(theForm.f_zip.value).length == 0)
			er+='\n* Postort måste anges';
		if (trim(theForm.f_city.value).length == 0)
			er+='\n* Stad måste anges';
		if (trim(theForm.f_phone.value).length == 0)
			er+='\n* Telefon måste anges';
		if (er.length == 0)
			theForm.submit();
		else
			alert("Felmeddelande:"+er);
	},
	getTicketTotal: function() {
		var theForm=document.form_tickets;
		var zetId_ar=theForm.zetId_list.value.split(',');
		var i,qty,price,zetId;
		var ticketTotal=0;
		for (i=0;i<zetId_ar.length;i++) {
			zetId=zetId_ar[i];
			qty=trim(eval('theForm.qty_'+zetId).value);
			if (qty.length != 0) {
				price=parseInt(eval('theForm.price_'+zetId).value);
				ticketTotal+=parseInt(qty)*price;
			}
		}
		return ticketTotal;
	},
	updateTotal: function() {
		var theForm=document.form_tickets;
		var ticketTotal=this.getTicketTotal();
		var showPay=(ticketTotal != 0);
		get_object('pay_ticketTotal').innerHTML=(showPay)?ticketTotal+' kr':'';
		var totalPrice=parseInt(ticketTotal+shippingCost);
		get_object('pay_total').innerHTML=(showPay)?totalPrice+' kr':'';
		get_object('pay_shippingCost').style.display=(showPay)?'inline-block':'none';
	}
}
/*
function doBuyTicket(theForm) {
	var er='';
	if (getCheckedRadioValue(theForm.zevId) == '')
		er+='\n* Du måste välja föreställning';
	if (!isValid('positiveInteger',trim(theForm.f_qty.value)))
		er+='\n* Du måste ange antal biljetter';
	if (trim(theForm.f_firstname.value).length == 0)
		er+='\n* Förnamn måste anges';
	if (trim(theForm.f_lastname.value).length == 0)
		er+='\n* Efternamn måste anges';
	if (trim(theForm.f_address.value).length == 0)
		er+='\n* Adress måste anges';
	if (trim(theForm.f_zip.value).length == 0)
		er+='\n* Postort måste anges';
	if (trim(theForm.f_city.value).length == 0)
		er+='\n* Stad måste anges';
	if (trim(theForm.f_phone.value).length == 0)
		er+='\n* Telefon måste anges';
	if (er.length == 0)
		theForm.submit();
	else
		alert("Felmeddelande:"+er);
}
function updatePay() {
	var theForm=document.form_tickets;
	var qty=trim(theForm.f_qty.value);
	var zevId=getCheckedRadioValue(theForm.zevId);
	var showPay=false;
	if (zevId != '' && isValid('positiveInteger',qty)) {
		showPay=true;
		get_object('pay_ticketQty').innerHTML=qty+' st';
		var evnPrice=parseInt(get_object('zevPrice_'+zevId).value);
		get_object('pay_ticketPrice').innerHTML=evnPrice+' kr';
		var totalPrice=parseInt(evnPrice*qty+shippingCost);
		get_object('pay_total').innerHTML=totalPrice+' kr';
		theForm.ZTO_int_Total.value=totalPrice;
	}
	get_object('pay').style.display=(showPay)?'block':'none';
}
*/
