<!-- POPUP CENTRO -->
function popup_centro(theURL,winName,width,height,features) {
	var window_width = width;
	var window_height = height;
	var newfeatures= features;
	var window_top = (screen.height-window_height)/2;
	var window_left = (screen.width-window_width)/2;
	newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',' + newfeatures + '');
	newWindow.focus();
}
<!-- FIM POPUP CENTRO -->

// Identificação do Navegador
isIE = ( -1 < navigator.appName.indexOf("Microsoft") )? true : false;

function validaLogin (frm) {
	if ((frm.login.value == "") || (frm.senha.value == "")) {
		alert("Digite o login e senha corretamente.");
		return false;
	}
	else {
		return true;
	}
}

function confirma(msg,url) {
	if (confirm(msg)) {
		document.location.href = url;
	}
}

function format(value,format)
{
	value = value.replace(/\D/g,"");
	var result="";
	
	if(format.length < value.length)
		return value;
	
	for(i=0,j=0;(i<format.length)&&(j<value.length);i++)
	{
		var ch = format.charAt(i) ;
		if(ch == '#')
		{
			result += value.charAt(j++);
			continue;
		}
		result += ch;
	}
	return result;
}

/*
	função para remover espaços no inicio e fim da string
*/
function trim(str){
	return str.replace(/^\s*|\s*$/g,"");
}

/*
	funcao de validação de email
*/
function validaEmail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(email)) return true;
	else return false;
}

/*
	funcao de validação de data no formato 99/99/9999
*/
function validaData(data){
	var reDate = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
	return reDate.test(data);
}
	
/*
	funcao de validação de hora no formato 99:99
*/
function validaHora(hora){
	var reTime = /^([0-1]\d|2[0-3]):[0-5]\d$/;
	
	if (reTime.test(hora))
		return true;
	else
		return false;
}

/**
* Função para filtar um campo para aceitar apenas números
* e o caracter de ponto.
*/
function somenteNumero(evt)
{
	key = (isIE)? evt.keyCode : evt.which;

	if( ( key >= 96 && key <= 105) || (key >= 48 && key <= 57) || ( key == 194 || key == 190 || key == 46 || key == 8 || key == 9 || (key >= 35 && key <= 40) )  )
		return true;
	else
		return false;
}

/**
* Função utilizada para definir os Tipos de quarto
*/
function addTipoQuarto(objDestino)
{
	var texto;
	var valor;
	var valorDestino;
	var i;
	var	objQntQuarto 	= document.getElementById('Qnt_Quarto');
	var objTipoQuarto 	= document.getElementById('Cid_TipoQuarto');
	var objCategoria	= document.getElementById('Cid_EstCategoria');
	
	// Checando dados incorretos
	if( "" == objQntQuarto.value || 0 == objTipoQuarto.selectedIndex || 0 == objCategoria.selectedIndex )
	{
		alert("Favor Informar os dados corretamente!");
		objQntQuarto.focus();
		return false;
	}
	
	valor = objQntQuarto.value+';'+objTipoQuarto.options[objTipoQuarto.selectedIndex].value+";"+objCategoria.options[objCategoria.selectedIndex].value;
	texto = objQntQuarto.value+' - '+objTipoQuarto.options[objTipoQuarto.selectedIndex].text+" - "+objCategoria.options[objCategoria.selectedIndex].text;

	// Checando se o item já está cadastrado
	for( i=0; i < objDestino.length; i++ )
	{
		valorDestino = objDestino.options[i].value.split(";");
		
		if( valorDestino[1] == objTipoQuarto.options[objTipoQuarto.selectedIndex].value && valorDestino[2] == objCategoria.options[objCategoria.selectedIndex].value )
		{
			alert("Este tipo de quarto já está cadastrado! \n Caso queira redefinir, remova o item e cadastre novamente!")
			objQntQuarto.focus();
			return false;
		}
	}
	
	// Novo item
	objDestino.options[objDestino.length] = new Option(texto, valor);

	objQntQuarto.value = "";
	objTipoQuarto.selectedIndex = -1;
	objCategoria.selectedIndex = -1;
	
	objQntQuarto.focus();
}

/**
* Função utilizada para definir os Tipos de quarto
*/
function addQuartoValor(objDestino)
{
	var texto, valor, i, datai, dataf;
	var objTipoQuarto 	= document.getElementById('Cid_TipoQuarto2');
	var objValor		= document.getElementById('Valor');
	var objDataI		= document.getElementById('datInicio');
	var objDataF		= document.getElementById('datFinal');
	var dataI = new Date();
	var dataF = new Date();
	
	// Checando dados incorretos
	if( 0 == objTipoQuarto.selectedIndex || "" == objValor.value || isNaN(objValor.value) || "" == objDataI.value || "" == objDataF.value  )
	{
		alert("Favor Informar os dados corretamente!");
		objValor.focus();
		return false;
	}
	
	// Checando intervalo de datas
	datai = objDataI.value.split("-");
	dataf = objDataF.value.split("-");
	dataI.setFullYear(datai[2], datai[1], datai[0]);
	dataF.setFullYear(dataf[2], dataf[1], dataf[0]);
	
	if( !validaData(datai[0]+"/"+datai[1]+"/"+datai[2]) || !validaData(dataf[0]+"/"+dataf[1]+"/"+dataf[2]) || (dataI > dataF) )
	{
		alert("O intervalo de datas não é válido!");
		objDataI.focus();
		return false;
	}
	
	valor = objTipoQuarto.options[objTipoQuarto.selectedIndex].value+";"+objValor.value+";"+objDataI.value+";"+objDataF.value;
	texto = objTipoQuarto.options[objTipoQuarto.selectedIndex].text+" - R$ "+objValor.value+" [ "+objDataI.value+" até "+objDataF.value+" ]";

	// Checando se o item já está cadastrado
	for( i=0; i < objDestino.length; i++ )
	{
		if( valor == objDestino.options[i].value )
		{
			alert("Este item já está cadastrado!")
			objValor.focus();
			return false;
		}
	}
	
	// Novo item
	objDestino.options[objDestino.length] = new Option(texto, valor);
	
	objValor.value = "";
	objTipoQuarto.selectedIndex = -1;
	objDataI.value = "";
	objDataF.value = "";
	
	objValor.focus();
}

