/**
 * checkout.js
 * 
 * depends:
 * 	jQuery
 * 	P object (common.js)
 * 
 */

// stoelkeuze

P.stoelkeuze = {	
	init: function(){
		swfobject.registerObject("stoelkeuzeSWF", "9", "/flash/expressInstall.swf");
	},
	
	enableOption: function(){
		$('#keuze').attr('name','stoelkeuze_zelf');
	}
};



//totaal bereken functies

var VoorstellingTotaalBerekenaar = {
	berekenTotaal:function(){
		iSom = 0;
		// selects
		$('#ticketForm-kaartsoorten select').each(function(){
			iAantal = $(this).val();
			aTmp = $(this).attr('id').split('p');
			iVoorstellingId = aTmp[0].substring(1);
			iPrijsId = aTmp[1];
			iSubSom = oPrijzen[iVoorstellingId][iPrijsId] * iAantal;
			iSom += iSubSom;			
		});
		
		// extra's inputs
		$('#ticketForm-extras select').each(function(){
			iAantal = parseInt($(this).val());
			aTmp= $(this).attr('id').split('p');
			iPrijsId = aTmp[1];
			aTmp2 = aTmp[0].split('e');
			iVoorstellingId = aTmp2[0].substring(1);
			iSubVoorstellingId = aTmp2[1];
			iSubSom = oPrijzenExtra[iVoorstellingId][iSubVoorstellingId][iPrijsId] * iAantal;
			iSom += iSubSom;	
		});
		
		iSom = iSom.toFixed(2);				
		$('#ticketsTotaal span').text(iSom.replace('.', ','));
	},
	init: function(){
		
		$('#ticketForm-reserveren').prepend('<p class="keyvalue"><span class="key">Totaalprijs</span> <span class="value" id="ticketsTotaal">&euro;&nbsp;<span>0,00</span></span></p>');		
		//$('#reserveerSubmit').before('<fieldset id="kaartenSelecteren-totaal"><p>Totaal: <strong id="kostenTotaal">&euro;&nbsp;<span>0,00</span></strong><br /><span class="transKosten">excl. transactiekosten</span></fieldset>');
		$('#ticketForm select').change(function(){
			VoorstellingTotaalBerekenaar.berekenTotaal();
		});
		/*
			$('#aantalKaartenTable-extras input').blur(function(){
				berekenTotaal();
			});
		*/
	}
}
