function check_fields(string, frm) {
    for (i=2; i < arguments.length; i++) {
        if (frm[arguments[i]].value == '') {
            frm[arguments[i]].focus();
            alert(string);
            return false;
        }
    }
    return true;
}

version = navigator.appVersion.toLowerCase();
agent = navigator.userAgent.toLowerCase();
ie = (version.indexOf('msie')>-1);
win = (version.indexOf('windows')>-1);
opera = (agent.indexOf('opera')>-1);
ie50 = (version.indexOf('msie 5.0')>-1);

function prn(string) {
document.write(' \&\#8226\; \074a href=\"javascript:goprn();\"\076' + string + '\074/a\076');
}
function goprn() {
window.print();
}
function fav(string) {
if ((opera) && (win)) return false;
else if ((ie) && (win)) document.write(' \&\#8226\; \074a href=\"javascript:gofav();\"\076' + string + '\074/a\076');
}
function gofav(lang) {
window.external.addFavorite("http://www.nibe." + lang,"Nibe Heating");
}

// Open image window
function img_open(filename, w, h, title) {
	var wnd = window.open('', '', (w && h ? 'width=' + w + ',height=' + h : 'width=300,height=300'));
	if (!wnd) {
		return false;
	}
	wnd.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n<html xmlns="http://www.w3.org/1999/xhtml">\n');
	if (title) {
		wnd.document.write('<head>\n<title>' + title + '</title>\n</head>\n');
	}
	wnd.document.write('\n<body style="margin: 0;">\n\n');
	wnd.document.write('<img src="' + filename + '"' + (w && h ? ' width="' + w + '" height="' + h + '"' : '') + ' alt="' + (title ? title : '') + '" style="margin: 0;" />');
	wnd.document.write('\n</body>\n</html>\n');
	wnd.document.close();
	return true;
}

// Check if there is an e-mail in the field, simplified!
// example of use: <input onblur="return email_correct('Enter an e-mail!', this);">
function email_correct(s, f) {
	return ereg_correct(s, f, /^[^ @]+@[^ @]+\.[^ @]+$/);
}

// Check if field matches ereg
// example of use: <input onblur="return ereg_correct('Enter a date!', this, /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/);">
function ereg_correct(s, f, regexp) {
	if (f.value == '' || regexp.test(f.value)) {
		return true;
	}
	return focus_alert(s, f);
}

var focus_changing = false;
// Focus into field f, display message s and return false
function focus_alert(s, f) {
	if (!focus_changing) {
		focus_changing = true;
		f.focus();
		alert(s);
		focus_changing = false;
	}
	return false;
}