<!-- Copyright(c) 2005 Fastware B.V.. All rights reserved. $ -->
<!-- @author $Author: Nacho Pobes <n.pobes@fastware.nl> $ -->
<!-- @version $Id: common.js,v 0.1 2005/10/14 00:00:00 Nacho Pobes Exp $ -->
<!-- @content Basic JavaScript functionalities $ -->

<!-- Function ToogleSubmenu -->
function ToogleSubmenu(display){
	if (document.getElementById&&document.all){
		var e=window.event;
		var target=e.srcElement;
		var list_item=target.parentNode;
		var children=list_item.childNodes;
		var len=children.length;
		for (var i=0;i<len;i++){
			if (children[i].tagName=='UL'){
				ToogleDisplay(children[i],display);
			}
		}
	}
}

<!-- Function ToogleDisplay -->
function ToogleDisplay(obj,display){
	if (document.getElementById&&document.all){
		obj.style.display=display;
		obj.style.position='absolute';
		return true;
	}
}

<!-- Function ControlSearch -->
function ControlSearch(warning_empty,warning_too_small,warning_no_match){
	var dF=document.search_form;
	var search_terms=dF.search_terms.value;
	if (search_terms.value==''){
		alert(warning_empty);
		return false;
	}
	else if (search_terms.indexOf(' ')==-1&&search_terms.indexOf('+')==-1){
		if (ControlLengthKeyword(search_terms)==false){
			alert(warning_too_small);
			return false;
		}
		else if (ControlMatchKeyword(search_terms)==false) {
			alert(warning_no_match);
			return false;
		}
		return true;
	}
	else {
		var separator=(search_terms.indexOf('+')==-1)? ' ':'+';
		var words=search_terms.split(separator);
		var len=words.length;
		for (var i=0;i<len;i++){
			if (ControlLengthKeyword(words[i])==false){
				alert(warning_too_small);
				return false;
			}
			else if (ControlMatchKeyword(words[i])==false) {
				alert(warning_no_match);
				return false;
			}
		}
		return true;
	}
}

<!-- Function ControlLengthKeyword -->
function ControlLengthKeyword(word){
	return (word.length<3||word.length>35)? false:true;
}

<!-- Function ControlMatchKeyword -->
function ControlMatchKeyword(word){
	var pattern=/^[a-zA-Z0-9]+$/;
	return pattern.test(word);
}