// Function $ like in Prototype framework. // Unfortunately prototype not works with liferay in IE.//    id - id of the element.function $(id) {return document.getElementById(id);}// Submit form by it's id.//    id - id of the form.function submitFormById(id) {var form = $(id);	if (form) {form.submit();	}	}//Submit form by it's name.//name - name of the form.function submitFormByName(name) {var form = document.forms[name];if (form) {form.submit();	}	}// Preload image.//    src - url of image.function preloadImage(src) {if (document.images) {var image = new Image();image.src = src;}}// Browser-compatible function for adding window onload event listeners.//    func - function to execute when window has been loaded.function addOnLoadEvent(func) {if (window.addEventListener) {// W3C standardwindow.addEventListener('load', func, false); // !!!! not 'onload'} else if (window.attachEvent) {// Microsoftwindow.attachEvent('onload', func);}}// Trim string.//   string - string to trim.//   result: trimmed string.function trim(string) {return string.replace(/(^\s+)|(\s+$)/g, "");}// Submit field (and form), that have hint value.//    formId - id of the form, that contains field.//    fieldId - id of the field.function submitFieldWithHintValue(formId, fieldId) {var field = $(fieldId);if (field.value != field.title) {submitFormById(formId);}	}// Remove hint field class (grey letters).//    id - id of the field object (<input>);function removeFieldHintClass(id) {var field = $(id);if (field.value != field.title) {removeClass(field, 'form-empty-field');}	}// Add hint field class (grey letters).//    id - id of the field object (<input>);function addFieldHintClass(id) {var field = $(id);if (field.value == field.title) {addClass(field, 'form-empty-field');		}	}// Remove hint field value (like "Search..." at the search field).//    id - id of the field object (<input>);function removeFieldHintValue(id) {var field = $(id);if (field.value == field.title) {field.value = "";}removeFieldHintClass(id);}// Add hint field value (like "Search..." at the search field).//    id - id of the field object (<input>);function addFieldHintValue(id) {var field = $(id);if (trim(field.value).length == 0) {field.value = field.title;	}addFieldHintClass(id);}// Add class to element//   element - html element.//   clazz - class.function addClass(element, clazz){    var re = new RegExp("(^|\\s)" + clazz + "(\\s|$)", "g")    if (re.test(element.className)) return    element.className = (element.className + " " + clazz).replace(/\s+/g, " ").replace(/(^ | $)/g, "")}// Remove class from element//   element - html element.//   clazz - class.  function removeClass(element, clazz){    var re = new RegExp("(^|\\s)" + clazz + "(\\s|$)", "g")    element.className = element.className.replace(re, "$1").replace(/\s+/g, " ").replace(/(^ | $)/g, "")}
