// JavaScript Document
var regchoice=0;
var apdvschoice=0;
var workshop=0;
var qtickets=0;
var qtickets2=0;
$(document).ready(function(){
						   
	$("input[name='regchoice']").each(function(){
		if($(this).is(":checked")){
			var totalminregchoice=parseFloat($("#totalspan").text())-regchoice;
			$("#totalspan").text(totalminregchoice+parseFloat($(this).attr("rel")));
			regchoice=parseFloat($(this).attr("rel"));
		}
	})

	$("input[name='regchoice']").click(function(){
		var totalminregchoice=parseFloat($("#totalspan").text())-regchoice;
		$("#totalspan").text(totalminregchoice+parseFloat($(this).attr("rel")));
		regchoice=parseFloat($(this).attr("rel"));
	})

	$("input[name='workshop']").each(function(){
		if($(this).is(":checked")){
			var totalminworkshop=parseFloat($("#totalspan").text())-workshop;
			$("#totalspan").text(totalminworkshop+parseFloat($(this).attr("rel")));
			totalminworkshop=parseFloat($(this).attr("rel"));
		}
	})

	$("input[name='workshop']").click(function(){
		if($(this).is(":checked")){
			var totalminworkshop=parseFloat($("#totalspan").text())-workshop;
			$("#totalspan").text(totalminworkshop+parseFloat($(this).attr("rel")));
			workshop=parseFloat($(this).attr("rel"));
		}else{
			var totalminworkshop=parseFloat($("#totalspan").text())-workshop;
			$("#totalspan").text(totalminworkshop);
			workshop=0;
		}
	})


	$("input[name='apdvschoice']").each(function(){
		if($(this).is(":checked")){
			var totalminapdvschoice=parseFloat($("#totalspan").text())-apdvschoice;
			$("#totalspan").text(totalminapdvschoice+parseFloat($(this).attr("rel")));
			apdvschoice=parseFloat($(this).attr("rel"));
		}
	})
	$("input[name='apdvschoice']").click(function(){
		var totalminapdvschoice=parseFloat($("#totalspan").text())-apdvschoice;
		$("#totalspan").text(totalminapdvschoice+parseFloat($(this).attr("rel")));
		apdvschoice=parseFloat($(this).attr("rel"));
	})
	
	var totalminqtickets=parseFloat($("#totalspan").text())-qtickets;
	$("#totalspan").text(totalminqtickets+(parseFloat($("#qtickets").val())*100));
	qtickets=parseFloat($("#qtickets").val())*100;		

	$("#qtickets").change(function(){
		var totalminqtickets=parseFloat($("#totalspan").text())-qtickets;
		$("#totalspan").text(totalminqtickets+(parseFloat($("#qtickets").val())*100));
		qtickets=parseFloat($("#qtickets").val())*100;		
	})
	
	var totalminqtickets2=parseFloat($("#totalspan").text())-qtickets2;
	$("#totalspan").text(totalminqtickets2+(parseFloat($("#qtickets2").val())*30));
	qtickets2=parseFloat($("#qtickets2").val())*30;		

	$("#qtickets2").change(function(){
		var totalminqtickets2=parseFloat($("#totalspan").text())-qtickets2;
		$("#totalspan").text(totalminqtickets2+(parseFloat($("#qtickets2").val())*30));
		qtickets2=parseFloat($("#qtickets2").val())*30;		
	})

	$("#meetform").submit(function(){
		$("li.required").removeClass("required");
		$("label.required + input").each(function(){
			if($(this).val()==''){
				$(this).parent("li:first").addClass("required");
			}
		})
		var $requiredlis = $("li.required");
		if($requiredlis.length>0){
			$("#meetform").prepend('<p style="color: red;font-weight:bold">Please complete all required fields.</p>')
			$("#meetform").append('<p style="color: red;font-weight:bold">Please complete all required fields.</p>')
			return false;
		}else{
			$("#hidtotal").val($("#totalspan").text())
			return true;
		}
	})
});