function getElm(elm){
	return document.getElementById(elm);		
}
function ca(){
	co();
	
	totalamount = courseamount + optionsamount;
	getElm('amount').value=totalamount;
	
	course="";
	getElm('buybutton').style.display='none';
	getElm('buybutton').innerHTML = '';
	for(i=1;i<=3;i++){
		if(getElm('category'+i).checked==true){
			course = categoryarray[(i-1)];
		
			if(getElm('selo'+i).selectedIndex!=0){				
				course += " "+optionsarray[(i-1)][((getElm('selo'+i).selectedIndex)-1)]['name'];
				getElm('buybutton').style.display='block';
				getElm('buybutton').innerHTML='<input type="submit" name="submit" value="Buy Now" class="button" />';			
			}
		}
	}
	
	getElm('item_name').value=course+" "+options+" Training Course";
	
	if(totalamount>0){
		getElm('cost').innerHTML='&pound;'+totalamount;
		getElm('cost').style.display='block';
	}else{
		getElm('cost').style.display='none';
		getElm('cost').innerHTML='';
	}
}

function co(){
	optionsamount = 0;
	options ="";
	
	if(getElm('passinsurance').checked==true){		
		optionsamount = optionsamount+399;
		options += " + Pass Insurance";
	}
	if(getElm('industryfasttrack').checked==true){
		optionsamount = optionsamount+199;
		options += " + Fast Track";		
	}
	if(getElm('retest').checked==true){
		optionsamount = optionsamount+325;
		options += " + Retest";		
	}
}

function resetc(){
	getElm('step2').style.display='none';
	
	for(i=0;i<getElm('register_form').category.length;i++){		
		if(getElm('register_form').category[i].checked){
			getElm('opt'+(i+1)).style.display='block';	
			
			//alert(getElm('selo'+(i+1)).selectedIndex);
			
			getElm('selo'+(i+1)).options[0].selected=true;
			getElm('step2').style.display='block';
		}else{
			getElm('opt'+(i+1)).style.display='none';
		}
	}
}
function sc(i){
	getElm('step3').style.display='none';
	getElm('cost').style.display='none';
	courseamount=0;
	ca();
	getElm('cost').style.display='none';
	getElm('cost').innerHTML='';
	resetc();
}
function so(c,o){
	getElm('step3').style.display='none';
	
	if(c!=null){
		if(o.length>0){
			courseamount = optionsarray[c][o]['price'];
			getElm('step3').style.display='block';
		}else{
			courseamount = 0;
		}
	}else{
		
		courseamount = 0;
	}
	
	ca();
	
	if(o.length<1){
		getElm('cost').style.display='none';
		getElm('cost').innerHTML='';
	}
}
function loadform(){
	
	for(i=0;i<optionsarray.length;i++){
		optionshtml = '';
		
		for(j=0;j<optionsarray[i].length;j++){
			optionshtml += '<option value="'+j+'">'+optionsarray[i][j]['name']+' ( &pound;'+optionsarray[i][j]['price']+' )</option>';
		}
		
		getElm('opt'+(i+1)).innerHTML = '<select id="selo'+(i+1)+'" onchange="so('+i+',this.value)"><option value="">Please choose a course</option>'+optionshtml+'</select>';
	}
	
	optionshtml = '';
	
	resetc();
}