function search_onclick() { var search = document.getElementById('SearchString1'); if (search.value == 'Sláðu inn leitarorð') { search.value = ''; } } function search_onblur() { var search = document.getElementById('SearchString1'); if (search.value == '') { search.value = 'Sláðu inn leitarorð'; } } /* General form-validation */ function validate(form) { var isValid = true; for (var i = 0; i < form.elements.length; i++) { var elem = form.elements[i]; if (elem.className.indexOf('reqd') > 0) { /* input, select og textarea er höndlað á sama hátt .... */ if ((elem.tagName == "INPUT") || (elem.tagName == "TEXTAREA") || (elem.tagName == "SELECT")) { if (elem.className.indexOf('emailval') > 0) { isValid = isValidEmail(elem.value); } else { isValid = (elem.value != ''); } if (!isValid) { alert(elem.title + ' er ekki rétt útfyllt!'); elem.focus(); elem.style.borderColor = '#FF4A4A'; elem.style.backgroundColor = '#FDFAD0'; return false; } else { elem.style.borderColor = ''; elem.style.backgroundColor = ''; } } } } return true; } function isValidEmail(value) { return (value.indexOf(".") > 2) && (value.indexOf("@") > 0); } // Björgvin Sigurðsson 26. júlí 2007. // The function is used in employee lists to avoid showing full email addresses on the web. // Changes email address with [hja] instead of @ and adds the new value to the // href of the element which has the id specified in id. // Assumes that the element is a link and assumes that the email is a string with [hja] instead of @. // param email: the string with the [hja] // param id: ID of the link-element which the email address belongs to. function changeEmail(email, id) { var newEmail = email.replace('[hja]', '@'); document.getElementById(id).href = "mailto:"+email.replace('[hja]', '@'); }