/**
 * Mostra a janela de largura e altura indicado e posiciona no centro da tela.
 */
function showWindow( url, target, width, height ){
	x = ( screen.height - height ) / 2
	y = ( screen.width - width ) / 2
	config =  'top=' + x +
                  ',left=' + y +
                  ',height=' + height +
                  ',width=' + width +
                  ',scrollbars=yes' +
                  ',statusbar=yes';
	return window.open( url, target, config );
}
/**
 */
function showWindowValue( url, target, width, height ){
	var hWnd = showWindow( url, target, width, height );
	if( ( document.window != null ) && !hWnd.opener ){
		hWnd.opener = document.window;
	}
}

function checkQuery( form, msg ){
	if( form.query.value == "" ){
		alert( msg );
		form.query.focus()
		return false
	}else return true
}
// recupera o valor da combo e adiciona ao termo de pesquisa
function preencheQuery( select, separator ){
	if( select.selectedIndex != 0 ){
		form = select.form
		form.query.value += separator + select.options[ select.selectedIndex ].value + separator
		select.selectedIndex = 0
		form.query.focus()
	}
}

function checkAll( form, name, value ){
	for( i = 0; i < form.length; i++ ){
		element = form.elements[ i ]
		if( element.name == name ){
			element.checked = value
		}
	}
}

function checkAllCheckbox( form, value ){
	for( i = 0; i < form.length; i++ ){
		element = form.elements[ i ]
		if( element.type == 'checkbox' ){
			element.checked = value
		}
	}
}
