ie = document.all?1:0;


function have_err(obj, obj_err, text) {
	if(obj) obj.style.color = '#ff0000';
	if(obj_err) {
		obj_err.innerHTML = text;
		obj_err.style.display = '';
	}

	return true;
}

function no_have_err(obj, obj_err) {
	if(obj) obj.style.color = '#666666';
	if(obj_err) obj_err.style.display = 'none';

	return false;
}

function is_num(str) {
	return verify_str(str, '1234567890');
}

function is_phone(str) {
	return verify_str(str, '0123456789()-+ ');
}

function is_url(str) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i;
	return regexp.test(str);
}

function verify_str(str, c) {
	for(i=0; i<str.length; i++) {
		var f = false;
		for(j=0; j<c.length; j++) {
			if(str.substring(i, i+1) == c.substring(j, j+1)) {
				f = true;
				break;
			}


		}

		if(!f) {
			return false;
		}


	}

	return true;
}


function is_email(email) {
	var splitted = email.match("^(.+)@(.+)$");
	if(splitted == null) return false;

	if(splitted[1] != null ) {
		var regexp_user=/^\"?[\w-_\.]*\"?$/;

		if(splitted[1].match(regexp_user) == null) return false;
	}

	if(splitted[2] != null) {
		var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;

		if(splitted[2].match(regexp_domain) == null)  {
			var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
			if(splitted[2].match(regexp_ip) == null) return false;
		}

		return true;
	}

	return false;
}

function field_over(obj) {
        add_css_prop(obj, "field_over");
}

function field_out(obj) {
        del_css_prop(obj, "field_over");
}


