var nopacktitle = $('#nopacktitle').text()
var nofixedandmobile = $('#nofixedandmobile').text();
var needhelpjs = $('#needhelpjs').text();
var call = $('#call').text();
var supplierphone = $('#supplierphone2').text();
	
function submitForm(){
	var test = doCheck('wizard1');
	var i = test[0];
	var j = test[1];
	if($('#wizard1').length == 0 && $('#wizard').length > 0){
		test = doCheck('wizard');
		i = test[0];
		j = test[1];
	}
	
	//ALS HET EEN ONBESTAANDE COMBINATIE IS
	if( i == j && i > 1){
		$('<div id="dialog" title="' + nopacktitle + '">' + nofixedandmobile + '<br /><br /><strong>' + needhelpjs + '? ' + call + ' ' + supplierphone + '</strong></div>').dialog({
			buttons: { 
				Ok: function(){
					if($('#wizard1').length == 0 && $('#wizard').length > 0){
						$('#wizard input').each(function(){
							$(this).attr('checked', 'checked');
						});
						$('#wizard').submit();
					}
					else{
						$('#wizard1 input').each(function(){
							$(this).attr('checked', 'checked');
						});
						$('#wizard1').submit();
					}
				},
				Annuleren: function(){
					$(this).dialog('close');
				}
			},
			modal: true,
			width: 500
		});
		return false;
	}
	else{
		$('#wizard1').submit();
		if($('#wizard1submit').length > 0){
			$('#wizard1submit').click();
		}
	}
	return true
}

function doCheck(id){
	var i = 0;
	var j = 0;
	
	$('#' + id + ' input').each(function(){
			var checked = $(this).attr('checked');
			if($(this).attr('checked')){
				i++;
				if($(this).val() == 7 || $(this).val() == 11 || $(this).val() == 8 || $(this).val() == 12){
					j++;
				}
			}
		});
	return [i, j]
}
