function drop_down_alert() {
	alert('You will be able to personalize this consequence later in the contract');
	return false;
}

function submit_button_alert() {
	alert('You will be able to personalize this consequence later in the contract');
}

function consequence_warning(num) {
	var a=document.getElementsByName("consequences_text_" + num);
	var b=document.getElementsByName("consequences_" + num);
	if (a[0].value != '' && b[0].checked == false) {
		alert('If you want to use this consequence, please click on the box to the left');
	}
}

function checkbox_count(form, min, max) {
var sum=0;
	
	elements = document.forms[form].elements;
	for (var i = 0;i < elements.length ; i++ )
	{
		if (elements[i].getAttribute('type') == 'checkbox') {

			if (elements[i].checked == true)
			{
				sum++;
			}
		}
	}

	if (sum<min || sum>max) {
		alert ('You need to select only ' + min + '-' + max + ' checkboxes');
		return false;
	}
	else {
		return true;
	}
}

function textboxes_check(form, min, max) {
if (checkbox_count(form, min, max) == false) return false;

var sum=0;
	elements = document.forms[form].elements;
	
	for (var i = 0;i < elements.length ; i++ )
	{
		var czekbox = document.getElementsByName(form + "_" + i);
		if (czekbox.length > 0) {
			if(czekbox[0].getAttribute('type') == 'checkbox') {
				if (czekbox[0].checked == true) {
					var okienko_textowe = document.getElementsByName(form + "_text_" + i);
					if (okienko_textowe.length > 0) {
						if (okienko_textowe[0].value == "") {
							alert ('You have to enter the texts to all choosen ' + form);
							return false;
						}
					}
				}
			}
		}
	}
if (form == "consequences")	 
  {
	elements = document.forms[form].elements;
	for (var i = 0;i < elements.length ; i++ )
	{
		czekbox = document.getElementsByName("specials" + "_" + i);
		if (czekbox.length > 0) {
			if(czekbox[0].getAttribute('type') == 'checkbox') {
				if (czekbox[0].checked == true) {
					okienko_textowe = document.getElementsByName("specials" + "_text_" + i);
					if (okienko_textowe.length > 0) {
						if (okienko_textowe[0].value == "") {
							alert ('You have to enter the texts to all choosen ' + 'items');
							return false;
						}
					}
				}
			}
		}
	}
  }
  return true;
}

function match_check(count, zet) {
var radios=1;
var drops=1;

	for (var num=0; num<count; num++) {
		var a=document.getElementsByName("match_" + num);

		var ok=0;
		for (var k=0;k<zet ; k++)
		{
		    if (a[k].checked) {
			    ok=1;

			    var kk = k + 1;
			    var b=document.getElementsByName("match_hours_" + num + "_" + kk)[0];
			    var c=document.getElementsByName("match_days_" + num + "_" + kk)[0];
			    if (b && c && b.options[b.selectedIndex].value == "0" && c.options[c.selectedIndex].value == "1000"  ) {
				drops=0;
			    }

			    if (b && c && b.options[b.selectedIndex].value != "0" && c.options[c.selectedIndex].value != "1000") {
				drops=0;
			    }
		    }
		}

		if (ok==0) {
			radios=0;
		}


	}




	if (drops==0 || radios==0) {
		alert ('You need to select correct options');
		return false;
	}
	else {
		return true;
	}
}


function accept_check() {
	if (document.preview.accept.checked != "1") {
		alert('You need to accept the contract!');
		return false;
	}
}

