var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isIE = (navigator.appName == "Microsoft Internet Explorer"?true:false);

function clearSearch(input, word){	if(input.value == word) input.value = "";}

function getRef(id) {
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}

function getSty(id) {
	return (isNS4 ? getRef(id) : getRef(id).style);
} 

function printiMeil(name,domain,styleclass,text){
	imeil = name + "@" + domain;
	meil2 = "<a href=\"mai" + "lto:" + imeil + "\"";
	if(styleclass) meil2 += " class=" + styleclass;
	if(!text) text = imeil;
	meil2 += ">" + text + "</a>";
	document.write(meil2);
}

function openWindow(file, name, width, height){
	if(!name) name = "popup";
	if(!width) width = 600;
	if(!height) height = screen.height - 250;
	popUp = open(file,name,'toolbar=no,directories=no,location=no,menubar=no,resizable=yes,header=no,status=no,width='+width+',height='+height+',top='+(screen.height-height)/2+',left='+(screen.width - width)/2);
//	popUp.focus();
	return false;
}

function HighLightText(id, isOver, color, bgColor){
	parentref = getSty(id);
	overCol = "#336699";
	offCol = "#000000";
	if(color) overCol = offCol = color;
	newCol = isOver ? overCol : offCol;
	newBgCol = isOver ? bgColor : "#ffffff";
	with (parentref) {
		if (isNS4) color = newCol;
		else color = newCol;
    }
	with (parentref) {
		if (isNS4) bgColor = newBgCol;
		else backgroundColor = newBgCol;
    }
}

function changePage(url){
	document.location.href=url;
}


if(messages == undefined){
	messages = new Array();
	messages['required'] = "is required";
	messages['field'] = "Field";
}


function checkForm(forma){
	i = 0;
	message = requireds = toolongs = "";
	
	while(i < forma.elements.length){
		elem = forma.elements[i];
		myRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/i;
		myRe2 = /^[^\[\]]\[\]$/i;
		empty = toolong = false;
			switch(elem.type){
				case "select-one":
				case "select-multiple":

					if(elem.required && (elem.selectedIndex == -1 || !elem[elem.selectedIndex].value)) empty = true;
				break;
				default:
					if(elem.required && !elem.value) empty = true;
					else if(elem.maxlength && elem.value.length > elem.maxlength) toolong = true;
			}
			
			if(empty){
				if(requireds) requireds += ", ";
				requireds += /*"\"" +*/ elem.title /*+ "\""*/;
			}
			if(toolong){
				if(toolongs) toolongs += ", ";
				toolongs += /*"\"" +*/ elem.title /*+ "\""*/;
			}
		i++;
	}
	if(requireds) message += /*messages['field'] + " " +*/ requireds + " " + messages['required']+"\n\r";
	if(toolongs) message += /*messages['field'] + " " +*/ toolongs + " " + messages['toolong']+"\n\r";
	if(message){ 
		alert(message);
			return false;
		}
	return true;
}	