function addItem(objOrigem,objDestino){
	
}

/**
* Função para agrupar itens de um select em um campo oculto
*/
function agruparItensSelect(objSelect, destino)
{
	var i = 0;
	var str = "";
	
	for( i=0; i < objSelect.length; i++ )
	{
		str += objSelect.options[i].value+"@";
	}
	
	// Retirando o '#' final
	//destino.value = str.substr(0, (str.length -1));
	return str;
}

/**
* Remove o option de um select
*/
function removerOption(objSelect)
{
	if ( 0 == objSelect.length )
	{
		alert("Não há itens a serem removidos!");
		return false;
	}
	
	if( -1 == objSelect.selectedIndex )
	{
		alert("Selecione um item na lista");
		return false;
	}
	
	objSelect.remove(objSelect.selectedIndex);
}

/**
* Função para validação de intervalo de Datas
*/
function comparaDatas(dataInicio, dataTermino)
{
	//== quebrando as datas para comparar numeros
	vDataInicio = dataInicio.split("/");
	diaIni = vDataInicio[0]
	mesIni = vDataInicio[1]
	anoIni = vDataInicio[2]
	vDataTermino = dataTermino.split("/");
	diaTerm = vDataTermino[0]
	mesTerm = vDataTermino[1]
	anoTerm = vDataTermino[2]
	
	//== verificando se o ano,mes,dia final é menor que o ano,mes,dia inicial
	if (anoTerm < anoIni)
	{ return false; }
	else if (mesTerm < mesIni)
	{ return false;	}
	else if (diaTerm < diaIni)
	{ return false; }
	else
	{ return true; }

}

/**
* Método utilizado para copiar um Option de um Select
* para o outro
*/
function copiarOption(origem, destino)
{
	var i=0;
	
	// Somente se um item for selecionado na origem
	if( -1 != origem.selectedIndex )
	{
		// Checando se o item já está cadastrado
		for( i=0; i < destino.length; i++ )
		{
			if( destino.options[i].value == origem.options[origem.selectedIndex].value)
			{
				alert('Item já cadastrado!');
				return false;
			}
		}
		
		destino.options[destino.length] = new Option(origem.options[origem.selectedIndex].text, origem.options[origem.selectedIndex].value);
	}
}

// funcai que valida email
function checaEmail(Email) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Email))
	{ return true; }
	else
	{ return false; }		
}

// funcao que verifica se a data é realmente válida
function checkData(field) 
{
	var checkstr = "0123456789"; 
	var DateField = field; 
	var Datevalue = ""; 
	var DateTemp = ""; 
	var day; 
	var month; 
	var year; 
	var leap = 0; 
	var err = 0; 
	var i; 
	err = 0; 
	DateValue = DateField.value; 

	for (i = 0; i < DateValue.length; i++) 
	{ 
		if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) 
		{ DateTemp = DateTemp + DateValue.substr(i,1); } 
	} 

	DateValue = DateTemp; 

	if (DateValue.length == 6) 
	{ DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); } 

	if (DateValue.length != 8) 
	{ err = 1; } 

	year = DateValue.substr(4,4); 
	if (year == 0) 
	{ err = 1; } 

	month = DateValue.substr(2,2); 
	if ((month < 1) || (month > 12)) 
	{ err = 1; } 

	day = DateValue.substr(0,2); 
	if (day < 1) 
	{ err = 1; } 

	if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) 
	{ leap = 1; } 
	
	if ((month == 2) && (leap == 1) && (day > 29)) 
	{ err = 1; } 
	
	if ((month == 2) && (leap != 1) && (day > 28)) 
	{ err = 1; } 

	if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) 
	{ err = 1; } 
	
	if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) 
	{ err = 1; } 

	if ((day == 0) && (month == 0) && (year == 00)) 
	{ err = 1; } 
	
	//== verificando se foi encontrado algum erro
	if (err == 0) 
	{ return true; } 
	else 
	{ return false;	} 
	
}
// funcao que valida data

// Funções para DIV


	function resize() {
		document.getElementById('login').style.display = 'none';
		document.getElementById('logando').style.display = '';
		document.getElementById('popup').style.display = '';
	}
	
	function openMenu() {
		document.getElementById('menu').style.display = '';
	}
	function fechaMenu() {
		document.getElementById('menu').style.display = 'none';
	}
	function openSubMenu() {
		document.getElementById('submenu').style.display = '';
	}
	function fechaSubMenu() {
		document.getElementById('submenu').style.display = 'none';
	}
	function openInfo(div) {
		document.getElementById(div).style.display = '';
	}
	function closeInfo(div) {
		document.getElementById(div).style.display = 'none';
	}

// Fim funções da DIV