function pop_up( URL, width, height ){
  var features = "scrollbars=yes,resizable=yes,width=" + width + ",height=" + height;
  window.open( URL, "pop_up", features );
  return false;
}

function showSimpleFormWindow( name, getVars, width, height ){
  var features;
  features = "scrollbars=yes,resizable=yes,width=" + width + ",height=" + height;
  window.open( name + ".php" + getVars, name, features );
  return false;
} // fin de simpleFormWindow

function showSimpleFormWindow2( URL, name, width, height ){
  var features;
  features = "scrollbars=yes,resizable=yes,width=" + width + ",height=" + height;
  window.open( URL, name, features );
  return false;
} // fin de simpleFormWindow

function reloadClose( xtra ){
  if( xtra == '' )
    window.opener.location = window.opener.location;
  else
    window.opener.location = "http://" + window.opener.location.host + window.opener.location.pathname + xtra; 
  window.close();
} // fin de realoadClose

function redirect( locat ){
	window.opener.location = locat;
	window.close();
} // fin de realoadClose

function refresh(){
    window.opener.location = window.opener.location;
} // fin de realoadClose

function emailcheck(email){
	var binvalid = false;
	invalidChars = " /;,:";
	for (var j=0; j< invalidChars.length; j++) {
		badChar = invalidChars.charAt(j);
		if (email.indexOf(badChar,0) > -1) {
			binvalid = true;
			break;		
		}
	}
	var atPos = email.indexOf("@",1)
	// there must be one "@" symbol
	if (atPos == -1)
		binvalid=true;
	// and only one "@" symbol
	if (email.indexOf("@", atPos+1) != -1)
		binvalid=true;	
	// and at least one "." after the "@"
	periodPos = email.indexOf(".",atPos)
	if(periodPos == -1)
	    binvalid=true;
	// and at least one character between "@" and "."
	if (atPos + 2 > periodPos)
		binvalid=true;
	if (periodPos + 3 > email.length)
		binvalid=true;
	if (email.charAt(email.length-1)==".")
		binvalid=true;	
	return binvalid;
}

function countChars( element, content, maxlimit, lenElement ){
	if( content.length > maxlimit ) 
		element.value = content.substring( 0, maxlimit );
	else
		lenElement.value = element.value.length;
}

function sendToPrinter(){
	if( typeof( window.print ) != 'undefined' )
		window.print();
}

function getElement(e,f){
    if(document.layers){
        f=(f)?f:self;
        if(f.document.layers[e]) {
            return f.document.layers[e];
        }
        for(W=0;i<f.document.layers.length;W++) {
            return(getElement(e,fdocument.layers[W]));
        }
    }
    if(document.all) {
        return document.all[e];
    }
    return document.getElementById(e);
}

function showHide( elem, disp ){
	var elem = getElement( elem );
	elem.style.display = disp;
}	// showHide()
