// -----------------------------------------------------------------------------
// Search through source string and remove characters contained in 'exludeChars'
// -----------------------------------------------------------------------------
function filterExclude(source, excludeChars) {
 	var r = "";
	var s = source;
	var i, c;

	for (i = 0; i < s.length; i++) {
		c = s.charAt(i);
		if (excludeChars.indexOf(c) == -1) r += c;
	}
	return r;
}

// -----------------------------------------------------------------------------
// Check if input is empty or only contains blanks
// -----------------------------------------------------------------------------
//function isBlank(el) {
//alert(10);
//	s = el.value;
//alert(11);
//	s = filterExclude(s, " ");
//alert(12);
//alert(s.length)
//	return s.length <= 0;
//}


// -----------------------------------------------------------------------------
// Check input fields of the message form
// -----------------------------------------------------------------------------
function checkMessageInputFields(form, forumID, code) {
	var alertMsg = "Du må fylle ut feltene: \n";
	var valid    = true;

	if (isBlank(form.msg_subject)) {
		valid = false;
		alertMsg += "\n- Tema";
	}

	if (isBlank(form.msg_body)) {
		valid = false;
		alertMsg += "\n- Meldingstekst";
	}

	if (forumID == 1) {
		if (isBlank(form.msg_last_name)) {
			valid = false;
			alertMsg += "\n- Navn/Nick";
			}
        } else {
		if (isBlank(form.msg_first_name)) {
			valid = false;
			alertMsg += "\n- Fornavn";
			}
        }

//	if (isBlank(form.msg_last_name)) {
//		valid = false;
//		alertMsg += "\n- Etternavn";
//	}

//	if (isBlank(form.msg_email)) {
//		valid = false;
//		alertMsg += "\n- E-post";
//	}

	if (form.msg_code) {
		if (isBlank(form.msg_code)) {
			valid = false;
			alertMsg += "\n- Kode";
		} else if (form.msg_code.value != code) {
			valid = false;
			alertMsg += "\n- Koden er feil";
		}
	}

	if (!valid) alert(alertMsg);

	return valid;
}

// -----------------------------------------------------------------------------
// Check input fields of the message form
// -----------------------------------------------------------------------------
function openMultiMedicus(username, password, arg) {

	if (username.length == 0) {
		alert("Du må fylle inn brukernavn!");
		return false;
	}

	if (password.length == 0) {
		alert("Du må fylle inn passord!");
		return false;
	}

	if (arg == 1) {
		RefLink = "http://www.multimedicus.no/library_isdn/frameset.htm?user=" + username + "&pword=" + password;
 
	} else {
		RefLink = "http://www.multimedicus.no/library_broadband/frameset.htm?user=" + username + "&pword=" + password;
	}

	var topleft = 0;
	var top = 0;
	var width = 1024;
	var height = 768;
	var WindowName = "Library"

	var OpenString$ = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=never,resizable=0,width=' + width + ',height=' + height + ',left=' + topleft + ',top=' + top + ')';

	window.open(RefLink,WindowName,OpenString$);
	return true;
}

