/* XXX */

function checkinputs_add( F ) {
	var inputs = F.elements,
		i = inputs.length;

	var select = F.getElementsByTagName('select'),
		s = s1 = select.length;

	while( i-- ) {
		_h.rmClass(inputs[i], 'f-invalid');
	}

	while( s1-- ) {
		_h.rmClass(select[s1], 'f-invalid');
	}

	var reds = _h.byClass('f-red', F),
		r = reds.length;

	while( r-- ) {
		var val = reds[r].value;
		//console.log(val);

		if( !val.length ) {
			_h.addClass(reds[r], 'f-invalid');
			reds[r].focus();
			return false;
		}

	}

	//console.log(s);
	while( s-- ) {
		//console.log(select[s].value, select[s].value == 'Выберите');
		if( select[s].value == 'Выберите' ) {
			_h.addClass(select[s], 'f-invalid');
			select[s].focus();
			return false;
		}
	}

	var nums = _h.byClass('f-number', F),
		n = nums.length;

	while( n-- ) {

		var val = nums[n].value;
		//console.log(val);

		if( val.length && !(/^[0-9]+$/.test(val)) ) {
			_h.addClass(nums[n], 'f-invalid');
			nums[n].focus();
			return false;
		}

	}


	var p_code = _h.byId('inputaddnewcar_phone_code'),
		p_number = _h.byId('inputaddnewcar_phone_number'),
		phone = _h.byId('inputaddnewcar_phone');

	var p = p_code.value + '-' + p_number.value,
		phoneValid = false;

	if( /^[0-9]{3}\-[0-9]{7}/.test(p) || /^[0-9]{5}\-[0-9]{5}/.test(p) ) {
		phoneValid = true;
		phone.value = p;
	}


	if( !phoneValid ) {
		_h.addClass(p_code, 'f-invalid');
		_h.addClass(p_number, 'f-invalid');

		p_code.focus();

		return false;
	}

	//console.log(phone.value);

	return true;
	
}

