function set_err(id, text) {
	document.getElementById(id).innerHTML=text;
}

function check_input(input, err_id, err) {
	if (input.value=='') {
		set_err(err_id, err);
		return false;
	}
	return true;
}

function check_radio(radio, err_id, err) {
	check = 0;
	if (!radio) return true;
	len = radio.length;
	if (!len) return true;

	for (var i = 0; i < len; ++i) {
		if(radio[i].checked) {
			return true;
		}
	}
	set_err(err_id, err);
	return false;
}

function radio_value(radio){
	for (var i = 0; i < radio.length; ++i) {
		if (radio[i].checked)
			break;
	}
	if (i < radio.length) return radio[i].value;
	else return '';
}

function check_add_product() {
	good = true;
	if (!check_radio(document.product.model, 'err_model', 'Proszę wybrać model'))
		good = false;
	/*model = document.getElementById('model');
	if (model) {
		if (!check_input(model, 'err_model', 'Proszę wybrać model:')) good = false;
	}
	colour = document.getElementById('colour');
	if (colour) {
		if (!check_input(colour, 'err_colour', 'Proszę wybrać kolor:')) good = false;
	}
	size = document.getElementById('size');
	if (size) {
		if (!check_input(size, 'err_size', 'Proszę wybrać rozmiar:')) good = false;
	}*/
	return good;
}

